diff --git a/documentation/manual/core/en/zend.test.phpunit.html b/documentation/manual/core/en/zend.test.phpunit.html index c33ca5274c6a78b768857aee95f9261669eb9e43..9936fe6e2ca411d0fca91c267ba1fd578f117675 100644 --- a/documentation/manual/core/en/zend.test.phpunit.html +++ b/documentation/manual/core/en/zend.test.phpunit.html @@ -183,7 +183,7 @@ class UserControllerTest extends Zend_Test_PHPUnit_ControllerTestCase As noted in the <a href="zend.test.phpunit.html#zend.test.phpunit.loginexample" title="Example 44.1. Application Login TestCase example">Login example</a>, all MVC test cases should extend <code class="code">Zend_Test_PHPUnit_ControllerTestCase</code>. This class in turn - extends <code class="code">PHPUnit_Framework_TestCase</code>, and gives you all the + extends <code class="code">PHPUnit\Framework\TestCase</code>, and gives you all the structure and assertions you'd expect from PHPUnit -- as well as some scaffolding and assertions specific to Zend Framework's MVC implementation. diff --git a/laboratory/Zend_Tool/tests/TestHelper.php b/laboratory/Zend_Tool/tests/TestHelper.php index 979c8cbae08475d3e7593a4e4f85edb5c290778f..f10d376ad45b3fcb26145d7e9ec6d66c3c57a3f5 100644 --- a/laboratory/Zend_Tool/tests/TestHelper.php +++ b/laboratory/Zend_Tool/tests/TestHelper.php @@ -19,87 +19,15 @@ * @version $Id: TestHelper.php 9225 2008-04-14 18:44:43Z darby $ */ -/* - * Start output buffering - */ -//ob_start(); - -/* - * Include PHPUnit dependencies - */ -/* -// require_once 'PHPUnit/Framework.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/Runner/Version.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; -// require_once 'PHPUnit/Util/Filter.php'; -*/ - /* * Set error reporting to the level to which Zend Framework code must comply. */ error_reporting( E_ALL | E_STRICT ); -/* - * Determine the root, library, and tests directories of the framework - * distribution. - */ -/* -$zfRoot = dirname(__FILE__) . '/..'; -$zfCoreLibrary = "$zfRoot/library"; -$zfCoreTests = "$zfRoot/tests"; -*/ /* * Omit from code coverage reports the contents of the tests directory */ foreach (array('php', 'phtml', 'csv') as $suffix) { - PHPUnit_Util_Filter::addDirectoryToFilter($zfCoreTests, ".$suffix"); + PHPUnit\Util\Filter::addDirectoryToFilter($zfCoreTests, ".$suffix"); } - -/* - * Prepend the Zend Framework library/ and tests/ directories to the - * include_path. This allows the tests to run out of the box and helps prevent - * loading other copies of the framework code and tests that would supersede - * this copy. - */ -/* -$path = array( - $zfCoreLibrary, - $zfCoreTests, - get_include_path() - ); -set_include_path(implode(PATH_SEPARATOR, $path)); -*/ - -/* - * Load the user-defined test configuration file, if it exists; otherwise, load - * the default configuration. - */ -/* -if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) { - require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php'; -} else { - require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist'; -} -*/ - -/* - * Add Zend Framework library/ directory to the PHPUnit code coverage - * whitelist. This has the effect that only production code source files appear - * in the code coverage report and that all production code source files, even - * those that are not covered by a test yet, are processed. - */ -/* -if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true && - version_compare(PHPUnit_Runner_Version::id(), '3.1.6', '>=')) { - PHPUnit_Util_Filter::addDirectoryToWhitelist($zfCoreLibrary); -} -*/ - -/* - * Unset global variables that are no longer needed. - */ -//unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path); diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/ClassTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/ClassTest.php index c07389b025f5c032e812c5b01bdae74aec0716b0..ae2a181803b0b0e5ec7f1674d552eecbafbcdcb2 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/ClassTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/ClassTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/Class.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Class */ -class ZendL_Reflection_ClassTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_ClassTest extends PHPUnit\Framework\TestCase { static protected $_sampleClassFileRequired = false; diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ParamTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ParamTest.php index 551f8c89de354910eee99ae601ddf80cbaa18510..e89551f663908fa66e21ba86b2709eab7280d2cc 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ParamTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ParamTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/File.php'; * @group ZendL_Reflection_Docblock_Tag * @group ZendL_Reflection_Docblock_Tag_Param */ -class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit\Framework\TestCase { diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ReturnTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ReturnTest.php index 4fc7022644c4163dccc60d6c120be20d9a4e0ed5..c138e85998c55fbcff48a8509c30272691e64b69 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ReturnTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/Tag/ReturnTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/File.php'; * @group ZendL_Reflection_Docblock_Tag * @group ZendL_Reflection_Docblock_Tag_Return */ -class ZendL_Reflection_Docblock_Tag_ReturnTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_Docblock_Tag_ReturnTest extends PHPUnit\Framework\TestCase { static protected $_sampleClassFileRequired = false; diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/TagTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/TagTest.php index 770388011f95e44bab2dadb460b583940f1d0781..459d79f98e2eb9f115d53aa7e31eb39c3c0f3d4b 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/TagTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/Docblock/TagTest.php @@ -8,7 +8,7 @@ require_once 'ZendL/Reflection/File.php'; * @group ZendL_Reflection_Docblock * @group ZendL_Reflection_Docblock_Tag */ -class ZendL_Reflection_Docblock_TagTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_Docblock_TagTest extends PHPUnit\Framework\TestCase { diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/DocblockTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/DocblockTest.php index 061801ba75b762ccd39a13e45355648aadde7337..b15563d77029a20daa2139022129b7d94e72b717 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/DocblockTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/DocblockTest.php @@ -7,7 +7,7 @@ require_once 'ZendL/Reflection/File.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Docblock */ -class ZendL_Reflection_DocblockTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_DocblockTest extends PHPUnit\Framework\TestCase { diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/ExtensionTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/ExtensionTest.php index 2faaecd34a1c714d9faca09a03126eb123365e4d..3606e1de8b73e996d42dc43a32877824c4660215 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/ExtensionTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/ExtensionTest.php @@ -8,7 +8,7 @@ require_once 'ZendL/Reflection/Extension.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Extension */ -class ZendL_Reflection_ExtensionTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_ExtensionTest extends PHPUnit\Framework\TestCase { public function testClassReturn() diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/FileTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/FileTest.php index 5c9d29dc6cbbbc2aca7feb3510abcc490b76a83b..d46a36ca1267f117e4fd31a2d2af6ad8aab40f4c 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/FileTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/FileTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/File.php'; * @group ZendL_Reflection * @group ZendL_Reflection_File */ -class ZendL_Reflection_FileTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_FileTest extends PHPUnit\Framework\TestCase { public function testConstructor() diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/FunctionTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/FunctionTest.php index 5d84233c5b63846eaff4264917729941b54883ef..983de5afa140a378ce00e27ce716d11ae893c56c 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/FunctionTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/FunctionTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/Function.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Function */ -class ZendL_Reflection_FunctionTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_FunctionTest extends PHPUnit\Framework\TestCase { static protected $_sampleClassFileRequired = false; diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/MethodTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/MethodTest.php index d2125eee539fd83fcba5ea2d9d09c30210baa528..20bc8c1952068e6c807e741252c5b572ae7a6729 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/MethodTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/MethodTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/Method.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Method */ -class ZendL_Reflection_MethodTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_MethodTest extends PHPUnit\Framework\TestCase { static protected $_sampleClassFileRequired = false; diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/ParameterTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/ParameterTest.php index aed74e00ebfa83c1ddbddfd0b63f078581368d71..9d691b41be37298b5a24f6560bec091427e47336 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/ParameterTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/ParameterTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/Parameter.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Parameter */ -class ZendL_Reflection_ParameterTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_ParameterTest extends PHPUnit\Framework\TestCase { static protected $_sampleClassFileRequired = false; diff --git a/laboratory/Zend_Tool/tests/ZendL/Reflection/PropertyTest.php b/laboratory/Zend_Tool/tests/ZendL/Reflection/PropertyTest.php index d3169e08d5b5a50b0c54ea329f6e6f34ea29fde1..f21be77d1a029520e36266f4e25aadf17a570c73 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Reflection/PropertyTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Reflection/PropertyTest.php @@ -9,7 +9,7 @@ require_once 'ZendL/Reflection/Property.php'; * @group ZendL_Reflection * @group ZendL_Reflection_Property */ -class ZendL_Reflection_PropertyTest extends PHPUnit_Framework_TestCase +class ZendL_Reflection_PropertyTest extends PHPUnit\Framework\TestCase { static protected $_sampleClassFileRequired = false; diff --git a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/ClassTest.php b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/ClassTest.php index ebace62b59d71aca5f6bf19e24fc67ee97df360b..88000301cf1adfe36297a41a5fca1c741ce4d6e7 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/ClassTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/ClassTest.php @@ -6,7 +6,7 @@ require_once 'ZendL/Tool/CodeGenerator/Php/Class.php'; * * @group ZendL_Tool_CodeGenerator_Php */ -class ZendL_Tool_CodeGenerator_Php_ClassTest extends PHPUnit_Framework_TestCase +class ZendL_Tool_CodeGenerator_Php_ClassTest extends PHPUnit\Framework\TestCase { public function testConstruction() diff --git a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/FileTest.php b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/FileTest.php index e0754bd5a5828ef48584e67240d89385095789f6..68263f6e58147bf90ec444f95c63373067941f6c 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/FileTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/FileTest.php @@ -8,7 +8,7 @@ require_once 'ZendL/Reflection/File.php'; * @group ZendL_Tool_CodeGenerator_Php * @group ZendL_Tool_CodeGenerator_Php_File */ -class ZendL_Tool_CodeGenerator_Php_FileTest extends PHPUnit_Framework_TestCase +class ZendL_Tool_CodeGenerator_Php_FileTest extends PHPUnit\Framework\TestCase { public function testConstruction() diff --git a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/MethodTest.php b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/MethodTest.php index ceeedfff49b9130a074ac939093d5474ca782486..8dfe46758af077c315f63c78991403334cbb88c9 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/MethodTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/MethodTest.php @@ -6,7 +6,7 @@ require_once 'ZendL/Tool/CodeGenerator/Php/Method.php'; * * @group ZendL_Tool_CodeGenerator_Php */ -class ZendL_Tool_CodeGenerator_Php_MethodTest extends PHPUnit_Framework_TestCase +class ZendL_Tool_CodeGenerator_Php_MethodTest extends PHPUnit\Framework\TestCase { public function testConstructor() diff --git a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/PropertyTest.php b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/PropertyTest.php index 4808634350757a8133729d781503432a6d46888a..373ce05617c81f128c39bc4c43fd0f397a0fbc30 100644 --- a/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/PropertyTest.php +++ b/laboratory/Zend_Tool/tests/ZendL/Tool/CodeGenerator/Php/PropertyTest.php @@ -6,7 +6,7 @@ require_once 'ZendL/Tool/CodeGenerator/Php/Property.php'; * * @group ZendL_Tool_CodeGenerator_Php */ -class ZendL_Tool_CodeGenerator_Php_PropertyTest extends PHPUnit_Framework_TestCase +class ZendL_Tool_CodeGenerator_Php_PropertyTest extends PHPUnit\Framework\TestCase { public function testConstructor() diff --git a/library/Zend/Captcha/ReCaptcha.php b/library/Zend/Captcha/ReCaptcha.php index 974560455eba6724a77f5395abd36597341dd174..3974a6c9761c220756eb997a19c77e043416dc47 100644 --- a/library/Zend/Captcha/ReCaptcha.php +++ b/library/Zend/Captcha/ReCaptcha.php @@ -27,9 +27,9 @@ require_once 'Zend/Service/ReCaptcha.php'; /** * ReCaptcha adapter - * + * * Allows to insert captchas driven by ReCaptcha service - * + * * @see http://recaptcha.net/apidocs/captcha/ * * @category Zend @@ -39,7 +39,7 @@ require_once 'Zend/Service/ReCaptcha.php'; * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: $ */ -class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base +class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base { /** * Recaptcha public key @@ -54,15 +54,15 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base * @var string */ protected $_privkey; - + /**@+ - * ReCaptcha Field names + * ReCaptcha Field names * @var string */ protected $_CHALLENGE = 'recaptcha_challenge_field'; protected $_RESPONSE = 'recaptcha_response_field'; /**@-*/ - + /** * Recaptcha service object * @@ -72,7 +72,7 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base /** * Parameters defined by the service - * + * * @var array */ protected $_serviceParams = array(); @@ -88,62 +88,61 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base /** * Error messages - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::MISSING_VALUE => 'Missing captcha fields', self::ERR_CAPTCHA => 'Failed to validate captcha', self::BAD_CAPTCHA => 'Captcha value is wrong: %value%', - ); - + ]; + /** * Retrieve ReCaptcha Private key * * @return string */ - public function getPrivkey() + public function getPrivkey() { return $this->_privkey; } - + /** * Retrieve ReCaptcha Public key * * @return string */ - public function getPubkey() + public function getPubkey() { return $this->_pubkey; } - + /** * Set ReCaptcha Private key * * @param string $_privkey * @return Zend_Captcha_ReCaptcha */ - public function setPrivkey($privkey) + public function setPrivkey($privkey) { $this->_privkey = $privkey; return $this; } - + /** * Set ReCaptcha public key * * @param string $_pubkey * @return Zend_Captcha_ReCaptcha */ - public function setPubkey($pubkey) + public function setPubkey($pubkey) { $this->_pubkey = $pubkey; return $this; } - + /** * Constructor * - * @param array|Zend_Config $options + * @param array|Zend_Config $options * @return void */ public function __construct($options = null) @@ -163,8 +162,8 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base /** * Set service object - * - * @param Zend_Service_ReCaptcha $service + * + * @param Zend_Service_ReCaptcha $service * @return Zend_Captcha_ReCaptcha */ public function setService(Zend_Service_ReCaptcha $service) @@ -175,7 +174,7 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base /** * Retrieve ReCaptcha service object - * + * * @return Zend_Service_ReCaptcha */ public function getService() @@ -187,9 +186,9 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base * Set option * * If option is a service parameter, proxies to the service. - * - * @param string $key - * @param mixed $value + * + * @param string $key + * @param mixed $value * @return Zend_Captcha_ReCaptcha */ public function setOption($key, $value) @@ -201,7 +200,7 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base } return parent::setOption($key, $value); } - + /** * Generate captcha * @@ -228,14 +227,14 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base } $service = $this->getService(); - - $res = $service->verify($context[$this->_CHALLENGE], $context[$this->_RESPONSE]); - + + $res = $service->verify($context[$this->_CHALLENGE], $context[$this->_RESPONSE]); + if (!$res) { $this->_error(self::ERR_CAPTCHA); return false; } - + if (!$res->isValid()) { $this->_error(self::BAD_CAPTCHA, $res->getErrorCode()); $service->setParam('error', $res->getErrorCode()); @@ -244,12 +243,12 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base return true; } - + /** * Render captcha - * - * @param Zend_View $view - * @param mixed $element + * + * @param Zend_View $view + * @param mixed $element * @return string */ public function render(Zend_View $view, $element = null) diff --git a/library/Zend/Captcha/Word.php b/library/Zend/Captcha/Word.php index e1255cde86ef00a1ab3cae2b988f6aba26bb78b3..d5d92193fb9deaa3584b43372ad00d08e6028627 100644 --- a/library/Zend/Captcha/Word.php +++ b/library/Zend/Captcha/Word.php @@ -105,13 +105,12 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base /** * Error messages - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::MISSING_VALUE => 'Empty captcha value', self::MISSING_ID => 'Captcha ID field is missing', self::BAD_CAPTCHA => 'Captcha value is wrong', - ); + ]; /** * Length of the word to generate diff --git a/library/Zend/Controller/Action.php b/library/Zend/Controller/Action.php index 018a607c9aefe37352e386ffaf741b7badb153c9..ae5fcc2b8f4cd08f83d92c27cf2260abe6c9ccca 100644 --- a/library/Zend/Controller/Action.php +++ b/library/Zend/Controller/Action.php @@ -83,6 +83,8 @@ abstract class Zend_Controller_Action */ protected $_helper = null; + protected array $_actions_attributs = []; + /** * Class constructor * @@ -129,6 +131,17 @@ abstract class Zend_Controller_Action { } + public function setAttributs(string $key, mixed $value): self + { + $this->_actions_attributs [$key] = $value; + return $this; + } + + public function getAttributs(string $key, mixed $default = null): mixed + { + return $this->_actions_attributs [$key] ?? $default; + } + /** * Initialize View object * diff --git a/library/Zend/Controller/Action/Helper/ContextSwitch.php b/library/Zend/Controller/Action/Helper/ContextSwitch.php index a4f60d917408213a510c0bd85b3abcbdf237dea9..f5c8747650f4f5535624779d384acef6cdee5495 100644 --- a/library/Zend/Controller/Action/Helper/ContextSwitch.php +++ b/library/Zend/Controller/Action/Helper/ContextSwitch.php @@ -72,18 +72,18 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * @var string */ protected $_currentContext; - + /** * Default context (xml) * @var string */ - protected $_defaultContext = 'xml'; - + protected $_defaultContext = 'xml'; + /** * Whether or not to disable layouts when switching contexts * @var boolean */ - protected $_disableLayout = true; + protected $_disableLayout = true; /** * Methods that require special configuration @@ -116,8 +116,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Constructor - * - * @param array|Zend_Config $options + * + * @param array|Zend_Config $options * @return void */ public function __construct($options = null) @@ -148,8 +148,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Configure object from array of options - * - * @param array $options + * + * @param array $options * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setOptions(array $options) @@ -178,8 +178,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set object state from config object - * - * @param Zend_Config $config + * + * @param Zend_Config $config * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setConfig(Zend_Config $config) @@ -189,21 +189,21 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Strategy pattern: return object - * + * * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function direct() { return $this; } - + /** * Initialize context detection and switching * * @param mixed $format * @throws Zend_Controller_Action_Exception * @return void - */ + */ public function initContext($format = null) { $this->_currentContext = null; @@ -212,7 +212,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $request = $this->getRequest(); $action = $request->getActionName(); - // Return if no context switching enabled, or no context switching + // Return if no context switching enabled, or no context switching // enabled for this action $contexts = $this->getActionContexts($action); if (empty($contexts)) { @@ -233,7 +233,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action return; } - // Return if invalid context parameter provided and no format or invalid + // Return if invalid context parameter provided and no format or invalid // format provided if (!$this->hasContext($context)) { if (empty($format) || !$this->hasContext($format)) { @@ -292,7 +292,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * JSON context extra initialization * * Turns off viewRenderer auto-rendering - * + * * @return void */ public function initJsonContext() @@ -310,8 +310,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Should JSON contexts auto-serialize? - * - * @param boolean $flag + * + * @param boolean $flag * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setAutoJsonSerialization($flag) @@ -322,7 +322,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Get JSON context auto-serialization flag - * + * * @return boolean */ public function getAutoJsonSerialization() @@ -332,8 +332,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set suffix from array - * - * @param array $spec + * + * @param array $spec * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ protected function _setSuffix(array $spec) @@ -396,10 +396,10 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action } return $this; } - + /** * Customize view script suffix to use when switching context. - * + * * Passing an empty suffix value to the setters disables the view script * suffix change. * @@ -408,7 +408,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * @param boolean $prependViewRendererSuffix Whether or not to prepend the new suffix to the viewrenderer suffix * @throws Zend_Controller_Action_Exception * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function setSuffix($context, $suffix, $prependViewRendererSuffix = true) { if (!isset($this->_contexts[$context])) { @@ -450,7 +450,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Retrieve suffix for given context type - * + * * @param string $type Context type * @throws Zend_Controller_Action_Exception * @return string @@ -470,9 +470,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Does the given context exist? - * - * @param string $context - * @param boolean $throwException + * + * @param string $context + * @param boolean $throwException * @throws Zend_Controller_Action_Exception if context does not exist and throwException is true * @return bool */ @@ -511,11 +511,11 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Add header to context - * - * @param string $context - * @param string $header + * + * @param string $context + * @param string $header * @param string $content - * @throws Zend_Controller_Action_Exception + * @throws Zend_Controller_Action_Exception * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function addHeader($context, $header, $content) @@ -537,10 +537,10 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $this->_contexts[$context]['headers'][$header] = $content; return $this; } - + /** * Customize response header to use when switching context - * + * * Passing an empty header value to the setters disables the response * header. * @@ -548,7 +548,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * @param string $header Header to set * @param string $content Header content * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function setHeader($context, $header, $content) { $this->hasContext($context, true); @@ -562,9 +562,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Add multiple headers at once for a given context - * - * @param string $context - * @param array $headers + * + * @param string $context + * @param array $headers * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function addHeaders($context, array $headers) @@ -578,8 +578,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set headers from context => headers pairs - * - * @param array $options + * + * @param array $options * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ protected function _setHeaders(array $options) @@ -596,9 +596,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set multiple headers at once for a given context - * - * @param string $context - * @param array $headers + * + * @param string $context + * @param array $headers * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setHeaders($context, array $headers) @@ -615,7 +615,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * Retrieve context header * * Returns the value of a given header for a given context type - * + * * @param string $context * @param string $header * @return string|null @@ -636,7 +636,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * Retrieve context headers * * Returns all headers for a context as key/value pairs - * + * * @param string $context * @return array */ @@ -649,9 +649,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Remove a single header from a context - * - * @param string $context - * @param string $header + * + * @param string $context + * @param string $header * @return boolean */ public function removeHeader($context, $header) @@ -669,8 +669,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Clear all headers for a given context - * - * @param string $context + * + * @param string $context * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function clearHeaders($context) @@ -683,9 +683,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Validate trigger and return in normalized form - * + * * @param string $trigger - * @throws Zend_Controller_Action_Exception + * @throws Zend_Controller_Action_Exception * @return string */ protected function _validateTrigger($trigger) @@ -708,10 +708,10 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set a callback for a given context and trigger - * - * @param string $context - * @param string $trigger - * @param string|array $callback + * + * @param string $context + * @param string $trigger + * @param string|array $callback * @throws Zend_Controller_Action_Exception * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ @@ -736,8 +736,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set callbacks from array of context => callbacks pairs - * - * @param array $options + * + * @param array $options * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ protected function _setCallbacks(array $options) @@ -756,9 +756,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * Set callbacks for a given context * * Callbacks should be in trigger/callback pairs. - * - * @param string $context - * @param array $callbacks + * + * @param string $context + * @param array $callbacks * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setCallbacks($context, array $callbacks) @@ -777,9 +777,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Get a single callback for a given context and trigger - * - * @param string $context - * @param string $trigger + * + * @param string $context + * @param string $trigger * @return string|array|null */ public function getCallback($context, $trigger) @@ -795,8 +795,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Get all callbacks for a given context - * - * @param string $context + * + * @param string $context * @return array */ public function getCallbacks($context) @@ -807,9 +807,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Clear a callback for a given context and trigger - * - * @param string $context - * @param string $trigger + * + * @param string $context + * @param string $trigger * @return boolean */ public function removeCallback($context, $trigger) @@ -826,8 +826,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Clear all callbacks for a given context - * - * @param string $context + * + * @param string $context * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function clearCallbacks($context) @@ -842,7 +842,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * * @param string $name * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function setContextParam($name) { $this->_contextParam = (string) $name; @@ -851,21 +851,21 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Return context format request parameter name - * + * * @return string */ public function getContextParam() { return $this->_contextParam; } - + /** * Indicate default context to use when no context format provided * * @param string $type * @throws Zend_Controller_Action_Exception * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function setDefaultContext($type) { if (!isset($this->_contexts[$type])) { @@ -882,20 +882,20 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Return default context - * + * * @return string */ public function getDefaultContext() { return $this->_defaultContext; } - + /** * Set flag indicating if layout should be disabled * * @param boolean $flag * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function setAutoDisableLayout($flag) { $this->_disableLayout = ($flag) ? true : false; @@ -904,14 +904,14 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Retrieve auto layout disable flag - * + * * @return boolean */ public function getAutoDisableLayout() { return $this->_disableLayout; } - + /** * Add new context * @@ -919,7 +919,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * @param array $spec Context specification * @throws Zend_Controller_Action_Exception * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function addContext($context, array $spec) { if ($this->hasContext($context)) { @@ -945,7 +945,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * @param string $context Context type * @param array $spec Context specification * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface - */ + */ public function setContext($context, array $spec) { $this->removeContext($context); @@ -954,8 +954,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Add multiple contexts - * - * @param array $contexts + * + * @param array $contexts * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function addContexts(array $contexts) @@ -968,8 +968,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set multiple contexts, after first removing all - * - * @param array $contexts + * + * @param array $contexts * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setContexts(array $contexts) @@ -983,8 +983,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Retrieve context specification - * - * @param string $context + * + * @param string $context * @return array|null */ public function getContext($context) @@ -997,7 +997,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Retrieve context definitions - * + * * @return array */ public function getContexts() @@ -1007,8 +1007,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Remove a context - * - * @param string $context + * + * @param string $context * @return boolean */ public function removeContext($context) @@ -1022,7 +1022,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Remove all contexts - * + * * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function clearContexts() @@ -1033,7 +1033,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Return current context, if any - * + * * @return null|string */ public function getCurrentContext() @@ -1046,7 +1046,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * * Execute postDispatch callback for current context, if available * - * @throws Zend_Controller_Action_Exception + * @throws Zend_Controller_Action_Exception * @return void */ public function postDispatch() @@ -1075,7 +1075,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action * JSON post processing * * JSON serialize view variables to response body - * + * * @return void */ public function postJsonContext() @@ -1098,9 +1098,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Add one or more contexts to an action - * - * @param string $action - * @param string|array $context + * + * @param string $action + * @param string|array $context * @return Zend_Controller_Action_Helper_ContextSwitch|void Provides a fluent interface */ public function addActionContext($action, $context) @@ -1113,24 +1113,26 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $action = (string) $action; $contextKey = $this->_contextKey; - if (!isset($controller->$contextKey)) { - $controller->$contextKey = array(); - } + if ( ! $controller->getAttributs($contextKey)) + $controller->setAttributs($contextKey, []); + $contexts_keys = $controller->getAttributs($contextKey); if (true === $context) { $contexts = $this->getContexts(); - $controller->{$contextKey}[$action] = array_keys($contexts); + $contexts_keys[$action] = array_keys($contexts); + $controller->setAttributs($contextKey, $contexts_keys); return $this; } $context = (array) $context; - if (!isset($controller->{$contextKey}[$action])) { - $controller->{$contextKey}[$action] = $context; + $actions = $contexts_keys[$action] ?? []; + + if ( ! $actions) { + $contexts_keys[$action] = $context; + $controller->setAttributs($contextKey, $contexts_keys); } else { - $controller->{$contextKey}[$action] = array_merge( - $controller->{$contextKey}[$action], - $context - ); + $contexts_keys[$action] = array_merge($actions, $context); + $controller->setAttributs($contextKey, $contexts_keys); } return $this; @@ -1138,9 +1140,9 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Set a context as available for a given controller action - * - * @param string $action - * @param string|array $context + * + * @param string $action + * @param string|array $context * @return Zend_Controller_Action_Helper_ContextSwitch|void Provides a fluent interface */ public function setActionContext($action, $context) @@ -1153,15 +1155,17 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $action = (string) $action; $contextKey = $this->_contextKey; - if (!isset($controller->$contextKey)) { - $controller->$contextKey = array(); - } + if ( ! $controller->getAttributs($contextKey)) + $controller->setAttributs($contextKey, []); + $contexts_keys = $controller->getAttributs($contextKey); if (true === $context) { $contexts = $this->getContexts(); - $controller->{$contextKey}[$action] = array_keys($contexts); + $contexts_keys[$action] = array_keys($contexts); + $controller->setAttributs($contextKey, $contexts_keys); } else { - $controller->{$contextKey}[$action] = (array) $context; + $contexts_keys[$action] = (array) $context; + $controller->setAttributs($contextKey, $contexts_keys); } return $this; @@ -1169,8 +1173,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Add multiple action/context pairs at once - * - * @param array $contexts + * + * @param array $contexts * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function addActionContexts(array $contexts) @@ -1183,8 +1187,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Overwrite and set multiple action contexts at once - * - * @param array $contexts + * + * @param array $contexts * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function setActionContexts(array $contexts) @@ -1197,10 +1201,10 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Does a particular controller action have the given context(s)? - * - * @param string $action + * + * @param string $action * @param string|array $context - * @throws Zend_Controller_Action_Exception + * @throws Zend_Controller_Action_Exception * @return boolean */ public function hasActionContext($action, $context) @@ -1213,13 +1217,10 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $action = (string) $action; $contextKey = $this->_contextKey; - if (!isset($controller->{$contextKey})) { + if ( ! ($contexts_keys = $controller->getAttributs($contextKey, []))) return false; - } - - $allContexts = $controller->{$contextKey}; - if (!is_array($allContexts)) { + if ( ! is_array($contexts_keys)) { /** * @see Zend_Controller_Action_Exception */ @@ -1227,15 +1228,15 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action throw new Zend_Controller_Action_Exception("Invalid contexts found for controller"); } - if (!isset($allContexts[$action])) { + if (!isset($contexts_keys[$action])) { return false; } - if (true === $allContexts[$action]) { + if (true === $contexts_keys[$action]) { return true; } - $contexts = $allContexts[$action]; + $contexts = $contexts_keys[$action]; if (!is_array($contexts)) { /** @@ -1263,8 +1264,8 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action /** * Get contexts for a given action or all actions in the controller - * - * @param string $action + * + * @param string $action * @return array */ public function getActionContexts($action = null) @@ -1276,26 +1277,25 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $action = (string) $action; $contextKey = $this->_contextKey; - if (!isset($controller->$contextKey)) { - return array(); - } + if ( ! ($contexts_keys = $controller->getAttributs($contextKey, []))) + return []; if (null !== $action) { - if (isset($controller->{$contextKey}[$action])) { - return $controller->{$contextKey}[$action]; + if ($actions = ($contexts_keys[$action] ?? [])) { + return $actions; } else { - return array(); + return []; } } - return $controller->$contextKey; + return $contexts_keys; } /** * Remove one or more contexts for a given controller action - * - * @param string $action - * @param string|array $context + * + * @param string $action + * @param string|array $context * @return boolean */ public function removeActionContext($action, $context) @@ -1304,24 +1304,29 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $controller = $this->getActionController(); $contextKey = $this->_contextKey; $action = (string) $action; - $contexts = $controller->$contextKey; - $actionContexts = $contexts[$action]; - $contexts = (array) $context; - foreach ($contexts as $context) { - $index = array_search($context, $actionContexts); - if (false !== $index) { - unset($controller->{$contextKey}[$action][$index]); - } + $contexts_keys = $controller->getAttributs($contextKey, []); + $actionContexts = $contexts_keys[$action] ?? []; + $contexts_actions = (array) $context; + + foreach ($contexts_actions as $context_action) { + $index = array_search($context_action, $actionContexts); + + if (false !== $index) + unset($actionContexts[$index]); } + + $contexts_keys [$action] = $actionContexts; + $controller->setAttributs($contextKey, $contexts_keys); return true; } + return false; } /** * Clear all contexts for a given controller action or all actions - * - * @param string $action + * + * @param string $action * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface */ public function clearActionContexts($action = null) @@ -1329,26 +1334,24 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action $controller = $this->getActionController(); $contextKey = $this->_contextKey; - if (!isset($controller->$contextKey) || empty($controller->$contextKey)) { + if ( ! ($contexts_keys = $controller->getAttributs($contextKey, []))) return $this; - } if (null === $action) { - $controller->$contextKey = array(); + $controller->setAttributs($contextKey, []); return $this; } $action = (string) $action; - if (isset($controller->{$contextKey}[$action])) { - unset($controller->{$contextKey}[$action]); - } + unset($contexts_keys[$action]); + $controller->setAttributs($contextKey, $contexts_keys); return $this; } /** * Retrieve ViewRenderer - * + * * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface */ protected function _getViewRenderer() @@ -1360,4 +1363,3 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action return $this->_viewRenderer; } } - diff --git a/library/Zend/Controller/Action/Helper/Redirector.php b/library/Zend/Controller/Action/Helper/Redirector.php index c36b44b3970001ccee5d23c3f54fc9c1abc34a59..5496592c66e63ba3438690237b4a191deae39107 100644 --- a/library/Zend/Controller/Action/Helper/Redirector.php +++ b/library/Zend/Controller/Action/Helper/Redirector.php @@ -19,7 +19,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** +/** * @see Zend_Controller_Action_Exception */ require_once 'Zend/Controller/Action/Exception.php'; @@ -256,8 +256,8 @@ class Zend_Controller_Action_Helper_Redirector extends Zend_Controller_Action_He if (null === $module) { $module = $curModule; - } - + } + if ($module == $dispatcher->getDefaultModule()) { $module = ''; } @@ -320,10 +320,10 @@ class Zend_Controller_Action_Helper_Redirector extends Zend_Controller_Action_He * @param array $options * @return void */ - public function setGotoUrl($url, array $options = array()) + public function setGotoUrl($url, array $options = []) { // prevent header injections - $url = str_replace(array("\n", "\r"), '', $url); + $url = str_replace(["\n", "\r"], '', ($url ?? '')); $exit = $this->getExit(); $prependBase = $this->getPrependBase(); @@ -485,9 +485,9 @@ class Zend_Controller_Action_Helper_Redirector extends Zend_Controller_Action_He * Overloading * * Overloading for old 'goto', 'setGoto', and 'gotoAndExit' methods - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return mixed * @throws Zend_Controller_Action_Exception for invalid methods */ diff --git a/library/Zend/Controller/Request/Http.php b/library/Zend/Controller/Request/Http.php index e28d47ad2ca069717c90f33daf8c7ce673c40d10..d2bcafa7372c9e88b42c1a4f21cf7fca3e73018e 100644 --- a/library/Zend/Controller/Request/Http.php +++ b/library/Zend/Controller/Request/Http.php @@ -43,7 +43,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract * */ const SCHEME_HTTP = 'http'; - + /** * Scheme for https * @@ -237,9 +237,9 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract /** * Set GET values - * - * @param string|array $spec - * @param null|mixed $value + * + * @param string|array $spec + * @param null|mixed $value * @return Zend_Controller_Request_Http */ public function setQuery($spec, $value = null) @@ -279,9 +279,9 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract /** * Set POST values - * - * @param string|array $spec - * @param null|mixed $value + * + * @param string|array $spec + * @param null|mixed $value * @return Zend_Controller_Request_Http */ public function setPost($spec, $value = null) @@ -481,7 +481,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract } // Does the baseUrl have anything in common with the request_uri? - $requestUri = $this->getRequestUri(); + $requestUri = $this->getRequestUri() ?? ''; if (0 === strpos($requestUri, $baseUrl)) { // full $baseUrl matches @@ -627,8 +627,8 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract * Set allowed parameter sources * * Can be empty array, or contain one or more of '_GET' or '_POST'. - * - * @param array $paramSoures + * + * @param array $paramSoures * @return Zend_Controller_Request_Http */ public function setParamSources(array $paramSources = array()) @@ -639,7 +639,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract /** * Get list of allowed parameter sources - * + * * @return array */ public function getParamSources() @@ -867,7 +867,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract return false; } - + /** * Is the request a Javascript XMLHttpRequest? * @@ -882,14 +882,14 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract /** * Is this a Flash request? - * + * * @return bool */ public function isFlashRequest() { return ($this->getHeader('USER_AGENT') == 'Shockwave Flash'); } - + /** * Is https secure request * @@ -899,7 +899,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract { return ($this->getScheme() === self::SCHEME_HTTPS); } - + /** * Return the raw body of the request, if present * @@ -949,7 +949,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract return false; } - + /** * Get the request URI scheme * @@ -959,7 +959,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract { return ($this->getServer('HTTPS') == 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP; } - + /** * Get the HTTP host. * @@ -975,10 +975,10 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract if (!empty($host)) { return $host; } - + $scheme = $this->getScheme(); $name = $this->getServer('SERVER_NAME'); - $port = $this->getServer('SERVER_PORT'); + $port = $this->getServer('SERVER_PORT'); if (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) { return $name; diff --git a/library/Zend/Controller/Router/Rewrite.php b/library/Zend/Controller/Router/Rewrite.php index b73c5049f9f0db5db1770a74960316a9551e7ad9..617599a23818647fe2bc553e44c68ac8793d852a 100644 --- a/library/Zend/Controller/Router/Rewrite.php +++ b/library/Zend/Controller/Router/Rewrite.php @@ -330,9 +330,9 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract $url = $route->assemble($userParams, $reset, $encode); if (!preg_match('|^[a-z]+://|', $url)) { - $url = rtrim($this->getFrontController()->getBaseUrl(), '/') . '/' . $url; + $url = rtrim($this->getFrontController()->getBaseUrl() ?? '', '/') . '/' . $url; } return $url; } -} \ No newline at end of file +} diff --git a/library/Zend/Controller/Router/Route/Module.php b/library/Zend/Controller/Router/Route/Module.php index c0596274b7b6537c70b8e2e57fac404f843c991f..09e361795d28f1cf3797d6b8e0e2977bf3cdaa92 100644 --- a/library/Zend/Controller/Router/Route/Module.php +++ b/library/Zend/Controller/Router/Route/Module.php @@ -72,7 +72,7 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A public function getVersion() { return 1; } - + /** * Instantiates route based on passed Zend_Config structure */ @@ -219,7 +219,7 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A unset($params[$this->_actionKey]); foreach ($params as $key => $value) { - if ($encode) $value = urlencode($value); + if ($encode) $value = urlencode((string) $value); $url .= '/' . $key; $url .= '/' . $value; } diff --git a/library/Zend/Db/Table/Abstract.php b/library/Zend/Db/Table/Abstract.php index 8cdbb3ef51d97eee601ad04bd3391230d6180db7..c4a2c2ea74172e0709ddc865b3696a85c4882deb 100644 --- a/library/Zend/Db/Table/Abstract.php +++ b/library/Zend/Db/Table/Abstract.php @@ -218,7 +218,7 @@ abstract class Zend_Db_Table_Abstract * @param mixed $config Array of user-specified config options, or just the Db Adapter. * @return void */ - public function __construct($config = array()) + public function __construct(array $config = []) { /** * Allow a scalar argument to be the Adapter object or Registry key. @@ -600,8 +600,7 @@ abstract class Zend_Db_Table_Abstract if (null === $this->_metadataCache || !($metadata = $this->_metadataCache->load($cacheId))) { // Metadata are not loaded from cache $isMetadataFromCache = false; - // Fetch metadata from the adapter's describeTable() method - $metadata = $this->_db->describeTable($this->_name, $this->_schema); + $metadata = $this->_setupDescribe(); // If $this has a metadata cache, then cache the metadata if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) { /** @@ -622,6 +621,12 @@ abstract class Zend_Db_Table_Abstract return $isMetadataFromCache; } + protected function _setupDescribe(): array + { + // Fetch metadata from the adapter's describeTable() method + return $this->_db->describeTable($this->_name, $this->_schema); + } + /** * Initialize primary key from metadata. * If $_primary is not defined, discover primary keys @@ -750,16 +755,16 @@ abstract class Zend_Db_Table_Abstract self::DEPENDENT_TABLES => $this->_dependentTables, self::SEQUENCE => $this->_sequence ); - + if ($key === null) { return $info; } - + if (!array_key_exists($key, $info)) { require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"'); } - + return $info[$key]; } diff --git a/library/Zend/Dom/Query.php b/library/Zend/Dom/Query.php index af5d46ac7490b9328943e249523b8c3bba39efb8..85231deac432eed5de9369af7de06e98aa1057f8 100644 --- a/library/Zend/Dom/Query.php +++ b/library/Zend/Dom/Query.php @@ -30,7 +30,7 @@ require_once 'Zend/Dom/Query/Result.php'; /** * Query DOM structures based on CSS selectors and/or XPath - * + * * @package Zend_Dom * @subpackage Query * @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc. @@ -59,8 +59,8 @@ class Zend_Dom_Query /** * Constructor - * - * @param null|string $document + * + * @param null|string $document * @return void */ public function __construct($document = null) @@ -72,8 +72,8 @@ class Zend_Dom_Query /** * Set document to query - * - * @param string $document + * + * @param string $document * @return Zend_Dom_Query */ public function setDocument($document) @@ -88,9 +88,9 @@ class Zend_Dom_Query } /** - * Register HTML document - * - * @param string $document + * Register HTML document + * + * @param string $document * @return Zend_Dom_Query */ public function setDocumentHtml($document) @@ -102,8 +102,8 @@ class Zend_Dom_Query /** * Register XHTML document - * - * @param string $document + * + * @param string $document * @return Zend_Dom_Query */ public function setDocumentXhtml($document) @@ -115,8 +115,8 @@ class Zend_Dom_Query /** * Register XML document - * - * @param string $document + * + * @param string $document * @return Zend_Dom_Query */ public function setDocumentXml($document) @@ -128,7 +128,7 @@ class Zend_Dom_Query /** * Retrieve current document - * + * * @return string */ public function getDocument() @@ -138,7 +138,7 @@ class Zend_Dom_Query /** * Get document type - * + * * @return string */ public function getDocumentType() @@ -148,8 +148,8 @@ class Zend_Dom_Query /** * Perform a CSS selector query - * - * @param string $query + * + * @param string $query * @return Zend_Dom_Query_Result */ public function query($query) @@ -160,7 +160,7 @@ class Zend_Dom_Query /** * Perform an XPath query - * + * * @param string $xpathQuery * @param string $query CSS selector query * @return Zend_Dom_Query_Result @@ -190,13 +190,41 @@ class Zend_Dom_Query throw new Zend_Dom_Exception(sprintf('Error parsing document (type == %s)', $type)); } - $nodeList = $this->_getNodeList($domDoc, $xpathQuery); + $nodeList = $this->_getNodeList($domDoc, $xpathQuery); return new Zend_Dom_Query_Result($query, $xpathQuery, $domDoc, $nodeList); } + public function queryAsString(string $query): string + { + return $this->_domResultAsString($this->query($query)); + } + + public function xpathAsString(string $xpath): string + { + return $this->_domResultAsString($this->queryXpath($xpath)); + } + + protected function _domResultAsString(Zend_Dom_Query_Result $dom_result): string + { + if (0 === count($dom_result)) + return ''; + + $result = []; + foreach ($dom_result as $node) { + $doc = $node->ownerDocument; + $content = $doc->saveXML($node); + $tag = $node->nodeName; + $regex = '|</?' . $tag . '[^>]*>|'; + + $result [] = preg_replace($regex, '', $content); + } + + return implode('', $result); + } + /** * Prepare node list - * + * * @param DOMDocument $document * @param string|array $xpathQuery * @return array @@ -204,7 +232,7 @@ class Zend_Dom_Query protected function _getNodeList($document, $xpathQuery) { $xpath = new DOMXPath($document); - $xpathQuery = (string) $xpathQuery; + $xpathQuery = is_array($xpathQuery) ? implode('', $xpathQuery) : (string) $xpathQuery; if (preg_match_all('|\[contains\((@[a-z0-9_-]+),\s?\' |i', $xpathQuery, $matches)) { foreach ($matches[1] as $attribute) { $queryString = '//*[' . $attribute . ']'; diff --git a/library/Zend/Dom/Query/Result.php b/library/Zend/Dom/Query/Result.php index a29d2c818c125200e6946f6a2265b7c8f01b97b0..a8341929d95bfc2b190d8ac9572843557837e62c 100644 --- a/library/Zend/Dom/Query/Result.php +++ b/library/Zend/Dom/Query/Result.php @@ -20,7 +20,7 @@ /** * Results for DOM XPath query - * + * * @package Zend_Dom * @subpackage Query * @uses Iterator @@ -71,10 +71,10 @@ class Zend_Dom_Query_Result implements Iterator,Countable /** * Constructor - * - * @param string $cssQuery - * @param string|array $xpathQuery - * @param DOMDocument $document + * + * @param string $cssQuery + * @param string|array $xpathQuery + * @param DOMDocument $document * @param DOMNodeList $nodeList * @return void */ @@ -88,7 +88,7 @@ class Zend_Dom_Query_Result implements Iterator,Countable /** * Retrieve CSS Query - * + * * @return string */ public function getCssQuery() @@ -98,7 +98,7 @@ class Zend_Dom_Query_Result implements Iterator,Countable /** * Retrieve XPath query - * + * * @return string */ public function getXpathQuery() @@ -108,7 +108,7 @@ class Zend_Dom_Query_Result implements Iterator,Countable /** * Retrieve DOMDocument - * + * * @return DOMDocument */ public function getDocument() @@ -118,21 +118,21 @@ class Zend_Dom_Query_Result implements Iterator,Countable /** * Iterator: rewind to first element - * + * * @return void */ - public function rewind() + public function rewind(): void { $this->_position = 0; - return $this->_nodeList->item(0); + $this->_nodeList->item(0); } /** * Iterator: is current position valid? - * + * * @return bool */ - public function valid() + public function valid(): bool { if (in_array($this->_position, range(0, $this->_nodeList->length - 1))) { return true; @@ -142,41 +142,41 @@ class Zend_Dom_Query_Result implements Iterator,Countable /** * Iterator: return current element - * + * * @return DOMElement */ - public function current() + public function current(): mixed { return $this->_nodeList->item($this->_position); } /** * Iterator: return key of current element - * + * * @return int */ - public function key() + public function key(): mixed { return $this->_position; } /** * Iterator: move to next element - * + * * @return void */ - public function next() + public function next(): void { ++$this->_position; - return $this->_nodeList->item($this->_position); + $this->_nodeList->item($this->_position); } /** * Countable: get count - * + * * @return int */ - public function count() + public function count(): int { return $this->_nodeList->length; } diff --git a/library/Zend/Feed/Abstract.php b/library/Zend/Feed/Abstract.php index 52218265c9a1329c369cfb5235e1208499b2cf54..c70782d95a85e8ce07e5a8fe22656b02edb01282 100644 --- a/library/Zend/Feed/Abstract.php +++ b/library/Zend/Feed/Abstract.php @@ -77,7 +77,7 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator $client->setUri($uri); $response = $client->request('GET'); if ($response->getStatus() !== 200) { - /** + /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; @@ -123,8 +123,8 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator $php_errormsg = '(error message not available)'; } } - - /** + + /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; @@ -181,7 +181,7 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator * * @return void */ - public function rewind() + public function rewind(): void { $this->_entryIndex = 0; } @@ -192,7 +192,7 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator * * @return mixed The current row, or null if no rows. */ - public function current() + public function current(): mixed { return new $this->_entryClassName( null, @@ -205,7 +205,7 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator * * @return mixed The current row number (starts at 0), or NULL if no rows */ - public function key() + public function key(): mixed { return $this->_entryIndex; } @@ -216,7 +216,7 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator * * @return mixed The next row, or null if no more rows. */ - public function next() + public function next(): void { ++$this->_entryIndex; } @@ -227,7 +227,7 @@ abstract class Zend_Feed_Abstract extends Zend_Feed_Element implements Iterator * * @return boolean Whether the iteration is valid */ - public function valid() + public function valid(): bool { return 0 <= $this->_entryIndex && $this->_entryIndex < $this->count(); } diff --git a/library/Zend/Feed/Element.php b/library/Zend/Feed/Element.php index 4ee09438ea0c1de3b744cd288cc8702ea5085cd7..c1f29c17d259494f5f8a634cdc66a024186565ee 100644 --- a/library/Zend/Feed/Element.php +++ b/library/Zend/Feed/Element.php @@ -211,7 +211,7 @@ class Zend_Feed_Element implements ArrayAccess $this->_element->appendChild($node); } } elseif (count($nodes) > 1) { - /** + /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; @@ -341,7 +341,7 @@ class Zend_Feed_Element implements ArrayAccess * @param string $offset * @return boolean */ - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); @@ -358,7 +358,7 @@ class Zend_Feed_Element implements ArrayAccess * @param string $offset * @return string */ - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); @@ -376,15 +376,15 @@ class Zend_Feed_Element implements ArrayAccess * @param string $value * @return string */ - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->ensureAppended(); if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); - return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $attr, $value); + $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $attr, $value); } else { - return $this->_element->setAttribute($offset, $value); + $this->_element->setAttribute($offset, $value); } } @@ -395,13 +395,13 @@ class Zend_Feed_Element implements ArrayAccess * @param string $offset * @return boolean */ - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); - return $this->_element->removeAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); + $this->_element->removeAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { - return $this->_element->removeAttribute($offset); + $this->_element->removeAttribute($offset); } } diff --git a/library/Zend/Form.php b/library/Zend/Form.php index 77c1b6095448fdef81d76ed11a915cf1da1386b4..b577ca68c29b25a50180d3806222140772e12d90 100644 --- a/library/Zend/Form.php +++ b/library/Zend/Form.php @@ -873,7 +873,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface return $id; } - $id = $this->getFullyQualifiedName(); + $id = $this->getFullyQualifiedName() ?? ''; // Bail early if no array notation detected if (!strstr($id, '[')) { diff --git a/library/Zend/Form/Decorator/Label.php b/library/Zend/Form/Decorator/Label.php index 58832f068598547bb2a96ec58b0a9da50c135f08..419bdba9528dce1eb495292ddd0b24ee50da6ac1 100644 --- a/library/Zend/Form/Decorator/Label.php +++ b/library/Zend/Form/Decorator/Label.php @@ -35,7 +35,7 @@ require_once 'Zend/Form/Decorator/Abstract.php'; * - req(uired)Suffix: a suffix to the label to use when the element is required * * Any other options passed will be used as HTML attributes of the label tag. - * + * * @category Zend * @package Zend_Form * @subpackage Decorator @@ -56,11 +56,25 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract * @var string */ protected $_tag; + protected array $_decorator_attribs = []; + + public function __set($key, $val) + { + $this->_decorator_attribs [$key] = $val; + } + + + public function __get($key) + { + return (array_key_exists($key, $this->_decorator_attribs) + ? $this->_decorator_attribs[$key] + : null); + } /** * Set element ID - * - * @param string $id + * + * @param string $id * @return Zend_Form_Decorator_Label */ public function setId($id) @@ -72,9 +86,9 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Retrieve element ID (used in 'for' attribute) * - * If none set in decorator, looks first for element 'id' attribute, and + * If none set in decorator, looks first for element 'id' attribute, and * defaults to element name. - * + * * @return string */ public function getId() @@ -92,8 +106,8 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Set HTML tag with which to surround label - * - * @param string $tag + * + * @param string $tag * @return Zend_Form_Decorator_Label */ public function setTag($tag) @@ -108,7 +122,7 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Get HTML tag, if any, with which to surround label - * + * * @return void */ public function getTag() @@ -128,9 +142,9 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Get class with which to define label * - * Appends either 'optional' or 'required' to class, depending on whether + * Appends either 'optional' or 'required' to class, depending on whether * or not the element is required. - * + * * @return string */ public function getClass() @@ -155,8 +169,8 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Load an optional/required suffix/prefix key - * - * @param string $key + * + * @param string $key * @return void */ protected function _loadOptReqKey($key) @@ -179,9 +193,9 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract * - getOptSuffix() * - reqOptPrefix() * - reqOptSuffix() - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return mixed * @throws Zend_Form_Exception for unsupported methods */ @@ -223,7 +237,7 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Get label to render - * + * * @return void */ public function getLabel() @@ -233,7 +247,7 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract } $label = $element->getLabel(); - $label = trim($label); + $label = trim($label ?? ''); if (empty($label)) { return ''; @@ -263,8 +277,8 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract /** * Render a label - * - * @param string $content + * + * @param string $content * @return string */ public function render($content) @@ -290,7 +304,7 @@ class Zend_Form_Decorator_Label extends Zend_Form_Decorator_Abstract if (!empty($label)) { $options['class'] = $class; - $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options); + $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options); } else { $label = ' '; } diff --git a/library/Zend/Form/Decorator/ViewHelper.php b/library/Zend/Form/Decorator/ViewHelper.php index 8bf56b7761e7bbc3867a49a1b7802cabfd7b85bb..75d17a21beafdeaa522fddaef1bc1f47ca2570ee 100644 --- a/library/Zend/Form/Decorator/ViewHelper.php +++ b/library/Zend/Form/Decorator/ViewHelper.php @@ -31,9 +31,9 @@ require_once 'Zend/Form/Decorator/Abstract.php'; * - placement: whether to append or prepend the generated content to the passed in content * - helper: the name of the view helper to use * - * Assumes the view helper accepts three parameters, the name, value, and + * Assumes the view helper accepts three parameters, the name, value, and * optional attributes; these will be provided by the element. - * + * * @category Zend * @package Zend_Form * @subpackage Decorator @@ -61,8 +61,8 @@ class Zend_Form_Decorator_ViewHelper extends Zend_Form_Decorator_Abstract /** * Set view helper to use when rendering - * - * @param string $helper + * + * @param string $helper * @return Zend_Form_Decorator_Element_ViewHelper */ public function setHelper($helper) @@ -105,9 +105,9 @@ class Zend_Form_Decorator_ViewHelper extends Zend_Form_Decorator_Abstract /** * Get name * - * If element is a Zend_Form_Element, will attempt to namespace it if the + * If element is a Zend_Form_Element, will attempt to namespace it if the * element belongs to an array. - * + * * @return string */ public function getName() @@ -139,7 +139,7 @@ class Zend_Form_Decorator_ViewHelper extends Zend_Form_Decorator_Abstract * Retrieve element attributes * * Set id to element name and/or array item. - * + * * @return array */ public function getElementAttribs() @@ -182,8 +182,8 @@ class Zend_Form_Decorator_ViewHelper extends Zend_Form_Decorator_Abstract * Get value * * If element type is one of the button types, returns the label. - * - * @param Zend_Form_Element $element + * + * @param Zend_Form_Element $element * @return string|null */ public function getValue($element) @@ -204,10 +204,10 @@ class Zend_Form_Decorator_ViewHelper extends Zend_Form_Decorator_Abstract /** * Render an element using a view helper * - * Determine view helper from 'viewHelper' option, or, if none set, from - * the element type. Then call as + * Determine view helper from 'viewHelper' option, or, if none set, from + * the element type. Then call as * helper($element->getName(), $element->getValue(), $element->getAttribs()) - * + * * @param string $content * @return string * @throws Zend_Form_Decorator_Exception if element or view are not registered @@ -234,7 +234,7 @@ class Zend_Form_Decorator_ViewHelper extends Zend_Form_Decorator_Abstract $id = $element->getId(); $attribs['id'] = $id; - $elementContent = $view->$helper($name, $value, $attribs, $element->options); + $elementContent = $view->$helper($name, $value, $attribs, $element->getAttrib('options')); switch ($this->getPlacement()) { case self::APPEND: return $content . $separator . $elementContent; diff --git a/library/Zend/Form/DisplayGroup.php b/library/Zend/Form/DisplayGroup.php index ada8ecdbc329370accfb527c46891dfe6b342bad..0e0774e113d0075e4de03976d24ae4d86dd1aa14 100644 --- a/library/Zend/Form/DisplayGroup.php +++ b/library/Zend/Form/DisplayGroup.php @@ -20,7 +20,7 @@ /** * Zend_Form_DisplayGroup - * + * * @category Zend * @package Zend_Form * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) @@ -107,10 +107,10 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Constructor - * - * @param string $name - * @param Zend_Loader_PluginLoader $loader - * @param array|Zend_Config $options + * + * @param string $name + * @param Zend_Loader_PluginLoader $loader + * @param array|Zend_Config $options * @return void */ public function __construct($name, Zend_Loader_PluginLoader $loader, $options = null) @@ -133,7 +133,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Initialize object; used by extending classes - * + * * @return void */ public function init() @@ -142,8 +142,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set options - * - * @param array $options + * + * @param array $options * @return Zend_Form_DisplayGroup */ public function setOptions(array $options) @@ -171,8 +171,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set options from config object - * - * @param Zend_Config $config + * + * @param Zend_Config $config * @return Zend_Form_DisplayGroup */ public function setConfig(Zend_Config $config) @@ -182,9 +182,9 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set group attribute - * - * @param string $key - * @param mixed $value + * + * @param string $key + * @param mixed $value * @return Zend_Form_DisplayGroup */ public function setAttrib($key, $value) @@ -196,8 +196,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add multiple form attributes at once - * - * @param array $attribs + * + * @param array $attribs * @return Zend_Form_DisplayGroup */ public function addAttribs(array $attribs) @@ -212,8 +212,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable * Set multiple form attributes at once * * Overwrites any previously set attributes. - * - * @param array $attribs + * + * @param array $attribs * @return Zend_Form_DisplayGroup */ public function setAttribs(array $attribs) @@ -224,8 +224,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve a single form attribute - * - * @param string $key + * + * @param string $key * @return mixed */ public function getAttrib($key) @@ -240,7 +240,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve all form attributes/metadata - * + * * @return array */ public function getAttribs() @@ -250,8 +250,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Remove attribute - * - * @param string $key + * + * @param string $key * @return bool */ public function removeAttrib($key) @@ -266,7 +266,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Clear all form attributes - * + * * @return Zend_Form */ public function clearAttribs() @@ -277,8 +277,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Filter a name to only allow valid variable characters - * - * @param string $value + * + * @param string $value * @return string */ public function filterName($value) @@ -288,8 +288,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set group name - * - * @param string $name + * + * @param string $name * @return Zend_Form_DisplayGroup */ public function setName($name) @@ -306,7 +306,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve group name - * + * * @return string */ public function getName() @@ -318,7 +318,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable * Get fully qualified name * * Places name as subitem of array and/or appends brackets. - * + * * @return string */ public function getFullyQualifiedName() @@ -328,7 +328,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Get element id - * + * * @return string */ public function getId() @@ -357,8 +357,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set group legend - * - * @param string $legend + * + * @param string $legend * @return Zend_Form_DisplayGroup */ public function setLegend($legend) @@ -368,7 +368,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve group legend - * + * * @return string */ public function getLegend() @@ -378,8 +378,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set description - * - * @param string $value + * + * @param string $value * @return Zend_Form_DisplayGroup */ public function setDescription($value) @@ -390,7 +390,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Get description - * + * * @return string */ public function getDescription() @@ -400,8 +400,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set group order - * - * @param int $order + * + * @param int $order * @return Zend_Form_Element */ public function setOrder($order) @@ -412,7 +412,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve group order - * + * * @return int */ public function getOrder() @@ -424,8 +424,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add element to stack - * - * @param Zend_Form_Element $element + * + * @param Zend_Form_Element $element * @return Zend_Form_DisplayGroup */ public function addElement(Zend_Form_Element $element) @@ -437,8 +437,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add multiple elements at once - * - * @param array $elements + * + * @param array $elements * @return Zend_Form_DisplayGroup * @throws Zend_Form_Exception if any element is not a Zend_Form_Element */ @@ -456,8 +456,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set multiple elements at once (overwrites) - * - * @param array $elements + * + * @param array $elements * @return Zend_Form_DisplayGroup */ public function setElements(array $elements) @@ -468,8 +468,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve element - * - * @param string $name + * + * @param string $name * @return Zend_Form_Element|null */ public function getElement($name) @@ -493,8 +493,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Remove a single element - * - * @param string $name + * + * @param string $name * @return boolean */ public function removeElement($name) @@ -511,7 +511,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Remove all elements - * + * * @return Zend_Form_DisplayGroup */ public function clearElements() @@ -525,8 +525,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set plugin loader - * - * @param Zend_Loader_PluginLoader $loader + * + * @param Zend_Loader_PluginLoader $loader * @return Zend_Form_DisplayGroup */ public function setPluginLoader(Zend_Loader_PluginLoader $loader) @@ -537,7 +537,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve plugin loader - * + * * @return Zend_Loader_PluginLoader */ public function getPluginLoader() @@ -547,9 +547,9 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add a prefix path for the plugin loader - * - * @param string $prefix - * @param string $path + * + * @param string $prefix + * @param string $path * @return Zend_Form_DisplayGroup */ public function addPrefixPath($prefix, $path) @@ -560,15 +560,15 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add several prefix paths at once - * - * @param array $spec + * + * @param array $spec * @return Zend_Form_DisplayGroup */ public function addPrefixPaths(array $spec) { if (isset($spec['prefix']) && isset($spec['path'])) { return $this->addPrefixPath($spec['prefix'], $spec['path']); - } + } foreach ($spec as $prefix => $paths) { if (is_numeric($prefix) && is_array($paths)) { $prefix = null; @@ -592,8 +592,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set flag to disable loading default decorators - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setDisableLoadDefaultDecorators($flag) @@ -604,7 +604,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Should we load the default decorators? - * + * * @return bool */ public function loadDefaultDecoratorsIsDisabled() @@ -614,7 +614,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Load default decorators - * + * * @return void */ public function loadDefaultDecorators() @@ -634,9 +634,9 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Instantiate a decorator based on class name or class name fragment - * - * @param string $name - * @param null|array $options + * + * @param string $name + * @param null|array $options * @return Zend_Form_Decorator_Interface */ protected function _getDecorator($name, $options = null) @@ -654,8 +654,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add a decorator for rendering the group - * - * @param string|Zend_Form_Decorator_Interface $decorator + * + * @param string|Zend_Form_Decorator_Interface $decorator * @param array|Zend_Config $options Options with which to initialize decorator * @return Zend_Form_DisplayGroup */ @@ -697,8 +697,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Add many decorators at once - * - * @param array $decorators + * + * @param array $decorators * @return Zend_Form_DisplayGroup */ public function addDecorators(array $decorators) @@ -741,8 +741,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Overwrite all decorators - * - * @param array $decorators + * + * @param array $decorators * @return Zend_Form_DisplayGroup */ public function setDecorators(array $decorators) @@ -753,8 +753,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve a registered decorator - * - * @param string $name + * + * @param string $name * @return false|Zend_Form_Decorator_Abstract */ public function getDecorator($name) @@ -785,7 +785,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve all decorators - * + * * @return array */ public function getDecorators() @@ -800,8 +800,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Remove a single decorator - * - * @param string $name + * + * @param string $name * @return bool */ public function removeDecorator($name) @@ -822,7 +822,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Clear all decorators - * + * * @return Zend_Form_DisplayGroup */ public function clearDecorators() @@ -833,8 +833,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set view - * - * @param Zend_View_Interface $view + * + * @param Zend_View_Interface $view * @return Zend_Form_DisplayGroup */ public function setView(Zend_View_Interface $view = null) @@ -845,7 +845,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve view - * + * * @return Zend_View_Interface */ public function getView() @@ -861,7 +861,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Render display group - * + * * @return string */ public function render(Zend_View_Interface $view = null) @@ -879,7 +879,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * String representation of group - * + * * @return string */ public function __toString() @@ -895,8 +895,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Set translator object - * - * @param Zend_Translate|Zend_Translate_Adapter|null $translator + * + * @param Zend_Translate|Zend_Translate_Adapter|null $translator * @return Zend_Form_DisplayGroup */ public function setTranslator($translator = null) @@ -914,7 +914,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Retrieve translator object - * + * * @return Zend_Translate_Adapter|null */ public function getTranslator() @@ -933,8 +933,8 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Indicate whether or not translation should be disabled - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_DisplayGroup */ public function setDisableTranslator($flag) @@ -945,7 +945,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Is translation disabled? - * + * * @return bool */ public function translatorIsDisabled() @@ -957,9 +957,9 @@ class Zend_Form_DisplayGroup implements Iterator,Countable * Overloading: allow rendering specific decorators * * Call renderDecoratorName() to render a specific decorator. - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return string * @throws Zend_Form_Exception for invalid decorator or invalid method call */ @@ -988,10 +988,10 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Current element - * + * * @return Zend_Form_Element */ - public function current() + public function current(): mixed { $this->_sort(); current($this->_elementOrder); @@ -1001,10 +1001,10 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Current element - * + * * @return string */ - public function key() + public function key(): mixed { $this->_sort(); return key($this->_elementOrder); @@ -1012,10 +1012,10 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Move pointer to next element - * + * * @return void */ - public function next() + public function next(): void { $this->_sort(); next($this->_elementOrder); @@ -1023,10 +1023,10 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Move pointer to beginning of element loop - * + * * @return void */ - public function rewind() + public function rewind(): void { $this->_sort(); reset($this->_elementOrder); @@ -1034,10 +1034,10 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Determine if current element/subform/display group is valid - * + * * @return bool */ - public function valid() + public function valid(): bool { $this->_sort(); return (current($this->_elementOrder) !== false); @@ -1045,17 +1045,17 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Count of elements/subforms that are iterable - * + * * @return int */ - public function count() + public function count(): int { return count($this->_elements); } /** * Sort items according to their order - * + * * @return void */ protected function _sort() @@ -1089,7 +1089,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable /** * Lazy-load a decorator - * + * * @param array $decorator Decorator type and options * @param mixed $name Decorator name or alias * @return Zend_Form_Decorator_Interface diff --git a/library/Zend/Form/Element.php b/library/Zend/Form/Element.php index 619c7de174cfbf757306fd81f1e1a4784ef07f5c..bafcae1a54dc7358c2e947a7c5dc13a51d43e808 100644 --- a/library/Zend/Form/Element.php +++ b/library/Zend/Form/Element.php @@ -71,7 +71,7 @@ class Zend_Form_Element implements Zend_Validate_Interface * Element decorators * @var array */ - protected $_decorators = array(); + protected array $_decorators = []; /** * Element description @@ -89,19 +89,19 @@ class Zend_Form_Element implements Zend_Validate_Interface * Custom error messages * @var array */ - protected $_errorMessages = array(); + protected array $_errorMessages = []; /** * Validation errors * @var array */ - protected $_errors = array(); + protected array $_errors = []; /** * Element filters * @var array */ - protected $_filters = array(); + protected array $_filters = []; /** * Ignore flag (used when retrieving values at form level) @@ -131,13 +131,13 @@ class Zend_Form_Element implements Zend_Validate_Interface * Plugin loaders for filter and validator chains * @var array */ - protected $_loaders = array(); + protected array $_loaders = []; /** * Formatted validation error messages * @var array */ - protected $_messages = array(); + protected array $_messages = []; /** * Element name @@ -178,13 +178,13 @@ class Zend_Form_Element implements Zend_Validate_Interface * Array of initialized validators * @var array Validators */ - protected $_validators = array(); + protected array $_validators = []; /** * Array of un-initialized validators * @var array */ - protected $_validatorRules = array(); + protected array $_validatorRules = []; /** * Element value @@ -196,6 +196,7 @@ class Zend_Form_Element implements Zend_Validate_Interface * @var Zend_View_Interface */ protected $_view; + protected array $_element_attribs = []; /** * Constructor @@ -478,9 +479,9 @@ class Zend_Form_Element implements Zend_Validate_Interface */ public function getId() { - if (isset($this->id)) { - return $this->id; - } + if ($id = ($this->id ?? '')) + return $id; + $id = $this->getFullyQualifiedName(); @@ -790,12 +791,18 @@ class Zend_Form_Element implements Zend_Validate_Interface throw new Zend_Form_Exception(sprintf('Invalid attribute "%s"; must not contain a leading underscore', $name)); } - if (null === $value) { - unset($this->$name); - } else { + if (property_exists($this, $name)) { $this->$name = $value; + return $this; + } + + if (null === $value) { + unset($this->_element_attribs[$name]); + return $this; } + $this->_element_attribs [$name] = $value; + return $this; } @@ -823,11 +830,10 @@ class Zend_Form_Element implements Zend_Validate_Interface public function getAttrib($name) { $name = (string) $name; - if (isset($this->$name)) { - return $this->$name; - } - return null; + return property_exists($this, $name) + ? $this->$name + : $this->_element_attribs[$name] ?? null; } /** @@ -838,13 +844,12 @@ class Zend_Form_Element implements Zend_Validate_Interface public function getAttribs() { $attribs = get_object_vars($this); - foreach ($attribs as $key => $value) { - if ('_' == substr($key, 0, 1)) { + + foreach ($attribs as $key => $value) + if ('_' == substr($key, 0, 1)) unset($attribs[$key]); - } - } - return $attribs; + return array_merge($attribs, $this->_element_attribs); } /** @@ -862,11 +867,10 @@ class Zend_Form_Element implements Zend_Validate_Interface throw new Zend_Form_Exception(sprintf('Cannot retrieve value for protected/private property "%s"', $key)); } - if (!isset($this->$key)) { - return null; - } + if (property_exists($this, $key)) + return $this->$key; - return $this->$key; + return $this->_element_attribs[$key] ?? null; } /** @@ -2107,7 +2111,7 @@ class Zend_Form_Element implements Zend_Validate_Interface } $messages[$key] = $aggregateMessages; } else { - $messages[$key] = str_replace('%value%', $value, $message); + $messages[$key] = str_replace('%value%', ($value ?? ''), $message); } } return $messages; diff --git a/library/Zend/Http/Client.php b/library/Zend/Http/Client.php index 83c034a95d1bc54f140d8cc970a99af32fd82ba4..df95b58f59a114076c3a64f10dd0d9e9ff49a374 100644 --- a/library/Zend/Http/Client.php +++ b/library/Zend/Http/Client.php @@ -822,7 +822,7 @@ class Zend_Http_Client if (! empty($this->paramsGet)) { $query = $uri->getQuery(); if (! empty($query)) $query .= '&'; - $query .= http_build_query($this->paramsGet, null, '&'); + $query .= http_build_query($this->paramsGet, '', '&'); $uri->setQuery($query); } diff --git a/library/Zend/Http/Response.php b/library/Zend/Http/Response.php index ce6d983102df68f1633f45ca03d98bff385c46d0..3ede03295b076cece67e987a83fbb4b95686009a 100644 --- a/library/Zend/Http/Response.php +++ b/library/Zend/Http/Response.php @@ -268,7 +268,7 @@ class Zend_Http_Response } // Decode any content-encoding (gzip or deflate) if needed - switch (strtolower($this->getHeader('content-encoding'))) { + switch (strtolower((string) $this->getHeader('content-encoding'))) { // Handle gzip encoding case 'gzip': @@ -483,11 +483,11 @@ class Zend_Http_Response public static function extractHeaders($response_str) { $headers = array(); - + // First, split body and headers $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2); if (! $parts[0]) return $headers; - + // Split headers part to lines $lines = explode("\n", $parts[0]); unset($parts); @@ -535,7 +535,7 @@ class Zend_Http_Response public static function extractBody($response_str) { $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2); - if (isset($parts[1])) { + if (isset($parts[1])) { return $parts[1]; } else { return ''; @@ -551,7 +551,7 @@ class Zend_Http_Response public static function decodeChunkedBody($body) { $decBody = ''; - + while (trim($body)) { if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) { require_once 'Zend/Http/Exception.php'; @@ -580,8 +580,8 @@ class Zend_Http_Response { if (! function_exists('gzinflate')) { require_once 'Zend/Http/Exception.php'; - throw new Zend_Http_Exception('Unable to decode gzipped response ' . - 'body: perhaps the zlib extension is not loaded?'); + throw new Zend_Http_Exception('Unable to decode gzipped response ' . + 'body: perhaps the zlib extension is not loaded?'); } return gzinflate(substr($body, 10)); @@ -599,8 +599,8 @@ class Zend_Http_Response { if (! function_exists('gzuncompress')) { require_once 'Zend/Http/Exception.php'; - throw new Zend_Http_Exception('Unable to decode deflated response ' . - 'body: perhaps the zlib extension is not loaded?'); + throw new Zend_Http_Exception('Unable to decode deflated response ' . + 'body: perhaps the zlib extension is not loaded?'); } return gzuncompress($body); diff --git a/library/Zend/Paginator/Adapter/Null.php b/library/Zend/Paginator/Adapter/Null.php index 0ef3e05c913f38ebb1fec9c642c6ad314f3c4ea9..970d5051394e157bac0e082f1bd3cbdf6979e58d 100644 --- a/library/Zend/Paginator/Adapter/Null.php +++ b/library/Zend/Paginator/Adapter/Null.php @@ -38,10 +38,10 @@ class Zend_Paginator_Adapter_Null implements Zend_Paginator_Adapter_Interface * @var integer */ protected $_count = null; - + /** * Constructor. - * + * * @param array $count Total item count */ public function __construct($count = 0) @@ -66,8 +66,8 @@ class Zend_Paginator_Adapter_Null implements Zend_Paginator_Adapter_Interface * * @return integer */ - public function count() + public function count(): int { return $this->_count; } -} \ No newline at end of file +} diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php index 425e0c9007ed3190feaaeab31c7b3493f94b0538..95c3ef123af3757a897c5317aba11a4c62b276e4 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php @@ -1,9 +1,7 @@ <?php -/** PHPUnit_Framework_Constraint */ -// require_once 'PHPUnit/Framework/Constraint.php'; - /** Zend_Dom_Query */ require_once 'Zend/Dom/Query.php'; +use PHPUnit\Framework\Exception; /** * Zend_Dom_Query-based PHPUnit Constraint @@ -14,7 +12,7 @@ require_once 'Zend/Dom/Query.php'; * @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc. * @license New BSD {@link http://framework.zend.com/license/new-bsd} */ -class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit\Framework\Constraint\Constraint { /**#@+ * @const string Assertion type constants @@ -111,10 +109,9 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint * @param null|string Assertion type * @return bool */ - public function evaluate($other, $description = '', $returnResult = FALSE) + public function evaluate($other, string $description = '', bool $returnResult = false): ?bool { - $assertType = $description; - //public function evaluate($other, $assertType = null) + $assertType = $description; if (strstr($assertType, 'Not')) { $this->setNegate(true); @@ -126,10 +123,8 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint $assertType = str_replace('Xpath', 'Query', $assertType); } - if (!in_array($assertType, $this->_assertTypes)) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception(sprintf('Invalid assertion type "%s" provided to %s constraint', $assertType, __CLASS__)); - } + if ( ! in_array($assertType, $this->_assertTypes)) + throw new Exception(sprintf('Invalid assertion type "%s" provided to %s constraint', $assertType, __CLASS__)); $this->_assertType = $assertType; @@ -141,19 +136,17 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint switch ($assertType) { case self::ASSERT_CONTENT_CONTAINS: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No content provided against which to match'); - } + if (3 > $argc) + throw new Exception('No content provided against which to match'); + $this->_content = $content = $argv[2]; return ($this->_negate) ? $this->_notMatchContent($result, $content) : $this->_matchContent($result, $content); case self::ASSERT_CONTENT_REGEX: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No pattern provided against which to match'); - } + if (3 > $argc) + throw new Exception('No pattern provided against which to match'); + $this->_content = $content = $argv[2]; return ($this->_negate) ? $this->_notRegexContent($result, $content) @@ -161,10 +154,9 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint case self::ASSERT_CONTENT_COUNT: case self::ASSERT_CONTENT_COUNT_MIN: case self::ASSERT_CONTENT_COUNT_MAX: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No count provided against which to compare'); - } + if (3 > $argc) + throw new Exception('No count provided against which to compare'); + $this->_content = $content = $argv[2]; return $this->_countContent($result, $content, $assertType); case self::ASSERT_QUERY: @@ -185,14 +177,11 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint * @param string $description * @param bool $not * @return void - * @throws PHPUnit_Framework_ExpectationFailedException */ - public function fail($other, $description, SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) + public function fail($other, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = null): void { - $not = $comparisonFailure; - //public function fail($other, $description, $not = false) + $not = $comparisonFailure; - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; switch ($this->_assertType) { case self::ASSERT_CONTENT_CONTAINS: $failure = 'Failed asserting node denoted by %s CONTAINS content "%s"'; @@ -237,7 +226,7 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint $failure = $description . "\n" . $failure; } - throw new Zend_Test_PHPUnit_Constraint_Exception($failure); + throw new Exception($failure); } /** @@ -245,7 +234,7 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint * * @return string */ - public function toString() + public function toString(): string { return ''; } diff --git a/library/Zend/Test/PHPUnit/Constraint/Exception.php b/library/Zend/Test/PHPUnit/Constraint/Exception.php deleted file mode 100644 index fe41a08129ca6cf7aa4b8838b0ba279dda82e032..0000000000000000000000000000000000000000 --- a/library/Zend/Test/PHPUnit/Constraint/Exception.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** PHPUnit_Framework_ExpectationFailedException */ -// require_once 'PHPUnit/Framework/ExpectationFailedException.php'; - -/** - * Zend_Test_PHPUnit_Constraint_Exception - * - * @uses PHPUnit_Framework_ExpectationFailedException - * @package Zend_Test - * @subpackage PHPUnit - * @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc. - * @license New BSD {@link http://framework.zend.com/license/new-bsd} - */ -class Zend_Test_PHPUnit_Constraint_Exception extends PHPUnit_Framework_ExpectationFailedException -{ -} diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect.php b/library/Zend/Test/PHPUnit/Constraint/Redirect.php index 01e79ec69a06f25b2db086b4da4cb3db02222265..ec52648ca57749806006f12894b2fb8768d18119 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect.php @@ -1,6 +1,5 @@ <?php -/** PHPUnit_Framework_Constraint */ -// require_once 'PHPUnit/Framework/Constraint.php'; +use PHPUnit\Framework\Exception; /** * Redirection constraints @@ -11,7 +10,7 @@ * @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc. * @license New BSD {@link http://framework.zend.com/license/new-bsd} */ -class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit\Framework\Constraint\Constraint { /**#@+ * @const string Assertion type constants @@ -76,25 +75,19 @@ class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint * @param null|string Assertion type * @return bool */ - public function evaluate($other, $description = '', $returnResult = FALSE) + public function evaluate($other, string $description = '', bool $returnResult = FALSE): ?bool { - //public function evaluate($other, $assertType = null) - - $assertType = $description; - if (!$other instanceof Zend_Controller_Response_Abstract) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('Redirect constraint assertions require a response object'); - } + $assertType = $description; + if ( ! $other instanceof Zend_Controller_Response_Abstract) + throw new Exception('Redirect constraint assertions require a response object'); if (strstr($assertType, 'Not')) { $this->setNegate(true); $assertType = str_replace('Not', '', $assertType); } - if (!in_array($assertType, $this->_assertTypes)) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception(sprintf('Invalid assertion type "%s" provided to %s constraint', $assertType, __CLASS__)); - } + if ( ! in_array($assertType, $this->_assertTypes)) + throw new Exception(sprintf('Invalid assertion type "%s" provided to %s constraint', $assertType, __CLASS__)); $this->_assertType = $assertType; @@ -104,19 +97,17 @@ class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint switch ($assertType) { case self::ASSERT_REDIRECT_TO: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No redirect URL provided against which to match'); - } + if (3 > $argc) + throw new Exception('No redirect URL provided against which to match'); + $this->_match = $match = $argv[2]; return ($this->_negate) ? $this->_notMatch($response, $match) : $this->_match($response, $match); case self::ASSERT_REDIRECT_REGEX: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No pattern provided against which to match redirect'); - } + if (3 > $argc) + throw new Exception('No pattern provided against which to match redirect'); + $this->_match = $match = $argv[2]; return ($this->_negate) ? $this->_notRegex($response, $match) @@ -135,14 +126,11 @@ class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint * @param string $description Additional message to display * @param bool $not * @return void - * @throws PHPUnit_Framework_ExpectationFailedException */ - public function fail($other, $description, SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) + public function fail($other, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL): void { - //public function fail($other, $description, $not = false) - $not = $comparisonFailure; + $not = $comparisonFailure; - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; switch ($this->_assertType) { case self::ASSERT_REDIRECT_TO: $failure = 'Failed asserting response redirects to "%s"'; @@ -171,7 +159,7 @@ class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint $failure = $description . "\n" . $failure; } - throw new Zend_Test_PHPUnit_Constraint_Exception($failure); + throw new Exception($failure); } /** @@ -179,7 +167,7 @@ class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint * * @return string */ - public function toString() + public function toString(): string { return ''; } diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php index 3f61363f1738b3c158fcb868fc4f973278db0521..e268736ebfb888240ed8bbd50b5a865ba43cf5fe 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php @@ -1,6 +1,5 @@ <?php -/** PHPUnit_Framework_Constraint */ -// require_once 'PHPUnit/Framework/Constraint.php'; +use PHPUnit\Framework\Exception; /** * Response header PHPUnit Constraint @@ -11,7 +10,7 @@ * @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc. * @license New BSD {@link http://framework.zend.com/license/new-bsd} */ -class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit\Framework\Constraint\Constraint { /**#@+ * @const string Assertion type constants @@ -87,24 +86,19 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons * @param null|string Assertion type * @return bool */ - public function evaluate($other, $description = '', $returnResult = FALSE) + public function evaluate($other, string $description = '', bool $returnResult = FALSE): ?bool { - $assertType = $description; - //public function evaluate($other, $assertType = null) - if (!$other instanceof Zend_Controller_Response_Abstract) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('Header constraint assertions require a response object'); - } + $assertType = $description; + if ( ! $other instanceof Zend_Controller_Response_Abstract) + throw new Exception('Header constraint assertions require a response object'); if (strstr($assertType, 'Not')) { $this->setNegate(true); $assertType = str_replace('Not', '', $assertType); } - if (!in_array($assertType, $this->_assertTypes)) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception(sprintf('Invalid assertion type "%s" provided to %s constraint', $assertType, __CLASS__)); - } + if ( ! in_array($assertType, $this->_assertTypes)) + throw new Exception(sprintf('Invalid assertion type "%s" provided to %s constraint', $assertType, __CLASS__)); $this->_assertType = $assertType; @@ -114,46 +108,41 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons switch ($assertType) { case self::ASSERT_RESPONSE_CODE: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No response code provided against which to match'); - } + if (3 > $argc) + throw new Exception('No response code provided against which to match'); + $this->_code = $code = $argv[2]; return ($this->_negate) ? $this->_notCode($response, $code) : $this->_code($response, $code); case self::ASSERT_HEADER: - if (3 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('No header provided against which to match'); - } + if (3 > $argc) + throw new Exception('No header provided against which to match'); + $this->_header = $header = $argv[2]; return ($this->_negate) ? $this->_notHeader($response, $header) : $this->_header($response, $header); case self::ASSERT_HEADER_CONTAINS: - if (4 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('Both a header name and content to match are required for ' . __FUNCTION__); - } + if (4 > $argc) + throw new Exception('Both a header name and content to match are required for ' . __FUNCTION__); + $this->_header = $header = $argv[2]; $this->_match = $match = $argv[3]; return ($this->_negate) ? $this->_notHeaderContains($response, $header, $match) : $this->_headerContains($response, $header, $match); case self::ASSERT_HEADER_REGEX: - if (4 > $argc) { - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('Both a header name and content to match are required for ' . __FUNCTION__); - } + if (4 > $argc) + throw new Exception('Both a header name and content to match are required for ' . __FUNCTION__); + $this->_header = $header = $argv[2]; $this->_match = $match = $argv[3]; return ($this->_negate) ? $this->_notHeaderRegex($response, $header, $match) : $this->_headerRegex($response, $header, $match); default: - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; - throw new Zend_Test_PHPUnit_Constraint_Exception('Invalid assertion type ' . __FUNCTION__); + throw new Exception('Invalid assertion type ' . __FUNCTION__); } } @@ -167,11 +156,9 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons * @return void * @throws PHPUnit_Framework_ExpectationFailedException */ - public function fail($other, $description, SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) + public function fail($other, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL): void { - $not = $comparisonFailure; - //public function fail($other, $description, $not = false) - require_once 'Zend/Test/PHPUnit/Constraint/Exception.php'; + $not = $comparisonFailure; switch ($this->_assertType) { case self::ASSERT_RESPONSE_CODE: $failure = 'Failed asserting response code "%s"'; @@ -202,14 +189,14 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons $failure = sprintf($failure, $this->_header, $this->_match); break; default: - throw new Zend_Test_PHPUnit_Constraint_Exception('Invalid assertion type ' . __FUNCTION__); + throw new Exception('Invalid assertion type ' . __FUNCTION__); } if (!empty($description)) { $failure = $description . "\n" . $failure; } - throw new Zend_Test_PHPUnit_Constraint_Exception($failure); + throw new Exception($failure); } /** @@ -217,7 +204,7 @@ class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Cons * * @return string */ - public function toString() + public function toString(): string { return ''; } diff --git a/library/Zend/Test/PHPUnit/ControllerTestCase.php b/library/Zend/Test/PHPUnit/ControllerTestCase.php index 60ce8446f6a8fd9e76d6752b68d2b5cc6ce7fc94..9505516b414d5a14cec438af723355259e45f06f 100644 --- a/library/Zend/Test/PHPUnit/ControllerTestCase.php +++ b/library/Zend/Test/PHPUnit/ControllerTestCase.php @@ -1,8 +1,4 @@ <?php - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - /** Zend_Controller_Front */ require_once 'Zend/Controller/Front.php'; @@ -20,14 +16,14 @@ require_once 'Zend/Session.php'; /** * Functional testing scaffold for MVC applications - * - * @uses PHPUnit_Framework_TestCase + * + * @uses PHPUnit\Framework\TestCase * @package Zend_Test * @subpackage PHPUnit * @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc. * @license New BSD {@link http://framework.zend.com/license/new-bsd} */ -abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_TestCase +abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit\Framework\TestCase { /** * @var mixed Bootstrap file path or callback @@ -39,31 +35,29 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te */ protected $_frontController; - /** - * @var Zend_Dom_Query - */ - protected $_query; + protected ?Zend_Dom_Query $_query = null; /** * @var Zend_Controller_Request_Abstract */ protected $_request; - + /** * @var Zend_Controller_Response_Abstract */ protected $_response; + protected array $_controller_attribs = []; /** * Overlaoding: prevent overloading to special properties - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return void */ public function __set($name, $value) { - if (in_array($name, array('request', 'response', 'frontController'))) { + if (in_array($name, ['request', 'response', 'frontController'])) { throw new Zend_Exception(sprintf('Setting %s object manually is not allowed', $name)); } @@ -71,15 +65,15 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te throw new Zend_Exception('Overloading of non-public properties is prohibited'); } - $this->$name = $value; + $this->_controller_attribs [$name] = $value; } /** * Overloading for common properties * * Provides overloading for request, response, and frontController objects. - * - * @param mixed $name + * + * @param mixed $name * @return void */ public function __get($name) @@ -93,17 +87,17 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te return $this->getFrontController(); } - return null; + return $this->_controller_attribs[$name] ?? null; } /** * Set up MVC app * * Calls {@link bootstrap()} by default - * + * * @return void */ - protected function setUp() + protected function setUp(): void { $this->bootstrap(); } @@ -113,10 +107,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te * * Resets the front controller, and then bootstraps it. * - * If {@link $bootstrap} is a callback, executes it; if it is a file, it include's - * it. When done, sets the test case request and response objects into the + * If {@link $bootstrap} is a callback, executes it; if it is a file, it include's + * it. When done, sets the test case request and response objects into the * front controller. - * + * * @return void */ final public function bootstrap() @@ -140,15 +134,12 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te /** * Dispatch the MVC * - * If a URL is provided, sets it as the request URI in the request object. - * Then sets test case request and response objects in front controller, + * If a URL is provided, sets it as the request URI in the request object. + * Then sets test case request and response objects in front controller, * disables throwing exceptions, and disables returning the response. * Finally, dispatches the front controller. - * - * @param string|null $url - * @return void */ - public function dispatch($url = null) + public function dispatch(string $url = ''): void { // redirector should not exit $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); @@ -159,9 +150,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te $json->suppressExit = true; $request = $this->getRequest(); - if (null !== $url) { + if ($url) $request->setRequestUri($url); - } + $request->setPathInfo(null); $controller = $this->getFrontController(); $this->frontController @@ -174,19 +165,18 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te /** * Reset MVC state - * - * Creates new request/response objects, resets the front controller + * + * Creates new request/response objects, resets the front controller * instance, and resets the action helper broker. * * @todo Need to update Zend_Layout to add a resetInstance() method - * @return void */ - public function reset() + public function reset(): void { - $_SESSION = array(); - $_GET = array(); - $_POST = array(); - $_COOKIE = array(); + $_SESSION = []; + $_GET = []; + $_POST = []; + $_COOKIE = []; $this->_request = null; $this->_response = null; Zend_Layout::resetMvcInstance(); @@ -198,13 +188,11 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te /** * Rest all view placeholders - * - * @return void */ - protected function _resetPlaceholders() + protected function _resetPlaceholders(): void { $registry = Zend_Registry::getInstance(); - $remove = array(); + $remove = []; foreach ($registry as $key => $value) { if (strstr($key, '_View_')) { $remove[] = $key; @@ -220,10 +208,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te * Reset the response object * * Useful for test cases that need to test multiple trips to the server. - * - * @return Zend_Test_PHPUnit_ControllerTestCase */ - public function resetResponse() + public function resetResponse(): self { $this->_response = null; $this->_resetPlaceholders(); @@ -232,753 +218,646 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te /** * Assert against DOM selection - * - * @param string $path CSS selector path - * @param string $message - * @return void */ - public function assertQuery($path, $message = '') + public function assertQuery(string $path, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" exists', + $path); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(count($dom_query->query($path)) > 0, $msg); } /** * Assert against DOM selection - * - * @param string $path CSS selector path - * @param string $message - * @return void */ - public function assertNotQuery($path, $message = '') + public function assertNotQuery(string $path, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" NOT exists', + $path); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(0 === count($dom_query->query($path)), $msg); } /** * Assert against DOM selection; node should contain content - * - * @param string $path CSS selector path - * @param string $match content that should be contained in matched nodes - * @param string $message - * @return void */ - public function assertQueryContentContains($path, $match, $message = '') + public function assertQueryContentContains(string $path, + string $match, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $match)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" contains content "%s"', + $path, + $match); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertContains($match, $dom_query->queryAsString($path), $msg); } /** * Assert against DOM selection; node should NOT contain content - * - * @param string $path CSS selector path - * @param string $match content that should NOT be contained in matched nodes - * @param string $message - * @return void */ - public function assertNotQueryContentContains($path, $match, $message = '') + public function assertNotQueryContentContains(string $path, + string $match, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $match)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" DOES NOT contains content "%s"', + $path, + $match); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertNotContains($match, $dom_query->queryAsString($path), $msg); } /** * Assert against DOM selection; node should match content - * - * @param string $path CSS selector path - * @param string $pattern Pattern that should be contained in matched nodes - * @param string $message - * @return void */ - public function assertQueryContentRegex($path, $pattern, $message = '') + public function assertQueryContentRegex(string $path, + string $pattern, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" contains content matching "%s"', + $path, + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertMatchesRegularExpression($pattern, + $dom_query->queryAsString($path), + $msg); } /** * Assert against DOM selection; node should NOT match content - * - * @param string $path CSS selector path - * @param string $pattern pattern that should NOT be contained in matched nodes - * @param string $message - * @return void */ - public function assertNotQueryContentRegex($path, $pattern, $message = '') + public function assertNotQueryContentRegex(string $path, + string $pattern, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" DOES NOT contains content matching "%s"', + $path, + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertDoesNotMatchRegularExpression($pattern, + $dom_query->queryAsString($path), + $msg); } /** * Assert against DOM selection; should contain exact number of nodes - * - * @param string $path CSS selector path - * @param string $count Number of nodes that should match - * @param string $message - * @return void */ - public function assertQueryCount($path, $count, $message = '') + public function assertQueryCount(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" occurs exalty "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertCount($count, $dom_query->query($path), $msg); } /** * Assert against DOM selection; should NOT contain exact number of nodes - * - * @param string $path CSS selector path - * @param string $count Number of nodes that should NOT match - * @param string $message - * @return void */ - public function assertNotQueryCount($path, $count, $message = '') + public function assertNotQueryCount(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" DOES NOT occurs exalty "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertNotCount($count, $dom_query->query($path), $msg); } /** * Assert against DOM selection; should contain at least this number of nodes - * - * @param string $path CSS selector path - * @param string $count Minimum number of nodes that should match - * @param string $message - * @return void */ - public function assertQueryCountMin($path, $count, $message = '') + public function assertQueryCountMin(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" occurs at least "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(count($dom_query->query($path)) >= $count, $msg); } /** * Assert against DOM selection; should contain no more than this number of nodes - * - * @param string $path CSS selector path - * @param string $count Maximum number of nodes that should match - * @param string $message - * @return void */ - public function assertQueryCountMax($path, $count, $message = '') + public function assertQueryCountMax(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" occurs at most "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(count($dom_query->query($path)) <= $count, $message); } /** * Assert against XPath selection - * - * @param string $path XPath path - * @param string $message - * @return void */ - public function assertXpath($path, $message = '') + public function assertXpath(string $path, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" exists', + $path); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(count($dom_query->queryXpath($path)) > 0, $msg); } /** * Assert against XPath selection - * - * @param string $path XPath path - * @param string $message - * @return void */ - public function assertNotXpath($path, $message = '') + public function assertNotXpath(string $path, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" NOT exists', + $path); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(0 === count($dom_query->queryXpath($path)), $msg); } /** * Assert against XPath selection; node should contain content - * - * @param string $path XPath path - * @param string $match content that should be contained in matched nodes - * @param string $message - * @return void */ - public function assertXpathContentContains($path, $match, $message = '') + public function assertXpathContentContains(string $path, + string $match, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $match)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" contains content "%s"', + $path, + $match); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertContains($match, $dom_query->xpathAsString($path), $msg); } /** * Assert against XPath selection; node should NOT contain content - * - * @param string $path XPath path - * @param string $match content that should NOT be contained in matched nodes - * @param string $message - * @return void */ - public function assertNotXpathContentContains($path, $match, $message = '') + public function assertNotXpathContentContains(string $path, + string $match, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $match)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" DOES NOT contains content "%s"', + $path, + $match); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertNotContains($match, $dom_query->xpathAsString($path), $msg); } /** * Assert against XPath selection; node should match content - * - * @param string $path XPath path - * @param string $pattern Pattern that should be contained in matched nodes - * @param string $message - * @return void */ - public function assertXpathContentRegex($path, $pattern, $message = '') + public function assertXpathContentRegex(string $path, + string $pattern, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" contains content matching "%s"', + $path, + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertMatchesRegularExpression($pattern, + $dom_query->xpathAsString($path), + $msg); } /** * Assert against XPath selection; node should NOT match content - * - * @param string $path XPath path - * @param string $pattern pattern that should NOT be contained in matched nodes - * @param string $message - * @return void */ - public function assertNotXpathContentRegex($path, $pattern, $message = '') + public function assertNotXpathContentRegex(string $path, + string $pattern, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" DOES NOT contains content matching "%s"', + $path, + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertDoesNotMatchRegularExpression($pattern, + $dom_query->xpathAsString($path), + $msg); } /** * Assert against XPath selection; should contain exact number of nodes - * - * @param string $path XPath path - * @param string $count Number of nodes that should match - * @param string $message - * @return void */ - public function assertXpathCount($path, $count, $message = '') + public function assertXpathCount(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" occurs exalty "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertCount($count, $dom_query->queryXpath($path), $msg); } /** * Assert against XPath selection; should NOT contain exact number of nodes - * - * @param string $path XPath path - * @param string $count Number of nodes that should NOT match - * @param string $message - * @return void */ - public function assertNotXpathCount($path, $count, $message = '') + public function assertNotXpathCount(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" DOES NOT occurs exalty "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertNotCount($count, $dom_query->queryXpath($path), $msg); } /** * Assert against XPath selection; should contain at least this number of nodes - * - * @param string $path XPath path - * @param string $count Minimum number of nodes that should match - * @param string $message - * @return void */ - public function assertXpathCountMin($path, $count, $message = '') + public function assertXpathCountMin(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" occurs at least "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(count($dom_query->queryXpath($path)) >= $count, $msg); } /** * Assert against XPath selection; should contain no more than this number of nodes - * - * @param string $path XPath path - * @param string $count Maximum number of nodes that should match - * @param string $message - * @return void */ - public function assertXpathCountMax($path, $count, $message = '') + public function assertXpathCountMax(string $path, int $count, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path); - $content = $this->response->outputBody(); - if (!$constraint->evaluate($content, __FUNCTION__, $count)) { - $constraint->fail($path, $message); - } + $msg = sprintf('Failed asserting node denoted by "%s" occurs at most "%d" times', + $path, + $count); + if ($message) + $msg = $message . "\n" . $msg; + + $dom_query = $this->getQuery($this->getResponse()->outputBody()); + $this->assertTrue(count($dom_query->queryXpath($path)) <= $count, $msg); } /** * Assert that response is a redirect - * - * @param string $message - * @return void */ - public function assertRedirect($message = '') + public function assertRedirect(string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_Redirect(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response is a redirect'); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertTrue($this->getResponse()->isRedirect(), $msg); } /** * Assert that response is NOT a redirect - * - * @param string $message - * @return void */ - public function assertNotRedirect($message = '') + public function assertNotRedirect(string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_Redirect(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response is NOT a redirect'); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertFalse($this->getResponse()->isRedirect(), $msg); } /** * Assert that response redirects to given URL - * - * @param string $url - * @param string $message - * @return void */ - public function assertRedirectTo($url, $message = '') + public function assertRedirectTo(string $url, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_Redirect(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $url)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response redirects to "%s"', $url); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertTrue($this->_extractRedirectFromResponse() == $url, $msg); } /** * Assert that response does not redirect to given URL - * - * @param string $url - * @param string $message - * @return void */ - public function assertNotRedirectTo($url, $message = '') + public function assertNotRedirectTo(string $url, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_Redirect(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $url)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response redirects to "%s"', $url); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertFalse($this->_extractRedirectFromResponse() == $url, $msg); } /** * Assert that redirect location matches pattern - * - * @param string $pattern - * @param string $message - * @return void */ - public function assertRedirectRegex($pattern, $message = '') + public function assertRedirectRegex(string $pattern, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_Redirect(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $pattern)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response redirects to url matching "%s"', $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertTrue((bool) preg_match($pattern, $this->_extractRedirectFromResponse()), + $msg); } /** * Assert that redirect location does not match pattern - * - * @param string $pattern - * @param string $message - * @return void */ - public function assertNotRedirectRegex($pattern, $message = '') + public function assertNotRedirectRegex(string $pattern, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_Redirect(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $pattern)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response DOES NOT redirects to url matching "%s"', + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertFalse((bool) preg_match($pattern, $this->_extractRedirectFromResponse()), + $msg); + } + + protected function _extractRedirectFromResponse(): string + { + $response = $this->getResponse(); + + $headers = $response->isRedirect() ? $response->sendHeaders() : []; + + return str_replace('Location: ', '', ($headers['location'] ?? '')); } /** * Assert response code - * - * @param int $code - * @param string $message - * @return void */ - public function assertResponseCode($code, $message = '') + public function assertResponseCode(int $code, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $code)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response code is "%s"', $code); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertEquals($code, $this->_responseCode(), $msg); } /** * Assert response code - * - * @param int $code - * @param string $message - * @return void */ - public function assertNotResponseCode($code, $message = '') + public function assertNotResponseCode(int $code, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $constraint->setNegate(true); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $code)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response code is NOT "%s"', $code); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertNotEquals($code, $this->_responseCode(), $msg); + } + + protected function _responseCode(): int + { + return ($code = $this->getResponse()->getHttpResponseCode()) + ? $code + : 200; } /** * Assert response header exists - * - * @param string $header - * @param string $message - * @return void */ - public function assertHeader($header, $message = '') + public function assertHeader(string $header, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $header)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response header "%s" was found', $header); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertTrue(array_key_exists(strtolower($header), + $this->getResponse()->sendHeaders()), + $msg); } /** * Assert response header does not exist - * - * @param string $header - * @param string $message - * @return void */ - public function assertNotHeader($header, $message = '') + public function assertNotHeader(string $header, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $constraint->setNegate(true); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $header)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response header "%s" was NOT found', $header); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertFalse(array_key_exists(strtolower($header), + $this->getResponse()->sendHeaders()), + $msg); } /** * Assert response header exists and contains the given string - * - * @param string $header - * @param string $match - * @param string $message - * @return void */ - public function assertHeaderContains($header, $match, $message = '') + public function assertHeaderContains(string $header, string $match, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $header, $match)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response header "%s" exists and contains "%s"', + $header, + $match); + if ($message) + $msg = $message . "\n" . $msg; + + $headers = $this->getResponse()->sendHeaders(); + $header = strtolower($header); + $fullHeader = array_key_exists($header, $headers) ? $headers[$header] : ''; + $contents = str_replace($header . ': ', '', $fullHeader); + $this->assertContains($match, $contents, $msg); } /** * Assert response header does not exist and/or does not contain the given string - * - * @param string $header - * @param string $match - * @param string $message - * @return void */ - public function assertNotHeaderContains($header, $match, $message = '') + public function assertNotHeaderContains(string $header, + string $match, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $constraint->setNegate(true); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $header, $match)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response header "%s" DOES NOT contain "%s"', + $header, + $match); + if ($message) + $msg = $message . "\n" . $msg; + + $headers = $this->getResponse()->sendHeaders(); + $header = strtolower($header); + $fullHeader = array_key_exists($header, $headers) ? $headers[$header] : ''; + $contents = str_replace($header . ': ', '', $fullHeader); + $this->assertNotContains($match, $contents, $msg); } /** * Assert response header exists and matches the given pattern - * - * @param string $header - * @param string $pattern - * @param string $message - * @return void */ - public function assertHeaderRegex($header, $pattern, $message = '') + public function assertHeaderRegex(string $header, string $pattern, string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $header, $pattern)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response header "%s" exists and matches regex "%s"', + $header, + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $headers = $this->getResponse()->sendHeaders(); + $header = strtolower($header); + $fullHeader = array_key_exists($header, $headers) ? $headers[$header] : ''; + $contents = str_replace($header . ': ', '', $fullHeader); + $this->assertTrue(preg_match($pattern, $contents), $msg); } /** * Assert response header does not exist and/or does not match the given regex - * - * @param string $header - * @param string $pattern - * @param string $message - * @return void */ - public function assertNotHeaderRegex($header, $pattern, $message = '') + public function assertNotHeaderRegex(string $header, + string $pattern, + string $message = ''): void { - require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php'; - $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader(); - $constraint->setNegate(true); - $response = $this->response; - if (!$constraint->evaluate($response, __FUNCTION__, $header, $pattern)) { - $constraint->fail($response, $message); - } + $msg = sprintf('Failed asserting response header "%s" DOES NOT matches regex "%s"', + $header, + $pattern); + if ($message) + $msg = $message . "\n" . $msg; + + $headers = $this->getResponse()->sendHeaders(); + $header = strtolower($header); + $fullHeader = array_key_exists($header, $headers) ? $headers[$header] : ''; + $contents = str_replace($header . ': ', '', $fullHeader); + $this->assertFalse(preg_match($pattern, $contents), $msg); } /** * Assert that the last handled request used the given module - * - * @param string $module - * @param string $message - * @return void */ - public function assertModule($module, $message = '') + public function assertModule(string $module, string $message = ''): void { - if ($module != $this->request->getModuleName()) { - $msg = sprintf('Failed asserting last module used was "%s"', $module); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting last module used was "%s"', $module); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertEquals($module, $this->request->getModuleName(), $message); } /** * Assert that the last handled request did NOT use the given module - * - * @param string $module - * @param string $message - * @return void */ - public function assertNotModule($module, $message = '') + public function assertNotModule(string $module, string $message = ''): void { - if ($module == $this->request->getModuleName()) { - $msg = sprintf('Failed asserting last module used was NOT "%s"', $module); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting last module used was NOT "%s"', $module); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertNotEquals($module, $this->request->getModuleName(), $message); } /** * Assert that the last handled request used the given controller - * - * @param string $controller - * @param string $message - * @return void */ - public function assertController($controller, $message = '') + public function assertController(string $controller, string $message = ''): void { - if ($controller != $this->request->getControllerName()) { - $msg = sprintf('Failed asserting last controller used was "%s"', $controller); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting last controller used was "%s"', $controller); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertEquals($controller, $this->request->getControllerName(), $message); } /** * Assert that the last handled request did NOT use the given controller - * - * @param string $controller - * @param string $message - * @return void */ - public function assertNotController($controller, $message = '') + public function assertNotController(string $controller, string $message = ''): void { - if ($controller == $this->request->getControllerName()) { - $msg = sprintf('Failed asserting last controller used was NOT "%s"', $controller); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting last controller used was NOT "%s"', $controller); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertNotEquals($controller, $this->request->getControllerName(), $message); } /** * Assert that the last handled request used the given action - * - * @param string $action - * @param string $message - * @return void */ - public function assertAction($action, $message = '') + public function assertAction(string $action, string $message = ''): void { - if ($action != $this->request->getActionName()) { - $msg = sprintf('Failed asserting last action used was "%s"', $action); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting last action used was "%s"', $action); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertEquals($action, $this->request->getActionName(), $message); } /** * Assert that the last handled request did NOT use the given action - * - * @param string $action - * @param string $message - * @return void */ - public function assertNotAction($action, $message = '') + public function assertNotAction(string $action, string $message = ''): void { - if ($action == $this->request->getActionName()) { - $msg = sprintf('Failed asserting last action used was NOT "%s"', $action); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting last action used was NOT "%s"', $action); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertNotEquals($action, $this->request->getActionName(), $message); } /** * Assert that the specified route was used - * - * @param string $route - * @param string $message - * @return void */ - public function assertRoute($route, $message = '') + public function assertRoute(string $route, string $message = ''): void { - $router = $this->frontController->getRouter(); - if ($route != $router->getCurrentRouteName()) { - $msg = sprintf('Failed asserting route matched was "%s"', $route); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting route matched was "%s"', $route); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertEquals($route, + $this->frontController->getRouter()->getCurrentRouteName(), + $message); } /** * Assert that the route matched is NOT as specified - * - * @param string $route - * @param string $message - * @return void */ - public function assertNotRoute($route, $message = '') + public function assertNotRoute(string $route, string $message = ''): void { - $router = $this->frontController->getRouter(); - if ($route == $router->getCurrentRouteName()) { - $msg = sprintf('Failed asserting route matched was NOT "%s"', $route); - if (!empty($message)) { - $msg = $message . "\n" . $msg; - } - $this->fail($msg); - } + $msg = sprintf('Failed asserting route matched was NOT "%s"', $route); + if ($message) + $msg = $message . "\n" . $msg; + + $this->assertEquals($route, + $this->frontController->getRouter()->getCurrentRouteName(), + $message); } /** * Retrieve front controller instance - * + * * @return Zend_Controller_Front */ public function getFrontController() @@ -991,7 +870,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te /** * Retrieve test case request object - * + * * @return Zend_Controller_Request_Abstract */ public function getRequest() @@ -1004,8 +883,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te } /** - * Retrieve test case response object - * + * Retrieve test case response object + * * @return Zend_Controller_Response_Abstract */ public function getResponse() @@ -1017,17 +896,15 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te return $this->_response; } - /** - * Retrieve DOM query object - * - * @return Zend_Dom_Query - */ - public function getQuery() + public function getQuery(string $document = ''): Zend_Dom_Query { if (null === $this->_query) { require_once 'Zend/Dom/Query.php'; $this->_query = new Zend_Dom_Query; } - return $this->_query; + + return $document + ? $this->_query->setDocument($document) + : $this->_query; } } diff --git a/library/Zend/Validate.php b/library/Zend/Validate.php index b57930af86fabe90884d2f1bc9006326a1b87513..c8d36acb788a9bf2b0f1dccd2b9275036278904e 100644 --- a/library/Zend/Validate.php +++ b/library/Zend/Validate.php @@ -40,14 +40,14 @@ class Zend_Validate implements Zend_Validate_Interface * * @var array */ - protected $_validators = array(); + protected array $_validators = []; /** * Array of validation failure messages * * @var array */ - protected $_messages = array(); + protected array $_messages = []; /** * Array of validation failure message codes @@ -55,7 +55,22 @@ class Zend_Validate implements Zend_Validate_Interface * @var array * @deprecated Since 1.5.0 */ - protected $_errors = array(); + protected array $_errors = []; + protected array $_element_attribs = []; + + public function __set($key, $val) + { + $this->_element_attribs [$key] = $val; + } + + + public function __get($key) + { + return (array_key_exists($key, $this->_element_attribs) + ? $this->_element_attribs[$key] + : null); + } + /** * Adds a validator to the end of the chain diff --git a/library/Zend/Validate/Abstract.php b/library/Zend/Validate/Abstract.php index 5e8cceb8b3f4272b0446153e98b1dae9d4ce170d..f9340b40c2b46d6e9758d36c46ed8e7da885d528 100644 --- a/library/Zend/Validate/Abstract.php +++ b/library/Zend/Validate/Abstract.php @@ -47,24 +47,24 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface * * @var array */ - protected $_messageVariables = array(); + protected array $_messageVariables = []; /** * Validation failure message template definitions * * @var array */ - protected $_messageTemplates = array(); + protected array $_messageTemplates = []; /** * Array of validation failure messages * * @var array */ - protected $_messages = array(); + protected array $_messages = []; /** - * Flag indidcating whether or not value should be obfuscated in error + * Flag indidcating whether or not value should be obfuscated in error * messages * @var bool */ @@ -76,7 +76,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface * @var array * @deprecated Since 1.5.0 */ - protected $_errors = array(); + protected array $_errors = []; /** * Translation object @@ -89,6 +89,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface * @var Zend_Translate */ protected static $_defaultTranslator; + protected array $_validate_attribs = []; /** * Returns array of validation failure messages @@ -157,12 +158,15 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface */ public function __get($property) { - if ($property == 'value') { + if ($property == 'value') return $this->_value; - } - if (array_key_exists($property, $this->_messageVariables)) { + + if (array_key_exists($property, $this->_validate_attribs)) + return $this->_validate_attribs[$property]; + + if (array_key_exists($property, $this->_messageVariables)) return $this->{$this->_messageVariables[$property]}; - } + /** * @see Zend_Validate_Exception */ @@ -170,12 +174,19 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface throw new Zend_Validate_Exception("No property exists by the name '$property'"); } + + public function __set($key, $val) + { + $this->_validate_attribs [$key] = $val; + } + + /** * Constructs and returns a validation failure message with the given message key and value. * * Returns null if and only if $messageKey does not correspond to an existing template. * - * If a translator is available and a translation exists for $messageKey, + * If a translator is available and a translation exists for $messageKey, * the translation will be used. * * @param string $messageKey @@ -204,7 +215,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface $message = str_replace('%value%', (string) $value, $message); foreach ($this->_messageVariables as $ident => $property) { - $message = str_replace("%$ident%", $this->$property, $message); + $message = str_replace("%$ident%", (string) $this->$property, $message); } return $message; } @@ -253,8 +264,8 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface /** * Set flag indicating whether or not value should be obfuscated in messages - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Validate_Abstract */ public function setObscureValue($flag) @@ -264,9 +275,9 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } /** - * Retrieve flag indicating whether or not value should be obfuscated in + * Retrieve flag indicating whether or not value should be obfuscated in * messages - * + * * @return bool */ public function getObscureValue() @@ -276,8 +287,8 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface /** * Set translation object - * - * @param Zend_Translate|Zend_Translate_Adapter|null $translator + * + * @param Zend_Translate|Zend_Translate_Adapter|null $translator * @return Zend_Validate_Abstract */ public function setTranslator($translator = null) @@ -295,7 +306,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface /** * Return translation object - * + * * @return Zend_Translate_Adapter|null */ public function getTranslator() @@ -309,8 +320,8 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface /** * Set default translation object for all validate objects - * - * @param Zend_Translate|Zend_Translate_Adapter|null $translator + * + * @param Zend_Translate|Zend_Translate_Adapter|null $translator * @return void */ public static function setDefaultTranslator($translator = null) @@ -327,7 +338,7 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface /** * Get default translation object for all validate objects - * + * * @return Zend_Translate_Adapter|null */ public static function getDefaultTranslator() diff --git a/library/Zend/Validate/Alnum.php b/library/Zend/Validate/Alnum.php index 36b0adcb702d2e1d7b270af92c2581cb54eb6411..0f4320dbe7a6b4f1f14fdefcd9a4549ec05df85a 100644 --- a/library/Zend/Validate/Alnum.php +++ b/library/Zend/Validate/Alnum.php @@ -61,13 +61,11 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_ALNUM => "'%value%' has not only alphabetic and digit characters", self::STRING_EMPTY => "'%value%' is an empty string" - ); + ]; /** * Sets default option values for this instance diff --git a/library/Zend/Validate/Alpha.php b/library/Zend/Validate/Alpha.php index 0f2298ea77aa2d299042846487b2b9833a01bcc2..c40ed1327b3a8d8135760622cec4eb6c33cd819c 100644 --- a/library/Zend/Validate/Alpha.php +++ b/library/Zend/Validate/Alpha.php @@ -61,13 +61,11 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_ALPHA => "'%value%' has not only alphabetic characters", self::STRING_EMPTY => "'%value%' is an empty string" - ); + ]; /** * Sets default option values for this instance diff --git a/library/Zend/Validate/Barcode/Ean13.php b/library/Zend/Validate/Barcode/Ean13.php index d1b3a989c712e0ef3c3d12dfc9edff797a3ab7df..d982a948eb850a2c6b6c41319fa154dcb8c661b7 100644 --- a/library/Zend/Validate/Barcode/Ean13.php +++ b/library/Zend/Validate/Barcode/Ean13.php @@ -55,14 +55,12 @@ class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::INVALID => "'%value%' is an invalid EAN-13 barcode", self::INVALID_LENGTH => "'%value%' should be 13 characters", self::NOT_NUMERIC => "'%value%' should contain only numeric characters", - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/Barcode/UpcA.php b/library/Zend/Validate/Barcode/UpcA.php index c584e818da7a50eab39b28d5767e1f9b31a4c556..b99a816ac76f92b219c663ba15546fa9438c14c1 100644 --- a/library/Zend/Validate/Barcode/UpcA.php +++ b/library/Zend/Validate/Barcode/UpcA.php @@ -49,13 +49,11 @@ class Zend_Validate_Barcode_UpcA extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::INVALID => "'%value%' is an invalid UPC-A barcode", self::INVALID_LENGTH => "'%value%' should be 12 characters", - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/Between.php b/library/Zend/Validate/Between.php index bb0b7267f4cb4495fedbca2226b938ebcbee2d8a..3c04fbe3749499ea028888061a8ee6aca34e9a84 100644 --- a/library/Zend/Validate/Between.php +++ b/library/Zend/Validate/Between.php @@ -47,23 +47,19 @@ class Zend_Validate_Between extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_BETWEEN => "'%value%' is not between '%min%' and '%max%', inclusively", self::NOT_BETWEEN_STRICT => "'%value%' is not strictly between '%min%' and '%max%'" - ); + ]; /** * Additional variables available for validation failure messages - * - * @var array */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'min' => '_min', 'max' => '_max' - ); + ]; /** * Minimum value diff --git a/library/Zend/Validate/Ccnum.php b/library/Zend/Validate/Ccnum.php index 227a4ec3342bf6a67653d8f19c66167d65221c15..dfb7c90aa3b695cc9c6d39b3c885661391eb92d7 100644 --- a/library/Zend/Validate/Ccnum.php +++ b/library/Zend/Validate/Ccnum.php @@ -54,13 +54,11 @@ class Zend_Validate_Ccnum extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::LENGTH => "'%value%' must contain between 13 and 19 digits", self::CHECKSUM => "Luhn algorithm (mod-10 checksum) failed on '%value%'" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/Date.php b/library/Zend/Validate/Date.php index af84eba85305a4c26e15e468613c6a641e908991..fb213d70cc26aa522e825d554ac63624e629e21e 100644 --- a/library/Zend/Validate/Date.php +++ b/library/Zend/Validate/Date.php @@ -52,14 +52,12 @@ class Zend_Validate_Date extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_YYYY_MM_DD => "'%value%' is not of the format YYYY-MM-DD", self::INVALID => "'%value%' does not appear to be a valid date", self::FALSEFORMAT => "'%value%' does not fit given date format" - ); + ]; /** * Optional format diff --git a/library/Zend/Validate/Digits.php b/library/Zend/Validate/Digits.php index c42ec0acfff9451b5a5fd4c453ccf7118812b4cb..38581afed1037b176ee2d045e8288c806ba99235 100644 --- a/library/Zend/Validate/Digits.php +++ b/library/Zend/Validate/Digits.php @@ -54,13 +54,11 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_DIGITS => "'%value%' contains not only digit characters", self::STRING_EMPTY => "'%value%' is an empty string" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/EmailAddress.php b/library/Zend/Validate/EmailAddress.php index d8e9595c03dce221483346827dd74e48d5689a23..f7b7f686ec2a548315919740ecb8fa41bcfd49fc 100644 --- a/library/Zend/Validate/EmailAddress.php +++ b/library/Zend/Validate/EmailAddress.php @@ -49,25 +49,19 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract const QUOTED_STRING = 'emailAddressQuotedString'; const INVALID_LOCAL_PART = 'emailAddressInvalidLocalPart'; - /** - * @var array - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::INVALID => "'%value%' is not a valid email address in the basic format local-part@hostname", self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", self::DOT_ATOM => "'%localPart%' not matched against dot-atom format", self::QUOTED_STRING => "'%localPart%' not matched against quoted-string format", self::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'" - ); + ]; - /** - * @var array - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'hostname' => '_hostname', 'localPart' => '_localPart' - ); + ]; /** * Local object for validating the hostname part of an email address diff --git a/library/Zend/Validate/File/Count.php b/library/Zend/Validate/File/Count.php index 8007a6f5d97c86ffcbf3ac03a68ba6e608b84502..98adf19ac8331d868aec5c73280897157fc6bbc7 100644 --- a/library/Zend/Validate/File/Count.php +++ b/library/Zend/Validate/File/Count.php @@ -41,22 +41,16 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract const TOO_LESS = 'fileCountTooLess'; /**#@-*/ - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::TOO_MUCH => "Too much files, maximum '%max%' are allowed but '%count%' are given", self::TOO_LESS => "Too less files, minimum '%min%' are expected but '%count%' are given" - ); + ]; - /** - * @var array Error message template variables - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'min' => '_min', 'max' => '_max', 'count' => '_count' - ); + ]; /** * Minimum file count diff --git a/library/Zend/Validate/File/ExcludeExtension.php b/library/Zend/Validate/File/ExcludeExtension.php index b74852f5252a36e31e1de04bde8a973908d2ceec..636e0836aa48e4bb98236ee154a4128148feba7d 100644 --- a/library/Zend/Validate/File/ExcludeExtension.php +++ b/library/Zend/Validate/File/ExcludeExtension.php @@ -40,13 +40,10 @@ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension const FALSE_EXTENSION = 'fileExcludeExtensionFalse'; const NOT_FOUND = 'fileExcludeExtensionNotFound'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::FALSE_EXTENSION => "The file '%value%' has a false extension", self::NOT_FOUND => "The file '%value%' was not found" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/File/Exists.php b/library/Zend/Validate/File/Exists.php index 268090bcb52440f88da8f17d6485e2f08cb24cb4..c16befc4b149e53063fd1e8d110667b2d4dd7419 100644 --- a/library/Zend/Validate/File/Exists.php +++ b/library/Zend/Validate/File/Exists.php @@ -39,12 +39,9 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract */ const DOES_NOT_EXIST = 'fileExistsDoesNotExist'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::DOES_NOT_EXIST => "The file '%value%' does not exist" - ); + ]; /** * Internal list of directories @@ -52,12 +49,9 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract */ protected $_directory = ''; - /** - * @var array Error message template variables - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'directory' => '_directory' - ); + ]; /** * Sets validator options @@ -161,7 +155,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract $check = true; if (!file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { $this->_throw($file, self::DOES_NOT_EXIST); - return false; + return false; } } diff --git a/library/Zend/Validate/File/Extension.php b/library/Zend/Validate/File/Extension.php index 5eb0f8f70572ea3c2ef4c2faca68d372ee9baafb..1d05f51c4320ae2a69c49884d094d54ea473909c 100644 --- a/library/Zend/Validate/File/Extension.php +++ b/library/Zend/Validate/File/Extension.php @@ -40,13 +40,10 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract const FALSE_EXTENSION = 'fileExtensionFalse'; const NOT_FOUND = 'fileExtensionNotFound'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::FALSE_EXTENSION => "The file '%value%' has a false extension", self::NOT_FOUND => "The file '%value%' was not found" - ); + ]; /** * Internal list of extensions @@ -61,12 +58,9 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract */ protected $_case = false; - /** - * @var array Error message template variables - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'extension' => '_extension' - ); + ]; /** * Sets validator options diff --git a/library/Zend/Validate/File/FilesSize.php b/library/Zend/Validate/File/FilesSize.php index fe9fdd551aeda35e5a0e817cb40ef45bb5c37d18..8fec0ae52297992eeb28a86add4d21297bce3b26 100644 --- a/library/Zend/Validate/File/FilesSize.php +++ b/library/Zend/Validate/File/FilesSize.php @@ -41,14 +41,11 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size const TOO_SMALL = 'fileFilesSizeTooSmall'; const NOT_READABLE = 'fileFilesSizeNotReadable'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::TOO_BIG => "All files in sum should have a maximum size of '%max%' but '%size%' were detected", self::TOO_SMALL => "All files in sum should have a minimum size of '%min%' but '%size%' were detected", self::NOT_READABLE => "One or more files can not be read" - ); + ]; /** * Internal file array diff --git a/library/Zend/Validate/File/ImageSize.php b/library/Zend/Validate/File/ImageSize.php index 5852b8114d8e98fdab87bf0ae6106f60362a43b0..334efa9a024f79f5d7f74a3ec7532dceea33b095 100644 --- a/library/Zend/Validate/File/ImageSize.php +++ b/library/Zend/Validate/File/ImageSize.php @@ -44,29 +44,23 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract const NOT_DETECTED = 'fileImageSizeNotDetected'; const NOT_READABLE = 'fileImageSizeNotReadable'; - /** - * @var array Error message template - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::WIDTH_TOO_BIG => "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected", self::WIDTH_TOO_SMALL => "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected", self::HEIGHT_TOO_BIG => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected", self::HEIGHT_TOO_SMALL => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected", self::NOT_DETECTED => "The size of image '%value%' could not be detected", self::NOT_READABLE => "The image '%value%' can not be read" - ); + ]; - /** - * @var array Error message template variables - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'minwidth' => '_minwidth', 'maxwidth' => '_maxwidth', 'minheight' => '_minheight', 'maxheight' => '_maxheight', 'width' => '_width', 'height' => '_height' - ); + ]; /** * Minimum image width diff --git a/library/Zend/Validate/File/IsCompressed.php b/library/Zend/Validate/File/IsCompressed.php index b31d23dccbb3158fb4c2030e464ad91f6b438f00..eddbf002d96f59ee49074a4047d5f1b4b7b0946b 100644 --- a/library/Zend/Validate/File/IsCompressed.php +++ b/library/Zend/Validate/File/IsCompressed.php @@ -41,14 +41,11 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType const NOT_DETECTED = 'fileIsCompressedNotDetected'; const NOT_READABLE = 'fileIsCompressedNotReadable'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::FALSE_TYPE => "The file '%value%' is not compressed, '%type%' detected", self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", self::NOT_READABLE => "The file '%value%' can not be read" - ); + ]; /** * Sets validator options diff --git a/library/Zend/Validate/File/IsImage.php b/library/Zend/Validate/File/IsImage.php index 8a1d0deb55f16e2e49d43670132f8f262b0505e9..95ea0b50a19059dee00736f86552b4d3f53fa33a 100644 --- a/library/Zend/Validate/File/IsImage.php +++ b/library/Zend/Validate/File/IsImage.php @@ -41,14 +41,11 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType const NOT_DETECTED = 'fileIsImageNotDetected'; const NOT_READABLE = 'fileIsImageNotReadable'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::FALSE_TYPE => "The file '%value%' is no image, '%type%' detected", self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", self::NOT_READABLE => "The file '%value%' can not be read" - ); + ]; /** * Sets validator options diff --git a/library/Zend/Validate/File/MimeType.php b/library/Zend/Validate/File/MimeType.php index dafc95c6087a4ecc94d92109f72064fc6624bcf3..c6a07eeea9bfab74b836847a6e067c276efd7dfc 100644 --- a/library/Zend/Validate/File/MimeType.php +++ b/library/Zend/Validate/File/MimeType.php @@ -37,22 +37,16 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract const FALSE_TYPE = 'fileMimeTypeFalse'; const NOT_DETECTED = 'fileMimeTypeNotDetected'; const NOT_READABLE = 'fileMimeTypeNotReadable'; - - /** - * @var array - */ - protected $_messageTemplates = array( + + protected array $_messageTemplates = [ self::FALSE_TYPE => "The file '%value%' has a false mimetype of '%type%'", self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected", self::NOT_READABLE => "The file '%value%' can not be read" - ); + ]; - /** - * @var array - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'type' => '_type' - ); + ]; /** * @var string diff --git a/library/Zend/Validate/File/NotExists.php b/library/Zend/Validate/File/NotExists.php index 2b812fc2cd4529faf3d9f030c0a424b94a16f577..c4406bd3dc750619653ab773e6b63673e6003516 100644 --- a/library/Zend/Validate/File/NotExists.php +++ b/library/Zend/Validate/File/NotExists.php @@ -39,12 +39,9 @@ class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists */ const DOES_EXIST = 'fileNotExistsDoesExist'; - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::DOES_EXIST => "The file '%value%' does exist" - ); + ]; /** * Defined by Zend_Validate_Interface @@ -72,13 +69,13 @@ class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists $check = true; if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { $this->_throw($file, self::DOES_EXIST); - return false; + return false; } } if (!isset($check)) { $this->_throw($file, self::DOES_EXIST); - return false; + return false; } return true; diff --git a/library/Zend/Validate/File/Size.php b/library/Zend/Validate/File/Size.php index a7d949e01582af0cea635b51dc308ddb369618ef..82f134e2c4310b795c744f78caf8ebfb26e3eb67 100644 --- a/library/Zend/Validate/File/Size.php +++ b/library/Zend/Validate/File/Size.php @@ -41,24 +41,18 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract const TOO_SMALL = 'fileSizeTooSmall'; const NOT_FOUND = 'fileSizeNotFound'; /**#@-*/ - - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + + protected array $_messageTemplates = [ self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", self::NOT_FOUND => "The file '%value%' could not be found" - ); + ]; - /** - * @var array Error message template variables - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'min' => '_min', 'max' => '_max', 'size' => '_size', - ); + ]; /** * Minimum filesize @@ -298,7 +292,7 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract * @param integer $size * @return string */ - protected function _toByteString($size) + protected function _toByteString($size) { $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); for ($i=0; $size >= 1024 && $i < 9; $i++) { @@ -313,7 +307,7 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract * @param string $size * @return integer */ - protected function _fromByteString($size) + protected function _fromByteString($size) { if (is_numeric($size)) { return (integer) $size; diff --git a/library/Zend/Validate/File/Upload.php b/library/Zend/Validate/File/Upload.php index a56cf145abb6c4d36d99f9fb5ac5ef67c4b70b05..113c249f512a022f23ea1fa946798e035554f61c 100644 --- a/library/Zend/Validate/File/Upload.php +++ b/library/Zend/Validate/File/Upload.php @@ -49,10 +49,7 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract const UNKNOWN = 'fileUploadErrorUnknown'; /**@#-*/ - /** - * @var array Error message templates - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::INI_SIZE => "The file '%value%' exceeds the defined ini size", self::FORM_SIZE => "The file '%value%' exceeds the defined form size", self::PARTIAL => "The file '%value%' was only partially uploaded", @@ -63,7 +60,7 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract self::ATTACK => "The file '%value%' was illegal uploaded, possible attack", self::FILE_NOT_FOUND => "The file '%value%' was not found", self::UNKNOWN => "Unknown error while uploading the file '%value%'" - ); + ]; /** * Internal array of files diff --git a/library/Zend/Validate/Float.php b/library/Zend/Validate/Float.php index 0405161d43bc34996f902019e915c074256b2750..098e77b6edd3f66187003521b966a3cd05564532 100644 --- a/library/Zend/Validate/Float.php +++ b/library/Zend/Validate/Float.php @@ -38,12 +38,9 @@ class Zend_Validate_Float extends Zend_Validate_Abstract const NOT_FLOAT = 'notFloat'; - /** - * @var array - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_FLOAT => "'%value%' does not appear to be a float" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/GreaterThan.php b/library/Zend/Validate/GreaterThan.php index 35e658c2341690b74ce7e4520bf905a87de02b5c..a0649566a7b964481a93e0b8e3fcd168a1d0a216 100644 --- a/library/Zend/Validate/GreaterThan.php +++ b/library/Zend/Validate/GreaterThan.php @@ -38,19 +38,13 @@ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract const NOT_GREATER = 'notGreaterThan'; - /** - * @var array - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_GREATER => "'%value%' is not greater than '%min%'" - ); + ]; - /** - * @var array - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'min' => '_min' - ); + ]; /** * Minimum value diff --git a/library/Zend/Validate/Hex.php b/library/Zend/Validate/Hex.php index 9512edaeb76b2bddabe83e46953d74c5212c6417..271c6847b993cdd7d48a5076d9dd0a61f0e7d304 100644 --- a/library/Zend/Validate/Hex.php +++ b/library/Zend/Validate/Hex.php @@ -42,12 +42,10 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract /** * Validation failure message template definitions - * - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_HEX => "'%value%' has not only hexadecimal digit characters" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/Hostname.php b/library/Zend/Validate/Hostname.php index 660529317a90de666f3e6d60cd2bdebe84cc2cf2..8c3fda0bab062d6b41f5e5fe3318898a186e2d5e 100644 --- a/library/Zend/Validate/Hostname.php +++ b/library/Zend/Validate/Hostname.php @@ -66,7 +66,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract /** * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed", self::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list", self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position", @@ -75,14 +75,14 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract self::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname", self::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name", self::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but local network names are not allowed" - ); + ]; /** * @var array */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'tld' => '_tld' - ); + ]; /** * Allows Internet domain names (e.g., example.com) diff --git a/library/Zend/Validate/Identical.php b/library/Zend/Validate/Identical.php index 02a5366161ef681c6bb0c613249c2b6e9ecac170..ac161c911727e35957498359141dcfa2d55e2a00 100644 --- a/library/Zend/Validate/Identical.php +++ b/library/Zend/Validate/Identical.php @@ -40,12 +40,11 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract /** * Error messages - * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_SAME => 'Tokens do not match', self::MISSING_TOKEN => 'No token was provided to match against', - ); + ]; /** * Original token against which to validate @@ -68,8 +67,8 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract /** * Set token against which to compare - * - * @param string $token + * + * @param string $token * @return Zend_Validate_Identical */ public function setToken($token) @@ -80,7 +79,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract /** * Retrieve token - * + * * @return string */ public function getToken() @@ -91,7 +90,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract /** * Defined by Zend_Validate_Interface * - * Returns true if and only if a token has been set and the provided value + * Returns true if and only if a token has been set and the provided value * matches that token. * * @param string $value diff --git a/library/Zend/Validate/InArray.php b/library/Zend/Validate/InArray.php index 1c7725a2ea42e44601eca0ab54da59623c73a930..0b4c5997dd885ed527b299f399bc1b4fa99793d7 100644 --- a/library/Zend/Validate/InArray.php +++ b/library/Zend/Validate/InArray.php @@ -41,9 +41,9 @@ class Zend_Validate_InArray extends Zend_Validate_Abstract /** * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_IN_ARRAY => "'%value%' was not found in the haystack" - ); + ]; /** * Haystack of possible values diff --git a/library/Zend/Validate/Int.php b/library/Zend/Validate/Int.php index 0bde2cb4e401848f4396f809c7752b0506666a5a..0401f57e25d2361a5abf0f393186597bc53c685b 100644 --- a/library/Zend/Validate/Int.php +++ b/library/Zend/Validate/Int.php @@ -41,9 +41,9 @@ class Zend_Validate_Int extends Zend_Validate_Abstract /** * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_INT => "'%value%' does not appear to be an integer" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/Ip.php b/library/Zend/Validate/Ip.php index 3f40696d8dcfaa0549e12e74cf5f18a142e314a0..687cc545177145d96777a788812db4e57167829f 100644 --- a/library/Zend/Validate/Ip.php +++ b/library/Zend/Validate/Ip.php @@ -41,9 +41,9 @@ class Zend_Validate_Ip extends Zend_Validate_Abstract /** * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_IP_ADDRESS => "'%value%' does not appear to be a valid IP address" - ); + ]; /** * Defined by Zend_Validate_Interface diff --git a/library/Zend/Validate/LessThan.php b/library/Zend/Validate/LessThan.php index 9f7b72c12809bc0692c89d1e370c0a22379381b7..002d3f494672094741d84d1dceb9d9cf4b11248b 100644 --- a/library/Zend/Validate/LessThan.php +++ b/library/Zend/Validate/LessThan.php @@ -38,19 +38,13 @@ class Zend_Validate_LessThan extends Zend_Validate_Abstract const NOT_LESS = 'notLessThan'; - /** - * @var array - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_LESS => "'%value%' is not less than '%max%'" - ); + ]; - /** - * @var array - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'max' => '_max' - ); + ]; /** * Maximum value diff --git a/library/Zend/Validate/NotEmpty.php b/library/Zend/Validate/NotEmpty.php index 6638614fc3b4753d7ae6b51d237bbf465af67230..659807fd55e7128b70921e5775eb338e0444a49f 100644 --- a/library/Zend/Validate/NotEmpty.php +++ b/library/Zend/Validate/NotEmpty.php @@ -41,9 +41,9 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract /** * @var array */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::IS_EMPTY => "Value is empty, but a non-empty value is required" - ); + ]; /** * Defined by Zend_Validate_Interface @@ -58,7 +58,7 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract $this->_setValue((string) $value); if (is_string($value) - && (('' === $value) + && (('' === $value) || preg_match('/^\s+$/s', $value)) ) { $this->_error(); diff --git a/library/Zend/Validate/Regex.php b/library/Zend/Validate/Regex.php index 1566f0762b400c56fc548f30765b512c5b9860e9..191ffb6c2f045d1e0d03336fb918ba927c0849a7 100644 --- a/library/Zend/Validate/Regex.php +++ b/library/Zend/Validate/Regex.php @@ -38,19 +38,13 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract const NOT_MATCH = 'regexNotMatch'; - /** - * @var array - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'" - ); + ]; - /** - * @var array - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'pattern' => '_pattern' - ); + ]; /** * Regular expression pattern diff --git a/library/Zend/Validate/StringLength.php b/library/Zend/Validate/StringLength.php index c43f2ca3e93332ccca7f42f4b56c6594c0c3626b..d9872110119f0e125cdadba46e196be2da9503ba 100644 --- a/library/Zend/Validate/StringLength.php +++ b/library/Zend/Validate/StringLength.php @@ -39,21 +39,15 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract const TOO_SHORT = 'stringLengthTooShort'; const TOO_LONG = 'stringLengthTooLong'; - /** - * @var array - */ - protected $_messageTemplates = array( + protected array $_messageTemplates = [ self::TOO_SHORT => "'%value%' is less than %min% characters long", self::TOO_LONG => "'%value%' is greater than %max% characters long" - ); + ]; - /** - * @var array - */ - protected $_messageVariables = array( + protected array $_messageVariables = [ 'min' => '_min', 'max' => '_max' - ); + ]; /** * Minimum length diff --git a/library/Zend/View.php b/library/Zend/View.php index 32946934132673ad93a25cf0b257f66b9bc46f85..be31cd2e5ac1a77a5049b2be987f408a6246605b 100644 --- a/library/Zend/View.php +++ b/library/Zend/View.php @@ -51,8 +51,8 @@ class Zend_View extends Zend_View_Abstract * Constructor * * Register Zend_View_Stream stream wrapper if short tags are disabled. - * - * @param array $config + * + * @param array $config * @return void */ public function __construct($config = array()) @@ -74,8 +74,8 @@ class Zend_View extends Zend_View_Abstract /** * Set flag indicating if stream wrapper should be used if short_open_tag is off - * - * @param bool $flag + * + * @param bool $flag * @return Zend_View */ public function setUseStreamWrapper($flag) @@ -86,7 +86,7 @@ class Zend_View extends Zend_View_Abstract /** * Should the stream wrapper be used if short_open_tag is off? - * + * * @return bool */ public function useStreamWrapper() diff --git a/library/Zend/View/Abstract.php b/library/Zend/View/Abstract.php index 3e4e4efb1babd67bf323c5cc59b0f3e1f0281304..4aec49e2fd31d853a809b39634146147b527892c 100644 --- a/library/Zend/View/Abstract.php +++ b/library/Zend/View/Abstract.php @@ -432,9 +432,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface /** * Set plugin loader for a particular plugin type - * - * @param Zend_Loader_PluginLoader $loader - * @param string $type + * + * @param Zend_Loader_PluginLoader $loader + * @param string $type * @return Zend_View_Abstract */ public function setPluginLoader(Zend_Loader_PluginLoader $loader, $type) @@ -451,8 +451,8 @@ abstract class Zend_View_Abstract implements Zend_View_Interface /** * Retrieve plugin loader for a specific plugin type - * - * @param string $type + * + * @param string $type * @return Zend_Loader_PluginLoader */ public function getPluginLoader($type) @@ -800,7 +800,10 @@ abstract class Zend_View_Abstract implements Zend_View_Interface */ public function escape($var) { - if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities'))) { + if (in_array($this->_escape, ['htmlspecialchars', 'htmlentities'])) { + $var = is_array($var) + ? implode(' ', $var) + : $var ?? ''; return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_encoding); } @@ -1052,10 +1055,10 @@ abstract class Zend_View_Abstract implements Zend_View_Interface /** * Add a prefixPath for a plugin type - * - * @param string $type - * @param string $classPrefix - * @param array $paths + * + * @param string $type + * @param string $classPrefix + * @param array $paths * @return Zend_View_Abstract */ private function _addPluginPath($type, $classPrefix, array $paths) @@ -1069,9 +1072,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface /** * Get a path to a given plugin class of a given type - * - * @param string $type - * @param string $name + * + * @param string $type + * @param string $name * @return string|false */ private function _getPluginPath($type, $name) @@ -1091,9 +1094,9 @@ abstract class Zend_View_Abstract implements Zend_View_Interface /** * Retrieve a plugin object - * - * @param string $type - * @param string $name + * + * @param string $type + * @param string $name * @return object */ private function _getPlugin($type, $name) diff --git a/library/Zend/View/Helper/DeclareVars.php b/library/Zend/View/Helper/DeclareVars.php index 6b34049c1091268aff919f380f9c2e76e72b5b1a..74eecfccf8ea5402a9c6b2bd07fb5464cbe18572 100644 --- a/library/Zend/View/Helper/DeclareVars.php +++ b/library/Zend/View/Helper/DeclareVars.php @@ -88,7 +88,7 @@ class Zend_View_Helper_DeclareVars extends Zend_View_Helper_Abstract */ protected function _declareVar($key, $value = '') { - if (!isset($this->view->$key)) { + if (!$this->view->$key) { $this->view->$key = $value; } } diff --git a/library/Zend/View/Helper/HeadLink.php b/library/Zend/View/Helper/HeadLink.php index 61de3c855c9b6d3486c7a0eca1af7c097b38e82d..fd12ec66c26eff71a19959dfcb2fa2b72f69e4e9 100644 --- a/library/Zend/View/Helper/HeadLink.php +++ b/library/Zend/View/Helper/HeadLink.php @@ -50,7 +50,7 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S * Constructor * * Use PHP_EOL as separator - * + * * @return void */ public function __construct() @@ -58,11 +58,11 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S parent::__construct(); $this->setSeparator(PHP_EOL); } - + /** * headLink() - View Helper Method * - * Returns current object instance. Optionally, allows passing array of + * Returns current object instance. Optionally, allows passing array of * values to build link. * * @return Zend_View_Helper_HeadLink @@ -99,7 +99,7 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S * - offsetSetAlternate($index, $href, $type, $title) * - prependAlternate($href, $type, $title) * - setAlternate($href, $type, $title) - * + * * Items that may be added in the future: * - Navigation? need to find docs on this * - public function appendStart() @@ -118,8 +118,8 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S * - public function appendSection() * - public function appendSubsection() * - * @param mixed $method - * @param mixed $args + * @param mixed $method + * @param mixed $args * @return void */ public function __call($method, $args) @@ -165,8 +165,8 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S /** * Check if value is valid - * - * @param mixed $value + * + * @param mixed $value * @return boolean */ protected function _isValid($value) @@ -184,7 +184,7 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S return true; } - + /** * append() * @@ -203,19 +203,19 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S /** * offsetSet() - * - * @param string|int $index - * @param array $value + * + * @param string|int $index + * @param array $value * @return void */ - public function offsetSet($index, $value) + public function offsetSet(mixed $index, mixed $value): void { if (!$this->_isValid($value)) { require_once 'Zend/View/Exception.php'; throw new Zend_View_Exception('offsetSet() expects a data token; please use one of the custom offsetSet*() methods'); } - return $this->getContainer()->offsetSet($index, $value); + $this->getContainer()->offsetSet($index, $value); } /** @@ -250,24 +250,24 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S return $this->getContainer()->set($value); } - + /** * Create HTML link element from data item - * - * @param stdClass $item + * + * @param stdClass $item * @return string */ public function itemToString(stdClass $item) { $attributes = (array) $item; $link = '<link '; - + foreach ($this->_itemKeys as $itemKey) { if (isset($attributes[$itemKey])) { $link .= $itemKey . '="' . $this->_escape($attributes[$itemKey]) . '" '; } } - + if ($this->view instanceof Zend_View_Abstract) { $link .= ($this->view->doctype()->isXhtml()) ? '/>' : '>'; } else { @@ -279,17 +279,17 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S } if (isset($attributes['conditionalStylesheet']) - && (false !== $attributes['conditionalStylesheet'])) + && (false !== $attributes['conditionalStylesheet'])) { $link = '<!--[if ' . $attributes['conditionalStylesheet'] . ']> ' . $link . '<![endif]-->'; } - + return $link; } /** * Render link elements as string - * + * * @param string|int $indent * @return string */ @@ -309,8 +309,8 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S /** * Create data item for stack - * - * @param array $attributes + * + * @param array $attributes * @return stdClass */ public function createData(array $attributes) @@ -321,8 +321,8 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S /** * Create item for stylesheet link item - * - * @param array $args + * + * @param array $args * @return stdClass|false Returns fals if stylesheet is a duplicate */ public function createDataStylesheet(array $args) @@ -354,8 +354,8 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S /** * Is the linked stylesheet a duplicate? - * - * @param string $uri + * + * @param string $uri * @return bool */ protected function _isDuplicateStylesheet($uri) @@ -370,8 +370,8 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S /** * Create item for alternate link item - * - * @param array $args + * + * @param array $args * @return stdClass */ public function createDataAlternate(array $args) diff --git a/library/Zend/View/Helper/HeadMeta.php b/library/Zend/View/Helper/HeadMeta.php index 9118698c522ddc80c413f6ede13bdec30b6352e0..4cef691ce8a3e185bffa25d20e6c488ec183a7fb 100644 --- a/library/Zend/View/Helper/HeadMeta.php +++ b/library/Zend/View/Helper/HeadMeta.php @@ -54,7 +54,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S * Constructor * * Set separator to PHP_EOL - * + * * @return void */ public function __construct() @@ -65,12 +65,12 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * Retrieve object instance; optionally add meta tag - * - * @param string $content - * @param string $keyValue - * @param string $keyType - * @param array $modifiers - * @param string $placement + * + * @param string $content + * @param string $keyValue + * @param string $keyType + * @param array $modifiers + * @param string $placement * @return Zend_View_Helper_HeadMeta */ public function headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND) @@ -118,9 +118,9 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S * - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array()) * - prependHttpEquiv($keyValue, $content, $modifiers = array()) * - setHttpEquiv($keyValue, $content, $modifiers = array()) - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return Zend_View_Helper_HeadMeta */ public function __call($method, $args) @@ -156,7 +156,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S if ($action == 'set') { //var_dump($this->getContainer()); } - + $this->$action($item); return $this; } @@ -166,8 +166,8 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * Determine if item is valid - * - * @param mixed $item + * + * @param mixed $item * @return boolean */ protected function _isValid($item) @@ -185,8 +185,8 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * Append - * - * @param string $value + * + * @param string $value * @return void * @throws Zend_View_Exception */ @@ -202,25 +202,21 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * OffsetSet - * - * @param string|int $index - * @param string $value - * @return void * @throws Zend_View_Exception */ - public function offsetSet($index, $value) + public function offsetSet(mixed $index, mixed $value): void { if (!$this->_isValid($value)) { require_once 'Zend/View/Exception.php'; throw new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetMeta()'); } - return $this->getContainer()->offsetSet($index, $value); + $this->getContainer()->offsetSet($index, $value); } /** * OffsetUnset - * + * * @param string|int $index * @return void * @throws Zend_View_Exception @@ -231,14 +227,14 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S require_once 'Zend/View/Exception.php'; throw new Zend_View_Exception('Invalid index passed to offsetUnset.'); } - + return $this->getContainer()->offsetUnset($index); } - + /** * Prepend - * - * @param string $value + * + * @param string $value * @return void * @throws Zend_View_Exception */ @@ -254,8 +250,8 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * Set - * - * @param string $value + * + * @param string $value * @return void * @throws Zend_View_Exception */ @@ -272,17 +268,17 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S $this->offsetUnset($index); } } - + return $this->append($value); } /** * Build meta HTML string - * - * @param string $type - * @param string $typeValue - * @param string $content - * @param array $modifiers + * + * @param string $type + * @param string $typeValue + * @param string $content + * @param array $modifiers * @return string */ public function itemToString(stdClass $item) @@ -321,8 +317,8 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * Render placeholder as string - * - * @param string|int $indent + * + * @param string|int $indent * @return string */ public function toString($indent = null) @@ -340,11 +336,11 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S /** * Create data item for inserting into stack - * - * @param string $type - * @param string $typeValue - * @param string $content - * @param array $modifiers + * + * @param string $type + * @param string $typeValue + * @param string $content + * @param array $modifiers * @return stdClass */ public function createData($type, $typeValue, $content, array $modifiers) diff --git a/library/Zend/View/Helper/HeadScript.php b/library/Zend/View/Helper/HeadScript.php index 76d9a5d886c34d26d1c4335281332a3c1e1210e9..91bd5f34d1be71d2ee6869ea61d74944c471504a 100644 --- a/library/Zend/View/Helper/HeadScript.php +++ b/library/Zend/View/Helper/HeadScript.php @@ -52,7 +52,7 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container * @var bool */ protected $_arbitraryAttributes = false; - + /**#@+ * Capture type and/or attributes (used for hinting during capture) * @var string @@ -78,7 +78,7 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container protected $_requiredAttributes = array('type'); /** - * Whether or not to format scripts using CDATA; used only if doctype + * Whether or not to format scripts using CDATA; used only if doctype * helper is not accessible * @var bool */ @@ -88,7 +88,7 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container * Constructor * * Set separator to PHP_EOL. - * + * * @return void */ public function __construct() @@ -96,11 +96,11 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container parent::__construct(); $this->setSeparator(PHP_EOL); } - + /** * Return headScript object * - * Returns headScript helper object; optionally, allows specifying a script + * Returns headScript helper object; optionally, allows specifying a script * or script file to include. * * @param string $mode Script or file @@ -130,12 +130,12 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container return $this; } - + /** * Start capture action - * - * @param mixed $captureType - * @param string $typeOrAttrs + * + * @param mixed $captureType + * @param string $typeOrAttrs * @return void */ public function captureStart($captureType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $type = 'text/javascript', $attrs = array()) @@ -151,10 +151,10 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container $this->_captureScriptAttrs = $attrs; ob_start(); } - + /** * End capture action and store - * + * * @return void */ public function captureEnd() @@ -191,9 +191,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container * - offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array()) * - prependScript($script, $type = 'text/javascript', $attrs = array()) * - setScript($script, $type = 'text/javascript', $attrs = array()) - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return Zend_View_Helper_HeadScript * @throws Zend_View_Exception if too few arguments or invalid method */ @@ -258,14 +258,14 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Is the file specified a duplicate? - * - * @param string $file + * + * @param string $file * @return bool */ protected function _isDuplicate($file) { foreach ($this->getContainer() as $item) { - if (($item->source === null) + if (($item->source === null) && array_key_exists('src', $item->attributes) && ($file == $item->attributes['src'])) { @@ -277,9 +277,9 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Is the script provided valid? - * - * @param mixed $value - * @param string $method + * + * @param mixed $value + * @param string $method * @return bool */ protected function _isValid($value) @@ -296,8 +296,8 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Override append - * - * @param string $value + * + * @param string $value * @return void */ public function append($value) @@ -312,8 +312,8 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Override prepend - * - * @param string $value + * + * @param string $value * @return void */ public function prepend($value) @@ -328,8 +328,8 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Override set - * - * @param string $value + * + * @param string $value * @return void */ public function set($value) @@ -344,12 +344,12 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Override offsetSet - * - * @param string|int $index - * @param mixed $value + * + * @param string|int $index + * @param mixed $value * @return void */ - public function offsetSet($index, $value) + public function offsetSet(mixed $index, mixed $value): void { if (!$this->_isValid($value)) { require_once 'Zend/View/Exception.php'; @@ -357,13 +357,13 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container } $this->_isValid($value); - return $this->getContainer()->offsetSet($index, $value); + $this->getContainer()->offsetSet($index, $value); } /** * Set flag indicating if arbitrary attributes are allowed - * - * @param bool $flag + * + * @param bool $flag * @return Zend_View_Helper_HeadScript */ public function setAllowArbitraryAttributes($flag) @@ -374,7 +374,7 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Are arbitrary attributes allowed? - * + * * @return bool */ public function arbitraryAttributesAllowed() @@ -384,11 +384,11 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Create script HTML - * - * @param string $type - * @param array $attributes - * @param string $content - * @param string|int $indent + * + * @param string $type + * @param array $attributes + * @param string $content + * @param string|int $indent * @return string */ public function itemToString($item, $indent, $escapeStart, $escapeEnd) @@ -396,8 +396,8 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container $attrString = ''; if (!empty($item->attributes)) { foreach ($item->attributes as $key => $value) { - if (!$this->arbitraryAttributesAllowed() - && !in_array($key, $this->_optionalAttributes)) + if (!$this->arbitraryAttributesAllowed() + && !in_array($key, $this->_optionalAttributes)) { continue; } @@ -419,8 +419,8 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Retrieve string representation - * - * @param string|int $indent + * + * @param string|int $indent * @return string */ public function toString($indent = null) @@ -453,10 +453,10 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container /** * Create data item containing all necessary components of script - * - * @param string $type - * @param array $attributes - * @param string $content + * + * @param string $type + * @param array $attributes + * @param string $content * @return stdClass */ public function createData($type, array $attributes, $content = null) diff --git a/library/Zend/View/Helper/HeadStyle.php b/library/Zend/View/Helper/HeadStyle.php index c7321ac9e346283137132d021c28a98e733a2669..9344b829ff9bde9bd30219a10c1b6bb2d3cc83ed 100644 --- a/library/Zend/View/Helper/HeadStyle.php +++ b/library/Zend/View/Helper/HeadStyle.php @@ -50,7 +50,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ * @var array */ protected $_mediaTypes = array( - 'all', 'aural', 'braille', 'handheld', 'print', + 'all', 'aural', 'braille', 'handheld', 'print', 'projection', 'screen', 'tty', 'tv' ); @@ -76,7 +76,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ * Constructor * * Set separator to PHP_EOL. - * + * * @return void */ public function __construct() @@ -84,11 +84,11 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ parent::__construct(); $this->setSeparator(PHP_EOL); } - + /** * Return headStyle object * - * Returns headStyle helper object; optionally, allows specifying + * Returns headStyle helper object; optionally, allows specifying * * @param string $content Stylesheet contents * @param string $placement Append, prepend, or set @@ -124,9 +124,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ * - offsetSetStyle($index, $content, $attributes = array()) * - prependStyle($content, $attributes = array()) * - setStyle($content, $attributes = array()) - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return void * @throws Zend_View_Exception When no $content provided or invalid method */ @@ -171,9 +171,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Determine if a value is a valid style tag - * - * @param mixed $value - * @param string $method + * + * @param mixed $value + * @param string $method * @return boolean */ protected function _isValid($value) @@ -190,8 +190,8 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Override append to enforce style creation - * - * @param mixed $value + * + * @param mixed $value * @return void */ public function append($value) @@ -203,28 +203,24 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ return $this->getContainer()->append($value); } - + /** * Override offsetSet to enforce style creation - * - * @param string|int $index - * @param mixed $value - * @return void */ - public function offsetSet($index, $value) + public function offsetSet(mixed $index, mixed $value): void { if (!$this->_isValid($value)) { require_once 'Zend/View/Exception.php'; throw new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()'); } - return $this->getContainer()->offsetSet($index, $value); + $this->getContainer()->offsetSet($index, $value); } /** * Override prepend to enforce style creation - * - * @param mixed $value + * + * @param mixed $value * @return void */ public function prepend($value) @@ -239,8 +235,8 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Override set to enforce style creation - * - * @param mixed $value + * + * @param mixed $value * @return void */ public function set($value) @@ -255,9 +251,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Start capture action - * - * @param mixed $captureType - * @param string $typeOrAttrs + * + * @param mixed $captureType + * @param string $typeOrAttrs * @return void */ public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $attrs = null) @@ -272,10 +268,10 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ $this->_captureType = $type; ob_start(); } - + /** * End capture action and store - * + * * @return void */ public function captureEnd() @@ -301,9 +297,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Convert content and attributes into valid style tag - * + * * @param stdClass $item Item to render - * @param string $indent Indentation to use + * @param string $indent Indentation to use * @return string */ public function itemToString(stdClass $item, $indent) @@ -332,8 +328,8 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Create string representation of placeholder - * - * @param string|int $indent + * + * @param string|int $indent * @return string */ public function toString($indent = null) @@ -357,9 +353,9 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_ /** * Create data item for use in stack - * - * @param string $content - * @param array $attributes + * + * @param string $content + * @param array $attributes * @return stdClass */ public function createData($content, array $attributes) diff --git a/library/Zend/View/Helper/PaginationControl.php b/library/Zend/View/Helper/PaginationControl.php index c210f9a5ef44790a27a1958d4eae758d96567448..417cf514d2467d2175c535c8c7bd1386ea0365dc 100644 --- a/library/Zend/View/Helper/PaginationControl.php +++ b/library/Zend/View/Helper/PaginationControl.php @@ -29,7 +29,7 @@ class Zend_View_Helper_PaginationControl { /** * View instance - * + * * @var Zend_View_Instance */ public $view = null; @@ -62,7 +62,7 @@ class Zend_View_Helper_PaginationControl { self::$_defaultViewPartial = $partial; } - + /** * Gets the default view partial * @@ -75,7 +75,7 @@ class Zend_View_Helper_PaginationControl /** * Render the provided pages. This checks if $view->paginator is set and, - * if so, uses that. Also, if no scrolling style or partial are specified, + * if so, uses that. Also, if no scrolling style or partial are specified, * the defaults will be used (if set). * * @param Zend_Paginator (Optional) $paginator @@ -88,7 +88,7 @@ class Zend_View_Helper_PaginationControl public function paginationControl(Zend_Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null) { if ($paginator === null) { - if (isset($this->view->paginator) and $this->view->paginator !== null) { + if ($this->view->paginator) { $paginator = $this->view->paginator; } else { /** @@ -99,7 +99,7 @@ class Zend_View_Helper_PaginationControl throw new Zend_View_Exception('No paginator instance provided nor found'); } } - + if ($partial === null) { if (self::$_defaultViewPartial === null) { /** @@ -109,12 +109,12 @@ class Zend_View_Helper_PaginationControl throw new Zend_View_Exception('No view partial provided and no default set'); } - + $partial = self::$_defaultViewPartial; } $pages = get_object_vars($paginator->getPages($scrollingStyle)); - + if ($params !== null) { $pages = array_merge($pages, (array) $params); } @@ -132,10 +132,10 @@ class Zend_View_Helper_PaginationControl if ($partial[1] !== null) { return $this->view->partial($partial[0], $partial[1], $pages); } - + $partial = $partial[0]; } - + return $this->view->partial($partial, $pages); } -} \ No newline at end of file +} diff --git a/library/Zend/View/Helper/Placeholder/Container/Standalone.php b/library/Zend/View/Helper/Placeholder/Container/Standalone.php index d46ef9077feaccdad0c21c885fa5af63aa12a9cd..686deb51402f572310eceb82cbd1fd7dabb0703a 100644 --- a/library/Zend/View/Helper/Placeholder/Container/Standalone.php +++ b/library/Zend/View/Helper/Placeholder/Container/Standalone.php @@ -32,9 +32,9 @@ require_once 'Zend/View/Helper/Abstract.php'; * @subpackage Helper * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - */ + */ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_View_Helper_Abstract implements IteratorAggregate, Countable, ArrayAccess -{ +{ /** * @var Zend_View_Helper_Placeholder_Container_Abstract */ @@ -60,7 +60,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Constructor - * + * * @return void */ public function __construct() @@ -72,7 +72,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Retrieve registry - * + * * @return Zend_View_Helper_Placeholder_Registry */ public function getRegistry() @@ -81,9 +81,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi } /** - * Set registry object - * - * @param Zend_View_Helper_Placeholder_Registry $registry + * Set registry object + * + * @param Zend_View_Helper_Placeholder_Registry $registry * @return Zend_View_Helper_Placeholder_Container_Standalone */ public function setRegistry(Zend_View_Helper_Placeholder_Registry $registry) @@ -94,7 +94,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Set whether or not auto escaping should be used - * + * * @param bool $autoEscape whether or not to auto escape output * @return Zend_View_Helper_Placeholder_Container_Standalone */ @@ -103,7 +103,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi $this->_autoEscape = ($autoEscape) ? true : false; return $this; } - + /** * Return whether autoEscaping is enabled or disabled * @@ -116,8 +116,8 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Escape a string - * - * @param string $string + * + * @param string $string * @return string */ protected function _escape($string) @@ -131,8 +131,8 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Set container on which to operate - * - * @param Zend_View_Helper_Placeholder_Container_Abstract $container + * + * @param Zend_View_Helper_Placeholder_Container_Abstract $container * @return Zend_View_Helper_Placeholder_Container_Standalone */ public function setContainer(Zend_View_Helper_Placeholder_Container_Abstract $container) @@ -143,7 +143,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Retrieve placeholder container - * + * * @return Zend_View_Helper_Placeholder_Container_Abstract */ public function getContainer() @@ -153,9 +153,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Overloading: set property value - * - * @param string $key - * @param mixed $value + * + * @param string $key + * @param mixed $value * @return void */ public function __set($key, $value) @@ -166,8 +166,8 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Overloading: retrieve property - * - * @param string $key + * + * @param string $key * @return mixed */ public function __get($key) @@ -182,8 +182,8 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Overloading: check if property is set - * - * @param string $key + * + * @param string $key * @return bool */ public function __isset($key) @@ -194,8 +194,8 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Overloading: unset property - * - * @param string $key + * + * @param string $key * @return void */ public function __unset($key) @@ -210,9 +210,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi * Overload * * Proxy to container methods - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return mixed */ public function __call($method, $args) @@ -233,7 +233,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * String representation - * + * * @return string */ public function toString() @@ -243,7 +243,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Cast to string representation - * + * * @return string */ public function __toString() @@ -253,10 +253,10 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * Countable - * + * * @return int */ - public function count() + public function count(): int { $container = $this->getContainer(); return count($container); @@ -264,55 +264,55 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi /** * ArrayAccess: offsetExists - * - * @param string|int $offset + * + * @param string|int $offset * @return bool */ - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return $this->getContainer()->offsetExists($offset); } /** * ArrayAccess: offsetGet - * - * @param string|int $offset + * + * @param string|int $offset * @return mixed */ - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->getContainer()->offsetGet($offset); } /** * ArrayAccess: offsetSet - * - * @param string|int $offset - * @param mixed $value + * + * @param string|int $offset + * @param mixed $value * @return void */ - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { - return $this->getContainer()->offsetSet($offset, $value); + $this->getContainer()->offsetSet($offset, $value); } /** * ArrayAccess: offsetUnset - * - * @param string|int $offset + * + * @param string|int $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { - return $this->getContainer()->offsetUnset($offset); + $this->getContainer()->offsetUnset($offset); } /** * IteratorAggregate: get Iterator - * + * * @return Iterator */ - public function getIterator() + public function getIterator(): Traversable { return $this->getContainer()->getIterator(); } diff --git a/tests/AllTests.php b/tests/AllTests.php deleted file mode 100644 index b09bcd61ca17e4944635363c50b13b7168df6c38..0000000000000000000000000000000000000000 --- a/tests/AllTests.php +++ /dev/null @@ -1,66 +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 UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'AllTests::main'); -} - -/** - * Test helper - */ -require_once 'TestHelper.php'; - -/** - * @see Zend_AllTests - */ -require_once 'Zend/AllTests.php'; - -class AllTests -{ - public static function main() - { - $parameters = array(); - - if (TESTS_GENERATE_REPORT && extension_loaded('xdebug')) { - $parameters['reportDirectory'] = TESTS_GENERATE_REPORT_TARGET; - } - - if (defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE') && TESTS_ZEND_LOCALE_FORMAT_SETLOCALE) { - // run all tests in a special locale - setlocale(LC_ALL, TESTS_ZEND_LOCALE_FORMAT_SETLOCALE); - } - - PHPUnit_TextUI_TestRunner::run(self::suite(), $parameters); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework'); - - $suite->addTest(Zend_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'AllTests::main') { - AllTests::main(); -} diff --git a/tests/TestConfiguration.php.dist b/tests/TestConfiguration.php.dist deleted file mode 100644 index 484041f514a23af0ac603e437087b450ca338e37..0000000000000000000000000000000000000000 --- a/tests/TestConfiguration.php.dist +++ /dev/null @@ -1,485 +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 UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestConfiguration.php.dist 10743 2008-08-07 02:24:43Z matthew $ - */ - -/** - * This file defines configuration for running the unit tests for the Zend - * Framework. Some tests have dependencies to PHP extensions or databases - * which may not necessary installed on the target system. For these cases, - * the ability to disable or configure testing is provided below. Tests for - * components which should run universally are always run by the master - * suite and cannot be disabled. - * - * Do not edit this file. Instead, copy this file to TestConfiguration.php, - * and edit the new file. Never commit plaintext passwords to the source - * code repository. - */ - -/** - * Zend_Auth_Adapter_DbTable tests - */ -define('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED', false); -define('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_DATABASE', ':memory:'); - -/** - * Zend_Auth_Adapter_Ldap online tests - * (See also TESTS_ZEND_LDAP_* configuration constants below) - */ -define('TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED', false); - -/** - * Zend_Cache - * - * TESTS_ZEND_CACHE_SQLITE_ENABLED => sqlite extension has to be enabled - * TESTS_ZEND_CACHE_APC_ENABLED => apc extension has to be enabled - * TESTS_ZEND_CACHE_MEMCACHED_ENABLED => memcache extension has to be enabled and - * a memcached server has to be available - * TESTS_ZEND_CACHE_XCACHE_ENABLED => xcache extension has to be enabled - */ -define('TESTS_ZEND_CACHE_SQLITE_ENABLED', false); -define('TESTS_ZEND_CACHE_APC_ENABLED', false); -define('TESTS_ZEND_CACHE_XCACHE_ENABLED', true); -define('TESTS_ZEND_CACHE_XCACHE_USER', null); -define('TESTS_ZEND_CACHE_XCACHE_PASSWORD', null); -define('TESTS_ZEND_CACHE_PLATFORM_ENABLED', false); -define('TESTS_ZEND_CACHE_MEMCACHED_ENABLED', false); -define('TESTS_ZEND_CACHE_MEMCACHED_HOST', '127.0.0.1'); -define('TESTS_ZEND_CACHE_MEMCACHED_PORT', 11211); -define('TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT', true); - -/** - * Zend_Controller - * - * TESTS_ZEND_CONTROLLER_DISPATCHER_OB => test disabling output buffering in - * dispatcher - */ -define('TESTS_ZEND_CONTROLLER_DISPATCHER_OB', false); - -/** - * Zend_Db_Adapter_Pdo_Mysql and Zend_Db_Adapter_Mysqli - * - * There are separate properties to enable tests for the PDO_MYSQL adapter and - * the native Mysqli adapters, but the other properties are shared between the - * two MySQL-related Zend_Db adapters. - */ -define('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME', '127.0.0.1'); -define('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME', null); -define('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD', null); -define('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE', 'test'); -define('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT', 3306); - -/** - * Zend_Db_Adapter_Pdo_Sqlite - * - * Username and password are irrelevant for SQLite. - */ -define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE', ':memory:'); - -/** - * Zend_Db_Adapter_Pdo_Mssql - * - * Note that you need to patch your ntwdblib.dll, the one that - * comes with PHP does not work. See user comments at - * http://us2.php.net/manual/en/ref.mssql.php - */ -define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME', '127.0.0.1'); -define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME', null); -define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD', null); -define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE', 'test'); - -/** - * Zend_Db_Adapter_Pdo_Pgsql - */ -define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME', '127.0.0.1'); -define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME', null); -define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD', null); -define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE', 'postgres'); - -/** - * Zend_Db_Adapter_Oracle and Zend_Db_Adapter_Pdo_Oci - * - * There are separate properties to enable tests for the PDO_OCI adapter and - * the native Oracle adapter, but the other properties are shared between the - * two Oracle-related Zend_Db adapters. - */ -define('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME', '127.0.0.1'); -define('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME', null); -define('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD', null); -define('TESTS_ZEND_DB_ADAPTER_ORACLE_SID', 'xe'); - -/** - * Zend_Db_Adapter_Db2 and Zend_Db_Adapter_Pdo_Ibm - * There are separate properties to enable tests for the PDO_IBM adapter and - * the native DB2 adapter, but the other properties are shared between the - * two related Zend_Db adapters. - */ -define('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED', false); -define('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME', '127.0.0.1'); -define('TESTS_ZEND_DB_ADAPTER_DB2_PORT', 50000); -define('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME', null); -define('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD', null); -define('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE', 'sample'); - -/** - * Zend_Http_Client tests - * - * To enable the dynamic Zend_Http_Client tests, you will need to symbolically - * link or copy the files in tests/Zend/Http/Client/_files to a directory - * under your web server(s) document root and set this constant to point to the - * URL of this directory. - */ -define('TESTS_ZEND_HTTP_CLIENT_BASEURI', false); - -/** - * Zend_Http_Client_Proxy tests - * - * HTTP proxy to be used for testing the Proxy adapter. Set to a string of - * the form 'host:port'. Set to null to skip HTTP proxy tests. - */ -define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY', false); -define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER', ''); -define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS', ''); - -/** - * Zend_Gdata tests - * - * If the ONLINE_ENABLED property is false, only tests that can be executed with - * a mock HTTP client are run. No request is sent to the Google Gdata servers. - * If ONLINE_ENABLED is true, some tests may make requests to the remote - * servers. This does not work if you are running tests on a disconnected - * client host. Also, the tests may show as failures if the Google servers - * cannot be reached or if they do not respond for another reason. - * - * If the CLIENTLOGIN_ENABLED property below is false, the authenticated - * tests are reported Skipped in the test run. Set this property to true - * to enable tests that require ClientLogin authentication. Enter your - * Google login credentials in the EMAIL and PASSWORD properties below. - * - * Edit TestConfiguration.php, not TestConfiguration.php.dist. - * Never commit plaintext passwords to the source code repository. - * - * Note: the GData tests currently require that the TZID env variable - * be set or the timezone otherwise configured. You'll see errors from the - * tests if this is not the case. - */ -define('TESTS_ZEND_GDATA_ONLINE_ENABLED', false); -define('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED', false); - -/* - * The credentials provided here should be only for a TEST account. - * Data for various services in this account may be added to, updated, - * or deleted based upon the actions of these test accounts. - */ -define('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL', 'example@example.com'); -define('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD', 'password'); - -/* - * This is the ID of a blank blog. There is no need to have - * any content in this blog. Also, blogs can only be used - * several times for the purpose of these test cases before - * they must be deleted and recreated. Otherwise, the tests - * will start failing, as posts to Blogger will return a 201 Created - * response even though the entry was not posted to the blog. - * This problem is being investigated. - */ -define('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED', false); -define('TESTS_ZEND_GDATA_BLOG_ID', '1111111111111111111'); - -/* - * This is the key for a spreadsheet with data only in the first row of - * the spreadsheet. The strings 'a1', 'b1', 'c1', 'd1' should be in the - * corresponding cell locations. - */ -define('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED', false); -define('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY', 'o01111111111111111111.1111111111111111111'); -define('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID', 'default'); - -/* - * This indicates that online tests for the Google Calendar API should - * be performed. The default calendar will be used. - */ -define('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED', false); - -/* - * This is the fully-qualified domain name for a domiain hosted using - * Google Apps. This domain must be registered with Google Apps and - * have API access enabled. This should be a TEST domain only. - */ -define('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED', false); -define('TESTS_ZEND_GDATA_GAPPS_DOMAIN', 'example.com.invalid'); -define('TESTS_ZEND_GDATA_GAPPS_EMAIL', 'example@example.com'); -define('TESTS_ZEND_GDATA_GAPPS_PASSWORD', 'password'); - -/* - * This is the ONLINE_ENABLED property for Google Base. - */ -define('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED', false); - -/* - * This indicates that online tests for the YouTube data API should - * be performed. - */ -define('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED', false); - -/* - * This is the username to use for retrieving subscriptions, etc - */ -define('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT', 'zfgdata'); - -/* - * This indicates that online tests for the Google Documents API should - * be performed. - */ -define('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED', false); - -/* - * This indicates that online tests for the GData Photos API should - * be performed. - */ -define('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED', false); - -/** - * Zend_Date tests - * - * If the BCMATH_ENABLED property below is false, all arithmetic - * operations will use ordinary PHP math operators and functions. - * Otherwise, the bcmath functions will be used for unlimited precision. - * - * If the EXTENDED_COVERAGE property below is false, most of the I18N - * unit tests will not be computed... this speeds tests up to 80 minutes - * when doing reports. * - * Edit TestConfiguration.php, not TestConfiguration.php.dist. - */ -define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', true); -define('TESTS_ZEND_I18N_EXTENDED_COVERAGE', true); - -/** - * Zend_Ldap online tests - */ -define('TESTS_ZEND_LDAP_ONLINE_ENABLED', false); - -/* These largely map to the options described in the Zend_Ldap and - * Zend_Auth_Adapter_Ldap documentation. - * - * Example Configuration for Active Directory: - * HOST: dc1.w.net - * USE_START_TLS: true - * USE_SSL: false - * USERNAME: CN=User 1,CN=Users,DC=w,DC=net - * PRINCIPAL_NAME: user1@w.net - * LDAP_PASSWORD: pass1 - * BASE_DN: CN=Users,DC=w,DC=net - * DOMAIN_NAME: w.net - * ACCOUNT_DOMAIN_NAME_SHORT: W - * ALT_USERNAME: user2 - * ALT_DN: CN=User 2,CN=Users,DC=w,DC=net - * ALT_PASSWORD: pass2 - * - * Example Configuration for OpenLDAP - * HOST: s0.foo.net - * USERNAME: CN=user1,DC=foo,DC=net - * PRINCIPAL_NAME: user1@foo.net - * LDAP_PASSWORD: pass1 - * BIND_REQUIRES_DN: true - * BASE_DN: OU=Sales,DC=w,DC=net - * DOMAIN_NAME: foo.net - * ACCOUNT_DOMAIN_NAME_SHORT: FOO - * ALT_USERNAME: abaker - * ALT_DN: CN=Alice Baker,OU=Sales,DC=foo,DC=net - * ALT_PASSWORD: apass - */ -define('TESTS_ZEND_LDAP_HOST', 'localhost'); -//define('TESTS_ZEND_LDAP_PORT', 389); -define('TESTS_ZEND_LDAP_USE_START_TLS', true); -//define('TESTS_ZEND_LDAP_USE_SSL', false); -define('TESTS_ZEND_LDAP_USERNAME', 'CN=someUser,DC=example,DC=com'); -define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', 'someUser@example.com'); -define('TESTS_ZEND_LDAP_PASSWORD', null); -define('TESTS_ZEND_LDAP_BIND_REQUIRES_DN', true); -define('TESTS_ZEND_LDAP_BASE_DN', 'OU=Sales,DC=example,DC=com'); -//define('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT', '(&(objectClass=posixAccount)(uid=%s))'); -define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME', 'example.com'); -define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT', 'EXAMPLE'); -define('TESTS_ZEND_LDAP_ALT_USERNAME', 'anotherUser'); -define('TESTS_ZEND_LDAP_ALT_DN', 'CN=Another User,OU=Sales,DC=example,DC=com'); -define('TESTS_ZEND_LDAP_ALT_PASSWORD', null); - -/** - * Zend_Locale tests - * - * If the TESTS_ZEND_LOCALE_FORMAT_SETLOCALE property below is a valid, - * locally recognized locale (try "locale -a"), then all tests in - * tests/Zend/Locale/ test suites will execute *after* - * setlocale(LC_ALL, TESTS_ZEND_LOCALE_FORMAT_SETLOCALE); - * Primarily, this switches certain PHP functions to emit "localized" output, - * including the built-in "to string" for integer and float conversions. - * Thus, a locale of 'fr_FR' yields number-to-string conversions in a - * localized form with the decimal place separator chosen via: - * setlocale(LC_ALL, 'fr_FR@euro'); - */ -//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr'); -//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr_FR@euro'); -define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', false); - -/** - * Zend_Mail_Storage tests - * - * TESTS_ZEND_MAIL_SERVER_TESTDIR and TESTS_ZEND_MAIL_SERVER_FORMAT are used for POP3 and IMAP tests. - * TESTS_ZEND_MAIL_SERVER_FORMAT is the format your test mail server uses: 'mbox' or 'maildir'. The mail - * storage for the user specified in your POP3 or IMAP tests should be TESTS_ZEND_MAIL_SERVER_TESTDIR. Be - * careful: it's cleared before copying the files. If you want to copy the files manually set the dir - * to null (or anything == null). - * - * TESTS_ZEND_MAIL_TEMPDIR is used for testing write operations in local storages. If not set (== null) - * tempnam() is used. - */ -define('TESTS_ZEND_MAIL_SERVER_TESTDIR', null); -define('TESTS_ZEND_MAIL_SERVER_FORMAT', 'mbox'); -define('TESTS_ZEND_MAIL_TEMPDIR', null); - -/** - * Zend_Mail_Storage_Pop3 / Zend_Mail_Transport_Pop3 - * - * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail - * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR - */ -define('TESTS_ZEND_MAIL_POP3_ENABLED', false); -define('TESTS_ZEND_MAIL_POP3_HOST', 'localhost'); -define('TESTS_ZEND_MAIL_POP3_USER', 'test'); -define('TESTS_ZEND_MAIL_POP3_PASSWORD', ''); -// test SSL connections if enabled in your test server -define('TESTS_ZEND_MAIL_POP3_SSL', true); -define('TESTS_ZEND_MAIL_POP3_TLS', true); -// WRONG_PORT should be an existing server port, -// INVALID_PORT should be a non existing (each on defined host) -define('TESTS_ZEND_MAIL_POP3_WRONG_PORT', 80); -define('TESTS_ZEND_MAIL_POP3_INVALID_PORT', 3141); - -/** - * Zend_Mail_Storage_Imap / Zend_Mail_Transport_Imap - * - * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail - * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR - */ -define('TESTS_ZEND_MAIL_IMAP_ENABLED', false); -define('TESTS_ZEND_MAIL_IMAP_HOST', 'localhost'); -define('TESTS_ZEND_MAIL_IMAP_USER', 'test'); -define('TESTS_ZEND_MAIL_IMAP_PASSWORD', ''); -// test SSL connections if enabled in your test server -define('TESTS_ZEND_MAIL_IMAP_SSL', true); -define('TESTS_ZEND_MAIL_IMAP_TLS', true); -// WRONG_PORT should be an existing server port, -// INVALID_PORT should be a non-existing (each on defined host) -define('TESTS_ZEND_MAIL_IMAP_WRONG_PORT', 80); -define('TESTS_ZEND_MAIL_IMAP_INVALID_PORT', 3141); - - -/** - * Zend_Mail_Storage_Maildir test - * - * Before enabling this test you have to unpack messages.tar in - * Zend/Mail/_files/test.maildir/cur/ and remove the tar for this test to work. - * That's because the messages files have a colon in the filename and that's a - * forbidden character on Windows. - */ -define('TESTS_ZEND_MAIL_MAILDIR_ENABLED', false); - -/** - * Zend_Mail_Transport_Smtp - * - * @todo TO be implemented - */ -define('TESTS_ZEND_MAIL_SMTP_ENABLED', false); -define('TESTS_ZEND_MAIL_SMTP_HOST', 'localhost'); -define('TESTS_ZEND_MAIL_SMTP_PORT', 25); -define('TESTS_ZEND_MAIL_SMTP_USER', 'testuser'); -define('TESTS_ZEND_MAIL_SMTP_PASSWORD', 'testpassword'); -define('TESTS_ZEND_MAIL_SMTP_AUTH', false); -// AUTH can be set to false or a string of AUTH method (e.g. LOGIN, PLAIN, CRAMMD5 or DIGESTMD5) - -/** - * Zend_Service_Amazon online tests - */ -define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED', false); -define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID', 'Enter AWSAccessKeyId here'); - -/** - * Zend_Service_Delicious tests - */ -define('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED', false); - -/** - * Zend_Service_Flickr online tests - */ -define('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED', false); -define('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY', 'Enter API key here'); - -/** - * Zend_Service_Simpy tests - */ -define('TESTS_ZEND_SERVICE_SIMPY_ENABLED', false); - -/** - * Zend_Service_SlideShare tests - */ -define('TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME', ''); -define('TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD', ''); -define('TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET', ''); -define('TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY', ''); - -// The slide show ID to retrieve during tests -define('TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID', 0); - -// The tag to retrieve during tests -define('TESTS_ZEND_SERVICE_SLIDESHARE_TAG', 'zend'); - -// The group to retrieve during tests -define('TESTS_ZEND_SERVICE_SLIDESHARE_GROUP', ''); - -/** - * Zend_Service_Yahoo online tests - */ -define('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED', false); -define('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID', 'Enter APPID here'); - -/** - * Zend_Service_ReCaptcha tests - */ -define('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED', false); -define('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED', false); -define('TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY', 'public key'); -define('TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY', 'private key'); -define('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY', 'public mailhide key'); -define('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY', 'private mailhide key'); - -/** - * PHPUnit Code Coverage / Test Report - */ -define('TESTS_GENERATE_REPORT', false); -define('TESTS_GENERATE_REPORT_TARGET', '/path/to/target'); diff --git a/tests/TestHelper.php b/tests/TestHelper.php deleted file mode 100644 index 2ea4cb96dad8a8766f81098a14425290ab99a808..0000000000000000000000000000000000000000 --- a/tests/TestHelper.php +++ /dev/null @@ -1,95 +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 UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestHelper.php 9225 2008-04-14 18:44:43Z darby $ - */ - -/* - * Start output buffering - */ -ob_start(); - -/* - * Include PHPUnit dependencies - */ -// require_once 'PHPUnit/Framework.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/Runner/Version.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; -// require_once 'PHPUnit/Util/Filter.php'; - -/* - * Set error reporting to the level to which Zend Framework code must comply. - */ -error_reporting( E_ALL | E_STRICT ); - -/* - * Determine the root, library, and tests directories of the framework - * distribution. - */ -$zfRoot = dirname(__FILE__) . '/..'; -$zfCoreLibrary = "$zfRoot/library"; -$zfCoreTests = "$zfRoot/tests"; - -/* - * Omit from code coverage reports the contents of the tests directory - */ -foreach (array('php', 'phtml', 'csv') as $suffix) { - PHPUnit_Util_Filter::addDirectoryToFilter($zfCoreTests, ".$suffix"); -} - -/* - * Prepend the Zend Framework library/ and tests/ directories to the - * include_path. This allows the tests to run out of the box and helps prevent - * loading other copies of the framework code and tests that would supersede - * this copy. - */ -$path = array( - $zfCoreLibrary, - $zfCoreTests, - get_include_path() - ); -set_include_path(implode(PATH_SEPARATOR, $path)); - -/* - * Load the user-defined test configuration file, if it exists; otherwise, load - * the default configuration. - */ -if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) { - require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php'; -} else { - require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist'; -} - -/* - * Add Zend Framework library/ directory to the PHPUnit code coverage - * whitelist. This has the effect that only production code source files appear - * in the code coverage report and that all production code source files, even - * those that are not covered by a test yet, are processed. - */ -if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true && - version_compare(PHPUnit_Runner_Version::id(), '3.1.6', '>=')) { - PHPUnit_Util_Filter::addDirectoryToWhitelist($zfCoreLibrary); -} - -/* - * Unset global variables that are no longer needed. - */ -unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path); diff --git a/tests/Zend/AclTest.php b/tests/Zend/AclTest.php deleted file mode 100644 index f1d8e2c9e67278eec1ea5596657f6610ffddc3d9..0000000000000000000000000000000000000000 --- a/tests/Zend/AclTest.php +++ /dev/null @@ -1,1131 +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_Acl - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AclTest.php 9417 2008-05-08 16:28:31Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * Zend_Acl - */ -require_once 'Zend/Acl.php'; - -/** - * Zend_Acl_Resource - */ -require_once 'Zend/Acl/Resource.php'; - -/** - * Zend_Acl_Role - */ -require_once 'Zend/Acl/Role.php'; - -/** - * @category Zend - * @package Zend_Acl - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_AclTest extends PHPUnit_Framework_TestCase -{ - /** - * ACL object for each test method - * - * @var Zend_Acl - */ - protected $_acl; - - /** - * Instantiates a new ACL object and creates internal reference to it for each test method - * - * @return void - */ - public function setUp() - { - $this->_acl = new Zend_Acl(); - } - - /** - * Ensures that basic addition and retrieval of a single Role works - * - * @return void - */ - public function testRoleRegistryAddAndGetOne() - { - $roleGuest = new Zend_Acl_Role('guest'); - - $role = $this->_acl->addRole($roleGuest) - ->getRole($roleGuest->getRoleId()); - $this->assertTrue($roleGuest === $role); - $role = $this->_acl->getRole($roleGuest); - $this->assertTrue($roleGuest === $role); - } - - /** - * Ensures that basic removal of a single Role works - * - * @return void - */ - public function testRoleRegistryRemoveOne() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->removeRole($roleGuest); - $this->assertFalse($this->_acl->hasRole($roleGuest)); - } - - /** - * Ensures that an exception is thrown when a non-existent Role is specified for removal - * - * @return void - */ - public function testRoleRegistryRemoveOneNonExistent() - { - try { - $this->_acl->removeRole('nonexistent'); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon removing a non-existent Role'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Ensures that removal of all Roles works - * - * @return void - */ - public function testRoleRegistryRemoveAll() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->removeRoleAll(); - $this->assertFalse($this->_acl->hasRole($roleGuest)); - } - - /** - * Ensures that an exception is thrown when a non-existent Role is specified as a parent upon Role addition - * - * @return void - */ - public function testRoleRegistryAddInheritsNonExistent() - { - try { - $this->_acl->addRole(new Zend_Acl_Role('guest'), 'nonexistent'); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - } - - /** - * Ensures that an exception is thrown when a non-existent Role is specified to each parameter of inherits() - * - * @return void - */ - public function testRoleRegistryInheritsNonExistent() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest); - try { - $this->_acl->inheritsRole('nonexistent', $roleGuest); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent child Role'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - try { - $this->_acl->inheritsRole($roleGuest, 'nonexistent'); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent Role'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Tests basic Role inheritance - * - * @return void - */ - public function testRoleRegistryInherits() - { - $roleGuest = new Zend_Acl_Role('guest'); - $roleMember = new Zend_Acl_Role('member'); - $roleEditor = new Zend_Acl_Role('editor'); - $roleRegistry = new Zend_Acl_Role_Registry(); - $roleRegistry->add($roleGuest) - ->add($roleMember, $roleGuest->getRoleId()) - ->add($roleEditor, $roleMember); - $this->assertTrue(0 === count($roleRegistry->getParents($roleGuest))); - $roleMemberParents = $roleRegistry->getParents($roleMember); - $this->assertTrue(1 === count($roleMemberParents)); - $this->assertTrue(isset($roleMemberParents['guest'])); - $roleEditorParents = $roleRegistry->getParents($roleEditor); - $this->assertTrue(1 === count($roleEditorParents)); - $this->assertTrue(isset($roleEditorParents['member'])); - $this->assertTrue($roleRegistry->inherits($roleMember, $roleGuest, true)); - $this->assertTrue($roleRegistry->inherits($roleEditor, $roleMember, true)); - $this->assertTrue($roleRegistry->inherits($roleEditor, $roleGuest)); - $this->assertFalse($roleRegistry->inherits($roleGuest, $roleMember)); - $this->assertFalse($roleRegistry->inherits($roleMember, $roleEditor)); - $this->assertFalse($roleRegistry->inherits($roleGuest, $roleEditor)); - $roleRegistry->remove($roleMember); - $this->assertTrue(0 === count($roleRegistry->getParents($roleEditor))); - $this->assertFalse($roleRegistry->inherits($roleEditor, $roleGuest)); - } - - /** - * Tests basic Role multiple inheritance - * - * @return void - */ - public function testRoleRegistryInheritsMultiple() - { - $roleParent1 = new Zend_Acl_Role('parent1'); - $roleParent2 = new Zend_Acl_Role('parent2'); - $roleChild = new Zend_Acl_Role('child'); - $roleRegistry = new Zend_Acl_Role_Registry(); - $roleRegistry->add($roleParent1) - ->add($roleParent2) - ->add($roleChild, array($roleParent1, $roleParent2)); - $roleChildParents = $roleRegistry->getParents($roleChild); - $this->assertTrue(2 === count($roleChildParents)); - $i = 1; - foreach ($roleChildParents as $roleParentId => $roleParent) { - $this->assertTrue("parent$i" === $roleParentId); - $i++; - } - $this->assertTrue($roleRegistry->inherits($roleChild, $roleParent1)); - $this->assertTrue($roleRegistry->inherits($roleChild, $roleParent2)); - $roleRegistry->remove($roleParent1); - $roleChildParents = $roleRegistry->getParents($roleChild); - $this->assertTrue(1 === count($roleChildParents)); - $this->assertTrue(isset($roleChildParents['parent2'])); - $this->assertTrue($roleRegistry->inherits($roleChild, $roleParent2)); - } - - /** - * Ensures that the same Role cannot be registered more than once to the registry - * - * @return void - */ - public function testRoleRegistryDuplicate() - { - $roleGuest = new Zend_Acl_Role('guest'); - $roleRegistry = new Zend_Acl_Role_Registry(); - try { - $roleRegistry->add($roleGuest) - ->add($roleGuest); - $this->fail('Expected exception not thrown upon adding same Role twice'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('already exists', $e->getMessage()); - } - } - - /** - * Ensures that two Roles having the same ID cannot be registered - * - * @return void - */ - public function testRoleRegistryDuplicateId() - { - $roleGuest1 = new Zend_Acl_Role('guest'); - $roleGuest2 = new Zend_Acl_Role('guest'); - $roleRegistry = new Zend_Acl_Role_Registry(); - try { - $roleRegistry->add($roleGuest1) - ->add($roleGuest2); - $this->fail('Expected exception not thrown upon adding two Roles with same ID'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('already exists', $e->getMessage()); - } - } - - /** - * Ensures that basic addition and retrieval of a single Resource works - * - * @return void - */ - public function testResourceAddAndGetOne() - { - $resourceArea = new Zend_Acl_Resource('area'); - $resource = $this->_acl->add($resourceArea) - ->get($resourceArea->getResourceId()); - $this->assertTrue($resourceArea === $resource); - $resource = $this->_acl->get($resourceArea); - $this->assertTrue($resourceArea === $resource); - } - - /** - * Ensures that basic removal of a single Resource works - * - * @return void - */ - public function testResourceRemoveOne() - { - $resourceArea = new Zend_Acl_Resource('area'); - $this->_acl->add($resourceArea) - ->remove($resourceArea); - $this->assertFalse($this->_acl->has($resourceArea)); - } - - /** - * Ensures that an exception is thrown when a non-existent Resource is specified for removal - * - * @return void - */ - public function testResourceRemoveOneNonExistent() - { - try { - $this->_acl->remove('nonexistent'); - $this->fail('Expected Zend_Acl_Exception not thrown upon removing a non-existent Resource'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Ensures that removal of all Resources works - * - * @return void - */ - public function testResourceRemoveAll() - { - $resourceArea = new Zend_Acl_Resource('area'); - $this->_acl->add($resourceArea) - ->removeAll(); - $this->assertFalse($this->_acl->has($resourceArea)); - } - - /** - * Ensures that an exception is thrown when a non-existent Resource is specified as a parent upon Resource addition - * - * @return void - */ - public function testResourceAddInheritsNonExistent() - { - try { - $this->_acl->add(new Zend_Acl_Resource('area'), 'nonexistent'); - $this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent parent'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - } - - /** - * Ensures that an exception is thrown when a non-existent Resource is specified to each parameter of inherits() - * - * @return void - */ - public function testResourceInheritsNonExistent() - { - $resourceArea = new Zend_Acl_Resource('area'); - $this->_acl->add($resourceArea); - try { - $this->_acl->inherits('nonexistent', $resourceArea); - $this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent child Resource'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - try { - $this->_acl->inherits($resourceArea, 'nonexistent'); - $this->fail('Expected Zend_Acl_Exception not thrown upon specifying a non-existent parent Resource'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Tests basic Resource inheritance - * - * @return void - */ - public function testResourceInherits() - { - $resourceCity = new Zend_Acl_Resource('city'); - $resourceBuilding = new Zend_Acl_Resource('building'); - $resourceRoom = new Zend_Acl_Resource('room'); - $this->_acl->add($resourceCity) - ->add($resourceBuilding, $resourceCity->getResourceId()) - ->add($resourceRoom, $resourceBuilding); - $this->assertTrue($this->_acl->inherits($resourceBuilding, $resourceCity, true)); - $this->assertTrue($this->_acl->inherits($resourceRoom, $resourceBuilding, true)); - $this->assertTrue($this->_acl->inherits($resourceRoom, $resourceCity)); - $this->assertFalse($this->_acl->inherits($resourceCity, $resourceBuilding)); - $this->assertFalse($this->_acl->inherits($resourceBuilding, $resourceRoom)); - $this->assertFalse($this->_acl->inherits($resourceCity, $resourceRoom)); - $this->_acl->remove($resourceBuilding); - $this->assertFalse($this->_acl->has($resourceRoom)); - } - - /** - * Ensures that the same Resource cannot be added more than once - * - * @return void - */ - public function testResourceDuplicate() - { - try { - $resourceArea = new Zend_Acl_Resource('area'); - $this->_acl->add($resourceArea) - ->add($resourceArea); - $this->fail('Expected exception not thrown upon adding same Resource twice'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('already exists', $e->getMessage()); - } - } - - /** - * Ensures that two Resources having the same ID cannot be added - * - * @return void - */ - public function testResourceDuplicateId() - { - try { - $resourceArea1 = new Zend_Acl_Resource('area'); - $resourceArea2 = new Zend_Acl_Resource('area'); - $this->_acl->add($resourceArea1) - ->add($resourceArea2); - $this->fail('Expected exception not thrown upon adding two Resources with same ID'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('already exists', $e->getMessage()); - } - } - - /** - * Ensures that an exception is thrown when a non-existent Role and Resource parameters are specified to isAllowed() - * - * @return void - */ - public function testIsAllowedNonExistent() - { - try { - $this->_acl->isAllowed('nonexistent'); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon non-existent Role'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - try { - $this->_acl->isAllowed(null, 'nonexistent'); - $this->fail('Expected Zend_Acl_Exception not thrown upon non-existent Resource'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Ensures that by default, Zend_Acl denies access to everything by all - * - * @return void - */ - public function testDefaultDeny() - { - $this->assertFalse($this->_acl->isAllowed()); - } - - /** - * Ensures that the default rule obeys its assertion - * - * @return void - */ - public function testDefaultAssert() - { - $this->_acl->deny(null, null, null, new Zend_AclTest_AssertFalse()); - $this->assertTrue($this->_acl->isAllowed()); - $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege')); - } - - /** - * Ensures that ACL-wide rules (all Roles, Resources, and privileges) work properly - * - * @return void - */ - public function testDefaultRuleSet() - { - $this->_acl->allow(); - $this->assertTrue($this->_acl->isAllowed()); - $this->_acl->deny(); - $this->assertFalse($this->_acl->isAllowed()); - } - - /** - * Ensures that by default, Zend_Acl denies access to a privilege on anything by all - * - * @return void - */ - public function testDefaultPrivilegeDeny() - { - $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege')); - } - - /** - * Ensures that ACL-wide rules apply to privileges - * - * @return void - */ - public function testDefaultRuleSetPrivilege() - { - $this->_acl->allow(); - $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege')); - $this->_acl->deny(); - $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege')); - } - - /** - * Ensures that a privilege allowed for all Roles upon all Resources works properly - * - * @return void - */ - public function testPrivilegeAllow() - { - $this->_acl->allow(null, null, 'somePrivilege'); - $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege')); - } - - /** - * Ensures that a privilege denied for all Roles upon all Resources works properly - * - * @return void - */ - public function testPrivilegeDeny() - { - $this->_acl->allow(); - $this->_acl->deny(null, null, 'somePrivilege'); - $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege')); - } - - /** - * Ensures that multiple privileges work properly - * - * @return void - */ - public function testPrivileges() - { - $this->_acl->allow(null, null, array('p1', 'p2', 'p3')); - $this->assertTrue($this->_acl->isAllowed(null, null, 'p1')); - $this->assertTrue($this->_acl->isAllowed(null, null, 'p2')); - $this->assertTrue($this->_acl->isAllowed(null, null, 'p3')); - $this->assertFalse($this->_acl->isAllowed(null, null, 'p4')); - $this->_acl->deny(null, null, 'p1'); - $this->assertFalse($this->_acl->isAllowed(null, null, 'p1')); - $this->_acl->deny(null, null, array('p2', 'p3')); - $this->assertFalse($this->_acl->isAllowed(null, null, 'p2')); - $this->assertFalse($this->_acl->isAllowed(null, null, 'p3')); - } - - /** - * Ensures that assertions on privileges work properly - * - * @return void - */ - public function testPrivilegeAssert() - { - $this->_acl->allow(null, null, 'somePrivilege', new Zend_AclTest_AssertTrue()); - $this->assertTrue($this->_acl->isAllowed(null, null, 'somePrivilege')); - $this->_acl->allow(null, null, 'somePrivilege', new Zend_AclTest_AssertFalse()); - $this->assertFalse($this->_acl->isAllowed(null, null, 'somePrivilege')); - } - - /** - * Ensures that by default, Zend_Acl denies access to everything for a particular Role - * - * @return void - */ - public function testRoleDefaultDeny() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest); - $this->assertFalse($this->_acl->isAllowed($roleGuest)); - } - - /** - * Ensures that ACL-wide rules (all Resources and privileges) work properly for a particular Role - * - * @return void - */ - public function testRoleDefaultRuleSet() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->allow($roleGuest); - $this->assertTrue($this->_acl->isAllowed($roleGuest)); - $this->_acl->deny($roleGuest); - $this->assertFalse($this->_acl->isAllowed($roleGuest)); - } - - /** - * Ensures that by default, Zend_Acl denies access to a privilege on anything for a particular Role - * - * @return void - */ - public function testRoleDefaultPrivilegeDeny() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - } - - /** - * Ensures that ACL-wide rules apply to privileges for a particular Role - * - * @return void - */ - public function testRoleDefaultRuleSetPrivilege() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->allow($roleGuest); - $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - $this->_acl->deny($roleGuest); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - } - - /** - * Ensures that a privilege allowed for a particular Role upon all Resources works properly - * - * @return void - */ - public function testRolePrivilegeAllow() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->allow($roleGuest, null, 'somePrivilege'); - $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - } - - /** - * Ensures that a privilege denied for a particular Role upon all Resources works properly - * - * @return void - */ - public function testRolePrivilegeDeny() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->allow($roleGuest) - ->deny($roleGuest, null, 'somePrivilege'); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - } - - /** - * Ensures that multiple privileges work properly for a particular Role - * - * @return void - */ - public function testRolePrivileges() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->allow($roleGuest, null, array('p1', 'p2', 'p3')); - $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'p1')); - $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'p2')); - $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'p3')); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p4')); - $this->_acl->deny($roleGuest, null, 'p1'); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p1')); - $this->_acl->deny($roleGuest, null, array('p2', 'p3')); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p2')); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'p3')); - } - - /** - * Ensures that assertions on privileges work properly for a particular Role - * - * @return void - */ - public function testRolePrivilegeAssert() - { - $roleGuest = new Zend_Acl_Role('guest'); - $this->_acl->addRole($roleGuest) - ->allow($roleGuest, null, 'somePrivilege', new Zend_AclTest_AssertTrue()); - $this->assertTrue($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - $this->_acl->allow($roleGuest, null, 'somePrivilege', new Zend_AclTest_AssertFalse()); - $this->assertFalse($this->_acl->isAllowed($roleGuest, null, 'somePrivilege')); - } - - /** - * Ensures that removing the default deny rule results in default deny rule - * - * @return void - */ - public function testRemoveDefaultDeny() - { - $this->assertFalse($this->_acl->isAllowed()); - $this->_acl->removeDeny(); - $this->assertFalse($this->_acl->isAllowed()); - } - - /** - * Ensures that removing the default deny rule results in assertion method being removed - * - * @return void - */ - public function testRemoveDefaultDenyAssert() - { - $this->_acl->deny(null, null, null, new Zend_AclTest_AssertFalse()); - $this->assertTrue($this->_acl->isAllowed()); - $this->_acl->removeDeny(); - $this->assertFalse($this->_acl->isAllowed()); - } - - /** - * Ensures that removing the default allow rule results in default deny rule being assigned - * - * @return void - */ - public function testRemoveDefaultAllow() - { - $this->_acl->allow(); - $this->assertTrue($this->_acl->isAllowed()); - $this->_acl->removeAllow(); - $this->assertFalse($this->_acl->isAllowed()); - } - - /** - * Ensures that removing non-existent default allow rule does nothing - * - * @return void - */ - public function testRemoveDefaultAllowNonExistent() - { - $this->_acl->removeAllow(); - $this->assertFalse($this->_acl->isAllowed()); - } - - /** - * Ensures that removing non-existent default deny rule does nothing - * - * @return void - */ - public function testRemoveDefaultDenyNonExistent() - { - $this->_acl->allow() - ->removeDeny(); - $this->assertTrue($this->_acl->isAllowed()); - } - - /** - * Ensures that for a particular Role, a deny rule on a specific Resource is honored before an allow rule - * on the entire ACL - * - * @return void - */ - public function testRoleDefaultAllowRuleWithResourceDenyRule() - { - $this->_acl->addRole(new Zend_Acl_Role('guest')) - ->addRole(new Zend_Acl_Role('staff'), 'guest') - ->add(new Zend_Acl_Resource('area1')) - ->add(new Zend_Acl_Resource('area2')) - ->deny() - ->allow('staff') - ->deny('staff', array('area1', 'area2')); - $this->assertFalse($this->_acl->isAllowed('staff', 'area1')); - } - - /** - * Ensures that for a particular Role, a deny rule on a specific privilege is honored before an allow - * rule on the entire ACL - * - * @return void - */ - public function testRoleDefaultAllowRuleWithPrivilegeDenyRule() - { - $this->_acl->addRole(new Zend_Acl_Role('guest')) - ->addRole(new Zend_Acl_Role('staff'), 'guest') - ->deny() - ->allow('staff') - ->deny('staff', null, array('privilege1', 'privilege2')); - $this->assertFalse($this->_acl->isAllowed('staff', null, 'privilege1')); - } - - /** - * Ensure that basic rule removal works - * - * @return void - */ - public function testRulesRemove() - { - $this->_acl->allow(null, null, array('privilege1', 'privilege2')); - $this->assertFalse($this->_acl->isAllowed()); - $this->assertTrue($this->_acl->isAllowed(null, null, 'privilege1')); - $this->assertTrue($this->_acl->isAllowed(null, null, 'privilege2')); - $this->_acl->removeAllow(null, null, 'privilege1'); - $this->assertFalse($this->_acl->isAllowed(null, null, 'privilege1')); - $this->assertTrue($this->_acl->isAllowed(null, null, 'privilege2')); - } - - /** - * Ensures that removal of a Role results in its rules being removed - * - * @return void - */ - public function testRuleRoleRemove() - { - $this->_acl->addRole(new Zend_Acl_Role('guest')) - ->allow('guest'); - $this->assertTrue($this->_acl->isAllowed('guest')); - $this->_acl->removeRole('guest'); - try { - $this->_acl->isAllowed('guest'); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon isAllowed() on non-existent Role'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - $this->_acl->addRole(new Zend_Acl_Role('guest')); - $this->assertFalse($this->_acl->isAllowed('guest')); - } - - /** - * Ensures that removal of all Roles results in Role-specific rules being removed - * - * @return void - */ - public function testRuleRoleRemoveAll() - { - $this->_acl->addRole(new Zend_Acl_Role('guest')) - ->allow('guest'); - $this->assertTrue($this->_acl->isAllowed('guest')); - $this->_acl->removeRoleAll(); - try { - $this->_acl->isAllowed('guest'); - $this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon isAllowed() on non-existent Role'); - } catch (Zend_Acl_Role_Registry_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - $this->_acl->addRole(new Zend_Acl_Role('guest')); - $this->assertFalse($this->_acl->isAllowed('guest')); - } - - /** - * Ensures that removal of a Resource results in its rules being removed - * - * @return void - */ - public function testRulesResourceRemove() - { - $this->_acl->add(new Zend_Acl_Resource('area')) - ->allow(null, 'area'); - $this->assertTrue($this->_acl->isAllowed(null, 'area')); - $this->_acl->remove('area'); - try { - $this->_acl->isAllowed(null, 'area'); - $this->fail('Expected Zend_Acl_Exception not thrown upon isAllowed() on non-existent Resource'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - $this->_acl->add(new Zend_Acl_Resource('area')); - $this->assertFalse($this->_acl->isAllowed(null, 'area')); - } - - /** - * Ensures that removal of all Resources results in Resource-specific rules being removed - * - * @return void - */ - public function testRulesResourceRemoveAll() - { - $this->_acl->add(new Zend_Acl_Resource('area')) - ->allow(null, 'area'); - $this->assertTrue($this->_acl->isAllowed(null, 'area')); - $this->_acl->removeAll(); - try { - $this->_acl->isAllowed(null, 'area'); - $this->fail('Expected Zend_Acl_Exception not thrown upon isAllowed() on non-existent Resource'); - } catch (Zend_Acl_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - $this->_acl->add(new Zend_Acl_Resource('area')); - $this->assertFalse($this->_acl->isAllowed(null, 'area')); - } - - /** - * Ensures that an example for a content management system is operable - * - * @return void - */ - public function testCMSExample() - { - // Add some roles to the Role registry - $this->_acl->addRole(new Zend_Acl_Role('guest')) - ->addRole(new Zend_Acl_Role('staff'), 'guest') // staff inherits permissions from guest - ->addRole(new Zend_Acl_Role('editor'), 'staff') // editor inherits permissions from staff - ->addRole(new Zend_Acl_Role('administrator')); - - // Guest may only view content - $this->_acl->allow('guest', null, 'view'); - - // Staff inherits view privilege from guest, but also needs additional privileges - $this->_acl->allow('staff', null, array('edit', 'submit', 'revise')); - - // Editor inherits view, edit, submit, and revise privileges, but also needs additional privileges - $this->_acl->allow('editor', null, array('publish', 'archive', 'delete')); - - // Administrator inherits nothing but is allowed all privileges - $this->_acl->allow('administrator'); - - // Access control checks based on above permission sets - - $this->assertTrue($this->_acl->isAllowed('guest', null, 'view')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'edit')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'submit')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'revise')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'publish')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'archive')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'delete')); - $this->assertFalse($this->_acl->isAllowed('guest', null, 'unknown')); - $this->assertFalse($this->_acl->isAllowed('guest')); - - $this->assertTrue($this->_acl->isAllowed('staff', null, 'view')); - $this->assertTrue($this->_acl->isAllowed('staff', null, 'edit')); - $this->assertTrue($this->_acl->isAllowed('staff', null, 'submit')); - $this->assertTrue($this->_acl->isAllowed('staff', null, 'revise')); - $this->assertFalse($this->_acl->isAllowed('staff', null, 'publish')); - $this->assertFalse($this->_acl->isAllowed('staff', null, 'archive')); - $this->assertFalse($this->_acl->isAllowed('staff', null, 'delete')); - $this->assertFalse($this->_acl->isAllowed('staff', null, 'unknown')); - $this->assertFalse($this->_acl->isAllowed('staff')); - - $this->assertTrue($this->_acl->isAllowed('editor', null, 'view')); - $this->assertTrue($this->_acl->isAllowed('editor', null, 'edit')); - $this->assertTrue($this->_acl->isAllowed('editor', null, 'submit')); - $this->assertTrue($this->_acl->isAllowed('editor', null, 'revise')); - $this->assertTrue($this->_acl->isAllowed('editor', null, 'publish')); - $this->assertTrue($this->_acl->isAllowed('editor', null, 'archive')); - $this->assertTrue($this->_acl->isAllowed('editor', null, 'delete')); - $this->assertFalse($this->_acl->isAllowed('editor', null, 'unknown')); - $this->assertFalse($this->_acl->isAllowed('editor')); - - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'view')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'edit')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'submit')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'revise')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'publish')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'archive')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'delete')); - $this->assertTrue($this->_acl->isAllowed('administrator', null, 'unknown')); - $this->assertTrue($this->_acl->isAllowed('administrator')); - - // Some checks on specific areas, which inherit access controls from the root ACL node - $this->_acl->add(new Zend_Acl_Resource('newsletter')) - ->add(new Zend_Acl_Resource('pending'), 'newsletter') - ->add(new Zend_Acl_Resource('gallery')) - ->add(new Zend_Acl_Resource('profiles', 'gallery')) - ->add(new Zend_Acl_Resource('config')) - ->add(new Zend_Acl_Resource('hosts'), 'config'); - $this->assertTrue($this->_acl->isAllowed('guest', 'pending', 'view')); - $this->assertTrue($this->_acl->isAllowed('staff', 'profiles', 'revise')); - $this->assertTrue($this->_acl->isAllowed('staff', 'pending', 'view')); - $this->assertTrue($this->_acl->isAllowed('staff', 'pending', 'edit')); - $this->assertFalse($this->_acl->isAllowed('staff', 'pending', 'publish')); - $this->assertFalse($this->_acl->isAllowed('staff', 'pending')); - $this->assertFalse($this->_acl->isAllowed('editor', 'hosts', 'unknown')); - $this->assertTrue($this->_acl->isAllowed('administrator', 'pending')); - - // Add a new group, marketing, which bases its permissions on staff - $this->_acl->addRole(new Zend_Acl_Role('marketing'), 'staff'); - - // Refine the privilege sets for more specific needs - - // Allow marketing to publish and archive newsletters - $this->_acl->allow('marketing', 'newsletter', array('publish', 'archive')); - - // Allow marketing to publish and archive latest news - $this->_acl->add(new Zend_Acl_Resource('news')) - ->add(new Zend_Acl_Resource('latest'), 'news'); - $this->_acl->allow('marketing', 'latest', array('publish', 'archive')); - - // Deny staff (and marketing, by inheritance) rights to revise latest news - $this->_acl->deny('staff', 'latest', 'revise'); - - // Deny everyone access to archive news announcements - $this->_acl->add(new Zend_Acl_Resource('announcement'), 'news'); - $this->_acl->deny(null, 'announcement', 'archive'); - - // Access control checks for the above refined permission sets - - $this->assertTrue($this->_acl->isAllowed('marketing', null, 'view')); - $this->assertTrue($this->_acl->isAllowed('marketing', null, 'edit')); - $this->assertTrue($this->_acl->isAllowed('marketing', null, 'submit')); - $this->assertTrue($this->_acl->isAllowed('marketing', null, 'revise')); - $this->assertFalse($this->_acl->isAllowed('marketing', null, 'publish')); - $this->assertFalse($this->_acl->isAllowed('marketing', null, 'archive')); - $this->assertFalse($this->_acl->isAllowed('marketing', null, 'delete')); - $this->assertFalse($this->_acl->isAllowed('marketing', null, 'unknown')); - $this->assertFalse($this->_acl->isAllowed('marketing')); - - $this->assertTrue($this->_acl->isAllowed('marketing', 'newsletter', 'publish')); - $this->assertFalse($this->_acl->isAllowed('staff', 'pending', 'publish')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'pending', 'publish')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'newsletter', 'archive')); - $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'delete')); - $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter')); - - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'publish')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'archive')); - $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'delete')); - $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'revise')); - $this->assertFalse($this->_acl->isAllowed('marketing', 'latest')); - - $this->assertFalse($this->_acl->isAllowed('marketing', 'announcement', 'archive')); - $this->assertFalse($this->_acl->isAllowed('staff', 'announcement', 'archive')); - $this->assertFalse($this->_acl->isAllowed('administrator', 'announcement', 'archive')); - - $this->assertFalse($this->_acl->isAllowed('staff', 'latest', 'publish')); - $this->assertFalse($this->_acl->isAllowed('editor', 'announcement', 'archive')); - - // Remove some previous permission specifications - - // Marketing can no longer publish and archive newsletters - $this->_acl->removeAllow('marketing', 'newsletter', array('publish', 'archive')); - - // Marketing can no longer archive the latest news - $this->_acl->removeAllow('marketing', 'latest', 'archive'); - - // Now staff (and marketing, by inheritance) may revise latest news - $this->_acl->removeDeny('staff', 'latest', 'revise'); - - // Access control checks for the above refinements - - $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'publish')); - $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'archive')); - - $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'archive')); - - $this->assertTrue($this->_acl->isAllowed('staff', 'latest', 'revise')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'revise')); - - // Grant marketing all permissions on the latest news - $this->_acl->allow('marketing', 'latest'); - - // Access control checks for the above refinement - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'archive')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'publish')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'edit')); - $this->assertTrue($this->_acl->isAllowed('marketing', 'latest')); - - } - - /** - * Ensures that the $onlyParents argument to inheritsRole() works - * - * @return void - * @see http://framework.zend.com/issues/browse/ZF-2502 - */ - public function testRoleInheritanceSupportsCheckingOnlyParents() - { - $this->_acl->addRole(new Zend_Acl_Role('grandparent')) - ->addRole(new Zend_Acl_Role('parent'), 'grandparent') - ->addRole(new Zend_Acl_Role('child'), 'parent'); - $this->assertFalse($this->_acl->inheritsRole('child', 'grandparent', true)); - } - - /** - * Ensures that the solution for ZF-2234 works as expected - * - * @return void - * @see http://framework.zend.com/issues/browse/ZF-2234 - */ - public function testZf2234() - { - $acl = new Zend_AclTest_ExtensionForZf2234(); - - $someResource = new Zend_Acl_Resource('someResource'); - $someRole = new Zend_Acl_Role('someRole'); - - $acl->add($someResource) - ->addRole($someRole); - - $nullValue = null; - $nullReference =& $nullValue; - - try { - $acl->roleDFSVisitAllPrivileges($someRole, $someResource, $nullReference); - $this->fail('Expected Zend_Acl_Exception not thrown'); - } catch (Zend_Acl_Exception $e) { - $this->assertEquals('$dfs parameter may not be null', $e->getMessage()); - } - - try { - $acl->roleDFSOnePrivilege($someRole, $someResource, null); - $this->fail('Expected Zend_Acl_Exception not thrown'); - } catch (Zend_Acl_Exception $e) { - $this->assertEquals('$privilege parameter may not be null', $e->getMessage()); - } - - try { - $acl->roleDFSVisitOnePrivilege($someRole, $someResource, null); - $this->fail('Expected Zend_Acl_Exception not thrown'); - } catch (Zend_Acl_Exception $e) { - $this->assertEquals('$privilege parameter may not be null', $e->getMessage()); - } - - try { - $acl->roleDFSVisitOnePrivilege($someRole, $someResource, 'somePrivilege', $nullReference); - $this->fail('Expected Zend_Acl_Exception not thrown'); - } catch (Zend_Acl_Exception $e) { - $this->assertEquals('$dfs parameter may not be null', $e->getMessage()); - } - } - -} - - -class Zend_AclTest_AssertFalse implements Zend_Acl_Assert_Interface -{ - public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, - $privilege = null) - { - return false; - } -} - - -class Zend_AclTest_AssertTrue implements Zend_Acl_Assert_Interface -{ - public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, - $privilege = null) - { - return true; - } -} - -class Zend_AclTest_ExtensionForZf2234 extends Zend_Acl -{ - public function roleDFSVisitAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null, - &$dfs = null) - { - return $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs); - } - - public function roleDFSOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null, - $privilege = null) - { - return $this->_roleDFSOnePrivilege($role, $resource, $privilege); - } - - public function roleDFSVisitOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null, - $privilege = null, &$dfs = null) - { - return $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs); - } -} \ No newline at end of file diff --git a/tests/Zend/AllTests.php b/tests/Zend/AllTests.php deleted file mode 100644 index 69081dd6b35c40df99312507150935338952c382..0000000000000000000000000000000000000000 --- a/tests/Zend/AllTests.php +++ /dev/null @@ -1,181 +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 - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10743 2008-08-07 02:24:43Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_AllTests::main'); -} - -require_once 'Zend/AclTest.php'; -require_once 'Zend/Auth/AllTests.php'; -require_once 'Zend/Cache/AllTests.php'; -require_once 'Zend/Captcha/AllTests.php'; -require_once 'Zend/Db/AllTests.php'; -require_once 'Zend/Dom/AllTests.php'; -require_once 'Zend/ConfigTest.php'; -require_once 'Zend/Config/AllTests.php'; -require_once 'Zend/Console/GetoptTest.php'; -require_once 'Zend/Controller/AllTests.php'; -require_once 'Zend/CurrencyTest.php'; -require_once 'Zend/DateTest.php'; -require_once 'Zend/Date/AllTests.php'; -require_once 'Zend/DebugTest.php'; -require_once 'Zend/Feed/AllTests.php'; -require_once 'Zend/File/AllTests.php'; -require_once 'Zend/FilterTest.php'; -require_once 'Zend/Filter/AllTests.php'; -require_once 'Zend/Form/AllTests.php'; -require_once 'Zend/Gdata/AllTests.php'; -require_once 'Zend/Http/AllTests.php'; -require_once 'Zend/InfoCard/AllTests.php'; -require_once 'Zend/JsonTest.php'; -require_once 'Zend/Json/JsonXMLTest.php'; -require_once 'Zend/Layout/AllTests.php'; -require_once 'Zend/Ldap/AllTests.php'; -require_once 'Zend/LoaderTest.php'; -require_once 'Zend/Loader/PluginLoaderTest.php'; -require_once 'Zend/LocaleTest.php'; -require_once 'Zend/Locale/AllTests.php'; -require_once 'Zend/Log/AllTests.php'; -require_once 'Zend/MailTest.php'; -require_once 'Zend/Mail/AllTests.php'; -require_once 'Zend/Measure/AllTests.php'; -require_once 'Zend/Memory/AllTests.php'; -require_once 'Zend/MimeTest.php'; -require_once 'Zend/Mime/AllTests.php'; -require_once 'Zend/OpenIdTest.php'; -require_once 'Zend/OpenId/AllTests.php'; -require_once 'Zend/Paginator/AllTests.php'; -require_once 'Zend/Pdf/AllTests.php'; -require_once 'Zend/RegistryTest.php'; -require_once 'Zend/Rest/AllTests.php'; -require_once 'Zend/Search/Lucene/AllTests.php'; -require_once 'Zend/Server/AllTests.php'; -require_once 'Zend/Service/AllTests.php'; -require_once 'Zend/Session/AllTests.php'; -require_once 'Zend/Soap/AllTests.php'; -require_once 'Zend/Test/AllTests.php'; -require_once 'Zend/Text/AllTests.php'; -require_once 'Zend/TimeSyncTest.php'; -require_once 'Zend/TranslateTest.php'; -require_once 'Zend/Translate/AllTests.php'; -require_once 'Zend/UriTest.php'; -require_once 'Zend/Uri/AllTests.php'; -require_once 'Zend/ValidateTest.php'; -require_once 'Zend/Validate/AllTests.php'; -require_once 'Zend/VersionTest.php'; -require_once 'Zend/ViewTest.php'; -require_once 'Zend/Wildfire/AllTests.php'; -require_once 'Zend/XmlRpc/AllTests.php'; - -/** - * @category Zend - * @package Zend - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend'); - - $suite->addTestSuite('Zend_AclTest'); - $suite->addTest(Zend_Auth_AllTests::suite()); - $suite->addTest(Zend_Cache_AllTests::suite()); - $suite->addTest(Zend_Captcha_AllTests::suite()); - $suite->addTestSuite('Zend_ConfigTest'); - $suite->addTest(Zend_Config_AllTests::suite()); - $suite->addTestSuite('Zend_Console_GetoptTest'); - $suite->addTest(Zend_Controller_AllTests::suite()); - $suite->addTestSuite('Zend_CurrencyTest'); - $suite->addTestSuite('Zend_DateTest'); - $suite->addTest(Zend_Date_AllTests::suite()); - $suite->addTest(Zend_Db_AllTests::suite()); - $suite->addTestSuite('Zend_DebugTest'); - $suite->addTest(Zend_Dom_AllTests::suite()); - $suite->addTest(Zend_Feed_AllTests::suite()); - $suite->addTest(Zend_File_AllTests::suite()); - $suite->addTestSuite('Zend_FilterTest'); - $suite->addTest(Zend_Filter_AllTests::suite()); - $suite->addTest(Zend_Form_AllTests::suite()); - $suite->addTest(Zend_Gdata_AllTests::suite()); - $suite->addTest(Zend_Http_AllTests::suite()); - $suite->addTest(Zend_InfoCard_AllTests::suite()); - $suite->addTestSuite('Zend_JsonTest'); - $suite->addTestSuite('Zend_Json_JsonXMLTest'); - $suite->addTest(Zend_Layout_AllTests::suite()); - $suite->addTest(Zend_Ldap_AllTests::suite()); - $suite->addTestSuite('Zend_LoaderTest'); - $suite->addTestSuite('Zend_Loader_PluginLoaderTest'); - $suite->addTestSuite('Zend_LocaleTest'); - $suite->addTest(Zend_Locale_AllTests::suite()); - $suite->addTest(Zend_Log_AllTests::suite()); - $suite->addTestSuite('Zend_MailTest'); - $suite->addTest(Zend_Mail_AllTests::suite()); - $suite->addTest(Zend_Measure_AllTests::suite()); - $suite->addTest(Zend_Memory_AllTests::suite()); - $suite->addTestSuite('Zend_MimeTest'); - $suite->addTest(Zend_Mime_AllTests::suite()); - $suite->addTestSuite('Zend_OpenIdTest'); - $suite->addTest(Zend_OpenId_AllTests::suite()); - $suite->addTest(Zend_Paginator_AllTests::suite()); - $suite->addTest(Zend_Pdf_AllTests::suite()); - $suite->addTestSuite('Zend_RegistryTest'); - $suite->addTest(Zend_Rest_AllTests::suite()); - $suite->addTest(Zend_Search_Lucene_AllTests::suite()); - $suite->addTest(Zend_Server_AllTests::suite()); - $suite->addTest(Zend_Service_AllTests::suite()); - $suite->addTest(Zend_Session_AllTests::suite()); - $suite->addTest(Zend_Soap_AllTests::suite()); - $suite->addTest(Zend_Test_AllTests::suite()); - $suite->addTest(Zend_Text_AllTests::suite()); - $suite->addTestSuite('Zend_TimeSyncTest'); - $suite->addTestSuite('Zend_TranslateTest'); - $suite->addTest(Zend_Translate_AllTests::suite()); - $suite->addTestSuite('Zend_UriTest'); - $suite->addTest(Zend_Uri_AllTests::suite()); - $suite->addTestSuite('Zend_ValidateTest'); - $suite->addTest(Zend_Validate_AllTests::suite()); - $suite->addTestSuite('Zend_ViewTest'); - $suite->addTestSuite('Zend_VersionTest'); - $suite->addTest(Zend_Wildfire_AllTests::suite()); - $suite->addTest(Zend_XmlRpc_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_AllTests::main') { - Zend_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/AllTests.php b/tests/Zend/Auth/Adapter/AllTests.php deleted file mode 100644 index 2706b9ae0d97585fc165e5d810dea39f23183584..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/AllTests.php +++ /dev/null @@ -1,112 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8402 2008-02-25 19:35:08Z darby $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_Adapter_AllTests::main'); -} - - -/** - * PHPUnit_Framework_TestSuite - */ -// require_once 'PHPUnit/Framework/TestSuite.php'; - - -/** - * PHPUnit_TextUI_TestRunner - */ -// require_once 'PHPUnit/TextUI/TestRunner.php'; - - -/** - * @see Zend_Auth_Adapter_DbTable_AllTests - */ -require_once 'Zend/Auth/Adapter/DbTable/AllTests.php'; - - -/** - * @see Zend_Auth_Adapter_DigestTest - */ -require_once 'Zend/Auth/Adapter/DigestTest.php'; - - -/** - * @see Zend_Auth_Adapter_Http_AllTests - */ -require_once 'Zend/Auth/Adapter/Http/AllTests.php'; - - -/** - * @see Zend_Auth_Adapter_Ldap_AllTests - */ -require_once 'Zend/Auth/Adapter/Ldap/AllTests.php'; - - -/** - * @see Zend_Auth_Adapter_OpenId_AllTests - */ -require_once 'Zend/Auth/Adapter/OpenId/AllTests.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth Adapters'); - - $suite->addTest(Zend_Auth_Adapter_DbTable_AllTests::suite()); - $suite->addTestSuite('Zend_Auth_Adapter_DigestTest'); - $suite->addTest(Zend_Auth_Adapter_Http_AllTests::suite()); - $suite->addTest(Zend_Auth_Adapter_Ldap_AllTests::suite()); - $suite->addTest(Zend_Auth_Adapter_OpenId_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Auth_Adapter_AllTests::main') { - Zend_Auth_Adapter_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/DbTable/AllTests.php b/tests/Zend/Auth/Adapter/DbTable/AllTests.php deleted file mode 100644 index 2223b0fd9636a6e16ea16ec8339b95c9b017c57f..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/DbTable/AllTests.php +++ /dev/null @@ -1,106 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_Adapter_DbTable_AllTests::main'); -} - - -/** - * PHPUnit_Framework_TestSuite - */ -// require_once 'PHPUnit/Framework/TestSuite.php'; - - -/** - * PHPUnit_TextUI_TestRunner - */ -// require_once 'PHPUnit/TextUI/TestRunner.php'; - - -/** - * @see Zend_Auth_Adapter_DbTable_BasicSqliteTest - */ -require_once 'Zend/Auth/Adapter/DbTable/BasicSqliteTest.php'; - - -/** - * @see Zend_Auth_Adapter_DbTable_BasicSqliteTest_SkipTests - */ -require_once 'Zend/Auth/Adapter/DbTable/BasicSqliteTest/SkipTests.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_DbTable_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth_Adapter_Http'); - - if (!defined('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED') || - constant('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED') === false) { - $skipTest = new Zend_Auth_Adapter_DbTable_BasicSqliteTest_SkipTests(); - $skipTest->message = 'Tests are not enabled in TestConfiguration.php'; - $suite->addTest($skipTest); - } else if (!extension_loaded('pdo')) { - $skipTest = new Zend_Auth_Adapter_DbTable_BasicSqliteTest_SkipTests(); - $skipTest->message = "Extension 'PDO' is not loaded"; - $suite->addTest($skipTest); - } else if (!in_array('sqlite', PDO::getAvailableDrivers())) { - $skipTest = new Zend_Auth_Adapter_DbTable_BasicSqliteTest_SkipTests(); - $skipTest->message = "PDO driver 'sqlite' is not available"; - $suite->addTest($skipTest); - } else { - $suite->addTestSuite('Zend_Auth_Adapter_DbTable_BasicSqliteTest'); - } - - return $suite; - } -} - - -if (PHPUnit_MAIN_METHOD == 'Zend_Auth_Adapter_DbTable_AllTests::main') { - Zend_Auth_Adapter_DbTable_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest.php b/tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest.php deleted file mode 100644 index 2a1df3aa55f4c90dfce3f7a522acadd24d824495..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest.php +++ /dev/null @@ -1,326 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BasicSqliteTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @see Zend_Db_Adapter_Pdo_Sqlite - */ -require_once 'Zend/Db/Adapter/Pdo/Sqlite.php'; - - -/** - * This is required because Zend_Db_Adapter_Pdo_Sqlite uses Zend_Db constants - * but does not load the file containing the Zend_Db class. - * - * @see Zend_Db - */ -require_once 'Zend/Db.php'; - - -/** - * @see Zend_Auth_Adapter_DbTable - */ -require_once 'Zend/Auth/Adapter/DbTable.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_DbTable_BasicSqliteTest extends PHPUnit_Framework_TestCase -{ - /** - * Sqlite database connection - * - * @var Zend_Db_Adapter_Pdo_Sqlite - */ - protected $_db = null; - - /** - * Database table authentication adapter - * - * @var Zend_Auth_Adapter_DbTable - */ - protected $_adapter = null; - - /** - * Set up test configuration - * - * @return void - */ - public function setUp() - { - $this->_db = new Zend_Db_Adapter_Pdo_Sqlite( - array('dbname' => TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_DATABASE) - ); - - $sqlCreate = 'CREATE TABLE [users] ( ' - . '[id] INTEGER NOT NULL PRIMARY KEY, ' - . '[username] VARCHAR(50) NOT NULL, ' - . '[password] VARCHAR(32) NULL, ' - . '[real_name] VARCHAR(150) NULL)'; - $this->_db->query($sqlCreate); - - $sqlInsert = 'INSERT INTO users (username, password, real_name) ' - . 'VALUES ("my_username", "my_password", "My Real Name")'; - $this->_db->query($sqlInsert); - - $this->_adapter = new Zend_Auth_Adapter_DbTable($this->_db, 'users', 'username', 'password'); - } - - /** - * Ensures expected behavior for authentication success - * - * @return void - */ - public function testAuthenticateSuccess() - { - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password'); - $result = $this->_adapter->authenticate(); - $this->assertTrue($result->isValid()); - } - - /** - * Ensures expected behavior for authentication success - * - * @return void - */ - public function testAuthenticateSuccessWithTreatment() - { - $this->_adapter = new Zend_Auth_Adapter_DbTable($this->_db, 'users', 'username', 'password', '?'); - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password'); - $result = $this->_adapter->authenticate(); - $this->assertTrue($result->isValid()); - } - - /** - * Ensures expected behavior for for authentication failure - * reason: Identity not found. - * - */ - public function testAuthenticateFailureIdentityNotFound() - { - $this->_adapter->setIdentity('non_existent_username'); - $this->_adapter->setCredential('my_password'); - - try { - $result = $this->_adapter->authenticate(); - $this->assertEquals($result->getCode(), Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND); - } catch (Zend_Auth_Exception $e) { - $this->fail('Exception should have been thrown'); - } - } - - /** - * Ensures expected behavior for for authentication failure - * reason: Identity not found. - * - */ - public function testAuthenticateFailureIdentityAmbigious() - { - $sql_insert = 'INSERT INTO users (username, password, real_name) VALUES ("my_username", "my_password", "My Real Name")'; - $this->_db->query($sql_insert); - - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password'); - - try { - $result = $this->_adapter->authenticate(); - $this->assertEquals($result->getCode(), Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS); - } catch (Zend_Auth_Exception $e) { - $this->fail('Exception should have been thrown'); - } - } - - /** - * Ensures expected behavior for authentication failure because of a bad password - * - * @return void - */ - public function testAuthenticateFailureInvalidCredential() - { - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password_bad'); - $result = $this->_adapter->authenticate(); - $this->assertFalse($result->isValid()); - } - - /** - * Ensures that getResultRowObject() works for successful authentication - * - * @return void - */ - public function testGetResultRow() - { - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password'); - $result = $this->_adapter->authenticate(); - $resultRow = $this->_adapter->getResultRowObject(); - $this->assertEquals($resultRow->username, 'my_username'); - } - - /** - * Ensure that ResultRowObject returns only what told to be included - * - */ - public function testGetSpecificResultRow() - { - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password'); - $result = $this->_adapter->authenticate(); - $resultRow = $this->_adapter->getResultRowObject(array('username', 'real_name')); - $this->assertEquals(serialize($resultRow), 'O:8:"stdClass":2:{s:8:"username";s:11:"my_username";s:9:"real_name";s:12:"My Real Name";}'); - } - - /** - * Ensure that ResultRowObject returns an object has specific omissions - * - */ - public function testGetOmittedResultRow() - { - $this->_adapter->setIdentity('my_username'); - $this->_adapter->setCredential('my_password'); - $result = $this->_adapter->authenticate(); - $resultRow = $this->_adapter->getResultRowObject(null, 'password'); - $this->assertEquals(serialize($resultRow), 'O:8:"stdClass":3:{s:2:"id";s:1:"1";s:8:"username";s:11:"my_username";s:9:"real_name";s:12:"My Real Name";}'); - } - - /** - * Ensure that exceptions are caught - * - */ - public function testCatchExceptionNoTable() - { - $adapter = new Zend_Auth_Adapter_DbTable($this->_db); - - try { - $result = $adapter->authenticate(); - $this->fail('Exception should have been thrown'); - } catch (Zend_Auth_Exception $e) { - $this->assertEquals($e->getMessage(), 'A table must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.'); - } - } - - /** - * Ensure that exceptions are caught - * - */ - public function testCatchExceptionNoIdentityColumn() - { - $adapter = new Zend_Auth_Adapter_DbTable($this->_db, 'users'); - - try { - $result = $adapter->authenticate(); - $this->fail('Exception should have been thrown'); - } catch (Zend_Auth_Exception $e) { - $this->assertEquals($e->getMessage(), 'An identity column must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.'); - } - } - - /** - * Ensure that exceptions are caught - * - */ - public function testCatchExceptionNoCredentialColumn() - { - $adapter = new Zend_Auth_Adapter_DbTable($this->_db, 'users', 'username'); - - try { - $result = $adapter->authenticate(); - $this->fail('Exception should have been thrown'); - } catch (Zend_Auth_Exception $e) { - $this->assertEquals($e->getMessage(), 'A credential column must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.'); - } - } - - /** - * Ensure that exceptions are caught - * - */ - public function testCatchExceptionNoIdentity() - { - try { - $result = $this->_adapter->authenticate(); - $this->fail('Exception should have been thrown'); - } catch (Zend_Auth_Exception $e) { - $this->assertEquals($e->getMessage(), 'A value for the identity was not provided prior to authentication with Zend_Auth_Adapter_DbTable.'); - } - } - - /** - * Ensure that exceptions are caught - * - */ - public function testCatchExceptionNoCredential() - { - $this->_adapter->setIdentity('my_username'); - - try { - $result = $this->_adapter->authenticate(); - $this->fail('Exception should have been thrown'); - } catch (Zend_Auth_Exception $e) { - $this->assertEquals($e->getMessage(), 'A credential value was not provided prior to authentication with Zend_Auth_Adapter_DbTable.'); - } - } - - /** - * Ensure that exceptions are caught - * - */ - public function testCatchExceptionBadSql() - { - $this->_adapter->setTableName('bad_table_name'); - $this->_adapter->setIdentity('value'); - $this->_adapter->setCredential('value'); - - try { - $result = $this->_adapter->authenticate(); - $this->fail('Exception should have been thrown'); - } catch (Zend_Auth_Exception $e) { - $this->assertEquals($e->getMessage(), 'The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.'); - } - } - - - -} - - -class Zend_Auth_Adapter_DbTable_BasicSqliteTest_Skip extends Zend_Auth_Adapter_DbTable_BasicSqliteTest -{ - public function setUp() - { - $this->markTestSkipped('Zend_Auth_Adapter_DbTable Sqlite tests are not enabled in TestConfiguration.php'); - } -} diff --git a/tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest/SkipTests.php b/tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest/SkipTests.php deleted file mode 100644 index 00455e25cc5b0d71ac23de5b2f80cac95276419f..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest/SkipTests.php +++ /dev/null @@ -1,54 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BasicSqliteTest.php 4194 2007-03-22 23:50:34Z darby $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_DbTable_BasicSqliteTest_SkipTests extends PHPUnit_Framework_TestCase -{ - - public $message = 'Skipped for unspecified reason'; - - public function setUp() - { - $this->markTestSkipped($this->message); - } - - public function testBasicSqlite() - { - // this is here only so we have at least one test - } - -} diff --git a/tests/Zend/Auth/Adapter/Digest/_files/.htdigest.1 b/tests/Zend/Auth/Adapter/Digest/_files/.htdigest.1 deleted file mode 100644 index ff6292749e767246a18ada2872e3f8ff428f8124..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Digest/_files/.htdigest.1 +++ /dev/null @@ -1,2 +0,0 @@ -someUser:Some Realm:fde17b91c3a510ecbaf7dbd37f59d4f8 -someOtherUser:Some Other Realm:1911c62b21a85c85c4c1a57785893b94 diff --git a/tests/Zend/Auth/Adapter/DigestTest.php b/tests/Zend/Auth/Adapter/DigestTest.php deleted file mode 100644 index c9f8a3417dab6fb676830b3a0a5ea3cab9231479..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/DigestTest.php +++ /dev/null @@ -1,251 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DigestTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * Zend_Auth_Adapter_Digest - */ -require_once 'Zend/Auth/Adapter/Digest.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_DigestTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * Sets the path to test files - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(__FILE__) . '/Digest/_files'; - } - - /** - * Ensures that the adapter throws an exception when authentication is attempted before - * setting a required option - * - * @return void - */ - public function testOptionRequiredException() - { - $adapter = new Zend_Auth_Adapter_Digest(); - try { - $adapter->authenticate(); - $this->fail('Expected Zend_Auth_Adapter_Exception not thrown upon authentication attempt before setting ' - . 'a required option'); - } catch (Zend_Auth_Adapter_Exception $e) { - $this->assertContains('must be set before authentication', $e->getMessage()); - } - } - - /** - * Ensures that an exception is thrown upon authenticating against a nonexistent file - * - * @return void - */ - public function testFileNonExistentException() - { - $adapter = new Zend_Auth_Adapter_Digest('nonexistent', 'realm', 'username', 'password'); - try { - $adapter->authenticate(); - $this->fail('Expected Zend_Auth_Adapter_Exception not thrown upon authenticating against nonexistent ' - . 'file'); - } catch (Zend_Auth_Adapter_Exception $e) { - $this->assertContains('Cannot open', $e->getMessage()); - } - } - - /** - * Ensures expected behavior upon realm not found for existing user - * - * @return void - */ - public function testUserExistsRealmNonexistent() - { - $filename = "$this->_filesPath/.htdigest.1"; - $realm = 'Nonexistent Realm'; - $username = 'someUser'; - $password = 'somePassword'; - - $adapter = new Zend_Auth_Adapter_Digest($filename, $realm, $username, $password); - - $result = $adapter->authenticate(); - - $this->assertFalse($result->isValid()); - - $messages = $result->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals($result->getCode(), Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND); - $this->assertContains('combination not found', $messages[0]); - - $identity = $result->getIdentity(); - $this->assertEquals($identity['realm'], $realm); - $this->assertEquals($identity['username'], $username); - } - - /** - * Ensures expected behavior upon user not found in existing realm - * - * @return void - */ - public function testUserNonexistentRealmExists() - { - $filename = "$this->_filesPath/.htdigest.1"; - $realm = 'Some Realm'; - $username = 'nonexistentUser'; - $password = 'somePassword'; - - $adapter = new Zend_Auth_Adapter_Digest($filename, $realm, $username, $password); - - $result = $adapter->authenticate(); - - $this->assertFalse($result->isValid()); - $this->assertEquals($result->getCode(), Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND); - - $messages = $result->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertContains('combination not found', $messages[0]); - - $identity = $result->getIdentity(); - $this->assertEquals($identity['realm'], $realm); - $this->assertEquals($identity['username'], $username); - } - - /** - * Ensures expected behavior upon incorrect password - * - * @return void - */ - public function testIncorrectPassword() - { - $filename = "$this->_filesPath/.htdigest.1"; - $realm = 'Some Realm'; - $username = 'someUser'; - $password = 'incorrectPassword'; - - $adapter = new Zend_Auth_Adapter_Digest($filename, $realm, $username, $password); - - $result = $adapter->authenticate(); - - $this->assertFalse($result->isValid()); - $this->assertEquals($result->getCode(), Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID); - - $messages = $result->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertContains('Password incorrect', $messages[0]); - - $identity = $result->getIdentity(); - $this->assertEquals($identity['realm'], $realm); - $this->assertEquals($identity['username'], $username); - } - - /** - * Ensures that successful authentication works as expected - * - * @return void - */ - public function testAuthenticationSuccess() - { - $filename = "$this->_filesPath/.htdigest.1"; - $realm = 'Some Realm'; - $username = 'someUser'; - $password = 'somePassword'; - - $adapter = new Zend_Auth_Adapter_Digest($filename, $realm, $username, $password); - - $result = $adapter->authenticate(); - - $this->assertTrue($result->isValid()); - $this->assertEquals($result->getCode(), Zend_Auth_Result::SUCCESS); - - $this->assertEquals(array(), $result->getMessages()); - - $identity = $result->getIdentity(); - $this->assertEquals($identity['realm'], $realm); - $this->assertEquals($identity['username'], $username); - } - - /** - * Ensures that getFilename() returns expected default value - * - * @return void - */ - public function testGetFilename() - { - $adapter = new Zend_Auth_Adapter_Digest(); - $this->assertEquals(null, $adapter->getFilename()); - } - - /** - * Ensures that getRealm() returns expected default value - * - * @return void - */ - public function testGetRealm() - { - $adapter = new Zend_Auth_Adapter_Digest(); - $this->assertEquals(null, $adapter->getRealm()); - } - - /** - * Ensures that getUsername() returns expected default value - * - * @return void - */ - public function testGetUsername() - { - $adapter = new Zend_Auth_Adapter_Digest(); - $this->assertEquals(null, $adapter->getUsername()); - } - - /** - * Ensures that getPassword() returns expected default value - * - * @return void - */ - public function testGetPassword() - { - $adapter = new Zend_Auth_Adapter_Digest(); - $this->assertEquals(null, $adapter->getPassword()); - } -} \ No newline at end of file diff --git a/tests/Zend/Auth/Adapter/Http/AllTests.php b/tests/Zend/Auth/Adapter/Http/AllTests.php deleted file mode 100644 index 7ab422e528d0a88455bff071ced515b8045713b8..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/AllTests.php +++ /dev/null @@ -1,99 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8262 2008-02-21 22:07:06Z darby $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_Adapter_Http_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - - -/** - * @see Zend_Auth_Adapter_Http_AuthTest - */ -require_once 'Zend/Auth/Adapter/Http/AuthTest.php'; - - -/** - * @see Zend_Auth_Adapter_Http_ObjectTest - */ -require_once 'Zend/Auth/Adapter/Http/ObjectTest.php'; - - -/** - * @see Zend_Auth_Adapter_Http_ProxyTest - */ -require_once 'Zend/Auth/Adapter/Http/ProxyTest.php'; - - -/** - * @see Zend_Auth_Adapter_Http_Resolver_AllTests - */ -require_once 'Zend/Auth/Adapter/Http/Resolver/AllTests.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Http_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth_Adapter_Http'); - - $suite->addTestSuite('Zend_Auth_Adapter_Http_AuthTest'); - $suite->addTestSuite('Zend_Auth_Adapter_Http_ObjectTest'); - $suite->addTestSuite('Zend_Auth_Adapter_Http_ProxyTest'); - $suite->addTest(Zend_Auth_Adapter_Http_Resolver_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Auth_Adapter_Http_AllTests::main') { - Zend_Auth_Adapter_Http_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/Http/AuthTest.php b/tests/Zend/Auth/Adapter/Http/AuthTest.php deleted file mode 100644 index 4d67707ad3acb6582286b763be0e68c658c376d0..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/AuthTest.php +++ /dev/null @@ -1,495 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AuthTest.php 8269 2008-02-22 02:41:08Z gearhead $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @see Zend_Auth_Adapter_Http - */ -require_once 'Zend/Auth/Adapter/Http.php'; - - -/** - * @see Zend_Auth_Adapter_Http_Resolver_File - */ -require_once 'Zend/Auth/Adapter/Http/Resolver/File.php'; - - -/** - * @see Zend_Controller_Request_Http - */ -require_once 'Zend/Controller/Request/Http.php'; - - -/** - * @see Zend_Controller_Response_Http - */ -require_once 'Zend/Controller/Response/Http.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Http_AuthTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * HTTP Basic configuration - * - * @var array - */ - protected $_basicConfig; - - /** - * HTTP Digest configuration - * - * @var array - */ - protected $_digestConfig; - - /** - * HTTP Basic Digest configuration - * - * @var array - */ - protected $_bothConfig; - - /** - * File resolver setup against with HTTP Basic auth file - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_basicResolver; - - /** - * File resolver setup against with HTTP Digest auth file - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_digestResolver; - - /** - * Set up test configuration - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(__FILE__) . '/_files'; - $this->_basicResolver = new Zend_Auth_Adapter_Http_Resolver_File("{$this->_filesPath}/htbasic.1"); - $this->_digestResolver = new Zend_Auth_Adapter_Http_Resolver_File("{$this->_filesPath}/htdigest.3"); - $this->_basicConfig = array( - 'accept_schemes' => 'basic', - 'realm' => 'Test Realm' - ); - $this->_digestConfig = array( - 'accept_schemes' => 'digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ http://localhost/', - 'nonce_timeout' => 300 - ); - $this->_bothConfig = array( - 'accept_schemes' => 'basic digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ http://localhost/', - 'nonce_timeout' => 300 - ); - } - - public function testBasicChallenge() - { - // Trying to authenticate without sending an Authorization header - // should result in a 401 reply with a Www-Authenticate header, and a - // false result. - - // The expected Basic Www-Authenticate header value - $basic = 'Basic realm="' . $this->_bothConfig['realm'] . '"'; - - $data = $this->_doAuth('', 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testDigestChallenge() - { - // Trying to authenticate without sending an Authorization header - // should result in a 401 reply with a Www-Authenticate header, and a - // false result. - - // The expected Digest Www-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth('', 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testBothChallenges() - { - // Trying to authenticate without sending an Authorization header - // should result in a 401 reply with at least one Www-Authenticate - // header, and a false result. - - $data = $this->_doAuth('', 'both'); - extract($data); // $result, $status, $headers - - // The expected Www-Authenticate header values - $basic = 'Basic realm="' . $this->_bothConfig['realm'] . '"'; - $digest = $this->_digestChallenge(); - - // Make sure the result is false - $this->assertType('Zend_Auth_Result', $result); - $this->assertFalse($result->isValid()); - - // Verify the status code and the presence of both challenges - $this->assertEquals(401, $status); - $this->assertEquals('Www-Authenticate', $headers[0]['name']); - $this->assertEquals('Www-Authenticate', $headers[1]['name']); - - // Check to see if the expected challenges match the actual - $this->assertEquals($basic, $headers[0]['value']); - $this->assertEquals($digest, $headers[1]['value']); - } - - public function testBasicAuthValidCreds() - { - // Attempt Basic Authentication with a valid username and password - - $data = $this->_doAuth('Basic ' . base64_encode('Bryce:ThisIsNotMyPassword'), 'basic'); - $this->_checkOK($data); - } - - public function testBasicAuthBadCreds() - { - // Ensure that credentials containing invalid characters are treated as - // a bad username or password. - - // The expected Basic Www-Authenticate header value - $basic = 'Basic realm="' . $this->_basicConfig['realm'] . '"'; - - $data = $this->_doAuth('Basic ' . base64_encode("Bad\tChars:In:Creds"), 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testBasicAuthBadUser() - { - // Attempt Basic Authentication with a nonexistant username and - // password - - // The expected Basic Www-Authenticate header value - $basic = 'Basic realm="' . $this->_basicConfig['realm'] . '"'; - - $data = $this->_doAuth('Basic ' . base64_encode('Nobody:NotValid'), 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testBasicAuthBadPassword() - { - // Attempt Basic Authentication with a valid username, but invalid - // password - - // The expected Basic Www-Authenticate header value - $basic = 'Basic realm="' . $this->_basicConfig['realm'] . '"'; - - $data = $this->_doAuth('Basic ' . base64_encode('Bryce:Invalid'), 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testDigestAuthValidCreds() - { - // Attempt Digest Authentication with a valid username and password - - $data = $this->_doAuth($this->_digestReply('Bryce', 'ThisIsNotMyPassword'), 'digest'); - $this->_checkOK($data); - } - - public function testDigestAuthDefaultAlgo() - { - // If the client omits the aglorithm argument, it should default to MD5, - // and work just as above - - $cauth = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $cauth = preg_replace('/algorithm="MD5", /', '', $cauth); - - $data = $this->_doAuth($cauth, 'digest'); - $this->_checkOK($data); - } - - public function testDigestAuthQuotedNC() - { - // The nonce count isn't supposed to be quoted, but apparently some - // clients do anyway. - - $cauth = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $cauth = preg_replace('/nc=00000001/', 'nc="00000001"', $cauth); - - $data = $this->_doAuth($cauth, 'digest'); - $this->_checkOK($data); - } - - public function testDigestAuthBadCreds() - { - // Attempt Digest Authentication with a bad username and password - - // The expected Digest Www-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth($this->_digestReply('Nobody', 'NotValid'), 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testDigestAuthBadCreds2() - { - // Formerly, a username with invalid characters would result in a 400 - // response, but now should result in 401 response. - - // The expected Digest Www-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth($this->_digestReply('Bad:chars', 'NotValid'), 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testDigestTampered() - { - // Create the tampered header value - $tampered = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $tampered = preg_replace( - '/ nonce="[a-fA-F0-9]{32}", /', - ' nonce="'.str_repeat('0', 32).'", ', - $tampered - ); - - // The expected Digest Www-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth($tampered, 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testBadSchemeRequest() - { - // Sending a request for an invalid authentication scheme should result - // in a 400 Bad Request response. - - $data = $this->_doAuth('Invalid ' . base64_encode('Nobody:NotValid'), 'basic'); - $this->_checkBadRequest($data); - } - - public function testBadDigestRequest() - { - // If any of the individual parts of the Digest Authorization header - // are bad, it results in a 400 Bad Request. But that's a lot of - // possibilities, so we're just going to pick one for now. - $bad = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $bad = preg_replace( - '/realm="([^"]+)"/', // cut out the realm - '', $bad - ); - - $data = $this->_doAuth($bad, 'digest'); - $this->_checkBadRequest($data); - } - - /** - * Acts like a client sending the given Authenticate header value. - * - * @param string $clientHeader Authenticate header value - * @param string $scheme Which authentication scheme to use - * @return array Containing the result, response headers, and the status - */ - protected function _doAuth($clientHeader, $scheme) - { - // Set up stub request and response objects - $request = $this->getMock('Zend_Controller_Request_Http'); - $response = new Zend_Controller_Response_Http; - $response->setHttpResponseCode(200); - $response->headersSentThrowsException = false; - - // Set stub method return values - $request->expects($this->any()) - ->method('getRequestUri') - ->will($this->returnValue('/')); - $request->expects($this->any()) - ->method('getMethod') - ->will($this->returnValue('GET')); - $request->expects($this->any()) - ->method('getServer') - ->will($this->returnValue('PHPUnit')); - $request->expects($this->any()) - ->method('getHeader') - ->will($this->returnValue($clientHeader)); - - // Select an Authentication scheme - switch ($scheme) { - case 'basic': - $use = $this->_basicConfig; - break; - case 'digest': - $use = $this->_digestConfig; - break; - case 'both': - default: - $use = $this->_bothConfig; - } - - // Create the HTTP Auth adapter - $a = new Zend_Auth_Adapter_Http($use); - $a->setBasicResolver($this->_basicResolver); - $a->setDigestResolver($this->_digestResolver); - - // Send the authentication request - $a->setRequest($request); - $a->setResponse($response); - $result = $a->authenticate(); - - $return = array( - 'result' => $result, - 'status' => $response->getHttpResponseCode(), - 'headers' => $response->getHeaders() - ); - return $return; - } - - /** - * Constructs a local version of the digest challenge we expect to receive - * - * @return string - */ - protected function _digestChallenge() - { - $timeout = ceil(time() / 300) * 300; - $nonce = md5($timeout . ':PHPUnit:Zend_Auth_Adapter_Http'); - $opaque = md5('Opaque Data:Zend_Auth_Adapter_Http'); - $wwwauth = 'Digest ' - . 'realm="' . $this->_digestConfig['realm'] . '", ' - . 'domain="' . $this->_digestConfig['digest_domains'] . '", ' - . 'nonce="' . $nonce . '", ' - . 'opaque="' . $opaque . '", ' - . 'algorithm="MD5", ' - . 'qop="auth"'; - - return $wwwauth; - } - - /** - * Constructs a client digest Authorization header - * - * @return string - */ - protected function _digestReply($user, $pass) - { - $nc = '00000001'; - $timeout = ceil(time() / 300) * 300; - $nonce = md5($timeout . ':PHPUnit:Zend_Auth_Adapter_Http'); - $opaque = md5('Opaque Data:Zend_Auth_Adapter_Http'); - $cnonce = md5('cnonce'); - $response = md5(md5($user . ':' . $this->_digestConfig['realm'] . ':' . $pass) . ":$nonce:$nc:$cnonce:auth:" - . md5('GET:/')); - $cauth = 'Digest ' - . 'username="Bryce", ' - . 'realm="' . $this->_digestConfig['realm'] . '", ' - . 'nonce="' . $nonce . '", ' - . 'uri="/", ' - . 'response="' . $response . '", ' - . 'algorithm="MD5", ' - . 'cnonce="' . $cnonce . '", ' - . 'opaque="' . $opaque . '", ' - . 'qop="auth", ' - . 'nc=' . $nc; - - return $cauth; - } - - /** - * Checks for an expected 401 Unauthorized response - * - * @param array $data Authentication results - * @param string $expected Expected Www-Authenticate header value - * @return void - */ - protected function _checkUnauthorized($data, $expected) - { - extract($data); // $result, $status, $headers - - // Make sure the result is false - $this->assertType('Zend_Auth_Result', $result); - $this->assertFalse($result->isValid()); - - // Verify the status code and the presence of the challenge - $this->assertEquals(401, $status); - $this->assertEquals('Www-Authenticate', $headers[0]['name']); - - // Check to see if the expected challenge matches the actual - $this->assertEquals($expected, $headers[0]['value']); - } - - /** - * Checks for an expected 200 OK response - * - * @param array $data Authentication results - * @return void - */ - protected function _checkOK($data) - { - extract($data); // $result, $status, $headers - - // Make sure the result is true - $this->assertType('Zend_Auth_Result', $result); - $this->assertTrue($result->isValid()); - - // Verify we got a 200 response - $this->assertEquals(200, $status); - } - - /** - * Checks for an expected 400 Bad Request response - * - * @param array $data Authentication results - * @return void - */ - protected function _checkBadRequest($data) - { - extract($data); // $result, $status, $headers - - // Make sure the result is false - $this->assertType('Zend_Auth_Result', $result); - $this->assertFalse($result->isValid()); - - // Make sure it set the right HTTP code - $this->assertEquals(400, $status); - } -} diff --git a/tests/Zend/Auth/Adapter/Http/ObjectTest.php b/tests/Zend/Auth/Adapter/Http/ObjectTest.php deleted file mode 100644 index d776d88f2f8efb1e6dc9ed2ea14b821f3996bc7b..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/ObjectTest.php +++ /dev/null @@ -1,299 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ObjectTest.php 9404 2008-05-07 23:42:02Z doctorrock83 $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @see Zend_Auth_Adapter_Http - */ -require_once 'Zend/Auth/Adapter/Http.php'; - - -/** - * @see Zend_Auth_Adapter_Http_Resolver_File - */ -require_once 'Zend/Auth/Adapter/Http/Resolver/File.php'; - - -/** - * @see Zend_Controller_Request_Http - */ -require_once 'Zend/Controller/Request/Http.php'; - - -/** - * @see Zend_Controller_Response_Http - */ -require_once 'Zend/Controller/Response/Http.php'; - -/** - * @see Zend_Debug - */ -require_once 'Zend/Debug.php'; - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Http_ObjectTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * HTTP Basic configuration - * - * @var array - */ - protected $_basicConfig; - - /** - * HTTP Digest configuration - * - * @var array - */ - protected $_digestConfig; - - /** - * HTTP Basic Digest configuration - * - * @var array - */ - protected $_bothConfig; - - /** - * File resolver setup against with HTTP Basic auth file - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_basicResolver; - - /** - * File resolver setup against with HTTP Digest auth file - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_digestResolver; - - /** - * Sets up test configuration - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(__FILE__) . '/_files'; - $this->_basicResolver = new Zend_Auth_Adapter_Http_Resolver_File("$this->_filesPath/htbasic.1"); - $this->_digestResolver = new Zend_Auth_Adapter_Http_Resolver_File("$this->_filesPath/htdigest.3"); - $this->_basicConfig = array( - 'accept_schemes' => 'basic', - 'realm' => 'Test Realm' - ); - $this->_digestConfig = array( - 'accept_schemes' => 'digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ http://localhost/', - 'nonce_timeout' => 300 - ); - $this->_bothConfig = array( - 'accept_schemes' => 'basic digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ http://localhost/', - 'nonce_timeout' => 300 - ); - } - - public function testValidConfigs() - { - try { - $t = new Zend_Auth_Adapter_Http($this->_basicConfig); - } catch (Zend_Auth_Adapter_Exception $e) { - $this->fail('Valid config deemed invalid'); - } - $this->assertFalse(empty($t)); - $this->assertType('Zend_Auth_Adapter_Http', $t); - unset($t); - - try { - $t = new Zend_Auth_Adapter_Http($this->_digestConfig); - } catch (Zend_Auth_Adapter_Exception $e) { - $this->fail('Valid config deemed invalid'); - } - $this->assertFalse(empty($t)); - $this->assertType('Zend_Auth_Adapter_Http', $t); - unset($t); - - try { - $t = new Zend_Auth_Adapter_Http($this->_bothConfig); - } catch (Zend_Auth_Adapter_Exception $e) { - $this->fail('Valid config deemed invalid'); - } - $this->assertFalse(empty($t)); - $this->assertType('Zend_Auth_Adapter_Http', $t); - unset($t); - } - - public function testInvalidConfigs() - { - $badConfigs = array( - 'bad1' => array( - 'auth_type' => 'bogus', - 'realm' => 'Test Realm' - ), - 'bad2' => array( - 'auth_type' => 'digest', - 'realm' => 'Bad: "Chars"'."\n", - 'digest_domains' => '/ /admin', - 'nonce_timeout' => 300 - ), - 'bad3' => array( - 'auth_type' => 'digest', - 'realm' => 'Test Realm', - 'digest_domains' => 'no"quotes'."\tor tabs", - 'nonce_timeout' => 300 - ), - 'bad4' => array( - 'auth_type' => 'digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ /admin', - 'nonce_timeout' => 'junk' - ) - ); - - foreach ($badConfigs as $cfg) { - $t = null; - try { - $t = new Zend_Auth_Adapter_Http($cfg); - $this->fail('Accepted an invalid config'); - } catch (Zend_Auth_Adapter_Exception $e) { - // Good, it threw an exception - } - } - } - - public function testAuthenticateArgs() - { - $a = new Zend_Auth_Adapter_Http($this->_basicConfig); - - try { - $a->authenticate(); - $this->fail('Attempted authentication without request/response objects'); - } catch (Zend_Auth_Adapter_Exception $e) { - // Good, it threw an exception - } - - $request = $this->getMock('Zend_Controller_Request_Http'); - $response = $this->getMock('Zend_Controller_Response_Http'); - - // If this throws an exception, it fails - $a->setRequest($request) - ->setResponse($response) - ->authenticate(); - } - - public function testNoResolvers() - { - $request = $this->getMock('Zend_Controller_Request_Http'); - $response = $this->getMock('Zend_Controller_Response_Http'); - - // Stub request for Basic auth - $request->expects($this->any()) - ->method('getHeader') - ->will($this->returnValue('Basic <followed by a space caracter')); - - // Once for Basic - try { - $a = new Zend_Auth_Adapter_Http($this->_basicConfig); - $a->setRequest($request) - ->setResponse($response); - $result = $a->authenticate(); - $this->fail("Tried Basic authentication without a resolver.\n" . Zend_Debug::dump($result->getMessages(),null,false)); - } catch (Zend_Auth_Adapter_Exception $e) { - // Good, it threw an exception - unset($a); - } - - // Stub request for Digest auth, must be reseted (recreated) - $request = $this->getMock('Zend_Controller_Request_Http'); - $request->expects($this->any()) - ->method('getHeader') - ->will($this->returnValue('Digest <followed by a space caracter')); - - // Once for Digest - try { - $a = new Zend_Auth_Adapter_Http($this->_digestConfig); - $a->setRequest($request) - ->setResponse($response); - $result = $a->authenticate(); - $this->fail("Tried Digest authentication without a resolver.\n" . Zend_Debug::dump($result->getMessages(),null,false)); - } catch (Zend_Auth_Adapter_Exception $e) { - // Good, it threw an exception - unset($a); - } - } - - public function testWrongResolverUsed() - { - $response = $this->getMock('Zend_Controller_Response_Http'); - $request = $this->getMock('Zend_Controller_Request_Http'); - $request->expects($this->any()) - ->method('getHeader') - ->will($this->returnValue('Basic <followed by a space caracter')); // A basic Header will be provided by that request - - // Test a Digest auth process while the request is containing a Basic auth header - $a = new Zend_Auth_Adapter_Http($this->_digestConfig); - $a->setDigestResolver($this->_digestResolver) - ->setRequest($request) - ->setResponse($response); - $result = $a->authenticate(); - $this->assertEquals($result->getCode(),Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID); - } - - public function testUnsupportedScheme() - { - $response = $this->getMock('Zend_Controller_Response_Http'); - $request = $this->getMock('Zend_Controller_Request_Http'); - $request->expects($this->any()) - ->method('getHeader') - ->will($this->returnValue('NotSupportedScheme <followed by a space caracter')); - - $a = new Zend_Auth_Adapter_Http($this->_digestConfig); - $a->setDigestResolver($this->_digestResolver) - ->setRequest($request) - ->setResponse($response); - $result = $a->authenticate(); - $this->assertEquals($result->getCode(),Zend_Auth_Result::FAILURE_UNCATEGORIZED); - } -} diff --git a/tests/Zend/Auth/Adapter/Http/ProxyTest.php b/tests/Zend/Auth/Adapter/Http/ProxyTest.php deleted file mode 100644 index 2bd490589fdcfa51dfc424e763750332aa2f67a4..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/ProxyTest.php +++ /dev/null @@ -1,487 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ProxyTest.php 8549 2008-03-05 15:37:20Z darby $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - - -/** - * @see Zend_Auth_Adapter_Http - */ -require_once 'Zend/Auth/Adapter/Http.php'; - - -/** - * @see Zend_Auth_Adapter_Http_Resolver_File - */ -require_once 'Zend/Auth/Adapter/Http/Resolver/File.php'; - - -/** - * @see Zend_Controller_Request_Http - */ -require_once 'Zend/Controller/Request/Http.php'; - - -/** - * @see Zend_Controller_Response_Http - */ -require_once 'Zend/Controller/Response/Http.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Http_ProxyTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * HTTP Basic configuration - * - * @var array - */ - protected $_basicConfig; - - /** - * HTTP Digest configuration - * - * @var array - */ - protected $_digestConfig; - - /** - * HTTP Basic Digest configuration - * - * @var array - */ - protected $_bothConfig; - - /** - * File resolver setup against with HTTP Basic auth file - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_basicResolver; - - /** - * File resolver setup against with HTTP Digest auth file - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_digestResolver; - - /** - * Sets up test configuration - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(__FILE__) . '/_files'; - $this->_basicResolver = new Zend_Auth_Adapter_Http_Resolver_File("{$this->_filesPath}/htbasic.1"); - $this->_digestResolver = new Zend_Auth_Adapter_Http_Resolver_File("{$this->_filesPath}/htdigest.3"); - $this->_basicConfig = array( - 'accept_schemes' => 'basic', - 'realm' => 'Test Realm', - 'proxy_auth' => true - ); - $this->_digestConfig = array( - 'accept_schemes' => 'digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ http://localhost/', - 'nonce_timeout' => 300, - 'proxy_auth' => true - ); - $this->_bothConfig = array( - 'accept_schemes' => 'basic digest', - 'realm' => 'Test Realm', - 'digest_domains' => '/ http://localhost/', - 'nonce_timeout' => 300, - 'proxy_auth' => true - ); - } - - public function testBasicChallenge() - { - // Trying to authenticate without sending an Proxy-Authorization header - // should result in a 407 reply with a Proxy-Authenticate header, and a - // false result. - - // The expected Basic Proxy-Authenticate header value - $basic = 'Basic realm="' . $this->_bothConfig['realm'] . '"'; - - $data = $this->_doAuth('', 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testDigestChallenge() - { - // Trying to authenticate without sending an Proxy-Authorization header - // should result in a 407 reply with a Proxy-Authenticate header, and a - // false result. - - // The expected Digest Proxy-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth('', 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testBothChallenges() - { - // Trying to authenticate without sending an Proxy-Authorization header - // should result in a 407 reply with at least one Proxy-Authenticate - // header, and a false result. - - $data = $this->_doAuth('', 'both'); - extract($data); // $result, $status, $headers - - // The expected Proxy-Authenticate header values - $basic = 'Basic realm="' . $this->_bothConfig['realm'] . '"'; - $digest = $this->_digestChallenge(); - - // Make sure the result is false - $this->assertType('Zend_Auth_Result', $result); - $this->assertFalse($result->isValid()); - - // Verify the status code and the presence of both challenges - $this->assertEquals(407, $status); - $this->assertEquals('Proxy-Authenticate', $headers[0]['name']); - $this->assertEquals('Proxy-Authenticate', $headers[1]['name']); - - // Check to see if the expected challenges match the actual - $this->assertEquals($basic, $headers[0]['value']); - $this->assertEquals($digest, $headers[1]['value']); - } - - public function testBasicAuthValidCreds() - { - // Attempt Basic Authentication with a valid username and password - - $data = $this->_doAuth('Basic ' . base64_encode('Bryce:ThisIsNotMyPassword'), 'basic'); - $this->_checkOK($data); - } - - public function testBasicAuthBadCreds() - { - // Ensure that credentials containing invalid characters are treated as - // a bad username or password. - - // The expected Basic WWW-Authenticate header value - $basic = 'Basic realm="' . $this->_basicConfig['realm'] . '"'; - - $data = $this->_doAuth('Basic ' . base64_encode("Bad\tChars:In:Creds"), 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testBasicAuthBadUser() - { - // Attempt Basic Authentication with a bad username and password - - // The expected Basic Proxy-Authenticate header value - $basic = 'Basic realm="' . $this->_basicConfig['realm'] . '"'; - - $data = $this->_doAuth('Basic ' . base64_encode('Nobody:NotValid'), 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testBasicAuthBadPassword() - { - // Attempt Basic Authentication with a valid username, but invalid - // password - - // The expected Basic WWW-Authenticate header value - $basic = 'Basic realm="' . $this->_basicConfig['realm'] . '"'; - - $data = $this->_doAuth('Basic ' . base64_encode('Bryce:Invalid'), 'basic'); - $this->_checkUnauthorized($data, $basic); - } - - public function testDigestAuthValidCreds() - { - // Attempt Digest Authentication with a valid username and password - - $data = $this->_doAuth($this->_digestReply('Bryce', 'ThisIsNotMyPassword'), 'digest'); - $this->_checkOK($data); - } - - public function testDigestAuthDefaultAlgo() - { - // If the client omits the aglorithm argument, it should default to MD5, - // and work just as above - - $cauth = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $cauth = preg_replace('/algorithm="MD5", /', '', $cauth); - - $data = $this->_doAuth($cauth, 'digest'); - $this->_checkOK($data); - } - - public function testDigestAuthQuotedNC() - { - // The nonce count isn't supposed to be quoted, but apparently some - // clients do anyway. - - $cauth = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $cauth = preg_replace('/nc=00000001/', 'nc="00000001"', $cauth); - - $data = $this->_doAuth($cauth, 'digest'); - $this->_checkOK($data); - } - - public function testDigestAuthBadCreds() - { - // Attempt Digest Authentication with a bad username and password - - // The expected Digest Proxy-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth($this->_digestReply('Nobody', 'NotValid'), 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testDigestTampered() - { - // Create the tampered header value - $tampered = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $tampered = preg_replace( - '/ nonce="[a-fA-F0-9]{32}", /', - ' nonce="' . str_repeat('0', 32).'", ', - $tampered - ); - - // The expected Digest Proxy-Authenticate header value - $digest = $this->_digestChallenge(); - - $data = $this->_doAuth($tampered, 'digest'); - $this->_checkUnauthorized($data, $digest); - } - - public function testBadSchemeRequest() - { - // Sending a request for an invalid authentication scheme should result - // in a 400 Bad Request response. - - $data = $this->_doAuth('Invalid ' . base64_encode('Nobody:NotValid'), 'basic'); - $this->_checkBadRequest($data); - } - - public function testBadDigestRequest() - { - // If any of the individual parts of the Digest Proxy-Authorization header - // are bad, it results in a 400 Bad Request. But that's a lot of - // possibilities, so we're just going to pick one for now. - $bad = $this->_digestReply('Bryce', 'ThisIsNotMyPassword'); - $bad = preg_replace( - '/realm="([^"]+)"/', // cut out the realm - '', $bad - ); - - $data = $this->_doAuth($bad, 'digest'); - $this->_checkBadRequest($data); - } - - /** - * Acts like a client sending the given Authenticate header value. - * - * @param string $clientHeader Authenticate header value - * @param string $scheme Which authentication scheme to use - * @return array Containing the result, the response headers, and the status - */ - public function _doAuth($clientHeader, $scheme) - { - // Set up stub request and response objects - $request = $this->getMock('Zend_Controller_Request_Http'); - $response = new Zend_Controller_Response_Http; - $response->setHttpResponseCode(200); - $response->headersSentThrowsException = false; - - // Set stub method return values - $request->expects($this->any()) - ->method('getRequestUri') - ->will($this->returnValue('/')); - $request->expects($this->any()) - ->method('getMethod') - ->will($this->returnValue('GET')); - $request->expects($this->any()) - ->method('getServer') - ->will($this->returnValue('PHPUnit')); - $request->expects($this->any()) - ->method('getHeader') - ->will($this->returnValue($clientHeader)); - - // Select an Authentication scheme - switch ($scheme) { - case 'basic': - $use = $this->_basicConfig; - break; - case 'digest': - $use = $this->_digestConfig; - break; - case 'both': - default: - $use = $this->_bothConfig; - } - - // Create the HTTP Auth adapter - $a = new Zend_Auth_Adapter_Http($use); - $a->setBasicResolver($this->_basicResolver); - $a->setDigestResolver($this->_digestResolver); - - // Send the authentication request - $a->setRequest($request); - $a->setResponse($response); - $result = $a->authenticate(); - - $return = array( - 'result' => $result, - 'status' => $response->getHttpResponseCode(), - 'headers' => $response->getHeaders() - ); - return $return; - } - - /** - * Constructs a local version of the digest challenge we expect to receive - * - * @return string - */ - protected function _digestChallenge() - { - $timeout = ceil(time() / 300) * 300; - $nonce = md5($timeout . ':PHPUnit:Zend_Auth_Adapter_Http'); - $opaque = md5('Opaque Data:Zend_Auth_Adapter_Http'); - $wwwauth = 'Digest ' - . 'realm="' . $this->_digestConfig['realm'] . '", ' - . 'domain="' . $this->_digestConfig['digest_domains'] . '", ' - . 'nonce="' . $nonce . '", ' - . 'opaque="' . $opaque . '", ' - . 'algorithm="MD5", ' - . 'qop="auth"'; - - return $wwwauth; - } - - /** - * Constructs a client digest Proxy-Authorization header - * - * @param string $user - * @param string $pass - * @return string - */ - protected function _digestReply($user, $pass) - { - $nc = '00000001'; - $timeout = ceil(time() / 300) * 300; - $nonce = md5($timeout . ':PHPUnit:Zend_Auth_Adapter_Http'); - $opaque = md5('Opaque Data:Zend_Auth_Adapter_Http'); - $cnonce = md5('cnonce'); - $response = md5(md5($user . ':' . $this->_digestConfig['realm'] . ':' . $pass) . ":$nonce:$nc:$cnonce:auth:" - . md5('GET:/')); - $cauth = 'Digest ' - . 'username="Bryce", ' - . 'realm="' . $this->_digestConfig['realm'] . '", ' - . 'nonce="' . $nonce . '", ' - . 'uri="/", ' - . 'response="' . $response . '", ' - . 'algorithm="MD5", ' - . 'cnonce="' . $cnonce . '", ' - . 'opaque="' . $opaque . '", ' - . 'qop="auth", ' - . 'nc=' . $nc; - - return $cauth; - } - - /** - * Checks for an expected 407 Proxy-Unauthorized response - * - * @param array $data Authentication results - * @param string $expected Expected Proxy-Authenticate header value - * @return void - */ - protected function _checkUnauthorized($data, $expected) - { - extract($data); // $result, $status, $headers - - // Make sure the result is false - $this->assertType('Zend_Auth_Result', $result); - $this->assertFalse($result->isValid()); - - // Verify the status code and the presence of the challenge - $this->assertEquals(407, $status); - $this->assertEquals('Proxy-Authenticate', $headers[0]['name']); - - // Check to see if the expected challenge matches the actual - $this->assertEquals($expected, $headers[0]['value']); - } - - /** - * Checks for an expected 200 OK response - * - * @param array $data Authentication results - * @return void - */ - protected function _checkOK($data) - { - extract($data); // $result, $status, $headers - - // Make sure the result is true - $this->assertType('Zend_Auth_Result', $result); - $this->assertTrue($result->isValid()); - - // Verify we got a 200 response - $this->assertEquals(200, $status); - } - - /** - * Checks for an expected 400 Bad Request response - * - * @param array $data Authentication results - * @return void - */ - protected function _checkBadRequest($data) - { - extract($data); // $result, $status, $headers - - // Make sure the result is false - $this->assertType('Zend_Auth_Result', $result); - $this->assertFalse($result->isValid()); - - // Make sure it set the right HTTP code - $this->assertEquals(400, $status); - } -} diff --git a/tests/Zend/Auth/Adapter/Http/Resolver/AllTests.php b/tests/Zend/Auth/Adapter/Http/Resolver/AllTests.php deleted file mode 100644 index a3216246a2b470108b8016f7f9199543ae0dd566..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/Resolver/AllTests.php +++ /dev/null @@ -1,84 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_Adapter_Http_Resolver_AllTests::main'); -} - - -/** - * PHPUnit_Framework_TestSuite - */ -// require_once 'PHPUnit/Framework/TestSuite.php'; - - -/** - * PHPUnit_TextUI_TestRunner - */ -// require_once 'PHPUnit/TextUI/TestRunner.php'; - - -/** - * @see Zend_Auth_Adapter_Http_Resolver_FileTest - */ -require_once 'Zend/Auth/Adapter/Http/Resolver/FileTest.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Http_Resolver_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth_Adapter_Http Resolvers'); - - $suite->addTestSuite('Zend_Auth_Adapter_Http_Resolver_FileTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Auth_Adapter_Http_Resolver_AllTests::main') { - Zend_Auth_Adapter_Http_Resolver_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/Http/Resolver/FileTest.php b/tests/Zend/Auth/Adapter/Http/Resolver/FileTest.php deleted file mode 100644 index 285987a1fdf216f358a60b01edcec5894b208b18..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/Resolver/FileTest.php +++ /dev/null @@ -1,277 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FileTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @see Zend_Auth_Adapter_Http_Resolver_File - */ -require_once 'Zend/Auth/Adapter/Http/Resolver/File.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Http_Resolver_FileTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * Path to a valid file - * - * @var string - */ - protected $_validPath; - - /** - * Invalid path; does not exist - * - * @var string - */ - protected $_badPath; - - /** - * Resolver instance - * - * @var Zend_Auth_Adapter_Http_Resolver_File - */ - protected $_resolver; - - /** - * Sets the paths to files used in this test, and creates a shared resolver instance - * having a valid path. - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(dirname(__FILE__)) . '/_files'; - $this->_validPath = "$this->_filesPath/htdigest.3"; - $this->_badPath = 'doesnotexist'; - $this->_resolver = new Zend_Auth_Adapter_Http_Resolver_File($this->_validPath); - } - - /** - * Ensures that setFile() works as expected for valid input - * - * @return void - */ - public function testSetFileValid() - { - try { - $this->_resolver->setFile($this->_validPath); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->fail('Threw exception on valid file path'); - } - $this->assertEquals($this->_validPath, $this->_resolver->getFile()); - } - - /** - * Ensures that setFile() works as expected for invalid input - * - * @return void - */ - public function testSetFileInvalid() - { - try { - $this->_resolver->setFile($this->_badPath); - $this->fail('Accepted bad path'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Path not readable', $e->getMessage()); - } - } - - /** - * Ensures that __construct() works as expected for valid input - * - * @return void - */ - public function testConstructValid() - { - try { - $v = new Zend_Auth_Adapter_Http_Resolver_File($this->_validPath); - $this->assertEquals($this->_validPath, $v->getFile()); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->fail('Constructor threw exception on valid file path'); - } - } - - /** - * Ensures that __construct() works as expected for invalid input - * - * @return void - */ - public function testConstructInvalid() - { - try { - $v = new Zend_Auth_Adapter_Http_Resolver_File($this->_badPath); - $this->fail('Constructor accepted bad path'); - } catch(Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Path not readable', $e->getMessage()); - } - } - - /** - * Ensures that resolve() works as expected for empty username - * - * @return void - */ - public function testResolveUsernameEmpty() - { - try { - $this->_resolver->resolve('', ''); - $this->fail('Accepted empty username'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertEquals('Username is required', $e->getMessage()); - } - } - - /** - * Ensures that resolve() works as expected for empty realm - * - * @return void - */ - public function testResolveRealmEmpty() - { - try { - $this->_resolver->resolve('username', ''); - $this->fail('Accepted empty realm'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertEquals('Realm is required', $e->getMessage()); - } - } - - /** - * Ensures that resolve() works as expected for invalid username - * - * @return void - */ - public function testResolveUsernameInvalid() - { - try { - $this->_resolver->resolve('bad:name', 'realm'); - $this->fail('Accepted malformed username with colon'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Username must consist', $e->getMessage()); - } - try { - $this->_resolver->resolve("badname\n", 'realm'); - $this->fail('Accepted malformed username with newline'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Username must consist', $e->getMessage()); - } - } - - /** - * Ensures that resolve() works as expected for invalid realm - * - * @return void - */ - public function testResolveRealmInvalid() - { - try { - $this->_resolver->resolve('username', 'bad:realm'); - $this->fail('Accepted malformed realm with colon'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Realm must consist', $e->getMessage()); - } - try { - $this->_resolver->resolve('username', "badrealm\n"); - $this->fail('Accepted malformed realm with newline'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Realm must consist', $e->getMessage()); - } - } - - /** - * Ensures that resolve() works as expected when a previously readable file becomes unreadable - * - * @return void - */ - public function testResolveFileDisappearsMystery() - { - if (rename("$this->_filesPath/htdigest.3", "$this->_filesPath/htdigest.3.renamed")) { - try { - $this->_resolver->resolve('username', 'realm'); - $this->fail('Expected thrown exception upon resolve() after moving valid file'); - } catch (Zend_Auth_Adapter_Http_Resolver_Exception $e) { - $this->assertContains('Unable to open password file', $e->getMessage()); - } - rename("$this->_filesPath/htdigest.3.renamed", "$this->_filesPath/htdigest.3"); - } - } - - /** - * Ensures that resolve() works as expected when provided valid credentials - * - * @return void - */ - public function testResolveValid() - { - $this->assertEquals( - $this->_resolver->resolve('Bryce', 'Test Realm'), - 'd5b7c330d5685beb782a9e22f0f20579', - 'Rejected valid credentials' - ); - } - - /** - * Ensures that resolve() works as expected when provided nonexistent realm - * - * @return void - */ - public function testResolveRealmNonexistent() - { - $this->assertFalse( - $this->_resolver->resolve('Bryce', 'nonexistent'), - 'Accepted a valid user in the wrong realm' - ); - } - - /** - * Ensures that resolve() works as expected when provided nonexistent user - * - * @return void - */ - public function testResolveUserNonexistent() - { - $this->assertFalse( - $this->_resolver->resolve('nonexistent', 'Test Realm'), - 'Accepted a nonexistent user from an existing realm' - ); - } -} diff --git a/tests/Zend/Auth/Adapter/Http/_files/htbasic.1 b/tests/Zend/Auth/Adapter/Http/_files/htbasic.1 deleted file mode 100644 index 7f18f9627fe73f9c3e233280bff9e75ce1d75f62..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/_files/htbasic.1 +++ /dev/null @@ -1,3 +0,0 @@ -Bryce:Test Realm:ThisIsNotMyPassword -Mufasa:Test Realm:Circle Of Life -Bad Chars:In:Creds diff --git a/tests/Zend/Auth/Adapter/Http/_files/htdigest.3 b/tests/Zend/Auth/Adapter/Http/_files/htdigest.3 deleted file mode 100644 index f9f4944f3483c635bad3be22f4cdf3c5b4b2ec5e..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Http/_files/htdigest.3 +++ /dev/null @@ -1,2 +0,0 @@ -Bryce:Test Realm:d5b7c330d5685beb782a9e22f0f20579 -Mufasa:Test Realm:200dc292ecb68e04c95bb74ae2ce3c80 diff --git a/tests/Zend/Auth/Adapter/Ldap/AllTests.php b/tests/Zend/Auth/Adapter/Ldap/AllTests.php deleted file mode 100644 index cfb09305006d55c883cd5e9177cfcfff469786b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Ldap/AllTests.php +++ /dev/null @@ -1,88 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_Adapter_Ldap_AllTests::main'); -} - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Auth_Adapter_Ldap_OfflineTest - */ -require_once 'Zend/Auth/Adapter/Ldap/OfflineTest.php'; - -/** - * @category Zend - * @package Zend_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Ldap_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth_Adapter_Ldap'); - - $suite->addTestSuite('Zend_Auth_Adapter_Ldap_OfflineTest'); - - if (defined('TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED') - && constant('TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED')) { - /** - * @see Zend_Auth_Adapter_Ldap_OnlineTest - */ - require_once 'Zend/Auth/Adapter/Ldap/OnlineTest.php'; - $suite->addTestSuite('Zend_Auth_Adapter_Ldap_OnlineTest'); - } else { - $suite->addTest(new Zend_Auth_Adapter_Ldap_SkipOnlineTests()); - } - - return $suite; - } -} - -class Zend_Auth_Adapter_Ldap_SkipOnlineTests extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped('Zend_Auth_Adapter_Ldap online tests not enabled in TestConfiguration.php'); - } - - public function testNothing() - { - } -} - -if (PHPUnit_MAIN_METHOD === 'Zend_Auth_Adapter_Ldap_AllTests::main') { - Zend_Auth_Adapter_Ldap_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/Ldap/OfflineTest.php b/tests/Zend/Auth/Adapter/Ldap/OfflineTest.php deleted file mode 100644 index 6ef35b20a50cae750b09c4dba62208b7f83bba63..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Ldap/OfflineTest.php +++ /dev/null @@ -1,87 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OfflineTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** - * @see Zend_Auth_Adapter_Ldap - */ -require_once 'Zend/Auth/Adapter/Ldap.php'; - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Ldap_OfflineTest extends PHPUnit_Framework_TestCase -{ - /** - * Authentication adapter instance - * - * @var Zend_Auth_Adapter_Ldap - */ - protected $_adapter = null; - - /** - * Setup operations run prior to each test method: - * - * * Creates an instance of Zend_Auth_Adapter_Ldap - * - * @return void - */ - public function setUp() - { - $this->_adapter = new Zend_Auth_Adapter_Ldap(); - } - - public function testUsernameIsNullIfNotSet() - { - $this->assertNull($this->_adapter->getUsername()); - } - - public function testPasswordIsNullIfNotSet() - { - $this->assertNull($this->_adapter->getPassword()); - } - - public function testSetAndGetUsername() - { - $usernameExpected = 'someUsername'; - $usernameActual = $this->_adapter->setUsername($usernameExpected) - ->getUsername(); - $this->assertSame($usernameExpected, $usernameActual); - } - - public function testSetAndGetPassword() - { - $passwordExpected = 'somePassword'; - $passwordActual = $this->_adapter->setPassword($passwordExpected) - ->getPassword(); - $this->assertSame($passwordExpected, $passwordActual); - } -} diff --git a/tests/Zend/Auth/Adapter/Ldap/OnlineTest.php b/tests/Zend/Auth/Adapter/Ldap/OnlineTest.php deleted file mode 100644 index 7424bd77800ee1a226b45b1f383850c97bc0eb64..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/Ldap/OnlineTest.php +++ /dev/null @@ -1,174 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OnlineTest.php 8531 2008-03-04 18:09:35Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** - * @see Zend_Ldap - */ -require_once 'Zend/Ldap.php'; - -/** - * @see Zend_Auth_Adapter_Ldap - */ -require_once 'Zend/Auth/Adapter/Ldap.php'; - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_Ldap_OnlineTest extends PHPUnit_Framework_TestCase -{ - /** - * LDAP connection options - * - * @var array - */ - protected $_options = array(); - - /** - * @var array - */ - protected $_names = array(); - - public function setUp() - { - $this->_options = array( - 'host' => TESTS_ZEND_LDAP_HOST, - 'username' => TESTS_ZEND_LDAP_USERNAME, - 'password' => TESTS_ZEND_LDAP_PASSWORD, - 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, - ); - if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT != 389) - $this->_options['port'] = TESTS_ZEND_LDAP_PORT; - if (defined('TESTS_ZEND_LDAP_USE_SSL')) - $this->_options['useSsl'] = TESTS_ZEND_LDAP_USE_SSL; - if (defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN')) - $this->_options['bindRequiresDn'] = TESTS_ZEND_LDAP_BIND_REQUIRES_DN; - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME')) - $this->_options['accountDomainName'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME; - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT')) - $this->_options['accountDomainNameShort'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT; - if (defined('TESTS_ZEND_LDAP_ALT_USERNAME')) { - $this->_names[Zend_Ldap::ACCTNAME_FORM_USERNAME] = TESTS_ZEND_LDAP_ALT_USERNAME; - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME')) { - $this->_names[Zend_Ldap::ACCTNAME_FORM_PRINCIPAL] = - TESTS_ZEND_LDAP_ALT_USERNAME . '@' . TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME; - } - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT')) { - $this->_names[Zend_Ldap::ACCTNAME_FORM_BACKSLASH] = - TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT . '\\' . TESTS_ZEND_LDAP_ALT_USERNAME; - } - } - } - - public function testSimpleAuth() - { - $adapter = new Zend_Auth_Adapter_Ldap( - array($this->_options), - TESTS_ZEND_LDAP_ALT_USERNAME, - TESTS_ZEND_LDAP_ALT_PASSWORD - ); - - $result = $adapter->authenticate(); - $this->assertTrue($result instanceof Zend_Auth_Result); - $this->assertTrue($result->isValid()); - $this->assertTrue($result->getCode() == Zend_Auth_Result::SUCCESS); - } - - public function testCanonAuth() - { - /* This test authenticates with each of the account name forms - * (uname, uname@example.com, EXAMPLE\uname) AND it does so with - * the accountCanonicalForm set to each of the account name forms - * (e.g. authenticate with uname@example.com but getIdentity() returns - * EXAMPLE\uname). A total of 9 authentications are performed. - */ - foreach ($this->_names as $form => $formName) { - $options = $this->_options; - $options['accountCanonicalForm'] = $form; - $adapter = new Zend_Auth_Adapter_Ldap(array($options)); - $adapter->setPassword(TESTS_ZEND_LDAP_ALT_PASSWORD); - foreach ($this->_names as $username) { - $adapter->setUsername($username); - $result = $adapter->authenticate(); - $this->assertTrue($result instanceof Zend_Auth_Result); - $this->assertTrue($result->isValid()); - $this->assertTrue($result->getCode() == Zend_Auth_Result::SUCCESS); - $this->assertTrue($result->getIdentity() === $formName); - } - } - } - - public function testInvalidPassAuth() - { - $adapter = new Zend_Auth_Adapter_Ldap( - array($this->_options), - TESTS_ZEND_LDAP_ALT_USERNAME, - 'invalid' - ); - - $result = $adapter->authenticate(); - $this->assertTrue($result instanceof Zend_Auth_Result); - $this->assertTrue($result->isValid() === false); - $this->assertTrue($result->getCode() == Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID); - } - - public function testInvalidUserAuth() - { - $adapter = new Zend_Auth_Adapter_Ldap( - array($this->_options), - 'invalid', - 'doesntmatter' - ); - - $result = $adapter->authenticate(); - $this->assertTrue($result instanceof Zend_Auth_Result); - $this->assertTrue($result->isValid() === false); - $this->assertTrue( - $result->getCode() == Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND || - $result->getCode() == Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID - ); - } - - public function testMismatchDomainAuth() - { - $adapter = new Zend_Auth_Adapter_Ldap( - array($this->_options), - 'EXAMPLE\\doesntmatter', - 'doesntmatter' - ); - - $result = $adapter->authenticate(); - $this->assertTrue($result instanceof Zend_Auth_Result); - $this->assertFalse($result->isValid()); - $this->assertThat($result->getCode(), $this->lessThanOrEqual(Zend_Auth_Result::FAILURE)); - $messages = $result->getMessages(); - $this->assertContains('not found', $messages[0]); - } -} diff --git a/tests/Zend/Auth/Adapter/OpenId/AllTests.php b/tests/Zend/Auth/Adapter/OpenId/AllTests.php deleted file mode 100644 index 60a6777906f168dc48330dea32925234ac9d12ae..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/OpenId/AllTests.php +++ /dev/null @@ -1,78 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_Adapter_OpenId_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** - * Zend_Auth_Adapter_OpenIdTest - */ -require_once 'Zend/Auth/Adapter/OpenId/OpenIdTest.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_OpenId_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth_Adapter_OpenId'); - - $suite->addTestSuite('Zend_Auth_Adapter_OpenIdTest'); - - return $suite; - } -} - - -if (PHPUnit_MAIN_METHOD == 'Zend_Auth_Adapter_OpenId_AllTests::main') { - Zend_Auth_Adapter_OpenId_AllTests::main(); -} diff --git a/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php b/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php deleted file mode 100644 index e79a28ac457cb9e17d502ee01a3b2fe50d039dc3..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php +++ /dev/null @@ -1,500 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OpenIdTest.php 11879 2008-10-11 19:46:33Z alexander $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Zend_OpenId_ResponseHelper - */ -require_once 'Zend/OpenId/ResponseHelper.php'; - - -/** - * Zend_OpenId_Consumer_Storage_File - */ -require_once 'Zend/OpenId/Consumer/Storage/File.php'; - - -/** - * Zend_OpenId_Extension_Sreg - */ -require_once 'Zend/OpenId/Extension/Sreg.php'; - - -/** - * @see Zend_Auth_Adapter_OpenId - */ -require_once 'Zend/Auth/Adapter/OpenId.php'; - -/** - * @see Zend_OpenId_Consumer_Storage_File - */ -require_once 'Zend/OpenId/Consumer/Storage/File.php'; - -/** - * Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_Adapter_OpenIdTest extends PHPUnit_Framework_TestCase -{ - const ID = "http://id.myopenid.com/"; - const REAL_ID = "http://real_id.myopenid.com/"; - const SERVER = "http://www.myopenid.com/"; - - const HANDLE = "d41d8cd98f00b204e9800998ecf8427e"; - const MAC_FUNC = "sha1"; - const SECRET = "\x83\x82\xae\xa9\x22\x56\x0e\xce\x83\x3b\xa5\x5f\xa5\x3b\x7a\x97\x5f\x59\x73\x70"; - - public function testAuthenticateInvalid() - { - $adapter = new Zend_Auth_Adapter_OpenId(null, new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files")); - $ret = $adapter->authenticate(); - $this->assertFalse($ret->isValid()); - } - - public function testAuthenticateLoginInvalid() - { - $adapter = new Zend_Auth_Adapter_OpenId("%sd", new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files")); - $ret = $adapter->authenticate(); - $this->assertFalse($ret->isValid()); - } - - public function testAuthenticateLoginValid() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - - $response = new Zend_OpenId_ResponseHelper(true); - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - - $adapter = new Zend_Auth_Adapter_OpenId(self::ID, $storage); - $this->assertSame($adapter, $adapter->setResponse($response)); - $ret = $adapter->authenticate(); - $this->assertTrue(is_null($ret)); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - } - - public function testSetIdentity() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - - $response = new Zend_OpenId_ResponseHelper(true); - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - - $adapter = new Zend_Auth_Adapter_OpenId(null, $storage); - $this->assertSame($adapter, $adapter->setIdentity(self::ID)); - $adapter->setResponse($response); - $ret = $adapter->authenticate(); - $this->assertTrue(is_null($ret)); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - } - - public function testSetStorage() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - - $response = new Zend_OpenId_ResponseHelper(true); - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - - $adapter = new Zend_Auth_Adapter_OpenId(self::ID); - $this->assertSame($adapter, $adapter->setStorage($storage)); - $adapter->setResponse($response); - $ret = $adapter->authenticate(); - $this->assertTrue(is_null($ret)); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - } - - public function testSetReturnTo() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - - $response = new Zend_OpenId_ResponseHelper(true); - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - - $adapter = new Zend_Auth_Adapter_OpenId(self::ID, $storage); - $adapter->setResponse($response); - $this->assertSame($adapter, $adapter->setReturnTo("http://www.zf-test.com/return.php")); - $ret = $adapter->authenticate(); - $this->assertTrue(is_null($ret)); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Freturn.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - } - - public function testSetRoot() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - - $response = new Zend_OpenId_ResponseHelper(true); - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - - $adapter = new Zend_Auth_Adapter_OpenId(self::ID, $storage); - $adapter->setResponse($response); - $this->assertSame($adapter, $adapter->setRoot("http://www.zf-test.com/root.php")); - $ret = $adapter->authenticate(); - $this->assertTrue(is_null($ret)); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Froot.php', $query['openid.trust_root'] ); - } - - public function testAuthenticateVerifyInvalid() - { - unset($_SERVER['REQUEST_METHOD']); - $_GET = array('openid_mode'=>'id_res'); - $adapter = new Zend_Auth_Adapter_OpenId(null, new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files")); - $ret = $adapter->authenticate(); - $this->assertFalse($ret->isValid()); - } - - public function testAuthenticateVerifyGetValid() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - $storage->purgeNonces(); - - unset($_SERVER['REQUEST_METHOD']); - $_GET = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $adapter = new Zend_Auth_Adapter_OpenId(null, $storage); - $ret = $adapter->authenticate(); - $this->assertTrue($ret->isValid()); - } - - public function testAuthenticateVerifyPostValid() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - $storage->purgeNonces(); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_GET = array(); - $_POST = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $adapter = new Zend_Auth_Adapter_OpenId(null, $storage); - $ret = $adapter->authenticate(); - $this->assertTrue($ret->isValid()); - } - - public function testSetExtensions() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $this->assertTrue( $storage->delDiscoveryInfo(self::ID) ); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 2.0, $expiresIn) ); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - $storage->purgeNonces(); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $_GET = array( - "openid_ns" => Zend_OpenId::NS_2_0, - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_op_endpoint" => self::SERVER, - "openid_mode" => "id_res", - "openid_ns_sreg" => "http://openid.net/extensions/sreg/1.1", - "openid_sreg_nickname" => "test", - "openid_signed" => "ns,assoc_handle,return_to,claimed_id,identity,response_nonce,mode,ns.sreg,sreg.nickname,signed", - "openid_sig" => "jcV5K517GrjOxjRzi0QNLX2D+1s=" - ); - $_POST = array(); - $adapter = new Zend_Auth_Adapter_OpenId(null, $storage); - $sreg= new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>false)); - $this->assertSame($adapter, $adapter->setExtensions($sreg)); - $ret = $adapter->authenticate(); - $this->assertTrue($ret->isValid()); - $sreg_data = $sreg->getProperties(); - $this->assertSame("test", $sreg_data['nickname']); - } - - function testSetCheckImmediate() { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn); - - $response = new Zend_OpenId_ResponseHelper(true); - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - - $adapter = new Zend_Auth_Adapter_OpenId(self::ID, $storage); - $adapter->setCheckImmediate(true); - $this->assertSame($adapter, $adapter->setResponse($response)); - $ret = $adapter->authenticate(); - $this->assertTrue(is_null($ret)); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_immediate', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - } - - function testSetHttpClient() { - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $storage->delAssociation(self::SERVER); - $adapter = new Zend_Auth_Adapter_OpenId(self::ID, $storage); - $http = new Zend_Http_Client(null, - array( - 'maxredirects' => 4, - 'timeout' => 15, - 'useragent' => 'Zend_OpenId' - )); - $test = new Zend_Http_Client_Adapter_Test(); - $http->setAdapter($test); - $adapter->SetHttpClient($http); - $ret = $adapter->authenticate(); - $this->assertSame("GET / HTTP/1.1\r\n". - "Host: id.myopenid.com\r\n". - "Connection: close\r\n". - "Accept-encoding: gzip, deflate\r\n". - "User-Agent: Zend_OpenId\r\n\r\n", - $http->getLastRequest()); - } - -} diff --git a/tests/Zend/Auth/Adapter/OpenId/ResponseHelper.php b/tests/Zend/Auth/Adapter/OpenId/ResponseHelper.php deleted file mode 100644 index 36066543213f7341e37a61655123b7f17521107b..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/Adapter/OpenId/ResponseHelper.php +++ /dev/null @@ -1,50 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ResponseHelper.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId.php'; - -Zend_OpenId::$exitOnRedirect = false; - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_ResponseHelper extends Zend_Controller_Response_Abstract -{ - private $_canSendHeaders; - - public function __construct($canSendHeaders) - { - $this->_canSendHeaders = $canSendHeaders; - } - - public function canSendHeaders($throw = false) - { - return $this->_canSendHeaders; - } - - public function sendResponse() - { - } -} diff --git a/tests/Zend/Auth/AllTests.php b/tests/Zend/Auth/AllTests.php deleted file mode 100644 index 25f2250108eca70de2f3094b026e4c86fc23aa95..0000000000000000000000000000000000000000 --- a/tests/Zend/Auth/AllTests.php +++ /dev/null @@ -1,84 +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_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Auth_AllTests::main'); -} - - -/** - * PHPUnit_Framework_TestSuite - */ -// require_once 'PHPUnit/Framework/TestSuite.php'; - - -/** - * PHPUnit_TextUI_TestRunner - */ -// require_once 'PHPUnit/TextUI/TestRunner.php'; - - -/** - * @see Zend_Auth_Adapter_AllTests - */ -require_once 'Zend/Auth/Adapter/AllTests.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Auth_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Auth'); - - $suite->addTest(Zend_Auth_Adapter_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Auth_AllTests::main') { - Zend_Auth_AllTests::main(); -} diff --git a/tests/Zend/AuthTest.php b/tests/Zend/AuthTest.php deleted file mode 100644 index 5e94cb1c68442c8885ede31aef986635868dfc4d..0000000000000000000000000000000000000000 --- a/tests/Zend/AuthTest.php +++ /dev/null @@ -1,110 +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_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * Start output buffering to prevent problems using session - */ -ob_start(); - - -/** - * @see Zend_Auth - */ -require_once 'Zend/Auth.php'; - - -/** - * @see Zend_Auth_Adapter_Interface - */ -require_once 'Zend/Auth/Adapter/Interface.php'; - - -/** - * @category Zend - * @package Zend_Auth - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_AuthTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the Singleton pattern is implemented properly - * - * @return void - */ - public function testSingleton() - { - $this->assertTrue(Zend_Auth::getInstance() instanceof Zend_Auth); - $this->assertEquals(Zend_Auth::getInstance(), Zend_Auth::getInstance()); - } - - /** - * Ensures that getStorage() returns Zend_Auth_Storage_Session - * - * @return void - */ - public function testGetStorage() - { - $this->assertTrue(Zend_Auth::getInstance()->getStorage() instanceof Zend_Auth_Storage_Session); - } - - /** - * Ensures expected behavior for successful authentication - * - * @return void - */ - public function testAuthenticate() - { - $auth = Zend_Auth::getInstance(); - $result = $auth->authenticate(new Zend_AuthTest_Success_Adapter()); - $this->assertTrue($result instanceof Zend_Auth_Result); - $this->assertTrue($auth->hasIdentity()); - $this->assertEquals('someIdentity', $auth->getIdentity()); - } - - /** - * Ensures expected behavior for clearIdentity() - * - * @return void - */ - public function testClearIdentity() - { - $auth = Zend_Auth::getInstance(); - $auth->clearIdentity(); - $this->assertFalse($auth->hasIdentity()); - $this->assertEquals(null, $auth->getIdentity()); - } -} - - -class Zend_AuthTest_Success_Adapter implements Zend_Auth_Adapter_Interface -{ - public function authenticate() - { - return new Zend_Auth_Result(true, 'someIdentity'); - } -} diff --git a/tests/Zend/Cache/AllTests.php b/tests/Zend/Cache/AllTests.php deleted file mode 100644 index 83185ce206c59d0a0c642edffe4b04530d44f1a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/AllTests.php +++ /dev/null @@ -1,168 +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_Cache - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Cache_AllTests::main'); -} - -require_once 'Zend/Cache/FactoryTest.php'; -require_once 'Zend/Cache/CoreTest.php'; -require_once 'Zend/Cache/FileBackendTest.php'; -require_once 'Zend/Cache/SqliteBackendTest.php'; -require_once 'Zend/Cache/OutputFrontendTest.php'; -require_once 'Zend/Cache/FunctionFrontendTest.php'; -require_once 'Zend/Cache/ClassFrontendTest.php'; -require_once 'Zend/Cache/FileFrontendTest.php'; -require_once 'Zend/Cache/ApcBackendTest.php'; -require_once 'Zend/Cache/XcacheBackendTest.php'; -require_once 'Zend/Cache/MemcachedBackendTest.php'; -require_once 'Zend/Cache/PageFrontendTest.php'; -require_once 'Zend/Cache/ZendPlatformBackendTest.php'; -require_once 'Zend/Cache/SkipTests.php'; - -/** - * @category Zend - * @package Zend_Cache - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Cache_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Cache'); - - $suite->addTestSuite('Zend_Cache_FactoryTest'); - $suite->addTestSuite('Zend_Cache_CoreTest'); - $suite->addTestSuite('Zend_Cache_FileBackendTest'); - $suite->addTestSuite('Zend_Cache_OutputFrontendTest'); - $suite->addTestSuite('Zend_Cache_FunctionFrontendTest'); - $suite->addTestSuite('Zend_Cache_ClassFrontendTest'); - $suite->addTestSuite('Zend_Cache_FileFrontendTest'); - $suite->addTestSuite('Zend_Cache_PageFrontendTest'); - - /* - * Check if SQLite tests are enabled, and if extension and driver are available. - */ - if (!defined('TESTS_ZEND_CACHE_SQLITE_ENABLED') || - constant('TESTS_ZEND_CACHE_SQLITE_ENABLED') === false) { - $skipTest = new Zend_Cache_SqliteBackendTest_SkipTests(); - $skipTest->message = 'Tests are not enabled in TestConfiguration.php'; - $suite->addTest($skipTest); - } else if (!extension_loaded('sqlite')) { - $skipTest = new Zend_Cache_SqliteBackendTest_SkipTests(); - $skipTest->message = "Extension 'sqlite' is not loaded"; - $suite->addTest($skipTest); - } else { - $suite->addTestSuite('Zend_Cache_SqliteBackendTest'); - } - - /* - * Check if APC tests are enabled, and if extension is available. - */ - if (!defined('TESTS_ZEND_CACHE_APC_ENABLED') || - constant('TESTS_ZEND_CACHE_APC_ENABLED') === false) { - $skipTest = new Zend_Cache_ApcBackendTest_SkipTests(); - $skipTest->message = 'Tests are not enabled in TestConfiguration.php'; - $suite->addTest($skipTest); - } else if (!extension_loaded('apc')) { - $skipTest = new Zend_Cache_ApcBackendTest_SkipTests(); - $skipTest->message = "Extension 'APC' is not loaded"; - $suite->addTest($skipTest); - } else { - $suite->addTestSuite('Zend_Cache_ApcBackendTest'); - } - - /* - * Check if Xcache tests are enabled, and if extension is available. - */ - if (!defined('TESTS_ZEND_CACHE_XCACHE_ENABLED') || - constant('TESTS_ZEND_CACHE_XCACHE_ENABLED') === false) { - $skipTest = new Zend_Cache_XCacheBackendTest_SkipTests(); - $skipTest->message = 'Tests are not enabled in TestConfiguration.php'; - $suite->addTest($skipTest); - } else if (!extension_loaded('xcache')) { - $skipTest = new Zend_Cache_XCacheBackendTest_SkipTests(); - $skipTest->message = "Extension 'XCache' is not loaded"; - $suite->addTest($skipTest); - } else { - $suite->addTestSuite('Zend_Cache_XCacheBackendTest'); - } - - /* - * Check if Memcached tests are enabled, and if extension is available. - */ - if (!defined('TESTS_ZEND_CACHE_MEMCACHED_ENABLED') || - constant('TESTS_ZEND_CACHE_MEMCACHED_ENABLED') === false) { - $skipTest = new Zend_Cache_MemcachedBackendTest_SkipTests(); - $skipTest->message = 'Tests are not enabled in TestConfiguration.php'; - $suite->addTest($skipTest); - } else if (!extension_loaded('memcache')) { - $skipTest = new Zend_Cache_MemcachedBackendTest_SkipTests(); - $skipTest->message = "Extension 'APC' is not loaded"; - $suite->addTest($skipTest); - } else { - if (!defined('TESTS_ZEND_CACHE_MEMCACHED_HOST')) { - define('TESTS_ZEND_CACHE_MEMCACHED_HOST', '127.0.0.1'); - } - if (!defined('TESTS_ZEND_CACHE_MEMCACHED_PORT')) { - define('TESTS_ZEND_CACHE_MEMCACHED_PORT', 11211); - } - if (!defined('TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT')) { - define('TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT', true); - } - $suite->addTestSuite('Zend_Cache_MemcachedBackendTest'); - } - - /* - * Check if Zend Platform tests are enabled, and if extension is available. - */ - if (!defined('TESTS_ZEND_CACHE_PLATFORM_ENABLED') || - constant('TESTS_ZEND_CACHE_PLATFORM_ENABLED') === false) { - $skipTest = new Zend_Cache_ZendPlatformBackendTest_SkipTests(); - $skipTest->message = 'Tests are not enabled in TestConfiguration.php'; - $suite->addTest($skipTest); - } else if (!function_exists('accelerator_license_info')) { - $skipTest = new Zend_Cache_ZendPlatformBackendTest_SkipTests(); - $skipTest->message = 'Extension for Zend Platform is not loaded'; - $suite->addTest($skipTest); - } else { - $suite->addTestSuite('Zend_Cache_ZendPlatformBackendTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Cache_AllTests::main') { - Zend_Cache_AllTests::main(); -} diff --git a/tests/Zend/Cache/ApcBackendTest.php b/tests/Zend/Cache/ApcBackendTest.php deleted file mode 100644 index 16f5a2fd0195368cf83308b93f19861636c8b339..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/ApcBackendTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Backend/Apc.php'; - -/** - * Common tests for backends - */ -require_once 'CommonBackendTest.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_ApcBackendTest extends Zend_Cache_CommonBackendTest { - - protected $_instance; - - public function __construct() - { - parent::__construct('Zend_Cache_Backend_Apc'); - } - - public function setUp($notag = true) - { - $this->_instance = new Zend_Cache_Backend_Apc(array()); - parent::setUp($notag); - } - - public function tearDown() - { - parent::tearDown(); - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Backend_Apc(); - } - - public function testCleanModeOld() { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('old'); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testCleanModeMatchingTags() { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('matchingTag', array('tag1')); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testCleanModeNotMatchingTags() { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('notMatchingTag', array('tag1')); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - // Because of limitations of this backend... - public function testGetWithAnExpiredCacheId() {} - public function testCleanModeMatchingTags2() {} - public function testCleanModeNotMatchingTags2() {} - public function testCleanModeNotMatchingTags3() {} - public function testSaveCorrectCall() - { - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveCorrectCall(); - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testSaveWithNullLifeTime() - { - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveWithNullLifeTime(); - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testSaveWithSpecificLifeTime() - { - - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveWithSpecificLifeTime(); - $this->_instance->setDirectives(array('logging' => true)); - } - -} - - diff --git a/tests/Zend/Cache/ClassFrontendTest.php b/tests/Zend/Cache/ClassFrontendTest.php deleted file mode 100644 index d7bbce711d82ca8460ce662a39e6022c97852da9..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/ClassFrontendTest.php +++ /dev/null @@ -1,209 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Frontend/Class.php'; -require_once 'Zend/Cache/Backend/Test.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -class test { - - private $_string = 'hello !'; - - public static function foobar($param1, $param2) { - echo "foobar_output($param1, $param2)"; - return "foobar_return($param1, $param2)"; - } - - public function foobar2($param1, $param2) { - echo($this->_string); - echo "foobar2_output($param1, $param2)"; - return "foobar2_return($param1, $param2)"; - } - -} - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_ClassFrontendTest extends PHPUnit_Framework_TestCase { - - private $_instance1; - private $_instance2; - - public function setUp() - { - if (!$this->_instance1) { - $options1 = array( - 'cached_entity' => 'test' - ); - $this->_instance1 = new Zend_Cache_Frontend_Class($options1); - $this->_backend1 = new Zend_Cache_Backend_Test(); - $this->_instance1->setBackend($this->_backend1); - } - if (!$this->_instance2) { - $options2 = array( - 'cached_entity' => new test() - ); - $this->_instance2 = new Zend_Cache_Frontend_Class($options2); - $this->_backend2 = new Zend_Cache_Backend_Test(); - $this->_instance2->setBackend($this->_backend2); - } - } - - public function tearDown() - { - unset($this->_instance1); - unset($this->_instance2); - } - - public function testConstructorCorrectCall1() - { - $options = array( - 'cache_by_default' => false, - 'cached_entity' => 'test' - ); - $test = new Zend_Cache_Frontend_Class($options); - } - - public function testConstructorCorrectCall2() - { - $options = array( - 'cache_by_default' => false, - 'cached_entity' => new test() - ); - $test = new Zend_Cache_Frontend_Class($options); - } - - public function testConstructorBadCall() - { - $options = array( - 'cache_by_default' => true - ); - try { - $test = new Zend_Cache_Frontend_Class($options); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testCallCorrectCall1() - { - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance1->foobar('param1', 'param2'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('bar', $return); - $this->assertEquals('foo', $data); - } - - public function testCallCorrectCall2() - { - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance1->foobar('param3', 'param4'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar_return(param3, param4)', $return); - $this->assertEquals('foobar_output(param3, param4)', $data); - } - - public function testCallCorrectCall3() - { - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance2->foobar2('param1', 'param2'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('bar', $return); - $this->assertEquals('foo', $data); - } - - public function testCallCorrectCall4() - { - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance2->foobar2('param3', 'param4'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar2_return(param3, param4)', $return); - $this->assertEquals('hello !foobar2_output(param3, param4)', $data); - } - - public function testCallCorrectCall5() - { - // cacheByDefault = false - $this->_instance1->setOption('cache_by_default', false); - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance1->foobar('param1', 'param2'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar_return(param1, param2)', $return); - $this->assertEquals('foobar_output(param1, param2)', $data); - } - - public function testCallCorrectCall6() - { - // cacheByDefault = false - // cachedMethods = array('foobar') - $this->_instance1->setOption('cache_by_default', false); - $this->_instance1->setOption('cached_methods', array('foobar')); - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance1->foobar('param1', 'param2'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('bar', $return); - $this->assertEquals('foo', $data); - } - - public function testCallCorrectCall7() - { - // cacheByDefault = true - // nonCachedMethods = array('foobar') - $this->_instance1->setOption('cache_by_default', true); - $this->_instance1->setOption('non_cached_methods', array('foobar')); - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance1->foobar('param1', 'param2'); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar_return(param1, param2)', $return); - $this->assertEquals('foobar_output(param1, param2)', $data); - } - - public function testConstructorWithABadCachedEntity() - { - try { - $options = array( - 'cached_entity' => array() - ); - $instance = new Zend_Cache_Frontend_Class($options); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } -} - diff --git a/tests/Zend/Cache/CommonBackendTest.php b/tests/Zend/Cache/CommonBackendTest.php deleted file mode 100644 index 34d0e7218b9706c08fde179db1e4db8f118cf766..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/CommonBackendTest.php +++ /dev/null @@ -1,268 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_CommonBackendTest extends PHPUnit_Framework_TestCase { - - protected $_instance; - protected $_className; - protected $_root; - - public function __construct($className) - { - $this->_className = $className; - $this->_root = dirname(__FILE__); - date_default_timezone_set('UTC'); - } - - public function setUp($notag = false) - { - $this->mkdir(); - $this->_instance->setDirectives(array('logging' => true)); - if ($notag) { - $this->_instance->save('bar : data to cache', 'bar'); - $this->_instance->save('bar2 : data to cache', 'bar2'); - $this->_instance->save('bar3 : data to cache', 'bar3'); - } else { - $this->_instance->save('bar : data to cache', 'bar', array('tag3', 'tag4')); - $this->_instance->save('bar2 : data to cache', 'bar2', array('tag3', 'tag1')); - $this->_instance->save('bar3 : data to cache', 'bar3', array('tag2', 'tag3')); - } - } - - public function mkdir() - { - @mkdir($this->getTmpDir()); - } - - public function rmdir() - { - $tmpDir = $this->getTmpDir(false); - foreach (glob("$tmpDir*") as $dirname) { - @rmdir($dirname); - } - } - - public function getTmpDir($date = true) - { - $suffix = ''; - if ($date) { - $suffix = date('mdyHis'); - } - if (is_writeable($this->_root)) { - return $this->_root . DIRECTORY_SEPARATOR . 'zend_cache_tmp_dir_' . $suffix; - } else { - if (getenv('TMPDIR')){ - return getenv('TMPDIR') . DIRECTORY_SEPARATOR . 'zend_cache_tmp_dir_' . $suffix; - } else { - die("no writable tmpdir found"); - } - } - } - - public function tearDown() - { - $this->_instance->clean(); - $this->rmdir(); - } - - public function testConstructorCorrectCall() - { - $this->fail('PLEASE IMPLEMENT A testConstructorCorrectCall !!!'); - } - - public function testConstructorBadOption() - { - try { - $class = $this->_className; - $test = new $class(array('foo' => 'bar')); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSetDirectivesCorrectCall() - { - $this->_instance->setDirectives(array('lifetime' => 3600, 'logging' => true)); - } - - public function testSetDirectivesBadArgument() - { - try { - $this->_instance->setDirectives('foo'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSetDirectivesBadDirective() - { - // A bad directive (not known by a specific backend) is possible - // => so no exception here - $this->_instance->setDirectives(array('foo' => true, 'lifetime' => 3600)); - } - - public function testSetDirectivesBadDirective2() - { - try { - $this->_instance->setDirectives(array('foo' => true, 12 => 3600)); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveCorrectCall() - { - $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2')); - $this->assertTrue($res); - } - - public function testSaveWithNullLifeTime() - { - $this->_instance->setDirectives(array('lifetime' => null)); - $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2')); - $this->assertTrue($res); - } - - public function testSaveWithSpecificLifeTime() - { - $this->_instance->setDirectives(array('lifetime' => 3600)); - $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2'), 10); - $this->assertTrue($res); - } - - public function testRemoveCorrectCall() - { - $this->assertTrue($this->_instance->remove('bar')); - $this->assertFalse($this->_instance->test('bar')); - $this->assertFalse($this->_instance->remove('barbar')); - $this->assertFalse($this->_instance->test('barbar')); - } - - public function testTestWithAnExistingCacheId() - { - $res = $this->_instance->test('bar'); - if (!$res) { - $this->fail('test() return false'); - } - if (!($res > 999999)) { - $this->fail('test() return an incorrect integer'); - } - return; - } - - public function testTestWithANonExistingCacheId() - { - $this->assertFalse($this->_instance->test('barbar')); - } - - public function testTestWithAnExistingCacheIdAndANullLifeTime() - { - $this->_instance->setDirectives(array('lifetime' => null)); - $res = $this->_instance->test('bar'); - if (!$res) { - $this->fail('test() return false'); - } - if (!($res > 999999)) { - $this->fail('test() return an incorrect integer'); - } - return; - } - - public function testGetWithANonExistingCacheId() - { - $this->assertFalse($this->_instance->load('barbar')); - } - - public function testGetWithAnExistingCacheId() - { - $this->assertEquals('bar : data to cache', $this->_instance->load('bar')); - } - - public function testGetWithAnExistingCacheIdAndUTFCharacters() - { - $data = '"""""' . "'" . '\n' . 'ééééé'; - $this->_instance->save($data, 'foo'); - $this->assertEquals($data, $this->_instance->load('foo')); - } - - public function testGetWithAnExpiredCacheId() - { - $this->_instance->___expire('bar'); - $this->_instance->setDirectives(array('lifetime' => -1)); - $this->assertFalse($this->_instance->load('bar')); - $this->assertEquals('bar : data to cache', $this->_instance->load('bar', true)); - } - - public function testCleanModeAll() - { - $this->assertTrue($this->_instance->clean('all')); - $this->assertFalse($this->_instance->test('bar')); - $this->assertFalse($this->_instance->test('bar2')); - } - - public function testCleanModeOld() - { - $this->_instance->___expire('bar2'); - $this->assertTrue($this->_instance->clean('old')); - $this->assertTrue($this->_instance->test('bar') > 999999); - $this->assertFalse($this->_instance->test('bar2')); - } - - public function testCleanModeMatchingTags() - { - $this->assertTrue($this->_instance->clean('matchingTag', array('tag3'))); - $this->assertFalse($this->_instance->test('bar')); - $this->assertFalse($this->_instance->test('bar2')); - } - - public function testCleanModeMatchingTags2() - { - $this->assertTrue($this->_instance->clean('matchingTag', array('tag3', 'tag4'))); - $this->assertFalse($this->_instance->test('bar')); - $this->assertTrue($this->_instance->test('bar2') > 999999); - } - - public function testCleanModeNotMatchingTags() - { - $this->assertTrue($this->_instance->clean('notMatchingTag', array('tag3'))); - $this->assertTrue($this->_instance->test('bar') > 999999); - $this->assertTrue($this->_instance->test('bar2') > 999999); - } - - public function testCleanModeNotMatchingTags2() - { - $this->assertTrue($this->_instance->clean('notMatchingTag', array('tag4'))); - $this->assertTrue($this->_instance->test('bar') > 999999); - $this->assertFalse($this->_instance->test('bar2')); - } - - public function testCleanModeNotMatchingTags3() - { - $this->assertTrue($this->_instance->clean('notMatchingTag', array('tag4', 'tag1'))); - $this->assertTrue($this->_instance->test('bar') > 999999); - $this->assertTrue($this->_instance->test('bar2') > 999999); - $this->assertFalse($this->_instance->test('bar3')); - } - -} - - diff --git a/tests/Zend/Cache/CoreTest.php b/tests/Zend/Cache/CoreTest.php deleted file mode 100644 index 41e4d9b9b249e8001db2cfbd4660129d2166e092..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/CoreTest.php +++ /dev/null @@ -1,430 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Core.php'; -require_once 'Zend/Cache/Backend/File.php'; // TODO : use only Test backend ? -require_once 'Zend/Cache/Backend/Test.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_CoreTest extends PHPUnit_Framework_TestCase { - - private $_instance; - - public function setUp() - { - if (!$this->_instance) { - $this->_instance = new Zend_Cache_Core(array()); - $this->_backend = new Zend_Cache_Backend_Test(); - $this->_instance->setBackend($this->_backend); - } - } - - public function tearDown() - { - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Core(array('lifetime' => 3600, 'caching' => true)); - } - - public function testConstructorBadOption() - { - try { - $test = new Zend_Cache_Core(array('foo' => 'bar', 'lifetime' => 3600)); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSetLifeTime() - { - $this->_instance->setLifeTime(3600); - } - - public function testSetBackendCorrectCall1() - { - $backend = new Zend_Cache_Backend_File(array()); - $this->_instance->setBackend($backend); - } - - public function testSetBackendCorrectCall2() - { - $backend = new Zend_Cache_Backend_Test(array()); - $this->_instance->setBackend($backend); - $log = $backend->getLastLog(); - $this->assertEquals('setDirectives', $log['methodName']); - $this->assertType('array', $log['args'][0]); - } - - public function testSetOptionCorrectCall() - { - $this->_instance->setOption('caching', false); - } - - public function testSetOptionBadCall() - { - try { - $this->_instance->setOption(array('lifetime'), 1200); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSetOptionUnknownOption() - { - try { - $this->_instance->setOption('foo', 1200); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveCorrectBadCall1() - { - try { - $this->_instance->save('data', 'foo bar'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveCorrectBadCall2() - { - try { - $this->_instance->save('data', 'foobar', array('tag1', 'foo bar')); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveCorrectBadCall3() - { - try { - $this->_instance->save(array('data'), 'foobar'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveWithABadCacheId() - { - try { - $this->_instance->save(array('data'), true); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveWithABadCacheId2() - { - try { - $this->_instance->save(array('data'), 'internal_foo'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveWithABadTags() - { - try { - $this->_instance->save(array('data'), 'foo', 'foobar'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testSaveCorrectCallNoCaching() - { - $i1 = $this->_backend->getLogIndex(); - $this->_instance->setOption('caching', false); - $res = $this->_instance->save('data', 'foo'); - $i2 = $this->_backend->getLogIndex(); - $this->assertTrue($res); - $this->assertEquals($i1, $i2); - } - - public function testSaveCorrectCallNoWriteControl() - { - $this->_instance->setOption('write_control', false); - $res = $this->_instance->save('data', 'foo', array('tag1', 'tag2')); - $log = $this->_backend->getLastLog(); - $expected = array( - 'methodName' => 'save', - 'args' => array( - 0 => 'data', - 1 => 'foo', - 2 => array( - 0 => 'tag1', - 1 => 'tag2' - ) - ) - ); - $this->assertEquals($expected, $log); - } - - public function testSaveCorrectCall() - { - $res = $this->_instance->save('data', 'foo', array('tag1', 'tag2')); - $logs = $this->_backend->getAllLogs(); - $expected1 = array( - 'methodName' => 'save', - 'args' => array( - 0 => 'data', - 1 => 'foo', - 2 => array( - 0 => 'tag1', - 1 => 'tag2' - ) - ) - ); - $expected2 = array( - 'methodName' => 'get', - 'args' => array( - 0 => 'foo', - 1 => true - ) - ); - $expected3 = array( - 'methodName' => 'remove', - 'args' => array( - 0 => 'foo' - ) - ); - $this->assertFalse($res); - $this->assertEquals($expected1, $logs[count($logs) - 3]); - $this->assertEquals($expected2, $logs[count($logs) - 2]); - $this->assertEquals($expected3, $logs[count($logs) - 1]); - } - - public function testSaveCorrectCallButFileCorruption() - { - $res = $this->_instance->save('data', 'false', array('tag1', 'tag2')); - $logs = $this->_backend->getAllLogs(); - $expected1 = array( - 'methodName' => 'save', - 'args' => array( - 0 => 'data', - 1 => 'false', - 2 => array( - 0 => 'tag1', - 1 => 'tag2' - ) - ) - ); - $expected2 = array( - 'methodName' => 'remove', - 'args' => array( - 0 => 'false' - ) - ); - $this->assertFalse($res); - $this->assertEquals($expected1, $logs[count($logs) - 2]); - $this->assertEquals($expected2, $logs[count($logs) - 1]); - } - - public function testSaveCorrectCallWithAutomaticCleaning() - { - $this->_instance->setOption('automatic_cleaning_factor', 1); - $res = $this->_instance->save('data', 'false', array('tag1', 'tag2')); - $logs = $this->_backend->getAllLogs(); - $expected = array( - 'methodName' => 'clean', - 'args' => array( - 0 => 'old', - 1 => array() - ) - ); - $this->assertFalse($res); - $this->assertEquals($expected, $logs[count($logs) - 3]); - } - - public function testTestCorrectCallNoCaching() - { - $i1 = $this->_backend->getLogIndex(); - $this->_instance->setOption('caching', false); - $res = $this->_instance->test('foo'); - $i2 = $this->_backend->getLogIndex(); - $this->assertFalse($res); - $this->assertEquals($i1, $i2); - } - - public function testTestBadCall() - { - try { - $this->_instance->test('foo bar'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testTestCorrectCall1() - { - $res = $this->_instance->test('foo'); - $log = $this->_backend->getLastLog(); - $expected = array( - 'methodName' => 'test', - 'args' => array( - 0 => 'foo' - ) - ); - $this->assertEquals(123456, $res); - $this->assertEquals($expected, $log); - } - - public function testTestCorrectCall2() - { - $res = $this->_instance->test('false'); - $this->assertFalse($res); - } - - public function testGetCorrectCallNoCaching() - { - $i1 = $this->_backend->getLogIndex(); - $this->_instance->setOption('caching', false); - $res = $this->_instance->load('foo'); - $i2 = $this->_backend->getLogIndex(); - $this->assertFalse($res); - $this->assertEquals($i1, $i2); - } - - public function testGetBadCall() - { - try { - $res = $this->_instance->load('foo bar'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testGetCorrectCall1() - { - $res = $this->_instance->load('false'); - $this->assertFalse($res); - } - - public function testGetCorrectCall2() - { - $res = $this->_instance->load('bar'); - $this->assertEquals('foo', 'foo'); - } - - public function testGetCorrectCallWithAutomaticSerialization() - { - $this->_instance->setOption('automatic_serialization', true); - $res = $this->_instance->load('serialized'); - $this->assertEquals(array('foo'), $res); - } - - public function testRemoveBadCall() - { - try { - $res = $this->_instance->remove('foo bar'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testRemoveCorrectCallNoCaching() - { - $i1 = $this->_backend->getLogIndex(); - $this->_instance->setOption('caching', false); - $res = $this->_instance->remove('foo'); - $i2 = $this->_backend->getLogIndex(); - $this->assertTrue($res); - $this->assertEquals($i1, $i2); - } - - public function testRemoveCorrectCall() - { - $res = $this->_instance->remove('foo'); - $log = $this->_backend->getLastLog(); - $expected = array( - 'methodName' => 'remove', - 'args' => array( - 0 => 'foo' - ) - ); - $this->assertTrue($res); - $this->assertEquals($expected, $log); - } - - public function testCleanBadCall1() - { - try { - $res = $this->_instance->clean('matchingTag', array('foo bar', 'foo')); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testCleanBadCall2() - { - try { - $res = $this->_instance->clean('foo'); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testCleanCorrectCallNoCaching() - { - $i1 = $this->_backend->getLogIndex(); - $this->_instance->setOption('caching', false); - $res = $this->_instance->clean('all'); - $i2 = $this->_backend->getLogIndex(); - $this->assertTrue($res); - $this->assertEquals($i1, $i2); - } - - public function testCleanCorrectCall() - { - $res = $this->_instance->clean('matchingTag', array('tag1', 'tag2')); - $log = $this->_backend->getLastLog(); - $expected = array( - 'methodName' => 'clean', - 'args' => array( - 0 => 'matchingTag', - 1 => array( - 0 => 'tag1', - 1 => 'tag2' - ) - ) - ); - $this->assertTrue($res); - $this->assertEquals($expected, $log); - } - -} - - diff --git a/tests/Zend/Cache/FactoryException.php b/tests/Zend/Cache/FactoryException.php deleted file mode 100644 index 80ac19c3bd9cd4085047ccc4708131a76a6a3d5e..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/FactoryException.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -// require_once 'PHPUnit/Extensions/ExceptionTestCase.php'; -require_once 'Zend/Cache.php'; - -class Zend_Cache_FactoryException extends PHPUnit_Extensions_ExceptionTestCase -{ - function setUp(){ - $this->setExpectedException('Zend_Cache_Exception'); - } - - public function testBadFrontend() - { - Zend_Cache::factory('badFrontend', 'File'); - } - - public function testBadBackend() - { - Zend_Cache::factory('Output', 'badBackend'); - } - - public function testFrontendBadParam() - { - Zend_Cache::factory('badFrontend', 'File', array('badParam'=>true)); - } - - public function testBackendBadParam() - { - Zend_Cache::factory('Output', 'badBackend', array(), array('badParam'=>true)); - } - - public function testThrowMethod() - { - Zend_Cache::throwException('test'); - } -} diff --git a/tests/Zend/Cache/FactoryTest.php b/tests/Zend/Cache/FactoryTest.php deleted file mode 100644 index 3f27caf25c84a76448d7978b3f408332be7e2974..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/FactoryTest.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - -/** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_FactoryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - } - - public function tearDown() - { - } - - public function testFactoryCorrectCall() - { - $generated_frontend = Zend_Cache::factory('Core', 'File'); - $this->assertEquals('Zend_Cache_Core', get_class($generated_frontend)); - } - - public function testFactoryLoadsPlatformBackend() - { - try { - $cache = Zend_Cache::factory('Core', 'Zend-Platform'); - } catch (Zend_Cache_Exception $e) { - $message = $e->getMessage(); - if (strstr($message, 'Incorrect backend')) { - $this->fail('Zend Platform is a valid backend'); - } - } - } - - public function testBadFrontend() - { - try { - Zend_Cache::factory('badFrontend', 'File'); - } catch (Zend_Exception $e) { - return; - } - $this->fail('Zend_Exception was expected but not thrown'); - } - - public function testBadBackend() - { - try { - Zend_Cache::factory('Output', 'badBackend'); - } catch (Zend_Exception $e) { - return; - } - $this->fail('Zend_Exception was expected but not thrown'); - } - -} diff --git a/tests/Zend/Cache/FileBackendTest.php b/tests/Zend/Cache/FileBackendTest.php deleted file mode 100644 index e7f549ff2134e58de7f7dab1c40a3a33835eafd4..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/FileBackendTest.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - -/** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Backend/File.php'; - -/** - * Zend_Log - */ -require_once 'Zend/Log.php'; -require_once 'Zend/Log/Writer/Null.php'; - -/** - * Common tests for backends - */ -require_once 'CommonBackendTest.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_FileBackendTest extends Zend_Cache_CommonBackendTest { - - protected $_instance; - protected $_instance2; - protected $_cache_dir; - - public function __construct() - { - parent::__construct('Zend_Cache_Backend_File'); - } - - public function setUp($notag = false) - { - $this->mkdir(); - $this->_cache_dir = $this->getTmpDir() . DIRECTORY_SEPARATOR; - $this->_instance = new Zend_Cache_Backend_File(array( - 'cache_dir' => $this->_cache_dir, - )); - - $logger = new Zend_Log(new Zend_Log_Writer_Null()); - $this->_instance->setDirectives(array('logger' => $logger)); - - parent::setUp($notag); - } - - public function tearDown() - { - parent::tearDown(); - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Backend_File(array()); - } - - public function testConstructorWithABadFileNamePrefix() - { - try { - $class = new Zend_Cache_Backend_File(array( - 'file_name_prefix' => 'foo bar' - )); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testGetWithANonExistingCacheIdAndANullLifeTime() - { - $this->_instance->setDirectives(array('lifetime' => null)); - $this->assertFalse($this->_instance->load('barbar')); - } - - public function testSaveCorrectCallWithHashedDirectoryStructure() - { - $this->_instance->setOption('hashed_directory_level', 2); - $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2')); - $this->assertTrue($res); - } - - public function testCleanModeAllWithHashedDirectoryStructure() - { - $this->_instance->setOption('hashed_directory_level', 2); - $this->assertTrue($this->_instance->clean('all')); - $this->assertFalse($this->_instance->test('bar')); - $this->assertFalse($this->_instance->test('bar2')); - } - - public function testSaveWithABadCacheDir() - { - $this->_instance->setOption('cache_dir', '/foo/bar/lfjlqsdjfklsqd/'); - $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2')); - $this->assertFalse($res); - } - -} - - diff --git a/tests/Zend/Cache/FileFrontendTest.php b/tests/Zend/Cache/FileFrontendTest.php deleted file mode 100644 index 77bc6909c2dcb2ac2f2b5408ad19dd604c4652f1..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/FileFrontendTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Frontend/File.php'; -require_once 'Zend/Cache/Backend/Test.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_FileFrontendTest extends PHPUnit_Framework_TestCase { - - private $_instance1; - private $_instance2; - - - public function setUp() - { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $this->_masterFile = $this->_getTmpDirWindows() . DIRECTORY_SEPARATOR . 'zend_cache_master'; - } else { - $this->_masterFile = $this->_getTmpDirUnix() . DIRECTORY_SEPARATOR . 'zend_cache_master'; - } - if (!$this->_instance1) { - touch($this->_masterFile, 123455); - $this->_instance1 = new Zend_Cache_Frontend_File(array('master_file' => $this->_masterFile)); - $this->_backend = new Zend_Cache_Backend_Test(); - $this->_instance1->setBackend($this->_backend); - } - if (!$this->_instance2) { - touch($this->_masterFile); - $this->_instance2 = new Zend_Cache_Frontend_File(array('master_file' => $this->_masterFile)); - $this->_backend = new Zend_Cache_Backend_Test(); - $this->_instance2->setBackend($this->_backend); - } - - } - - public function tearDown() - { - unset($this->_instance1); - unlink($this->_masterFile); - } - - private function _getTmpDirWindows() - { - if (isset($_ENV['TEMP'])) { - return $_ENV['TEMP']; - } - if (isset($_ENV['TMP'])) { - return $_ENV['TMP']; - } - if (isset($_ENV['windir'])) { - return $_ENV['windir'] . '\\temp'; - } - if (isset($_ENV['SystemRoot'])) { - return $_ENV['SystemRoot'] . '\\temp'; - } - if (isset($_SERVER['TEMP'])) { - return $_SERVER['TEMP']; - } - if (isset($_SERVER['TMP'])) { - return $_SERVER['TMP']; - } - if (isset($_SERVER['windir'])) { - return $_SERVER['windir'] . '\\temp'; - } - if (isset($_SERVER['SystemRoot'])) { - return $_SERVER['SystemRoot'] . '\\temp'; - } - return '\temp'; - } - - private function _getTmpDirUnix() - { - if (isset($_ENV['TMPDIR'])) { - return $_ENV['TMPDIR']; - } - if (isset($_SERVER['TMPDIR'])) { - return $_SERVER['TMPDIR']; - } - return '/tmp'; - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Frontend_File(array('master_file' => $this->_masterFile, 'lifetime' => 3600, 'caching' => true)); - } - - public function testConstructorBadCall1() - { - # no masterfile - try { - $test = new Zend_Cache_Frontend_File(array('lifetime' => 3600, 'caching' => true)); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorBadCall2() - { - # incorrect option - try { - $test = new Zend_Cache_Frontend_File(array('master_file' => $this->_masterFile, 'foo' => 3600)); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testTestCorrectCall1() - { - $this->assertFalse($this->_instance1->test('false')); - } - - public function testTestCorrectCall2() - { - $this->assertTrue($this->_instance1->test('cache_id') > 1); - } - - public function testTestCorrectCall3() - { - $this->assertFalse($this->_instance2->test('cache_id')); - } - - public function testGetCorrectCall1() - { - $this->assertFalse($this->_instance1->load('false')); - } - - public function testGetCorrectCall2() - { - $this->assertEquals('foo', $this->_instance1->load('cache_id')); - } - - public function testGetCorrectCall3() - { - $this->assertFalse($this->_instance2->load('cache_id')); - } - - public function testConstructorWithABadMasterFile() - { - try { - $instance = new Zend_Cache_Frontend_File(array('master_file' => '/foo/bar/ljhfdjh/qhskldhqjk')); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testGetWithDoNotTestCacheValidity() - { - $this->assertEquals('foo', $this->_instance1->load('cache_id', true)); - } - -} - - diff --git a/tests/Zend/Cache/FunctionFrontendTest.php b/tests/Zend/Cache/FunctionFrontendTest.php deleted file mode 100644 index 395dfd8a172aa7d467f05923d82d0ae84a325957..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/FunctionFrontendTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Frontend/Function.php'; -require_once 'Zend/Cache/Backend/Test.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -function foobar($param1, $param2) { - echo "foobar_output($param1, $param2)"; - return "foobar_return($param1, $param2)"; -} - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_FunctionFrontendTest extends PHPUnit_Framework_TestCase { - - private $_instance; - - public function setUp() - { - if (!$this->_instance) { - $this->_instance = new Zend_Cache_Frontend_Function(array()); - $this->_backend = new Zend_Cache_Backend_Test(); - $this->_instance->setBackend($this->_backend); - } - } - - public function tearDown() - { - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $options = array( - 'cache_by_default' => false, - 'cached_functions' => array('foo', 'bar') - ); - $test = new Zend_Cache_Frontend_Function($options); - } - - public function testConstructorBadCall() - { - $options = array( - 'cache_by_default' => false, - 'foo' => array('foo', 'bar') - ); - try { - $test = new Zend_Cache_Frontend_Function($options); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testCallCorrectCall1() - { - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance->call('foobar', array('param1', 'param2')); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('bar', $return); - $this->assertEquals('foo', $data); - } - - public function testCallCorrectCall2() - { - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance->call('foobar', array('param3', 'param4')); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar_return(param3, param4)', $return); - $this->assertEquals('foobar_output(param3, param4)', $data); - } - - public function testCallCorrectCall3() - { - // cacheByDefault = false - $this->_instance->setOption('cache_by_default', false); - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance->call('foobar', array('param1', 'param2')); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar_return(param1, param2)', $return); - $this->assertEquals('foobar_output(param1, param2)', $data); - } - - public function testCallCorrectCall4() - { - // cacheByDefault = false - // cachedFunctions = array('foobar') - $this->_instance->setOption('cache_by_default', false); - $this->_instance->setOption('cached_functions', array('foobar')); - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance->call('foobar', array('param1', 'param2')); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('bar', $return); - $this->assertEquals('foo', $data); - } - - public function testCallCorrectCall5() - { - // cacheByDefault = true - // nonCachedFunctions = array('foobar') - $this->_instance->setOption('cache_by_default', true); - $this->_instance->setOption('non_cached_functions', array('foobar')); - ob_start(); - ob_implicit_flush(false); - $return = $this->_instance->call('foobar', array('param1', 'param2')); - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar_return(param1, param2)', $return); - $this->assertEquals('foobar_output(param1, param2)', $data); - } - - public function testCallWithABadSyntax1() - { - try { - $this->_instance->call(1, array()); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testCallWithABadSyntax2() - { - try { - $this->_instance->call('foo', 1); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } -} - diff --git a/tests/Zend/Cache/MemcachedBackendTest.php b/tests/Zend/Cache/MemcachedBackendTest.php deleted file mode 100644 index fc14da35bb36ca81223e230fc65e4bf260070f7a..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/MemcachedBackendTest.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Backend/Memcached.php'; - -/** - * Common tests for backends - */ -require_once 'CommonBackendTest.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_MemcachedBackendTest extends Zend_Cache_CommonBackendTest { - - protected $_instance; - - public function __construct() - { - parent::__construct('Zend_Cache_Backend_Memcached'); - } - - public function setUp($notag = true) - { - $server = array( - 'host' => TESTS_ZEND_CACHE_MEMCACHED_HOST, - 'port' => TESTS_ZEND_CACHE_MEMCACHED_PORT, - 'persistent' => TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT - ); - $options = array( - 'servers' => array(0 => $server) - ); - $this->_instance = new Zend_Cache_Backend_Memcached($options); - parent::setUp($notag); - } - - public function tearDown() - { - parent::tearDown(); - unset($this->_instance); - // We have to wait after a memcache flush - sleep(1); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Backend_Memcached(); - } - - public function testCleanModeOld() - { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('old'); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testCleanModeMatchingTags() - { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('matchingTag', array('tag1')); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testCleanModeNotMatchingTags() - { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('notMatchingTag', array('tag1')); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testGetWithCompression() - { - $this->_instance->setOption('compression', true); - $this->testGetWithAnExistingCacheIdAndUTFCharacters(); - } - - public function testConstructorWithAnAlternativeSyntax() - { - $server = array( - 'host' => TESTS_ZEND_CACHE_MEMCACHED_HOST, - 'port' => TESTS_ZEND_CACHE_MEMCACHED_PORT, - 'persistent' => TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT - ); - $options = array( - 'servers' => $server - ); - $this->_instance = new Zend_Cache_Backend_Memcached($options); - $this->testGetWithAnExistingCacheIdAndUTFCharacters(); - } - - // Because of limitations of this backend... - public function testGetWithAnExpiredCacheId() {} - public function testCleanModeMatchingTags2() {} - public function testCleanModeNotMatchingTags2() {} - public function testCleanModeNotMatchingTags3() {} - public function testSaveCorrectCall() - { - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveCorrectCall(); - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testSaveWithNullLifeTime() - { - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveWithNullLifeTime(); - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testSaveWithSpecificLifeTime() - { - - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveWithSpecificLifeTime(); - $this->_instance->setDirectives(array('logging' => true)); - } -} - - diff --git a/tests/Zend/Cache/OutputFrontendTest.php b/tests/Zend/Cache/OutputFrontendTest.php deleted file mode 100644 index 344baacfb2939dda2e5a352043c571ae568f43ef..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/OutputFrontendTest.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Frontend/Output.php'; -require_once 'Zend/Cache/Backend/Test.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_OutputFrontendTest extends PHPUnit_Framework_TestCase { - - private $_instance; - - public function setUp() - { - if (!$this->_instance) { - $this->_instance = new Zend_Cache_Frontend_Output(array()); - $this->_backend = new Zend_Cache_Backend_Test(); - $this->_instance->setBackend($this->_backend); - } - } - - public function tearDown() - { - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Frontend_Output(array('lifetime' => 3600, 'caching' => true)); - } - - public function testStartEndCorrectCall1() - { - ob_start(); - ob_implicit_flush(false); - if (!($this->_instance->start('123'))) { - echo('foobar'); - $this->_instance->end(); - } - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foo', $data); - } - - public function testStartEndCorrectCall2() - { - ob_start(); - ob_implicit_flush(false); - if (!($this->_instance->start('false'))) { - echo('foobar'); - $this->_instance->end(); - } - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar', $data); - } -} - diff --git a/tests/Zend/Cache/PageFrontendTest.php b/tests/Zend/Cache/PageFrontendTest.php deleted file mode 100644 index 66c5898b45677c8c5d366d803c28cec00196b0f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/PageFrontendTest.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Frontend/Page.php'; -require_once 'Zend/Cache/Backend/Test.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_PageFrontendTest extends PHPUnit_Framework_TestCase { - - private $_instance; - - public function setUp() - { - if (!$this->_instance) { - $this->_instance = new Zend_Cache_Frontend_Page(array()); - $this->_backend = new Zend_Cache_Backend_Test(); - $this->_instance->setBackend($this->_backend); - } - } - - public function tearDown() - { - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Frontend_Page(array('lifetime' => 3600, 'caching' => true)); - } - - public function testConstructorUnimplementedOption() - { - try { - $test = new Zend_Cache_Frontend_Page(array('http_conditional' => true)); - } catch (Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorWithBadDefaultOptions() - { - try { - $test = new Zend_Cache_Frontend_Page(array('default_options' => 'foo')); - } catch (Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorWithBadDefaultOptions2() - { - try { - $test = new Zend_Cache_Frontend_Page(array('default_options' => array('cache' => true, 'foo' => 'bar'))); - } catch (Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorWithBadRegexps() - { - try { - $test = new Zend_Cache_Frontend_Page(array('regexps' => 'foo')); - } catch (Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorWithBadRegexps2() - { - try { - $test = new Zend_Cache_Frontend_Page(array('regexps' => array('foo', 'bar'))); - } catch (Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorWithBadRegexps3() - { - $array = array( - '^/$' => array('cache' => true), - '^/index/' => array('cache' => true), - '^/article/' => array('cache' => false), - '^/article/view/' => array( - 'foo' => true, - 'cache_with_post_variables' => true, - 'make_id_with_post_variables' => true, - ) - ); - try { - $test = new Zend_Cache_Frontend_Page(array('regexps' => $array)); - } catch (Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testConstructorWithGoodRegexps() - { - $array = array( - '^/$' => array('cache' => true), - '^/index/' => array('cache' => true), - '^/article/' => array('cache' => false), - '^/article/view/' => array( - 'cache' => true, - 'cache_with_post_variables' => true, - 'make_id_with_post_variables' => true, - ) - ); - $test = new Zend_Cache_Frontend_Page(array('regexps' => $array)); - } - - public function testConstructorWithGoodDefaultOptions() - { - $test = new Zend_Cache_Frontend_Page(array('default_options' => array('cache' => true))); - } - - public function testStartEndCorrectCall1() - { - ob_start(); - ob_implicit_flush(false); - if (!($this->_instance->start('serialized2', true))) { - echo('foobar'); - ob_end_flush(); - } - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foo', $data); - } - - public function testStartEndCorrectCall2() - { - ob_start(); - ob_implicit_flush(false); - if (!($this->_instance->start('false', true))) { - echo('foobar'); - ob_end_flush(); - } - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('foobar', $data); - } - - public function testStartEndCorrectCallWithDebug() - { - $this->_instance->setOption('debug_header', true); - ob_start(); - ob_implicit_flush(false); - if (!($this->_instance->start('serialized2', true))) { - echo('foobar'); - ob_end_flush(); - } - $data = ob_get_contents(); - ob_end_clean(); - ob_implicit_flush(true); - $this->assertEquals('DEBUG HEADER : This is a cached page !foo', $data); - } -} - diff --git a/tests/Zend/Cache/SkipTests.php b/tests/Zend/Cache/SkipTests.php deleted file mode 100644 index 26f54c33b607e654bf585b369c1c6d685858f86e..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/SkipTests.php +++ /dev/null @@ -1,77 +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_Cache - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BasicSqliteTest.php 4194 2007-03-22 23:50:34Z darby $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Cache - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Cache_BackendTest_SkipTests extends PHPUnit_Framework_TestCase -{ - - public $message = 'Skipped for unspecified reason'; - - public function setUp() - { - $this->markTestSkipped($this->message); - } - - public function testCacheBackend() - { - // this is here only so we have at least one test - } - -} - -class Zend_Cache_ApcBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests -{ -} - -class Zend_Cache_XcacheBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests -{ -} - -class Zend_Cache_MemcachedBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests -{ -} - -class Zend_Cache_SqliteBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests -{ -} - -class Zend_Cache_ZendPlatformBackendTest_SkipTests extends Zend_Cache_BackendTest_SkipTests -{ -} diff --git a/tests/Zend/Cache/SqliteBackendTest.php b/tests/Zend/Cache/SqliteBackendTest.php deleted file mode 100644 index ab90083f5697b01caa14b7e380ac1bef53aff738..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/SqliteBackendTest.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - -/** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Backend/Sqlite.php'; - -/** - * Common tests for backends - */ -require_once 'CommonBackendTest.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_sqliteBackendTest extends Zend_Cache_CommonBackendTest { - - protected $_instance; - private $_cache_dir; - - public function __construct() - { - parent::__construct('Zend_Cache_Backend_Sqlite'); - } - - public function setUp($notag = false) - { - @mkdir($this->getTmpDir()); - $this->_cache_dir = $this->getTmpDir() . DIRECTORY_SEPARATOR; - $this->_instance = new Zend_Cache_Backend_Sqlite(array( - 'cache_db_complete_path' => $this->_cache_dir . 'cache.db' - )); - parent::setUp($notag); - } - - public function tearDown() - { - parent::tearDown(); - unset($this->_instance); - @unlink($this->_cache_dir . 'cache.db'); - $this->rmdir(); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Backend_Sqlite(array('cache_db_complete_path' => $this->_cache_dir . 'cache.db')); - } - - public function testConstructorWithABadDBPath() - { - try { - $test = new Zend_Cache_Backend_Sqlite(array('cache_db_complete_path' => '/foo/bar/lfjlqsdjfklsqd/cache.db')); - } catch (Zend_Cache_Exception $e) { - return; - } - $this->fail('Zend_Cache_Exception was expected but not thrown'); - } - - public function testCleanModeAllWithVacuum() - { - $this->_instance = new Zend_Cache_Backend_Sqlite(array( - 'cache_db_complete_path' => $this->_cache_dir . 'cache.db', - 'automatic_vacuum_factor' => 1 - )); - parent::setUp(); - $this->assertTrue($this->_instance->clean('all')); - $this->assertFalse($this->_instance->test('bar')); - $this->assertFalse($this->_instance->test('bar2')); - } - - public function testRemoveCorrectCallWithVacuum() - { - $this->_instance = new Zend_Cache_Backend_Sqlite(array( - 'cache_db_complete_path' => $this->_cache_dir . 'cache.db', - 'automatic_vacuum_factor' => 1 - )); - parent::setUp(); - $this->assertTrue($this->_instance->remove('bar')); - $this->assertFalse($this->_instance->test('bar')); - $this->assertFalse($this->_instance->remove('barbar')); - $this->assertFalse($this->_instance->test('barbar')); - } - -} - - diff --git a/tests/Zend/Cache/XcacheBackendTest.php b/tests/Zend/Cache/XcacheBackendTest.php deleted file mode 100644 index 3710acb4d1ebbe98da85553006d4741a3a506528..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/XcacheBackendTest.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Backend/Xcache.php'; - -/** - * Common tests for backends - */ -require_once 'CommonBackendTest.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_XcacheBackendTest extends Zend_Cache_CommonBackendTest { - - protected $_instance; - - public function __construct() - { - parent::__construct('Zend_Cache_Backend_Xcache'); - } - - public function setUp($notag = true) - { - $this->_instance = new Zend_Cache_Backend_Xcache(array( - 'user' => TESTS_ZEND_CACHE_XCACHE_USER, - 'password' => TESTS_ZEND_CACHE_XCACHE_PASSWORD - )); - parent::setUp($notag); - } - - public function tearDown() - { - parent::tearDown(); - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Backend_Xcache(); - } - - public function testCleanModeOld() { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('old'); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testCleanModeMatchingTags() { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('matchingTag', array('tag1')); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testCleanModeNotMatchingTags() { - $this->_instance->setDirectives(array('logging' => false)); - $this->_instance->clean('notMatchingTag', array('tag1')); - // do nothing, just to see if an error occured - $this->_instance->setDirectives(array('logging' => true)); - } - - // Because of limitations of this backend... - public function testGetWithAnExpiredCacheId() {} - public function testCleanModeMatchingTags2() {} - public function testCleanModeNotMatchingTags2() {} - public function testCleanModeNotMatchingTags3() {} - public function testSaveCorrectCall() - { - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveCorrectCall(); - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testSaveWithNullLifeTime() - { - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveWithNullLifeTime(); - $this->_instance->setDirectives(array('logging' => true)); - } - - public function testSaveWithSpecificLifeTime() - { - - $this->_instance->setDirectives(array('logging' => false)); - parent::testSaveWithSpecificLifeTime(); - $this->_instance->setDirectives(array('logging' => true)); - } - -} - - diff --git a/tests/Zend/Cache/ZendPlatformBackendTest.php b/tests/Zend/Cache/ZendPlatformBackendTest.php deleted file mode 100644 index bd71aa769a2ecdac0358dc21cdda20cb8726c312..0000000000000000000000000000000000000000 --- a/tests/Zend/Cache/ZendPlatformBackendTest.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -/** - * @package Zend_Cache - * @subpackage UnitTests - */ - - /** - * Zend_Cache - */ -require_once 'Zend/Cache.php'; -require_once 'Zend/Cache/Backend/ZendPlatform.php'; - -/** - * Common tests for backends - */ -require_once 'CommonBackendTest.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Cache - * @subpackage UnitTests - */ -class Zend_Cache_ZendPlatformBackendTest extends Zend_Cache_CommonBackendTest { - - protected $_instance; - - public function __construct() - { - parent::__construct('Zend_Cache_Backend_ZendPlatform'); - } - - public function setUp($notag = false) - { - if(!function_exists('output_cache_get')) { - $this->markTestSkipped('Zend Platform is not installed, skipping test'); - return; - } - $this->_instance = new Zend_Cache_Backend_ZendPlatform(array()); - parent::setUp($notag); - } - - public function tearDown() - { - parent::tearDown(); - unset($this->_instance); - } - - public function testConstructorCorrectCall() - { - $test = new Zend_Cache_Backend_ZendPlatform(); - } - - public function testRemoveCorrectCall() - { - $this->assertTrue($this->_instance->remove('bar')); - $this->assertFalse($this->_instance->test('bar')); - $this->assertTrue($this->_instance->remove('barbar')); - $this->assertFalse($this->_instance->test('barbar')); - } - - public function testGetWithAnExpiredCacheId() - { - sleep(2); - $this->_instance->setDirectives(array('lifetime' => 1)); - $this->assertEquals('bar : data to cache', $this->_instance->load('bar', true)); - $this->assertFalse($this->_instance->load('bar')); - $this->_instance->setDirectives(array('lifetime' => 3600)); - } - - // Because of limitations of this backend... - public function testCleanModeNotMatchingTags2() {} - public function testCleanModeNotMatchingTags3() {} - public function testCleanModeOld() {} - public function testCleanModeNotMatchingTags() {} -} - - diff --git a/tests/Zend/Captcha/AllTests.php b/tests/Zend/Captcha/AllTests.php deleted file mode 100644 index 5a9b12f6ef8e83018fa1d04d9bca7fe4b7e5a3a2..0000000000000000000000000000000000000000 --- a/tests/Zend/Captcha/AllTests.php +++ /dev/null @@ -1,66 +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_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10743 2008-08-07 02:24:43Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Captcha_AllTests::main'); -} - -require_once 'Zend/Captcha/DumbTest.php'; -require_once 'Zend/Captcha/FigletTest.php'; -require_once 'Zend/Captcha/ImageTest.php'; -require_once 'Zend/Captcha/ReCaptchaTest.php'; - -/** - * @category Zend - * @package Zend_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Captcha_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Captcha'); - - $suite->addTestSuite('Zend_Captcha_DumbTest'); - $suite->addTestSuite('Zend_Captcha_FigletTest'); - $suite->addTestSuite('Zend_Captcha_ImageTest'); - $suite->addTestSuite('Zend_Captcha_ReCaptchaTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Captcha_AllTests::main') { - Zend_Captcha_AllTests::main(); -} diff --git a/tests/Zend/Captcha/DumbTest.php b/tests/Zend/Captcha/DumbTest.php deleted file mode 100644 index 5c056b0d8aecd59e77b0b22350b7134f278ca021..0000000000000000000000000000000000000000 --- a/tests/Zend/Captcha/DumbTest.php +++ /dev/null @@ -1,143 +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_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DumbTest.php 10743 2008-08-07 02:24:43Z matthew $ - */ - -// Call Zend_Captcha_DumbTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Captcha_DumbTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Form/Element/Captcha.php'; -require_once 'Zend/View.php'; - -/** - * @category Zend - * @package Zend_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Captcha_DumbTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Captcha_DumbTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (isset($this->word)) { - unset($this->word); - } - - $this->element = new Zend_Form_Element_Captcha( - 'captchaD', - array( - 'captcha' => array( - 'Dumb', - 'sessionClass' => 'Zend_Captcha_DumbTest_SessionContainer' - ) - ) - ); - $this->captcha = $this->element->getCaptcha(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testRendersWordInReverse() - { - $id = $this->captcha->generate('test'); - $word = $this->captcha->getWord(); - $html = $this->captcha->render(new Zend_View); - $this->assertContains(strrev($word), $html); - $this->assertNotContains($word, $html); - } -} - -class Zend_Captcha_DumbTest_SessionContainer -{ - protected static $_word; - - public function __get($name) - { - if ('word' == $name) { - return self::$_word; - } - - return null; - } - - public function __set($name, $value) - { - if ('word' == $name) { - self::$_word = $value; - } else { - $this->$name = $value; - } - } - - public function __isset($name) - { - if (('word' == $name) && (null !== self::$_word)) { - return true; - } - - return false; - } - - public function __call($method, $args) - { - switch ($method) { - case 'setExpirationHops': - case 'setExpirationSeconds': - $this->$method = array_shift($args); - break; - default: - } - } -} - -// Call Zend_Captcha_DumbTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Captcha_DumbTest::main") { - Zend_Captcha_DumbTest::main(); -} diff --git a/tests/Zend/Captcha/FigletTest.php b/tests/Zend/Captcha/FigletTest.php deleted file mode 100644 index 7b815817152e9dc6dd88826a5a5e8b4453ad7b7d..0000000000000000000000000000000000000000 --- a/tests/Zend/Captcha/FigletTest.php +++ /dev/null @@ -1,312 +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_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10573 2008-07-31 14:54:00Z matthew $ - */ - -// Call Zend_Captcha_FigletTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Captcha_FigletTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Form/Element/Captcha.php'; -require_once 'Zend/Captcha/Adapter.php'; -require_once 'Zend/Config.php'; - -/** - * @category Zend - * @package Zend_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Captcha_FigletTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Captcha_FigletTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (isset($this->word)) { - unset($this->word); - } - - $this->element = new Zend_Form_Element_Captcha( - 'captchaF', - array( - 'captcha' => array( - 'Figlet', - 'sessionClass' => 'Zend_Captcha_FigletTest_SessionContainer' - ) - ) - ); - $this->captcha = $this->element->getCaptcha(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testCaptchaAdapterCreated() - { - $this->assertTrue($this->element->getCaptcha() instanceof Zend_Captcha_Adapter); - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testCaptchaIsRendered() - { - $html = $this->element->render($this->getView()); - $this->assertContains($this->element->getName(), $html); - } - - public function testCaptchaHasIdAndInput() - { - $html = $this->element->render($this->getView()); - $expect = sprintf('type="hidden" name="%s\[id\]" value="%s"', $this->element->getName(), $this->captcha->getId()); - $this->assertRegexp("/<input[^>]*?$expect/", $html, $html); - $expect = sprintf('type="text" name="%s\[input\]"', $this->element->getName()); - $this->assertRegexp("/<input[^>]*?$expect/", $html, $html); - } - - public function testTimeoutPopulatedByDefault() - { - $ttl = $this->captcha->getTimeout(); - $this->assertFalse(empty($ttl)); - $this->assertTrue(is_int($ttl)); - } - - public function testCanSetTimeout() - { - $ttl = $this->captcha->getTimeout(); - $this->captcha->setTimeout(3600); - $this->assertNotEquals($ttl, $this->captcha->getTimeout()); - $this->assertEquals(3600, $this->captcha->getTimeout()); - } - - public function testGenerateReturnsId() - { - $id = $this->captcha->generate(); - $this->assertFalse(empty($id)); - $this->assertTrue(is_string($id)); - $this->id = $id; - } - - public function testGetWordReturnsWord() - { - $this->captcha->generate(); - $word = $this->captcha->getWord(); - $this->assertFalse(empty($word)); - $this->assertTrue(is_string($word)); - $this->assertTrue(strlen($word) == 8); - $this->word = $word; - } - - public function testGetWordLength() - { - $this->captcha->setWordLen(4); - $this->captcha->generate(); - $word = $this->captcha->getWord(); - $this->assertTrue(is_string($word)); - $this->assertTrue(strlen($word) == 4); - $this->word = $word; - } - - public function testAdapterElementName() - { - $this->assertEquals($this->captcha->getName(), - $this->element->getName()); - } - - public function testGenerateIsRandomised() - { - $id1 = $this->captcha->generate(); - $word1 = $this->captcha->getWord(); - $id2 = $this->captcha->generate(); - $word2 = $this->captcha->getWord(); - - $this->assertFalse(empty($id1)); - $this->assertFalse(empty($id2)); - $this->assertFalse($id1 == $id2); - $this->assertFalse($word1 == $word2); - } - - public function testRenderSetsValue() - { - $this->testCaptchaIsRendered(); - $this->assertEquals($this->captcha->getId(), - $this->element->getValue()); - } - - public function testLabelIsNull() - { - $this->assertNull($this->element->getLabel()); - } - - public function testRenderInitializesSessionData() - { - $this->testCaptchaIsRendered(); - $session = $this->captcha->getSession(); - $this->assertEquals($this->captcha->getTimeout(), $session->setExpirationSeconds); - $this->assertEquals(1, $session->setExpirationHops); - $this->assertEquals($this->captcha->getWord(), $session->word); - } - - public function testWordValidates() - { - $this->testCaptchaIsRendered(); - $input = array($this->element->getName() => array("id" => $this->captcha->getId(), "input" => $this->captcha->getWord())); - $this->assertTrue($this->element->isValid("", $input)); - } - - public function testMissingNotValid() - { - $this->testCaptchaIsRendered(); - $this->assertFalse($this->element->isValid("", array())); - $input = array($this->element->getName() => array("input" => "blah")); - $this->assertFalse($this->element->isValid("", $input)); - } - - public function testWrongWordNotValid() - { - $this->testCaptchaIsRendered(); - $input = array($this->element->getName() => array("id" => $this->captcha->getId(), "input" => "blah")); - $this->assertFalse($this->element->isValid("", $input)); - } - - public function testUsesWordCaptchaDecoratorByDefault() - { - $this->assertEquals('Captcha_Word', $this->element->getCaptcha()->getDecorator()); - } - - public function testCaptchaShouldBeConfigurableViaConfigObject() - { - $options = array( - 'name' => 'foo', - 'sessionClass' => 'Zend_Captcha_FigletTest_SessionContainer', - 'wordLen' => 6, - 'timeout' => 300, - ); - $config = new Zend_Config($options); - $captcha = new Zend_Captcha_Figlet($config); - $test = $captcha->getOptions(); - $this->assertEquals($options, $test); - } - - public function testShouldAllowFigletsLargerThanFourteenCharacters() - { - $this->captcha->setName('foo') - ->setWordLen(14); - $id = $this->captcha->generate(); - } - - public function testShouldNotValidateEmptyInputAgainstEmptySession() - { - // Regression Test for ZF-4245 - $this->captcha->setName('foo') - ->setWordLen(6) - ->setTimeout(300); - $id = $this->captcha->generate(); - // Unset the generated word - // we have to reset $this->captcha for that - $this->captcha->getSession()->word = null; - $this->setUp(); - $this->captcha->setName('foo') - ->setWordLen(6) - ->setTimeout(300); - $empty = array($this->captcha->getName() => array('id' => $id, 'input' => '')); - $this->assertEquals(false, $this->captcha->isValid(null, $empty)); - } -} - -class Zend_Captcha_FigletTest_SessionContainer -{ - protected static $_word; - - public function __get($name) - { - if ('word' == $name) { - return self::$_word; - } - - return null; - } - - public function __set($name, $value) - { - if ('word' == $name) { - self::$_word = $value; - } else { - $this->$name = $value; - } - } - - public function __isset($name) - { - if (('word' == $name) && (null !== self::$_word)) { - return true; - } - - return false; - } - - public function __call($method, $args) - { - switch ($method) { - case 'setExpirationHops': - case 'setExpirationSeconds': - $this->$method = array_shift($args); - break; - default: - } - } -} - -// Call Zend_Captcha_FigletTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Captcha_FigletTest::main") { - Zend_Captcha_FigletTest::main(); -} diff --git a/tests/Zend/Captcha/ImageTest.php b/tests/Zend/Captcha/ImageTest.php deleted file mode 100644 index d2804d1435b3e6af5e14637448d847955c6ff382..0000000000000000000000000000000000000000 --- a/tests/Zend/Captcha/ImageTest.php +++ /dev/null @@ -1,350 +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_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10573 2008-07-31 14:54:00Z matthew $ - */ - -// Call Zend_Captcha_ImageTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Captcha_ImageTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Form/Element/Captcha.php'; -require_once 'Zend/Captcha/Adapter.php'; - -/** - * @category Zend - * @package Zend_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Captcha_ImageTest extends PHPUnit_Framework_TestCase -{ - protected $_tmpDir; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Captcha_ImageTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (!extension_loaded('gd')) { - $this->markTestSkipped('The GD extension is not available.'); - return; - } - if(!function_exists("imagepng")) { - $this->markTestSkipped("Image CAPTCHA requires PNG support"); - } - if(!function_exists("imageftbbox")) { - $this->markTestSkipped("Image CAPTCHA requires FT fonts support"); - } - - if (isset($this->word)) { - unset($this->word); - } - $this->testDir = $this->_getTmpDir() . '/ZF_test_images'; - if(!is_dir($this->testDir)) { - @mkdir($this->testDir); - } - $this->element = new Zend_Form_Element_Captcha('captchaI', array( - 'captcha' => array('Image', - 'sessionClass' => 'Zend_Captcha_ImageTest_SessionContainer', - 'imgDir' => $this->testDir, - 'font' => dirname(__FILE__). '/../Pdf/_fonts/Vera.ttf' - - ) - )); - $this->captcha = $this->element->getCaptcha(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - // remove chaptcha images - foreach(new DirectoryIterator($this->testDir) as $file) { - if(!$file->isDot() && !$file->isDir()) { - unlink($file->getPathname()); - } - } - - } - - /** - * Determine system TMP directory - * - * @return string - * @throws Zend_File_Transfer_Exception if unable to determine directory - */ - protected function _getTmpDir() - { - if (null === $this->_tmpDir) { - if (function_exists('sys_get_temp_dir')) { - $tmpdir = sys_get_temp_dir(); - } elseif (!empty($_ENV['TMP'])) { - $tmpdir = realpath($_ENV['TMP']); - } elseif (!empty($_ENV['TMPDIR'])) { - $tmpdir = realpath($_ENV['TMPDIR']); - } else if (!empty($_ENV['TEMP'])) { - $tmpdir = realpath($_ENV['TEMP']); - } else { - // Attemp to detect by creating a temporary file - $tempFile = tempnam(md5(uniqid(rand(), TRUE)), ''); - if ($tempFile) { - $tmpdir = realpath(dirname($tempFile)); - unlink($tempFile); - } else { - require_once 'Zend/File/Transfer/Exception.php'; - throw new Zend_File_Transfer_Exception('Could not determine temp directory'); - } - } - $this->_tmpDir = rtrim($tmpdir, "/\\"); - } - return $this->_tmpDir; - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testCaptchaIsRendered() - { - $html = $this->element->render($this->getView()); - $this->assertContains($this->element->getName(), $html); - } - - public function testCaptchaHasIdAndInput() - { - $html = $this->element->render($this->getView()); - $expect = sprintf('type="hidden" name="%s\[id\]" value="%s"', $this->element->getName(), $this->captcha->getId()); - $this->assertRegexp("/<input[^>]*?$expect/", $html, $html); - $expect = sprintf('type="text" name="%s\[input\]"', $this->element->getName()); - $this->assertRegexp("/<input[^>]*?$expect/", $html, $html); - } - - public function testCaptchaHasImage() - { - $html = $this->element->render($this->getView()); - $id = $this->captcha->getId(); - $this->assertRegexp("|<img[^>]*?src=\"/images/captcha/$id.png\"|", $html, "Expected $id in HTML:\n" . $html); - } - - public function testCaptchaSetSuffix() - { - $this->captcha->setSuffix(".jpeg"); - $html = $this->element->render($this->getView()); - $this->assertContains(".jpeg", $html, $html); - } - - public function testCaptchaSetImgURL() - { - $this->captcha->setImgURL("/some/other/URL/"); - $html = $this->element->render($this->getView()); - $this->assertContains("/some/other/URL/", $html, $html); - } - - public function testCaptchaCreatesImage() - { - $this->element->render($this->getView()); - $this->assertTrue(file_exists($this->testDir."/".$this->captcha->getId().".png")); - } - - public function testCaptchaSetExpiration() - { - $this->assertEquals($this->captcha->getExpiration(), 600); - $this->captcha->setExpiration(3600); - $this->assertEquals($this->captcha->getExpiration(), 3600); - } - - public function testCaptchaImageCleanup() - { - $this->element->render($this->getView()); - $filename = $this->testDir."/".$this->captcha->getId().".png"; - $this->assertTrue(file_exists($filename)); - $this->captcha->setExpiration(1); - $this->captcha->setGcFreq(1); - sleep(2); - $this->captcha->generate(); - $this->assertFalse(file_exists($filename), "File $filename was found even after GC"); - } - - public function testGenerateReturnsId() - { - $id = $this->captcha->generate(); - $this->assertFalse(empty($id)); - $this->assertTrue(is_string($id)); - $this->id = $id; - } - - public function testGetWordReturnsWord() - { - $this->captcha->generate(); - $word = $this->captcha->getWord(); - $this->assertFalse(empty($word)); - $this->assertTrue(is_string($word)); - $this->assertTrue(strlen($word) == 8); - $this->word = $word; - } - - public function testGetWordLength() - { - $this->captcha->setWordLen(4); - $this->captcha->generate(); - $word = $this->captcha->getWord(); - $this->assertTrue(is_string($word)); - $this->assertTrue(strlen($word) == 4); - $this->word = $word; - } - - public function testAdapterElementName() - { - $this->assertEquals($this->captcha->getName(), - $this->element->getName()); - } - - public function testGenerateIsRandomised() - { - $id1 = $this->captcha->generate(); - $word1 = $this->captcha->getWord(); - $id2 = $this->captcha->generate(); - $word2 = $this->captcha->getWord(); - - $this->assertFalse(empty($id1)); - $this->assertFalse(empty($id2)); - $this->assertFalse($id1 == $id2); - $this->assertFalse($word1 == $word2); - } - - public function testRenderSetsValue() - { - $this->testCaptchaIsRendered(); - $this->assertEquals($this->captcha->getId(), - $this->element->getValue()); - } - - public function testLabelIsNull() - { - $this->assertNull($this->element->getLabel()); - } - - public function testRenderInitializesSessionData() - { - $this->testCaptchaIsRendered(); - $session = $this->captcha->getSession(); - $this->assertEquals($this->captcha->getTimeout(), $session->setExpirationSeconds); - $this->assertEquals(1, $session->setExpirationHops); - $this->assertEquals($this->captcha->getWord(), $session->word); - } - - public function testWordValidates() - { - $this->testCaptchaIsRendered(); - $input = array($this->element->getName() => array("id" => $this->captcha->getId(), "input" => $this->captcha->getWord())); - $this->assertTrue($this->element->isValid("", $input)); - } - - public function testMissingNotValid() - { - $this->testCaptchaIsRendered(); - $this->assertFalse($this->element->isValid("", array())); - $input = array($this->element->getName() => array("input" => "blah")); - $this->assertFalse($this->element->isValid("", $input)); - } - - public function testWrongWordNotValid() - { - $this->testCaptchaIsRendered(); - $input = array($this->element->getName() => array("id" => $this->captcha->getId(), "input" => "blah")); - $this->assertFalse($this->element->isValid("", $input)); - } -} - -class Zend_Captcha_ImageTest_SessionContainer -{ - protected static $_word; - - public function __get($name) - { - if ('word' == $name) { - return self::$_word; - } - - return null; - } - - public function __set($name, $value) - { - if ('word' == $name) { - self::$_word = $value; - } else { - $this->$name = $value; - } - } - - public function __isset($name) - { - if (('word' == $name) && (null !== self::$_word)) { - return true; - } - - return false; - } - - public function __call($method, $args) - { - switch ($method) { - case 'setExpirationHops': - case 'setExpirationSeconds': - $this->$method = array_shift($args); - break; - default: - } - } -} - -// Call Zend_Captcha_ImageTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Captcha_ImageTest::main") { - Zend_Captcha_ImageTest::main(); -} diff --git a/tests/Zend/Captcha/ReCaptchaTest.php b/tests/Zend/Captcha/ReCaptchaTest.php deleted file mode 100644 index 1e0198c4286b2c9a88e48a97b0ffc495576b7d9d..0000000000000000000000000000000000000000 --- a/tests/Zend/Captcha/ReCaptchaTest.php +++ /dev/null @@ -1,165 +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_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ReCaptchaTest.php 10743 2008-08-07 02:24:43Z matthew $ - */ - -// Call Zend_Captcha_ReCaptchaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Captcha_ReCaptchaTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Form/Element/Captcha.php'; -require_once 'Zend/View.php'; - -/** - * @category Zend - * @package Zend_Captcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Captcha_ReCaptchaTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Captcha_ReCaptchaTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (isset($this->word)) { - unset($this->word); - } - - $this->element = new Zend_Form_Element_Captcha( - 'captchaR', - array( - 'captcha' => array( - 'ReCaptcha', - 'sessionClass' => 'Zend_Captcha_ReCaptchaTest_SessionContainer' - ) - ) - ); - $this->captcha = $this->element->getCaptcha(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testConstructorShouldSetOptions() - { - $options = array( - 'privKey' => 'privateKey', - 'pubKey' => 'publicKey', - 'ssl' => true, - 'xhtml' => true, - ); - $captcha = new Zend_Captcha_ReCaptcha($options); - $test = $captcha->getOptions(); - $compare = array('privKey' => $options['privKey'], 'pubKey' => $options['pubKey']); - $this->assertEquals($compare, $test); - - $service = $captcha->getService(); - $test = $service->getParams(); - $compare = array('ssl' => $options['ssl'], 'xhtml' => $options['xhtml']); - foreach ($compare as $key => $value) { - $this->assertTrue(array_key_exists($key, $test)); - $this->assertSame($value, $test[$key]); - } - } - - public function testShouldAllowSpecifyingServiceObject() - { - $captcha = new Zend_Captcha_ReCaptcha(); - $try = new Zend_Service_ReCaptcha(); - $this->assertNotSame($captcha->getService(), $try); - $captcha->setService($try); - $this->assertSame($captcha->getService(), $try); - } -} - -class Zend_Captcha_ReCaptchaTest_SessionContainer -{ - protected static $_word; - - public function __get($name) - { - if ('word' == $name) { - return self::$_word; - } - - return null; - } - - public function __set($name, $value) - { - if ('word' == $name) { - self::$_word = $value; - } else { - $this->$name = $value; - } - } - - public function __isset($name) - { - if (('word' == $name) && (null !== self::$_word)) { - return true; - } - - return false; - } - - public function __call($method, $args) - { - switch ($method) { - case 'setExpirationHops': - case 'setExpirationSeconds': - $this->$method = array_shift($args); - break; - default: - } - } -} - -// Call Zend_Captcha_ReCaptchaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Captcha_ReCaptchaTest::main") { - Zend_Captcha_ReCaptchaTest::main(); -} diff --git a/tests/Zend/Config/AllTests.php b/tests/Zend/Config/AllTests.php deleted file mode 100644 index b15fab9ea958c264e29310486b1eb55d753e8fd7..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/AllTests.php +++ /dev/null @@ -1,62 +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_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Config_AllTests::main'); -} - -require_once 'Zend/Config/IniTest.php'; -require_once 'Zend/Config/XmlTest.php'; - -/** - * @category Zend - * @package Zend_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Config_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Config'); - - $suite->addTestSuite('Zend_Config_IniTest'); - $suite->addTestSuite('Zend_Config_XmlTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Config_AllTests::main') { - Zend_Config_AllTests::main(); -} diff --git a/tests/Zend/Config/IniTest.php b/tests/Zend/Config/IniTest.php deleted file mode 100644 index 53399e1374bbec14a5b173fa0c7492da8b713ee3..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/IniTest.php +++ /dev/null @@ -1,266 +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_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IniTest.php 9636 2008-06-08 15:04:42Z rob $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Config_Ini - */ -require_once 'Zend/Config/Ini.php'; - -/** - * @category Zend - * @package Zend_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Config_IniTest extends PHPUnit_Framework_TestCase -{ - protected $_iniFileConfig; - protected $_iniFileAllSectionsConfig; - protected $_iniFileCircularConfig; - - public function setUp() - { - $this->_iniFileConfig = dirname(__FILE__) . '/_files/config.ini'; - $this->_iniFileAllSectionsConfig = dirname(__FILE__) . '/_files/allsections.ini'; - $this->_iniFileCircularConfig = dirname(__FILE__) . '/_files/circular.ini'; - $this->_iniFileMultipleInheritanceConfig = dirname(__FILE__) . '/_files/multipleinheritance.ini'; - $this->_iniFileSeparatorConfig = dirname(__FILE__) . '/_files/separator.ini'; - $this->_nonReadableConfig = dirname(__FILE__) . '/_files/nonreadable.ini'; - $this->_iniFileNoSectionsConfig = dirname(__FILE__) . '/_files/nosections.ini'; - $this->_iniFileInvalid = dirname(__FILE__) . '/_files/invalid.ini'; - } - - public function testLoadSingleSection() - { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'all'); - - $this->assertEquals('all', $config->hostname); - $this->assertEquals('live', $config->db->name); - $this->assertEquals('multi', $config->one->two->three); - $this->assertNull(@$config->nonexistent); // property doesn't exist - } - - public function testSectionInclude() - { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'staging'); - - $this->assertEquals('', $config->debug); // only in staging - $this->assertEquals('thisname', $config->name); // only in all - $this->assertEquals('username', $config->db->user); // only in all (nested version) - $this->assertEquals('staging', $config->hostname); // inherited and overridden - $this->assertEquals('dbstaging', $config->db->name); // inherited and overridden - } - - public function testTrueValues() - { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'debug'); - - $this->assertType('string', $config->debug); - $this->assertEquals('1', $config->debug); - $this->assertType('string', $config->values->changed); - $this->assertEquals('1', $config->values->changed); - } - - public function testEmptyValues() - { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'debug'); - - $this->assertType('string', $config->special->no); - $this->assertEquals('', $config->special->no); - $this->assertType('string', $config->special->null); - $this->assertEquals('', $config->special->null); - $this->assertType('string', $config->special->false); - $this->assertEquals('', $config->special->false); - } - - public function testMultiDepthExtends() - { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'other_staging'); - - $this->assertEquals('otherStaging', $config->only_in); // only in other_staging - $this->assertEquals('', $config->debug); // 1 level down: only in staging - $this->assertEquals('thisname', $config->name); // 2 levels down: only in all - $this->assertEquals('username', $config->db->user); // 2 levels down: only in all (nested version) - $this->assertEquals('staging', $config->hostname); // inherited from two to one and overridden - $this->assertEquals('dbstaging', $config->db->name); // inherited from two to one and overridden - $this->assertEquals('anotherpwd', $config->db->pass); // inherited from two to other_staging and overridden - } - - public function testErrorNoExtendsSection() - { - try { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'extendserror'); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('cannot be found', $expected->getMessage()); - } - } - - public function testInvalidKeys() - { - $sections = array('leadingdot', 'onedot', 'twodots', 'threedots', 'trailingdot'); - foreach ($sections as $section) { - try { - $config = new Zend_Config_Ini($this->_iniFileConfig, $section); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('Invalid key', $expected->getMessage()); - } - } - } - - public function testZF426() - { - try { - $config = new Zend_Config_Ini($this->_iniFileConfig, 'zf426'); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('Cannot create sub-key for', $expected->getMessage()); - } - } - - public function testZF413_MultiSections() - { - $config = new Zend_Config_Ini($this->_iniFileAllSectionsConfig, array('staging','other_staging')); - - $this->assertEquals('otherStaging', $config->only_in); - $this->assertEquals('staging', $config->hostname); - - } - - public function testZF413_AllSections() - { - $config = new Zend_Config_Ini($this->_iniFileAllSectionsConfig, null); - $this->assertEquals('otherStaging', $config->other_staging->only_in); - $this->assertEquals('staging', $config->staging->hostname); - } - - public function testZF414() - { - $config = new Zend_Config_Ini($this->_iniFileAllSectionsConfig, null); - $this->assertEquals(null, $config->getSectionName()); - $this->assertEquals(true, $config->areAllSectionsLoaded()); - - $config = new Zend_Config_Ini($this->_iniFileAllSectionsConfig, 'all'); - $this->assertEquals('all', $config->getSectionName()); - $this->assertEquals(false, $config->areAllSectionsLoaded()); - - $config = new Zend_Config_Ini($this->_iniFileAllSectionsConfig, array('staging','other_staging')); - $this->assertEquals(array('staging','other_staging'), $config->getSectionName()); - $this->assertEquals(false, $config->areAllSectionsLoaded()); - } - - public function testZF415() - { - try { - $config = new Zend_Config_Ini($this->_iniFileCircularConfig, null); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('circular inheritance', $expected->getMessage()); - } - } - - public function testErrorNoFile() - { - try { - $config = new Zend_Config_Ini('',''); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('Filename is not set', $expected->getMessage()); - } - } - - public function testErrorMultipleExensions() - { - try { - $config = new Zend_Config_Ini($this->_iniFileMultipleInheritanceConfig, 'three'); - zend::dump($config); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('may not extend multiple sections', $expected->getMessage()); - } - } - - public function testErrorNoSectionFound() - { - try { - $config = new Zend_Config_Ini($this->_iniFileConfig,array('all', 'notthere')); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('cannot be found', $expected->getMessage()); - } - - try { - $config = new Zend_Config_Ini($this->_iniFileConfig,'notthere'); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('cannot be found', $expected->getMessage()); - } - - } - - public function testZF739() - { - $config = new Zend_Config_Ini($this->_iniFileSeparatorConfig, 'all', array('nestSeparator'=>':')); - - $this->assertEquals('all', $config->hostname); - $this->assertEquals('live', $config->db->name); - $this->assertEquals('multi', $config->one->two->three); - } - - public function testZF2508NoSections() - { - $config = new Zend_Config_Ini($this->_iniFileNoSectionsConfig); - - $this->assertEquals('all', $config->hostname); - $this->assertEquals('two', $config->one->two); - $this->assertEquals('4', $config->one->three->four); - $this->assertEquals('5', $config->one->three->five); - } - - public function testZF2843NoSectionNoTree() - { - $filename = dirname(__FILE__) . '/_files/zf2843.ini'; - $config = new Zend_Config_Ini($filename, null, array('nestSeparator' => '.')); - - - $this->assertEquals('123', $config->abc); - $this->assertEquals('jkl', $config->ghi); - } - - public function testZF3196_InvalidIniFile() - { - try { - $config = new Zend_Config_Ini($this->_iniFileInvalid); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('Error parsing', $expected->getMessage()); - } - - } -} diff --git a/tests/Zend/Config/XmlTest.php b/tests/Zend/Config/XmlTest.php deleted file mode 100644 index d463bec6e19d36e6b31767ca7873aa866e4e91a7..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/XmlTest.php +++ /dev/null @@ -1,240 +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_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: XmlTest.php 10262 2008-07-21 16:31:27Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Config_Xml - */ -require_once 'Zend/Config/Xml.php'; - -/** - * @category Zend - * @package Zend_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Config_XmlTest extends PHPUnit_Framework_TestCase -{ - protected $_xmlFileConfig; - protected $_xmlFileAllSectionsConfig; - protected $_xmlFileCircularConfig; - protected $_xmlFileInvalid; - - public function setUp() - { - $this->_xmlFileConfig = dirname(__FILE__) . '/_files/config.xml'; - $this->_xmlFileAllSectionsConfig = dirname(__FILE__) . '/_files/allsections.xml'; - $this->_xmlFileCircularConfig = dirname(__FILE__) . '/_files/circular.xml'; - $this->_xmlFileTopLevelStringConfig = dirname(__FILE__) . '/_files/toplevelstring.xml'; - $this->_xmlFileOneTopLevelStringConfig = dirname(__FILE__) . '/_files/onetoplevelstring.xml'; - $this->_nonReadableConfig = dirname(__FILE__) . '/_files/nonreadable.xml'; - $this->_xmlFileSameNameKeysConfig = dirname(__FILE__) . '/_files/array.xml'; - $this->_xmlFileShortParamsOneConfig = dirname(__FILE__) . '/_files/shortparamsone.xml'; - $this->_xmlFileShortParamsTwoConfig = dirname(__FILE__) . '/_files/shortparamstwo.xml'; - $this->_xmlFileInvalid = dirname(__FILE__) . '/_files/invalid.xml'; - } - - public function testLoadSingleSection() - { - $config = new Zend_Config_Xml($this->_xmlFileConfig, 'all'); - $this->assertEquals('all', $config->hostname); - $this->assertEquals('live', $config->db->name); - $this->assertEquals('multi', $config->one->two->three); - $this->assertNull(@$config->nonexistent); // property doesn't exist - } - - public function testSectionInclude() - { - $config = new Zend_Config_Xml($this->_xmlFileConfig, 'staging'); - $this->assertEquals('false', $config->debug); // only in staging - $this->assertEquals('thisname', $config->name); // only in all - $this->assertEquals('username', $config->db->user); // only in all (nested version) - $this->assertEquals('staging', $config->hostname); // inherited and overridden - $this->assertEquals('dbstaging', $config->db->name); // inherited and overridden - } - - public function testMultiDepthExtends() - { - $config = new Zend_Config_Xml($this->_xmlFileConfig, 'other_staging'); - - $this->assertEquals('otherStaging', $config->only_in); // only in other_staging - $this->assertEquals('false', $config->debug); // 1 level down: only in staging - $this->assertEquals('thisname', $config->name); // 2 levels down: only in all - $this->assertEquals('username', $config->db->user); // 2 levels down: only in all (nested version) - $this->assertEquals('staging', $config->hostname); // inherited from two to one and overridden - $this->assertEquals('dbstaging', $config->db->name); // inherited from two to one and overridden - $this->assertEquals('anotherpwd', $config->db->pass); // inherited from two to other_staging and overridden - } - - public function testErrorNoInitialSection() - { - try { - $config = @new Zend_Config_Xml($this->_xmlFileConfig, 'notthere'); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('cannot be found in', $expected->getMessage()); - } - - try { - $config = @new Zend_Config_Xml($this->_xmlFileConfig, array('notthere', 'all')); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('cannot be found in', $expected->getMessage()); - } - } - - public function testErrorNoExtendsSection() - { - try { - $config = new Zend_Config_Xml($this->_xmlFileConfig, 'extendserror'); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('cannot be found', $expected->getMessage()); - } - } - - public function testZF413_MultiSections() - { - $config = new Zend_Config_Xml($this->_xmlFileAllSectionsConfig, array('staging','other_staging')); - - $this->assertEquals('otherStaging', $config->only_in); - $this->assertEquals('staging', $config->hostname); - } - - public function testZF413_AllSections() - { - $config = new Zend_Config_Xml($this->_xmlFileAllSectionsConfig, null); - $this->assertEquals('otherStaging', $config->other_staging->only_in); - $this->assertEquals('staging', $config->staging->hostname); - } - - public function testZF414() - { - $config = new Zend_Config_Xml($this->_xmlFileAllSectionsConfig, null); - $this->assertEquals(null, $config->getSectionName()); - $this->assertEquals(true, $config->areAllSectionsLoaded()); - - $config = new Zend_Config_Xml($this->_xmlFileAllSectionsConfig, 'all'); - $this->assertEquals('all', $config->getSectionName()); - $this->assertEquals(false, $config->areAllSectionsLoaded()); - - $config = new Zend_Config_Xml($this->_xmlFileAllSectionsConfig, array('staging','other_staging')); - $this->assertEquals(array('staging','other_staging'), $config->getSectionName()); - $this->assertEquals(false, $config->areAllSectionsLoaded()); - } - - public function testZF415() - { - try { - $config = new Zend_Config_Xml($this->_xmlFileCircularConfig, null); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('circular inheritance', $expected->getMessage()); - } - } - - public function testErrorNoFile() - { - try { - $config = new Zend_Config_Xml('',null); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('Filename is not set', $expected->getMessage()); - } - } - - public function testZF2162_TopLevelString() - { - $config = new Zend_Config_Xml($this->_xmlFileTopLevelStringConfig, null); - $this->assertEquals('one', $config->one); - $this->assertEquals('three', $config->two->three); - $this->assertEquals('five', $config->two->four->five); - $this->assertEquals('three', $config->six->three); - - $config = new Zend_Config_Xml($this->_xmlFileOneTopLevelStringConfig); - $this->assertEquals('one', $config->one); - $config = new Zend_Config_Xml($this->_xmlFileOneTopLevelStringConfig, 'one'); - $this->assertEquals('one', $config->one); - - } - - public function testZF2285_MultipleKeysOfTheSameName() - { - $config = new Zend_Config_Xml($this->_xmlFileSameNameKeysConfig, null); - $this->assertEquals('2a', $config->one->two->{0}); - $this->assertEquals('2b', $config->one->two->{1}); - $this->assertEquals('4', $config->three->four->{1}); - $this->assertEquals('5', $config->three->four->{0}->five); - } - - public function testZF2437_ArraysWithMultipleChildren() - { - $config = new Zend_Config_Xml($this->_xmlFileSameNameKeysConfig, null); - $this->assertEquals('1', $config->six->seven->{0}->eight); - $this->assertEquals('2', $config->six->seven->{1}->eight); - $this->assertEquals('3', $config->six->seven->{2}->eight); - $this->assertEquals('1', $config->six->seven->{0}->nine); - $this->assertEquals('2', $config->six->seven->{1}->nine); - $this->assertEquals('3', $config->six->seven->{2}->nine); - } - - public function testZF3578_InvalidOrMissingfXmlFile() - { - try { - $config = new Zend_Config_Xml($this->_xmlFileInvalid); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('parser error', $expected->getMessage()); - } - try { - $config = new Zend_Config_Xml('I/dont/exist'); - $this->fail('An expected Zend_Config_Exception has not been raised'); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('failed to load', $expected->getMessage()); - } - } - - public function testShortParamsOne() - { - $config = new Zend_Config_Xml($this->_xmlFileShortParamsOneConfig, 'all'); - $this->assertEquals('all', $config->hostname); - $this->assertEquals('thisname', $config->name); - $this->assertEquals('username', $config->db->user); - $this->assertEquals('live', $config->db->name); - $this->assertEquals('multi', $config->one->two->three); - } - - public function testShortParamsTwo() - { - $config = new Zend_Config_Xml($this->_xmlFileShortParamsTwoConfig, 'all'); - $this->assertEquals('all', $config->hostname); - $this->assertEquals('thisname', $config->name); - $this->assertEquals('username', $config->db->user); - $this->assertEquals('live', $config->db->name); - $this->assertEquals('multi', $config->one->two->three); - } -} diff --git a/tests/Zend/Config/_files/allsections.ini b/tests/Zend/Config/_files/allsections.ini deleted file mode 100644 index a080611392356edcb9cc3834befa67f3092eb5e3..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/allsections.ini +++ /dev/null @@ -1,26 +0,0 @@ -[all] -hostname = all -name = thisname -db.host = 127.0.0.1 -db.user = username -db.pass = password -db.name = live -one.two.three = multi - -[staging : all] -hostname = staging -db.name = dbstaging -debug = false - -[debug:all] -hostname = debug -debug = true -values.changed = yes -db.name = dbdebug -special.no = no -special.null = null -special.false = false - -[other_staging] -only_in = otherStaging -db.pass = anotherpwd diff --git a/tests/Zend/Config/_files/allsections.xml b/tests/Zend/Config/_files/allsections.xml deleted file mode 100644 index 1abb816741cab2b56c38b08eb2c8c1e37989c0e7..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/allsections.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<config> - <all> - <hostname>all</hostname> - <name>thisname</name> - <db> - <host>127.0.0.1</host> - <user>username</user> - <pass>password</pass> - <name>live</name> - </db> - <one> - <two> - <three>multi</three> - </two> - </one> - </all> - - <staging extends="all"> - <hostname>staging</hostname> - <db> - <name>dbstaging</name> - </db> - <debug>false</debug> - </staging> - - <other_staging> - <only_in>otherStaging</only_in> - <db> - <pass>anotherpwd</pass> - </db> - </other_staging> - - -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/array.xml b/tests/Zend/Config/_files/array.xml deleted file mode 100644 index 9a98105f8fd146399e99decdafdd32070ad14859..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/array.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0"?> -<config> - <one> - <two>2a</two> - <two>2b</two> - </one> - <three> - <four> - <five>5</five> - </four> - <four>4</four> - <four> - <five>5</five> - </four> - </three> - <six> - <seven> - <eight>1</eight> - <nine>1</nine> - </seven> - <seven> - <eight>2</eight> - <nine>2</nine> - </seven> - <seven> - <eight>3</eight> - <nine>3</nine> - </seven> - </six> -</config> - diff --git a/tests/Zend/Config/_files/circular.ini b/tests/Zend/Config/_files/circular.ini deleted file mode 100644 index 582fc6af38a24e0554cf17d8e28630942fb06b3b..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/circular.ini +++ /dev/null @@ -1,8 +0,0 @@ -[A : C] -someKey = value_A - -[B : A] -someKey = value_B - -[C : B] -someKey = value_C diff --git a/tests/Zend/Config/_files/circular.xml b/tests/Zend/Config/_files/circular.xml deleted file mode 100644 index 5180525ca780ba619fedbc334f3f4b5ce8c82462..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/circular.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<config> - <a extends="c"> - <someKey>value_A</someKey> - </a> - <b extends="a"> - <someKey>value_B</someKey> - </b> - <c extends="b"> - <someKey>value_C</someKey> - </c> -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/config.ini b/tests/Zend/Config/_files/config.ini deleted file mode 100644 index d88bb23439a3617ce71751052a5fceaa49b10b0b..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/config.ini +++ /dev/null @@ -1,50 +0,0 @@ -[all] -hostname = all -name = thisname -db.host = 127.0.0.1 -db.user = username -db.pass = password -db.name = live -one.two.three = multi - -[staging: all] -hostname = staging -db.name = dbstaging -debug = false - -[debug:all] -hostname = debug -debug = true -values.changed = yes -db.name = dbdebug -special.no = no -special.null = null -special.false = false - -[other_staging: staging] -only_in = otherStaging -db.pass = anotherpwd - - -; invalid keys -[leadingdot] -.test = dot-test - -[onedot] -. = dot-test - -[twodots] -... = dot-test - -[threedots] -... = dot-test - -[trailingdot] -test. = dot-test - -[extendserror:nonexistent] -testing =123 - -[zf426] -db = one -db.name = two diff --git a/tests/Zend/Config/_files/config.xml b/tests/Zend/Config/_files/config.xml deleted file mode 100644 index 517bef8dd5018e79ba5fd97e57f425806b5ffb90..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/config.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0"?> -<config> - <all> - <hostname>all</hostname> - <name>thisname</name> - <db> - <host>127.0.0.1</host> - <user>username</user> - <pass>password</pass> - <name>live</name> - </db> - <one> - <two> - <three>multi</three> - </two> - </one> - </all> - - <staging extends="all"> - <hostname>staging</hostname> - <db> - <name>dbstaging</name> - </db> - <debug>false</debug> - </staging> - - <other_staging extends="staging"> - <only_in>otherStaging</only_in> - <db> - <pass>anotherpwd</pass> - </db> - </other_staging> - - <extendserror extends="nonexistent"> - </extendserror> -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/invalid.ini b/tests/Zend/Config/_files/invalid.ini deleted file mode 100644 index 5e3f8f948401c90439cf6f74768d8aa18ae9c37a..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/invalid.ini +++ /dev/null @@ -1,2 +0,0 @@ -[default] -foo = /("bar) diff --git a/tests/Zend/Config/_files/invalid.xml b/tests/Zend/Config/_files/invalid.xml deleted file mode 100644 index 82769b38035cd681ba6f30addd3774db51b3ac5a..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/invalid.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<config> - <a extends="c"> - <someKey>value_A</someKey> - </a> - <b extends="a"> - <someKey>value_B</someKey> - </b> - <c extends="b"> - <someKey>value_C</someKey> - </c> -</other> \ No newline at end of file diff --git a/tests/Zend/Config/_files/multipleinheritance.ini b/tests/Zend/Config/_files/multipleinheritance.ini deleted file mode 100644 index 0b510058ac76c8cf921ff09836fb1d9acd65c211..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/multipleinheritance.ini +++ /dev/null @@ -1,8 +0,0 @@ -[one] -one = 1 - -[two] -two = 2 - -[multiinherit: one: two] -three=3 diff --git a/tests/Zend/Config/_files/nosections.ini b/tests/Zend/Config/_files/nosections.ini deleted file mode 100644 index 7b4ed43faa20b6cfd7b0cef16edf3be0a53945e4..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/nosections.ini +++ /dev/null @@ -1,5 +0,0 @@ - -hostname = all -one.two = two -one.three.four = 4 -one.three.five = 5 diff --git a/tests/Zend/Config/_files/onetoplevelstring.xml b/tests/Zend/Config/_files/onetoplevelstring.xml deleted file mode 100644 index 04be37065ac2bc8b4925894312a65b5a43bc8a91..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/onetoplevelstring.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0"?> -<config> - <one>one</one> -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/separator.ini b/tests/Zend/Config/_files/separator.ini deleted file mode 100644 index 94323afb67195808e27d4d45c9c50ed463f354a3..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/separator.ini +++ /dev/null @@ -1,8 +0,0 @@ -[all] -hostname = all -name = thisname -db:host = 127.0.0.1 -db:user = username -db:pass = password -db:name = live -one:two:three = multi \ No newline at end of file diff --git a/tests/Zend/Config/_files/shortparamsone.xml b/tests/Zend/Config/_files/shortparamsone.xml deleted file mode 100644 index bee0f20ade1321f2097f414dd75d08becba9670b..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/shortparamsone.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<config> - <all hostname="all" name="thisname"> - <db host="127.0.0.1" user="username" pass="password" name="live"/> - <one> - <two three="multi" /> - </one> - </all> - - <staging extends="all" hostname="staging" debug="false"> - <db name="dbstaging"/> - </staging> - - <other_staging extends="staging" only_in="otherStaging"> - <db pass="anotherpwd"/> - </other_staging> - - <extendserror extends="nonexistent"> - </extendserror> -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/shortparamstwo.xml b/tests/Zend/Config/_files/shortparamstwo.xml deleted file mode 100644 index 1eb107479c3341f0914f202456bf790747025d11..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/shortparamstwo.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0"?> -<config> - <all hostname="all" name="thisname"> - <db> - <host value="127.0.0.1"/> - <user value="username"/> - <pass value="password"/> - <name value="live"/> - </db> - <one> - <two> - <three value="multi"/> - </two> - </one> - </all> - - <staging extends="all" hostname="staging" debug="false"> - <db> - <name value="dbstaging"/> - </db> - </staging> - - <other_staging extends="staging" only_in="otherStaging"> - <db> - <pass value="anotherpwd"/> - </db> - </other_staging> - - <extendserror extends="nonexistent"> - </extendserror> -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/toplevelstring.xml b/tests/Zend/Config/_files/toplevelstring.xml deleted file mode 100644 index 59e258796a53a5820068adb2a1d6d20860d2a94e..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/toplevelstring.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<config> - <one>one</one> - <two> - <three>three</three> - <four> - <five>five</five> - </four> - </two> - <six extends="two"></six> -</config> \ No newline at end of file diff --git a/tests/Zend/Config/_files/zf2843.ini b/tests/Zend/Config/_files/zf2843.ini deleted file mode 100644 index ac510ea52b63bc6404ba860206a07c45b381fec3..0000000000000000000000000000000000000000 --- a/tests/Zend/Config/_files/zf2843.ini +++ /dev/null @@ -1,3 +0,0 @@ -abc = def -ghi = jkl -abc=123 diff --git a/tests/Zend/ConfigTest.php b/tests/Zend/ConfigTest.php deleted file mode 100644 index ff0fb0ed4984856125107cec75b304ccb4d5700d..0000000000000000000000000000000000000000 --- a/tests/Zend/ConfigTest.php +++ /dev/null @@ -1,441 +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_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ConfigTest.php 11502 2008-09-23 20:16:32Z rob $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * @category Zend - * @package Zend_Config - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_ConfigTest extends PHPUnit_Framework_TestCase -{ - protected $_iniFileConfig; - protected $_iniFileNested; - - public function setUp() - { - // Arrays representing common config configurations - $this->_all = array( - 'hostname' => 'all', - 'name' => 'thisname', - 'db' => array( - 'host' => '127.0.0.1', - 'user' => 'username', - 'pass' => 'password', - 'name' => 'live' - ), - 'one' => array( - 'two' => array( - 'three' => 'multi' - ) - ) - ); - - $this->_numericData = array( - 0 => 34, - 1 => 'test', - ); - - $this->_menuData1 = array( - 'button' => array( - 'b0' => array( - 'L1' => 'button0-1', - 'L2' => 'button0-2', - 'L3' => 'button0-3' - ), - 'b1' => array( - 'L1' => 'button1-1', - 'L2' => 'button1-2' - ), - 'b2' => array( - 'L1' => 'button2-1' - ) - ) - ); - - $this->_leadingdot = array('.test' => 'dot-test'); - $this->_invalidkey = array(' ' => 'test', ''=>'test2'); - - } - - public function testLoadSingleSection() - { - $config = new Zend_Config($this->_all, false); - - $this->assertEquals('all', $config->hostname); - $this->assertEquals('live', $config->db->name); - $this->assertEquals('multi', $config->one->two->three); - $this->assertNull($config->nonexistent); // property doesn't exist - } - - public function testIsset() - { - if (version_compare(PHP_VERSION, '5.1', '>=')) { - $config = new Zend_Config($this->_all, false); - - $this->assertFalse(isset($config->notarealkey)); - $this->assertTrue(isset($config->hostname)); // top level - $this->assertTrue(isset($config->db->name)); // one level down - } - } - - public function testModification() - { - $config = new Zend_Config($this->_all, true); - - // overwrite an existing key - $this->assertEquals('thisname', $config->name); - $config->name = 'anothername'; - $this->assertEquals('anothername', $config->name); - - // overwrite an existing multi-level key - $this->assertEquals('multi', $config->one->two->three); - $config->one->two->three = 'anothername'; - $this->assertEquals('anothername', $config->one->two->three); - - // create a new multi-level key - $config->does = array('not'=> array('exist' => 'yet')); - $this->assertEquals('yet', $config->does->not->exist); - - } - - public function testNoModifications() - { - $config = new Zend_Config($this->_all); - try { - $config->hostname = 'test'; - } catch (Zend_Config_Exception $expected) { - $this->assertContains('is read only', $expected->getMessage()); - return; - } - $this->fail('An expected Zend_Config_Exception has not been raised'); - } - - public function testNoNestedModifications() - { - $config = new Zend_Config($this->_all); - try { - $config->db->host = 'test'; - } catch (Zend_Config_Exception $expected) { - $this->assertContains('is read only', $expected->getMessage()); - return; - } - $this->fail('An expected Zend_Config_Exception has not been raised'); - } - - public function testNumericKeys() - { - $data = new Zend_Config($this->_numericData); - $this->assertEquals('test', $data->{1}); - $this->assertEquals(34, $data->{0}); - } - - public function testCount() - { - $data = new Zend_Config($this->_menuData1); - $this->assertEquals(3, count($data->button)); - } - - public function testIterator() - { - // top level - $config = new Zend_Config($this->_all); - $var = ''; - foreach ($config as $key=>$value) { - if (is_string($value)) { - $var .= "\nkey = $key, value = $value"; - } - } - $this->assertContains('key = name, value = thisname', $var); - - // 1 nest - $var = ''; - foreach ($config->db as $key=>$value) { - $var .= "\nkey = $key, value = $value"; - } - $this->assertContains('key = host, value = 127.0.0.1', $var); - - // 2 nests - $config = new Zend_Config($this->_menuData1); - $var = ''; - foreach ($config->button->b1 as $key=>$value) { - $var .= "\nkey = $key, value = $value"; - } - $this->assertContains('key = L1, value = button1-1', $var); - } - - public function testArray() - { - $config = new Zend_Config($this->_all); - - ob_start(); - print_r($config->toArray()); - $contents = ob_get_contents(); - ob_end_clean(); - - $this->assertContains('Array', $contents); - $this->assertContains('[hostname] => all', $contents); - $this->assertContains('[user] => username', $contents); - } - - public function testErrorWriteToReadOnly() - { - $config = new Zend_Config($this->_all); - try { - $config->test = '32'; - } catch (Zend_Config_Exception $expected) { - $this->assertContains('read only', $expected->getMessage()); - return; - } - - $this->fail('An expected Zend_Config_Exception has not been raised'); - } - - public function testZF343() - { - $config_array = array( - 'controls' => array( - 'visible' => array( - 'name' => 'visible', - 'type' => 'checkbox', - 'attribs' => array(), // empty array - ), - ), - ); - $form_config = new Zend_Config($config_array, true); - $this->assertSame(array(), $form_config->controls->visible->attribs->toArray()); - } - - public function testZF402() - { - $configArray = array( - 'data1' => 'someValue', - 'data2' => 'someValue', - 'false1' => false, - 'data3' => 'someValue' - ); - $config = new Zend_Config($configArray); - $this->assertTrue(count($config) === count($configArray)); - $count = 0; - foreach ($config as $key => $value) { - if ($key === 'false1') { - $this->assertTrue($value === false); - } else { - $this->assertTrue($value === 'someValue'); - } - $count++; - } - $this->assertTrue($count === 4); - } - - public function testZf1019_HandlingInvalidKeyNames() - { - $config = new Zend_Config($this->_leadingdot); - $array = $config->toArray(); - $this->assertContains('dot-test', $array['.test']); - } - - public function testZF1019_EmptyKeys() - { - $config = new Zend_Config($this->_invalidkey); - $array = $config->toArray(); - $this->assertContains('test', $array[' ']); - $this->assertContains('test', $array['']); - } - - public function testZF1417_DefaultValues() - { - $config = new Zend_Config($this->_all); - $value = $config->get('notthere', 'default'); - $this->assertTrue($value === 'default'); - $this->assertTrue($config->notThere === null); - - } - - public function testUnsetException() - { - // allow modifications is off - expect an exception - $config = new Zend_Config($this->_all, false); - - $this->assertTrue(isset($config->hostname)); // top level - - try { - unset($config->hostname); - } catch (Zend_Config_Exception $expected) { - $this->assertContains('is read only', $expected->getMessage()); - return; - } - $this->fail('Expected read only exception has not been raised.'); - } - public function testUnset() - { - // allow modifications is on - $config = new Zend_Config($this->_all, true); - - $this->assertTrue(isset($config->hostname)); - $this->assertTrue(isset($config->db->name)); - - unset($config->hostname); - unset($config->db->name); - - $this->assertFalse(isset($config->hostname)); - $this->assertFalse(isset($config->db->name)); - - } - - public function testMerge() - { - $stdArray = array( - 'test_feature' => false, - 'some_files' => array( - 'foo'=>'dir/foo.xml', - 'bar'=>'dir/bar.xml', - ), - 2 => 123, - ); - $stdConfig = new Zend_Config($stdArray, true); - - $devArray = array( - 'test_feature'=>true, - 'some_files' => array( - 'bar' => 'myDir/bar.xml', - 'baz' => 'myDir/baz.xml', - ), - 2 => 456, - ); - $devConfig = new Zend_Config($devArray); - - $stdConfig->merge($devConfig); - - $this->assertTrue($stdConfig->test_feature); - $this->assertEquals('myDir/bar.xml', $stdConfig->some_files->bar); - $this->assertEquals('myDir/baz.xml', $stdConfig->some_files->baz); - $this->assertEquals('dir/foo.xml', $stdConfig->some_files->foo); - $this->assertEquals(456, $stdConfig->{2}); - - } - - /** - * Ensures that toArray() supports objects of types other than Zend_Config - * - * @return void - */ - public function testToArraySupportsObjects() - { - $configData = array( - 'a' => new stdClass(), - 'b' => array( - 'c' => new stdClass(), - 'd' => new stdClass() - ) - ); - $config = new Zend_Config($configData); - $this->assertEquals($config->toArray(), $configData); - $this->assertType('stdClass', $config->a); - $this->assertType('stdClass', $config->b->c); - $this->assertType('stdClass', $config->b->d); - } - - /** - * ensure that modification is not allowed after calling setReadOnly() - * - */ - public function testSetReadOnly() - { - $configData = array( - 'a' => 'a' - ); - $config = new Zend_Config($configData, true); - $config->b = 'b'; - - $config->setReadOnly(); - try { - $config->c = 'c'; - } catch (Zend_Config_Exception $expected) { - $this->assertContains('is read only', $expected->getMessage()); - return; - } - $this->fail('Expected read only exception has not been raised.'); - } - - public function testZF3408_countNotDecreasingOnUnset() - { - $configData = array( - 'a' => 'a', - 'b' => 'b', - 'c' => 'c', - ); - $config = new Zend_Config($configData, true); - $this->assertEquals(count($config), 3); - unset($config->b); - $this->assertEquals(count($config), 2); - } - - public function testZF4107_ensureCloneDoesNotKeepNestedReferences() - { - $parent = new Zend_Config(array('key' => array('nested' => 'parent')), true); - $newConfig = clone $parent; - $newConfig->merge(new Zend_Config(array('key' => array('nested' => 'override')), true)); - - $this->assertEquals('override', $newConfig->key->nested, '$newConfig is not overridden'); - $this->assertEquals('parent', $parent->key->nested, '$parent has been overridden'); - - } - - /** - * @group ZF-3575 - * - */ - public function testMergeHonoursAllowModificationsFlagAtAllLevels() - { - $config = new Zend_Config(array('key' => array('nested' => 'yes'), 'key2'=>'yes'), false); - $config2 = new Zend_Config(array(), true); - - $config2->merge($config); - try { - $config2->key2 = 'no'; - } catch (Zend_Config_Exception $e) { - $this->fail('Unexpected exception at top level has been raised: ' . $e->getMessage()); - } - $this->assertEquals('no', $config2->key2); - - try { - $config2->key->nested = 'no'; - } catch (Zend_Config_Exception $e) { - $this->fail('Unexpected exception on nested object has been raised: ' . $e->getMessage()); - } - $this->assertEquals('no', $config2->key->nested); - - } -} - diff --git a/tests/Zend/Console/GetoptTest.php b/tests/Zend/Console/GetoptTest.php deleted file mode 100644 index da0e24d296147c7253f01eefbf7d94afb9da64f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Console/GetoptTest.php +++ /dev/null @@ -1,468 +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 - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -error_reporting( E_ALL | E_STRICT ); - -/** - * Zend_Console_Getopt - */ -require_once 'Zend/Console/Getopt.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Console_Getopt - * @subpackage UnitTests - */ -class Zend_Console_GetoptTest extends PHPUnit_Framework_TestCase -{ - public function testGetoptShortOptionsGnuMode() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals(true, $opts->a); - $this->assertNull(@$opts->b); - $this->assertEquals($opts->p, 'p_arg'); - } - - public function testGetoptLongOptionsZendMode() - { - $opts = new Zend_Console_Getopt(array( - 'apple|a' => 'Apple option', - 'banana|b' => 'Banana option', - 'pear|p=s' => 'Pear option' - ), - array('-a', '-p', 'p_arg')); - $this->assertTrue($opts->apple); - $this->assertNull(@$opts->banana); - $this->assertEquals($opts->pear, 'p_arg'); - } - - public function testGetoptZendModeEqualsParam() - { - $opts = new Zend_Console_Getopt(array( - 'apple|a' => 'Apple option', - 'banana|b' => 'Banana option', - 'pear|p=s' => 'Pear option' - ), - array('--pear=pear.phpunit.de')); - $this->assertEquals($opts->pear, 'pear.phpunit.de'); - } - - public function testGetoptToString() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals($opts->__toString(), 'a=true p=p_arg'); - } - - public function testGetoptDumpString() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals($opts->toString(), 'a=true p=p_arg'); - } - - public function testGetoptDumpArray() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals(implode(',', $opts->toArray()), 'a,p,p_arg'); - } - - public function testGetoptDumpJson() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals($opts->toJson(), - '{"options":[{"option":{"flag":"a","parameter":true}},{"option":{"flag":"p","parameter":"p_arg"}}]}'); - - } - - public function testGetoptDumpXml() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals($opts->toXml(), - "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<options><option flag=\"a\"/><option flag=\"p\" parameter=\"p_arg\"/></options>\n"); - } - - public function testGetoptExceptionForMissingFlag() - { - try { - $opts = new Zend_Console_Getopt(array('|a'=>'Apple option')); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), - 'Blank flag not allowed in rule "|a".'); - } - } - - public function testGetoptExceptionForDuplicateFlag() - { - try { - $opts = new Zend_Console_Getopt( - array('apple|apple'=>'apple-option')); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), - 'Option "--apple" is being defined more than once.'); - } - - try { - $opts = new Zend_Console_Getopt( - array('a'=>'Apple option', 'apple|a'=>'Apple option')); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), - 'Option "-a" is being defined more than once.'); - } - } - - public function testGetoptAddRules() - { - $opts = new Zend_Console_Getopt( - array( - 'apple|a' => 'Apple option', - 'banana|b' => 'Banana option' - ), - array('--pear', 'pear_param')); - try { - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Option "pear" is not recognized.'); - } - $opts->addRules(array('pear|p=s' => 'Pear option')); - $this->assertEquals($opts->pear, 'pear_param'); - } - - public function testGetoptExceptionMissingParameter() - { - $opts = new Zend_Console_Getopt( - array( - 'apple|a=s' => 'Apple with required parameter', - 'banana|b' => 'Banana' - ), - array('--apple')); - try { - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Option "apple" requires a parameter.'); - } - } - - public function testGetoptOptionalParameter() - { - $opts = new Zend_Console_Getopt( - array( - 'apple|a-s' => 'Apple with optional parameter', - 'banana|b' => 'Banana' - ), - array('--apple', '--banana')); - $this->assertTrue($opts->apple); - $this->assertTrue($opts->banana); - } - - public function testGetoptIgnoreCaseGnuMode() - { - $opts = new Zend_Console_Getopt('aB', array('-A', '-b'), - array(Zend_Console_Getopt::CONFIG_IGNORECASE => true)); - $this->assertEquals(true, $opts->a); - $this->assertEquals(true, $opts->B); - } - - public function testGetoptIgnoreCaseZendMode() - { - $opts = new Zend_Console_Getopt( - array( - 'apple|a' => 'Apple-option', - 'Banana|B' => 'Banana-option' - ), - array('--Apple', '--bAnaNa'), - array(Zend_Console_Getopt::CONFIG_IGNORECASE => true)); - $this->assertEquals(true, $opts->apple); - $this->assertEquals(true, $opts->BANANA); - } - - public function testGetoptIsSet() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - $this->assertTrue(isset($opts->a)); - $this->assertFalse(isset($opts->b)); - } - - public function testGetoptIsSetAlias() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - $opts->setAliases(array('a' => 'apple', 'b' => 'banana')); - $this->assertTrue(isset($opts->apple)); - $this->assertFalse(isset($opts->banana)); - } - - public function testGetoptIsSetInvalid() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - $opts->setAliases(array('a' => 'apple', 'b' => 'banana')); - $this->assertFalse(isset($opts->cumquat)); - } - - public function testGetoptSet() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - $this->assertFalse(isset($opts->b)); - $opts->b = true; - $this->assertTrue(isset($opts->b)); - } - - public function testGetoptSetBeforeParse() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - $opts->b = true; - $this->assertTrue(isset($opts->b)); - } - - public function testGetoptUnSet() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - $this->assertTrue(isset($opts->a)); - unset($opts->a); - $this->assertFalse(isset($opts->a)); - } - - public function testGetoptUnSetBeforeParse() - { - $opts = new Zend_Console_Getopt('ab', array('-a')); - unset($opts->a); - $this->assertFalse(isset($opts->a)); - } - - public function testGetoptAddArguments() - { - $opts = new Zend_Console_Getopt('abp:', array('-a')); - $this->assertNull(@$opts->p); - $opts->addArguments(array('-p', 'p_arg')); - $this->assertEquals($opts->p, 'p_arg'); - } - - public function testGetoptRemainingArgs() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '--', 'file1', 'file2')); - $this->assertEquals(implode(',', $opts->getRemainingArgs()), 'file1,file2'); - $opts = new Zend_Console_Getopt('abp:', array('-a', 'file1', 'file2')); - $this->assertEquals(implode(',', $opts->getRemainingArgs()), 'file1,file2'); - } - - public function testGetoptDashDashFalse() - { - try { - $opts = new Zend_Console_Getopt('abp:', array('-a', '--', '--fakeflag'), - array(Zend_Console_Getopt::CONFIG_DASHDASH => false)); - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Option "fakeflag" is not recognized.'); - } - } - - public function testGetoptGetOptions() - { - $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg')); - $this->assertEquals(implode(',', $opts->getOptions()), 'a,p'); - } - - public function testGetoptGetUsageMessage() - { - $opts = new Zend_Console_Getopt('abp:', array('-x')); - $message = preg_replace('/Usage: .* \[ options \]/', - 'Usage: <progname> [ options ]', - $opts->getUsageMessage()); - $message = preg_replace('/ /', '_', $message); - $this->assertEquals($message, - "Usage:_<progname>_[_options_]\n-a___________________\n-b___________________\n-p_<string>__________\n"); - } - - public function testGetoptUsageMessageFromException() - { - try { - $opts = new Zend_Console_Getopt(array( - 'apple|a-s' => 'apple', - 'banana1|banana2|banana3|banana4' => 'banana', - 'pear=s' => 'pear'), - array('-x')); - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $message = preg_replace('/Usage: .* \[ options \]/', - 'Usage: <progname> [ options ]', - $e->getUsageMessage()); - $message = preg_replace('/ /', '_', $message); - $this->assertEquals($message, - "Usage:_<progname>_[_options_]\n--apple|-a_[_<string>_]_________________apple\n--banana1|--banana2|--banana3|--banana4_banana\n--pear_<string>_________________________pear\n"); - - } - } - - public function testGetoptSetAliases() - { - $opts = new Zend_Console_Getopt('abp:', array('--apple')); - $opts->setAliases(array('a' => 'apple')); - $this->assertTrue($opts->a); - } - - public function testGetoptSetAliasesIgnoreCase() - { - $opts = new Zend_Console_Getopt('abp:', array('--apple'), - array(Zend_Console_Getopt::CONFIG_IGNORECASE => true)); - $opts->setAliases(array('a' => 'APPLE')); - $this->assertTrue($opts->apple); - } - - public function testGetoptSetAliasesWithNamingConflict() - { - $opts = new Zend_Console_Getopt('abp:', array('--apple')); - $opts->setAliases(array('a' => 'apple')); - try { - $opts->setAliases(array('b' => 'apple')); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Option "--apple" is being defined more than once.'); - } - } - - public function testGetoptSetAliasesInvalid() - { - $opts = new Zend_Console_Getopt('abp:', array('--apple')); - $opts->setAliases(array('c' => 'cumquat')); - $opts->setArguments(array('-c')); - try { - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals('Option "c" is not recognized.', $e->getMessage()); - } - } - - public function testGetoptSetHelp() - { - $opts = new Zend_Console_Getopt('abp:', array('-a')); - $opts->setHelp(array( - 'a' => 'apple', - 'b' => 'banana', - 'p' => 'pear')); - $message = preg_replace('/Usage: .* \[ options \]/', - 'Usage: <progname> [ options ]', - $opts->getUsageMessage()); - $message = preg_replace('/ /', '_', $message); - $this->assertEquals($message, - "Usage:_<progname>_[_options_]\n-a___________________apple\n-b___________________banana\n-p_<string>__________pear\n"); - - } - - public function testGetoptSetHelpInvalid() - { - $opts = new Zend_Console_Getopt('abp:', array('-a')); - $opts->setHelp(array( - 'a' => 'apple', - 'b' => 'banana', - 'p' => 'pear', - 'c' => 'cumquat')); - $message = preg_replace('/Usage: .* \[ options \]/', - 'Usage: <progname> [ options ]', - $opts->getUsageMessage()); - $message = preg_replace('/ /', '_', $message); - $this->assertEquals($message, - "Usage:_<progname>_[_options_]\n-a___________________apple\n-b___________________banana\n-p_<string>__________pear\n"); - } - - public function testGetoptCheckParameterType() - { - $opts = new Zend_Console_Getopt(array( - 'apple|a=i' => 'apple with integer', - 'banana|b=w' => 'banana with word', - 'pear|p=s' => 'pear with string', - 'orange|o-i' => 'orange with optional integer', - 'lemon|l-w' => 'lemon with optional word', - 'kumquat|k-s' => 'kumquat with optional string')); - - $opts->setArguments(array('-a', 327)); - $opts->parse(); - $this->assertEquals(327, $opts->a); - - $opts->setArguments(array('-a', 'noninteger')); - try { - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Option "apple" requires an integer parameter, but was given "noninteger".'); - } - - $opts->setArguments(array('-b', 'word')); - $this->assertEquals('word', $opts->b); - - $opts->setArguments(array('-b', 'two words')); - try { - $opts->parse(); - $this->fail('Expected to catch Zend_Console_Getopt_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Console_Getopt_Exception', $e, - 'Expected Zend_Console_Getopt_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Option "banana" requires a single-word parameter, but was given "two words".'); - } - - $opts->setArguments(array('-p', 'string')); - $this->assertEquals('string', $opts->p); - - $opts->setArguments(array('-o', 327)); - $this->assertEquals(327, $opts->o); - - $opts->setArguments(array('-o')); - $this->assertTrue($opts->o); - - $opts->setArguments(array('-l', 'word')); - $this->assertEquals('word', $opts->l); - - $opts->setArguments(array('-k', 'string')); - $this->assertEquals('string', $opts->k); - - } - -} diff --git a/tests/Zend/Controller/Action/Helper/ActionStackTest.php b/tests/Zend/Controller/Action/Helper/ActionStackTest.php deleted file mode 100644 index 5ee6bc478806912104b8ee38728bf8eeeadb513f..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/ActionStackTest.php +++ /dev/null @@ -1,174 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_ActionStackTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_ActionStackTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action/Helper/ActionStack.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Simple.php'; - -/** - * Test class for Zend_Controller_Action_Helper_ActionStack. - */ -class Zend_Controller_Action_Helper_ActionStackTest extends PHPUnit_Framework_TestCase -{ - - /** - * @var Zend_Controller_Front - */ - public $front; - - /** - * @var Zend_Controller_Request_Http - */ - public $request; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_ActionStackTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - - $this->request = new Zend_Controller_Request_Http(); - $this->front->setRequest($this->request); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testConstructorInstantiatesPluginIfNotPresent() - { - $this->assertFalse($this->front->hasPlugin('Zend_Controller_Plugin_ActionStack')); - $helper = new Zend_Controller_Action_Helper_ActionStack(); - $this->assertTrue($this->front->hasPlugin('Zend_Controller_Plugin_ActionStack')); - } - - public function testConstructorUsesExistingPluginWhenPresent() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $this->front->registerPlugin($plugin); - $helper = new Zend_Controller_Action_Helper_ActionStack(); - $this->assertTrue($this->front->hasPlugin('Zend_Controller_Plugin_ActionStack')); - $registered = $this->front->getPlugin('Zend_Controller_Plugin_ActionStack'); - $this->assertSame($plugin, $registered); - } - - public function testPushStackPushesToPluginStack() - { - $helper = new Zend_Controller_Action_Helper_ActionStack(); - $plugin = $this->front->getPlugin('Zend_Controller_Plugin_ActionStack'); - - $request = new Zend_Controller_Request_Simple(); - $request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - - $helper->pushStack($request); - - $next = $plugin->popStack(); - $this->assertTrue($next instanceof Zend_Controller_Request_Abstract); - $this->assertEquals($request->getModuleName(), $next->getModuleName()); - $this->assertEquals($request->getControllerName(), $next->getControllerName()); - $this->assertEquals($request->getActionName(), $next->getActionName()); - $this->assertFalse($next->isDispatched()); - } - - public function testActionToStackPushesNewRequestToPluginStack() - { - $helper = new Zend_Controller_Action_Helper_ActionStack(); - $plugin = $this->front->getPlugin('Zend_Controller_Plugin_ActionStack'); - - $helper->actionToStack('baz', 'bar', 'foo'); - $next = $plugin->popStack(); - $this->assertTrue($next instanceof Zend_Controller_Request_Abstract); - $this->assertEquals('foo', $next->getModuleName()); - $this->assertEquals('bar', $next->getControllerName()); - $this->assertEquals('baz', $next->getActionName()); - $this->assertFalse($next->isDispatched()); - } - - public function testPassingRequestToActionToStackPushesRequestToPluginStack() - { - $helper = new Zend_Controller_Action_Helper_ActionStack(); - $plugin = $this->front->getPlugin('Zend_Controller_Plugin_ActionStack'); - - $request = new Zend_Controller_Request_Simple(); - $request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - - $helper->actionToStack($request); - - $next = $plugin->popStack(); - $this->assertTrue($next instanceof Zend_Controller_Request_Abstract); - $this->assertEquals($request->getModuleName(), $next->getModuleName()); - $this->assertEquals($request->getControllerName(), $next->getControllerName()); - $this->assertEquals($request->getActionName(), $next->getActionName()); - $this->assertFalse($next->isDispatched()); - } - - public function testDirectProxiesToActionToStack() - { - $helper = new Zend_Controller_Action_Helper_ActionStack(); - /** FC should be reseted to test ActionStack with a really blank FC */ - $this->front->resetInstance(); - try{ - $helper->direct('baz', 'bar', 'foo'); - $this->fail('Zend_Controller_Action_Exception should be thrown'); - }catch(Zend_Exception $e){ - $this->assertType('Zend_Controller_Action_Exception', - $e, - 'Zend_Controller_Action_Exception expected, '.get_class($e).' caught'); - } - } - - public function testCannotStackActionIfNoRequestAvailable() - { - $helper = new Zend_Controller_Action_Helper_ActionStack(); - $plugin = $this->front->getPlugin('Zend_Controller_Plugin_ActionStack'); - - $helper->direct('baz', 'bar', 'foo'); - $next = $plugin->popStack(); - $this->assertTrue($next instanceof Zend_Controller_Request_Abstract); - $this->assertEquals('foo', $next->getModuleName()); - $this->assertEquals('bar', $next->getControllerName()); - $this->assertEquals('baz', $next->getActionName()); - $this->assertFalse($next->isDispatched()); - } -} - -// Call Zend_Controller_Action_Helper_ActionStackTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_ActionStackTest::main") { - Zend_Controller_Action_Helper_ActionStackTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php deleted file mode 100644 index 6f8729e4380034cec6b52e73bbdd5e3fcfb44ea1..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_AjaxContextTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_AjaxContextTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action/Helper/AjaxContext.php'; - -require_once 'Zend/Controller/Action.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; -require_once 'Zend/Layout.php'; -require_once 'Zend/View.php'; - - -/** - * Test class for Zend_Controller_Action_Helper_AjaxContext. - */ -class Zend_Controller_Action_Helper_AjaxContextTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_AjaxContextTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { - unset($_SERVER['HTTP_X_REQUESTED_WITH']); - } - - Zend_Controller_Action_Helper_AjaxContextTest_LayoutOverride::$_mvcInstance = null; - Zend_Controller_Action_HelperBroker::resetHelpers(); - - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules'); - - $this->layout = Zend_Layout::startMvc(); - - $this->helper = new Zend_Controller_Action_Helper_AjaxContext(); - - $this->request = new Zend_Controller_Request_Http(); - $this->response = new Zend_Controller_Response_Cli(); - - $this->front->setRequest($this->request)->setResponse($this->response); - $this->view = new Zend_VIew(); - $this->view->addHelperPath(dirname(__FILE__) . '/../../../../../library/Zend/View/Helper/'); - $this->viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $this->viewRenderer->setView($this->view); - - $this->controller = new Zend_Controller_Action_Helper_AjaxContextTestController( - $this->request, - $this->response, - array() - ); - $this->helper->setActionController($this->controller); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { - unset($_SERVER['HTTP_X_REQUESTED_WITH']); - } - } - - public function testDefaultContextsIncludesHtml() - { - $contexts = $this->helper->getContexts(); - $this->assertTrue(isset($contexts['html'])); - $this->assertEquals('ajax.phtml', $this->helper->getSuffix('html')); - $header = $this->helper->getHeaders('html'); - $this->assertTrue(empty($header)); - } - - public function checkNothingIsDone() - { - $this->assertEquals('phtml', $this->viewRenderer->getViewSuffix()); - $headers = $this->response->getHeaders(); - $this->assertTrue(empty($headers)); - } - - public function testInitContextFailsOnNonXhrRequests() - { - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->checkNothingIsDone(); - } - - public function testInitContextFailsWithNoAjaxableActions() - { - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - $this->assertTrue($this->request->isXmlHttpRequest()); - - $this->controller->contexts = $this->controller->ajaxable; - unset($this->controller->ajaxable); - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->checkNothingIsDone(); - } - - public function testInitContextSwitchesContextWithXhrRequests() - { - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - $this->assertTrue($this->request->isXmlHttpRequest()); - - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - - $this->assertEquals('xml.phtml', $this->viewRenderer->getViewSuffix()); - - $headers = $this->response->getHeaders(); - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - $found = true; - $value = $header['value']; - } - } - $this->assertTrue($found); - $this->assertEquals('application/xml', $value); - - $this->assertFalse($this->layout->isEnabled()); - } - - public function testGetCurrentContextResetToNullWhenSubsequentInitContextFailsXhrTest() - { - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - $this->assertTrue($this->request->isXmlHttpRequest()); - - $this->assertNull($this->helper->getCurrentContext()); - - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->assertEquals('xml', $this->helper->getCurrentContext()); - - unset($_SERVER['HTTP_X_REQUESTED_WITH']); - $this->request->setParam('format', 'foo') - ->setActionName('bogus'); - $this->helper->initContext(); - $this->assertNull($this->helper->getCurrentContext()); - } -} - -class Zend_Controller_Action_Helper_AjaxContextTestController extends Zend_Controller_Action -{ - public $ajaxable = array( - 'foo' => array('xml'), - 'bar' => array('xml', 'json'), - 'baz' => array(), - ); -} - -class Zend_Controller_Action_Helper_AjaxContextTest_LayoutOverride extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_Controller_Action_Helper_AjaxContextTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_AjaxContextTest::main") { - Zend_Controller_Action_Helper_AjaxContextTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/AllTests.php b/tests/Zend/Controller/Action/Helper/AllTests.php deleted file mode 100644 index 7e5df09861d6505598fb44822a8252a98d57665f..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/AllTests.php +++ /dev/null @@ -1,75 +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_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../.././../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Controller_Action_Helper_AllTests::main'); -} - -require_once 'Zend/Controller/Action/Helper/ActionStackTest.php'; -require_once 'Zend/Controller/Action/Helper/AjaxContextTest.php'; -require_once 'Zend/Controller/Action/Helper/AutoCompleteTest.php'; -require_once 'Zend/Controller/Action/Helper/ContextSwitchTest.php'; -require_once 'Zend/Controller/Action/Helper/FlashMessengerTest.php'; -require_once 'Zend/Controller/Action/Helper/JsonTest.php'; -require_once 'Zend/Controller/Action/Helper/RedirectorTest.php'; -require_once 'Zend/Controller/Action/Helper/UrlTest.php'; -require_once 'Zend/Controller/Action/Helper/ViewRendererTest.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Controller_Action_Helper_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Controller'); - - $suite->addTestSuite('Zend_Controller_Action_Helper_ActionStackTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_AutoCompleteTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_ContextSwitchTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_AjaxContextTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_FlashMessengerTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_JsonTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_RedirectorTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_UrlTest'); - $suite->addTestSuite('Zend_Controller_Action_Helper_ViewRendererTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Controller_Action_Helper_AllTests::main') { - Zend_Controller_Action_Helper_AllTests::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/AutoCompleteTest.php b/tests/Zend/Controller/Action/Helper/AutoCompleteTest.php deleted file mode 100644 index cfe05138cde0b38c3a61315d9f18fdb08f67a892..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/AutoCompleteTest.php +++ /dev/null @@ -1,256 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_AutoCompleteTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_AutoCompleteTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action/Helper/AutoCompleteDojo.php'; -require_once 'Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php'; - -require_once 'Zend/Controller/Action.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; -require_once 'Zend/Layout.php'; - - -/** - * Test class for Zend_Controller_Action_Helper_AutoComplete. - */ -class Zend_Controller_Action_Helper_AutoCompleteTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_AutoCompleteTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Controller_Action_Helper_AutoCompleteTest_LayoutOverride::$_mvcInstance = null; - Zend_Controller_Action_HelperBroker::resetHelpers(); - - $this->request = new Zend_Controller_Request_Http(); - $this->response = new Zend_Controller_Response_Cli(); - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->setRequest($this->request)->setResponse($this->response); - - $this->viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $this->layout = Zend_Layout::startMvc(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testConcreteImplementationsDeriveFromAutoCompleteBaseClass() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $this->assertTrue($dojo instanceof Zend_Controller_Action_Helper_AutoComplete_Abstract); - - $scriptaculous = new Zend_Controller_Action_Helper_AutoCompleteScriptaculous(); - $this->assertTrue($scriptaculous instanceof Zend_Controller_Action_Helper_AutoComplete_Abstract); - } - - public function testEncodeJsonProxiesToJsonActionHelper() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $data = array('foo', 'bar', 'baz'); - $encoded = $dojo->prepareAutoCompletion($data); - $decoded = Zend_Json::decode($encoded); - $test = array(); - foreach ($decoded['items'] as $item) { - $test[] = $item['name']; - } - $this->assertSame($data, $test); - $this->assertFalse($this->layout->isEnabled()); - $headers = $this->response->getHeaders(); - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - if ('application/json' == $header['value']) { - $found = true; - } - break; - } - } - $this->assertTrue($found, "JSON content-type header not found"); - } - - public function testDojoHelperThrowsExceptionOnInvalidDataFormat() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $data = array('foo' => 'bar', 'baz'); - try { - $encoded = $dojo->encodeJson($data); - $this->fail('Associative arrays without an "items" key should be considered invalid'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Invalid data', $e->getMessage()); - } - - $data = new stdClass; - $data->foo = 'bar'; - $data->bar = 'baz'; - try { - $encoded = $dojo->encodeJson($data); - $this->fail('Objects should be considered invalid'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Invalid data', $e->getMessage()); - } - - $data = 'foo'; - try { - $encoded = $dojo->encodeJson($data); - $this->fail('Strings should be considered invalid'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Invalid data', $e->getMessage()); - } - } - - public function testDojoHelperEncodesToJson() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $data = array('foo', 'bar', 'baz'); - $encoded = $dojo->direct($data, false); - $decoded = Zend_Json::decode($encoded); - $this->assertContains('items', array_keys($decoded)); - $this->assertContains('identifier', array_keys($decoded)); - $this->assertEquals('name', $decoded['identifier']); - - $test = array(); - foreach ($decoded['items'] as $item) { - $test[] = $item['label']; - } - $this->assertEquals($data, $test); - } - - public function testDojoHelperSendsResponseByDefault() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $dojo->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $encoded = $dojo->direct($data); - $decoded = Zend_Json::decode($encoded); - $test = array(); - foreach ($decoded['items'] as $item) { - $test[] = $item['name']; - } - $this->assertSame($data, $test); - $body = $this->response->getBody(); - $this->assertSame($encoded, $body); - } - - public function testDojoHelperDisablesLayoutsAndViewRendererByDefault() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $dojo->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $encoded = $dojo->direct($data); - $this->assertFalse($this->layout->isEnabled()); - $this->assertTrue($this->viewRenderer->getNoRender()); - } - - public function testDojoHelperCanEnableLayoutsAndViewRenderer() - { - $dojo = new Zend_Controller_Action_Helper_AutoCompleteDojo(); - $dojo->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $encoded = $dojo->direct($data, false, true); - $this->assertTrue($this->layout->isEnabled()); - $this->assertFalse($this->viewRenderer->getNoRender()); - } - - public function testScriptaculousHelperThrowsExceptionOnInvalidDataFormat() - { - $scriptaculous = new Zend_Controller_Action_Helper_AutoCompleteScriptaculous(); - - $data = new stdClass; - $data->foo = 'bar'; - $data->bar = 'baz'; - try { - $encoded = $scriptaculous->encodeJson($data); - $this->fail('Objects should be considered invalid'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Invalid data', $e->getMessage()); - } - } - - public function testScriptaculousHelperCreatesHtmlMarkup() - { - $scriptaculous = new Zend_Controller_Action_Helper_AutoCompleteScriptaculous(); - $scriptaculous->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $formatted = $scriptaculous->direct($data); - $this->assertContains('<ul>', $formatted); - foreach ($data as $value) { - $this->assertContains('<li>' . $value . '</li>', $formatted); - } - $this->assertContains('</ul>', $formatted); - } - - public function testScriptaculousHelperSendsResponseByDefault() - { - $scriptaculous = new Zend_Controller_Action_Helper_AutoCompleteScriptaculous(); - $scriptaculous->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $encoded = $scriptaculous->direct($data); - $body = $this->response->getBody(); - $this->assertSame($encoded, $body); - } - - public function testScriptaculousHelperDisablesLayoutsAndViewRendererByDefault() - { - $scriptaculous = new Zend_Controller_Action_Helper_AutoCompleteScriptaculous(); - $scriptaculous->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $encoded = $scriptaculous->direct($data); - $this->assertFalse($this->layout->isEnabled()); - $this->assertTrue($this->viewRenderer->getNoRender()); - } - - public function testScriptaculousHelperCanEnableLayoutsAndViewRenderer() - { - $scriptaculous = new Zend_Controller_Action_Helper_AutoCompleteScriptaculous(); - $scriptaculous->suppressExit = true; - $data = array('foo', 'bar', 'baz'); - $encoded = $scriptaculous->direct($data, false, true); - $this->assertTrue($this->layout->isEnabled()); - $this->assertFalse($this->viewRenderer->getNoRender()); - } -} - -class Zend_Controller_Action_Helper_AutoCompleteTest_LayoutOverride extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_Controller_Action_Helper_AutoCompleteTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_AutoCompleteTest::main") { - Zend_Controller_Action_Helper_AutoCompleteTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/ContextSwitchTest.php b/tests/Zend/Controller/Action/Helper/ContextSwitchTest.php deleted file mode 100644 index b08081dc9bea05fddfa32440e2fb5854d4f192ae..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/ContextSwitchTest.php +++ /dev/null @@ -1,871 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_ContextSwitchTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_ContextSwitchTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action/Helper/ContextSwitch.php'; - -require_once 'Zend/Config.php'; -require_once 'Zend/Controller/Action.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; -require_once 'Zend/Json.php'; -require_once 'Zend/Layout.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Controller_Action_Helper_ContextSwitch. - */ -class Zend_Controller_Action_Helper_ContextSwitchTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_ContextSwitchTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Controller_Action_Helper_ContextSwitchTest_LayoutOverride::$_mvcInstance = null; - Zend_Controller_Action_HelperBroker::resetHelpers(); - - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules'); - - $this->layout = Zend_Layout::startMvc(); - - $this->helper = new Zend_Controller_Action_Helper_ContextSwitch(); - Zend_Controller_Action_HelperBroker::addHelper($this->helper); - - $this->request = new Zend_Controller_Request_Http(); - $this->response = new Zend_Controller_Response_Cli(); - - $this->front->setRequest($this->request) - ->setResponse($this->response) - ->addControllerDirectory(dirname(__FILE__)); - - $this->view = new Zend_View(); - $this->view->addHelperPath(dirname(__FILE__) . '/../../../../../library/Zend/View/Helper/'); - $this->viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $this->viewRenderer->setView($this->view); - - $this->controller = new Zend_Controller_Action_Helper_ContextSwitchTestController( - $this->request, - $this->response, - array() - ); - $this->controller->setupContexts(); - $this->helper->setActionController($this->controller); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testDirectReturnsObjectInstance() - { - $helper = $this->helper->direct(); - $this->assertSame($this->helper, $helper); - } - - public function testSetSuffixModifiesContextSuffix() - { - $this->helper->setSuffix('xml', 'foobar'); - $this->assertContains('foobar', $this->helper->getSuffix('xml')); - } - - public function testSetSuffixPrependsToViewRendererSuffixByDefault() - { - $this->helper->setSuffix('xml', 'foobar'); - $expected = 'foobar.' . $this->viewRenderer->getViewSuffix(); - $this->assertContains($expected, $this->helper->getSuffix('xml')); - } - - public function testCanSetSuffixWithoutViewRendererSuffix() - { - $this->helper->setSuffix('xml', 'foobar', false); - $expected = 'foobar'; - $this->assertContains($expected, $this->helper->getSuffix('xml')); - } - - public function testSuffixAccessorsThrowExceptionOnInvalidContextType() - { - try { - $this->helper->setSuffix('foobar', 'foobar'); - $this->fail('setSuffix() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Cannot set suffix', $e->getMessage()); - } - - try { - $this->helper->getSuffix('foobar'); - $this->fail('getSuffix() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Cannot retrieve suffix', $e->getMessage()); - } - } - - public function testCanAddAdditionalHeadersPerContext() - { - $this->helper->addHeader('xml', 'X-Foo', 'Bar'); - $headers = $this->helper->getHeaders('xml'); - $this->assertTrue(isset($headers['Content-Type'])); - $this->assertEquals('application/xml', $headers['Content-Type']); - $this->assertTrue(isset($headers['X-Foo'])); - $this->assertEquals('Bar', $headers['X-Foo']); - } - - public function testCanAddMultipleHeadersPerContextSimultaneously() - { - $this->helper->addHeaders('xml', array( - 'X-Foo' => 'Bar', - 'X-Bar' => 'Baz' - )); - $headers = $this->helper->getHeaders('xml'); - $this->assertTrue(isset($headers['Content-Type'])); - $this->assertEquals('application/xml', $headers['Content-Type']); - $this->assertTrue(isset($headers['X-Foo'])); - $this->assertEquals('Bar', $headers['X-Foo']); - $this->assertTrue(isset($headers['X-Bar'])); - $this->assertEquals('Baz', $headers['X-Bar']); - } - - public function testAddHeaderThrowsExceptionWhenReferencingExistingHeader() - { - try { - $this->helper->addHeader('xml', 'Content-Type', 'application/xml'); - $this->fail('addHeader() should raise exception for existing headers'); - } catch (Zend_Controller_Exception $e) { - $this->assertContains('already exists', $e->getMessage()); - } - } - - public function testSetHeaderOverwritesHeaderExistingHeader() - { - $this->helper->setHeader('xml', 'Content-Type', 'application/foo-xml'); - $this->assertEquals('application/foo-xml', $this->helper->getHeader('xml', 'Content-Type')); - } - - public function testSetHeadersOverwritesHeaders() - { - $headers = array( - 'X-Foo' => 'Bar', - 'X-Bar' => 'Baz' - ); - $this->helper->setHeaders('xml', $headers); - $this->assertEquals($headers, $this->helper->getHeaders('xml')); - } - - public function testCanRemoveSingleHeaders() - { - $this->helper->addHeader('xml', 'X-Foo', 'Bar'); - $this->assertEquals('Bar', $this->helper->getHeader('xml', 'X-Foo')); - $this->helper->removeHeader('xml', 'X-Foo'); - $this->assertNull($this->helper->getHeader('xml', 'X-Foo')); - } - - public function testCanClearAllHeaders() - { - $this->helper->addHeader('xml', 'X-Foo', 'Bar'); - $expected = array('Content-Type' => 'application/xml', 'X-Foo' => 'Bar'); - $this->assertEquals($expected, $this->helper->getHeaders('xml')); - $this->helper->clearHeaders('xml'); - $this->assertEquals(array(), $this->helper->getHeaders('xml')); - } - - public function testHeaderAccessorsThrowExceptionOnInvalidContextType() - { - try { - $this->helper->addHeader('foobar', 'foobar', 'baz'); - $this->fail('addHeader() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->setHeader('foobar', 'foobar', 'baz'); - $this->fail('setHeader() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->getHeader('foobar', 'Content-Type'); - $this->fail('getHeader() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->getHeaders('foobar'); - $this->fail('getHeaders() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->addHeaders('foobar', array('X-Foo' => 'Bar')); - $this->fail('addHeaders() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->setHeaders('foobar', array('X-Foo' => 'Bar')); - $this->fail('setHeaders() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->removeHeader('foobar', 'X-Foo'); - $this->fail('removeHeader() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - - try { - $this->helper->clearHeaders('foobar'); - $this->fail('clearHeaders() should throw exception with invalid context type'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - } - - public function testCanSetCallbackByContextAndTrigger() - { - $this->helper->setCallback('xml', 'init', 'htmlentities'); - $this->assertEquals('htmlentities', $this->helper->getCallback('xml', 'init')); - - $this->helper->setCallback('xml', 'post', array('Zend_Controller_Action_Helper_ContextSwitchTest', 'main')); - $this->assertSame(array('Zend_Controller_Action_Helper_ContextSwitchTest', 'main'), $this->helper->getCallback('xml', 'post')); - } - - public function testCanSetAllCallbacksByContext() - { - $callbacks = array( - 'init' => 'htmlentities', - 'post' => array('Zend_Loader', 'registerAutoload') - ); - $this->helper->setCallbacks('xml', $callbacks); - $returned = $this->helper->getCallbacks('xml'); - $this->assertSame(array_values($callbacks), array_values($returned)); - } - - public function testCanRemoveCallbackByContextAndTrigger() - { - $this->testCanSetCallbackByContextAndTrigger(); - $this->helper->removeCallback('xml', 'init'); - $this->assertNull($this->helper->getCallback('xml', 'init')); - } - - public function testCanClearAllCallbacksByContext() - { - $this->testCanSetCallbackByContextAndTrigger(); - $this->helper->clearCallbacks('xml'); - $this->assertSame(array(), $this->helper->getCallbacks('xml')); - } - - public function testCanAddContext() - { - $this->helper->addContext('foobar', array( - 'suffix' => 'foo.bar', - 'headers' => array('Content-Type' => 'application/x-foobar', 'X-Foo' => 'Bar'), - )); - $context = $this->helper->getContext('foobar'); - $this->assertNotNull($context); - $this->assertTrue(is_array($context)); - $this->assertTrue(isset($context['suffix'])); - $this->assertTrue(isset($context['headers'])); - $this->assertTrue(isset($context['callbacks'])); - - $this->assertContains('foo.bar', $context['suffix']); - $this->assertEquals('application/x-foobar', $context['headers']['Content-Type']); - $this->assertEquals('Bar', $context['headers']['X-Foo']); - } - - public function testAddContextThrowsExceptionIfContextAlreadyExists() - { - try { - $this->helper->addContext('xml', array()); - $this->fail('Shold not be able to add context if already exists'); - } catch (Zend_Controller_Exception $e) { - $this->assertContains('exists', $e->getMessage()); - } - } - - public function testSetContextOverwritesExistingContext() - { - $this->helper->setContext('xml', array()); - $this->assertNull($this->helper->getHeader('xml', 'Content-Type')); - $this->assertEquals($this->viewRenderer->getViewSuffix(), $this->helper->getSuffix('xml')); - } - - public function testCanAddMultipleContextsAtOnce() - { - $this->helper->addContexts(array( - 'foobar' => array( - 'suffix' => 'foo.bar', - 'headers' => array('Content-Type' => 'application/x-foobar', 'X-Foo' => 'Bar'), - ), - 'barbaz' => array( - 'suffix' => 'bar.baz', - 'headers' => array('Content-Type' => 'application/x-barbaz', 'X-Bar' => 'Baz'), - ) - )); - $this->assertTrue($this->helper->hasContext('foobar')); - $this->assertTrue($this->helper->hasContext('barbaz')); - } - - public function testCanOverwriteManyContextsAtOnce() - { - $this->helper->setContexts(array( - 'xml' => array( - 'suffix' => array('suffix' => 'xml', 'prependViewRendererSuffix' => false), - 'headers' => array('Content-Type' => 'application/xml'), - 'callbacks' => array('TRIGGER_INIT' => 'foobar') - ), - 'foobar' => array( - 'suffix' => 'foo.bar', - 'headers' => array('Content-Type' => 'application/x-foobar', 'X-Foo' => 'Bar'), - ), - 'barbaz' => array( - 'suffix' => 'bar.baz', - 'headers' => array('Content-Type' => 'application/x-barbaz', 'X-Bar' => 'Baz'), - ) - )); - $this->assertTrue($this->helper->hasContext('xml')); - $this->assertFalse($this->helper->hasContext('json')); - $this->assertTrue($this->helper->hasContext('foobar')); - $this->assertTrue($this->helper->hasContext('barbaz')); - $this->assertEquals('xml', $this->helper->getSuffix('xml')); - $this->assertNotEquals('foo.bar', $this->helper->getSuffix('foobar')); - $this->assertContains('foo.bar', $this->helper->getSuffix('foobar')); - $this->assertNotEquals('bar.baz', $this->helper->getSuffix('barbaz')); - $this->assertContains('bar.baz', $this->helper->getSuffix('barbaz')); - } - - public function testCanRemoveSingleContext() - { - $this->assertTrue($this->helper->hasContext('xml')); - $this->helper->removeContext('xml'); - $this->assertFalse($this->helper->hasContext('xml')); - } - - public function testCanClearAllContexts() - { - $this->assertTrue($this->helper->hasContext('xml')); - $this->assertTrue($this->helper->hasContext('json')); - $contexts = $this->helper->getContexts(); - $this->helper->clearContexts(); - $received = $this->helper->getContexts(); - $this->assertNotEquals($contexts, $received); - $this->assertTrue(empty($received)); - } - - public function testDefaultContextParam() - { - $this->assertEquals('format', $this->helper->getContextParam()); - } - - public function testCanSetContextParam() - { - $this->helper->setContextParam('foobar'); - $this->assertEquals('foobar', $this->helper->getContextParam()); - } - - public function testDefaultContext() - { - $this->assertEquals('xml', $this->helper->getDefaultContext()); - } - - public function testCanSetDefaultContext() - { - $this->helper->setDefaultContext('json'); - $this->assertEquals('json', $this->helper->getDefaultContext()); - } - - public function testSetDefaultContextThrowsExceptionIfContextDoesNotExist() - { - try { - $this->helper->setDefaultContext('foobar'); - $this->fail('setDefaultContext() should raise exception if context does not exist'); - } catch (Zend_Controller_Action_Exception $e) { - $this->assertContains('Cannot set default context', $e->getMessage()); - } - } - - public function testContextSwitchDisablesLayoutsByDefault() - { - $this->assertTrue($this->helper->getAutoDisableLayout()); - } - - public function testCanChooseWhetherLayoutsAreDisabled() - { - $this->helper->setAutoDisableLayout(false); - $this->assertFalse($this->helper->getAutoDisableLayout()); - $this->helper->setAutoDisableLayout(true); - $this->assertTrue($this->helper->getAutoDisableLayout()); - } - - public function checkNothingIsDone() - { - $this->assertEquals('phtml', $this->viewRenderer->getViewSuffix()); - $headers = $this->response->getHeaders(); - $this->assertTrue(empty($headers)); - } - - public function testInitContextDoesNothingIfNoContextsSet() - { - unset($this->controller->contexts); - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->checkNothingIsDone(); - } - - public function testInitContextThrowsExceptionIfControllerContextsIsInvalid() - { - $this->controller->contexts = 'foo'; - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - try { - $this->helper->initContext(); - $this->fail('Invalid contexts array should cause failure'); - } catch (Zend_Controller_Exception $e) { - $this->assertContains('Invalid', $e->getMessage()); - } - $this->checkNothingIsDone(); - } - - public function testInitContextDoesNothingIfActionHasNoContexts() - { - $this->request->setParam('format', 'xml') - ->setActionName('baz'); - $this->helper->initContext(); - $this->checkNothingIsDone(); - - $this->request->setParam('format', 'json') - ->setActionName('baz'); - $this->helper->initContext(); - $this->checkNothingIsDone(); - } - - public function testInitContextDoesNothingIfActionDoesNotHaveContext() - { - $this->request->setParam('format', 'json') - ->setActionName('foo'); - $this->helper->initContext(); - $this->checkNothingIsDone(); - } - - public function testInitContextUsesBooleanTrueActionValueToAssumeAllContexts() - { - $this->request->setParam('format', 'json') - ->setActionName('all'); - $this->helper->initContext(); - $this->assertEquals('json', $this->helper->getCurrentContext()); - $this->assertContains('json', $this->viewRenderer->getViewSuffix()); - - $this->request->setParam('format', 'xml') - ->setActionName('all'); - $this->helper->initContext(); - $this->assertEquals('xml', $this->helper->getCurrentContext()); - $this->assertContains('xml', $this->viewRenderer->getViewSuffix()); - } - - public function testInitContextDoesNothingIfActionDoesNotHaveContextAndPassedFormatInvalid() - { - $this->request->setParam('format', 'json') - ->setActionName('foo'); - $this->helper->initContext('bogus'); - $this->checkNothingIsDone(); - } - - public function testInitContextSetsViewRendererViewSuffix() - { - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->assertContains('xml', $this->viewRenderer->getViewSuffix()); - } - - public function testInitContextSetsAppropriateResponseHeader() - { - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $headers = $this->response->getHeaders(); - - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - $found = true; - $value = $header['value']; - } - } - $this->assertTrue($found); - $this->assertEquals('application/xml', $value); - } - - public function testInitContextUsesPassedFormatWhenContextParamPresent() - { - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext('json'); - - $this->assertContains('json', $this->viewRenderer->getViewSuffix()); - - $headers = $this->response->getHeaders(); - - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - $found = true; - $value = $header['value']; - } - } - $this->assertTrue($found); - $this->assertEquals('application/json', $value); - } - - public function testInitContextUsesPassedFormatWhenNoContextParamNotPresent() - { - $this->request->setActionName('foo'); - $this->helper->initContext('xml'); - - $this->assertContains('xml', $this->viewRenderer->getViewSuffix()); - - $headers = $this->response->getHeaders(); - - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - $found = true; - $value = $header['value']; - } - } - $this->assertTrue($found); - $this->assertEquals('application/xml', $value); - } - - public function testInitContextDisablesLayoutByDefault() - { - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - - $this->assertFalse($this->layout->isEnabled()); - } - - public function testInitContextDoesNotDisableLayoutIfDisableLayoutDisabled() - { - $this->helper->setAutoDisableLayout(false); - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - - $this->assertTrue($this->layout->isEnabled()); - } - - public function testGetCurrentContextInitiallyNull() - { - $this->assertNull($this->helper->getCurrentContext()); - } - - public function testGetCurrentContextReturnsContextAfterInitContextIsSuccessful() - { - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - - $this->assertEquals('xml', $this->helper->getCurrentContext()); - } - - public function testGetCurrentContextResetToNullWhenSubsequentInitContextFails() - { - $this->assertNull($this->helper->getCurrentContext()); - - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->assertEquals('xml', $this->helper->getCurrentContext()); - - $this->request->setParam('format', 'foo') - ->setActionName('bogus'); - $this->helper->initContext(); - $this->assertNull($this->helper->getCurrentContext()); - } - - public function testGetCurrentContextChangesAfterSubsequentInitContextCalls() - { - $this->assertNull($this->helper->getCurrentContext()); - - $this->request->setParam('format', 'xml') - ->setActionName('foo'); - $this->helper->initContext(); - $this->assertEquals('xml', $this->helper->getCurrentContext()); - - $this->request->setParam('format', 'json') - ->setActionName('bar'); - $this->helper->initContext(); - $this->assertEquals('json', $this->helper->getCurrentContext()); - } - - public function testJsonContextShouldEncodeViewVariablesByDefaultAndNotRequireRenderingView() - { - $this->request->setParam('format', 'json') - ->setActionName('bar') - ->setDispatched(true); - $this->controller->dispatch('barAction'); - - $headers = $this->response->getHeaders(); - $found = false; - foreach ($headers as $header) { - if ($header['name'] == 'Content-Type') { - if ($header['value'] == 'application/json') { - $found = true; - } - break; - } - } - $this->assertTrue($found, 'JSON content type header not found'); - - $body = $this->response->getBody(); - $result = Zend_Json::decode($body); - $this->assertTrue(is_array($result), var_export($body, 1)); - $this->assertTrue(isset($result['foo'])); - $this->assertTrue(isset($result['bar'])); - $this->assertEquals('bar', $result['foo']); - $this->assertEquals('baz', $result['bar']); - } - - public function testAutoJsonSerializationMayBeDisabled() - { - $this->request->setParam('format', 'json') - ->setActionName('bar') - ->setDispatched(true); - $this->helper->setAutoJsonSerialization(false); - $this->controller->dispatch('barAction'); - - - $headers = $this->response->getHeaders(); - $found = false; - foreach ($headers as $header) { - if ($header['name'] == 'Content-Type') { - if ($header['value'] == 'application/json') { - $found = true; - } - break; - } - } - $this->assertTrue($found, 'JSON content type header not found'); - - $body = $this->response->getBody(); - $this->assertTrue(empty($body), $body); - } - - public function testCanAddOneOrMoreActionContexts() - { - $this->assertFalse($this->helper->hasActionContext('foo', 'json')); - $this->helper->addActionContext('foo', 'json'); - $this->assertTrue($this->helper->hasActionContext('foo', 'json')); - - $this->assertFalse($this->helper->hasActionContext('baz', 'xml')); - $this->assertFalse($this->helper->hasActionContext('baz', 'json'), var_export($this->controller->contexts, 1)); - $this->helper->addActionContext('baz', array('xml', 'json')); - $this->assertTrue($this->helper->hasActionContext('baz', 'xml')); - $this->assertTrue($this->helper->hasActionContext('baz', 'json')); - } - - public function testCanOverwriteAnActionContext() - { - $this->assertTrue($this->helper->hasActionContext('foo', 'xml')); - $this->helper->setActionContext('foo', 'json'); - $this->assertFalse($this->helper->hasActionContext('foo', 'xml')); - $this->assertTrue($this->helper->hasActionContext('foo', 'json')); - $this->helper->setActionContext('foo', array('xml', 'json')); - $this->assertTrue($this->helper->hasActionContext('foo', 'json')); - $this->assertTrue($this->helper->hasActionContext('foo', 'xml')); - } - - public function testCanAddContextsForMultipleActions() - { - $this->assertFalse($this->helper->hasActionContext('foo', 'json')); - $this->assertFalse($this->helper->hasActionContext('baz', 'json')); - $this->assertFalse($this->helper->hasActionContext('baz', 'xml')); - $this->helper->addActionContexts(array( - 'foo' => 'json', - 'baz' => array('json', 'xml'), - )); - $this->assertTrue($this->helper->hasActionContext('foo', 'json')); - $this->assertTrue($this->helper->hasActionContext('baz', 'json')); - $this->assertTrue($this->helper->hasActionContext('baz', 'xml')); - } - - public function testCanOverwriteContextsForMultipleActions() - { - $this->assertTrue($this->helper->hasActionContext('foo', 'xml')); - $this->assertTrue($this->helper->hasActionContext('bar', 'json')); - $this->assertTrue($this->helper->hasActionContext('bar', 'xml')); - $this->helper->setActionContexts(array( - 'foo' => 'json', - 'bar' => 'xml' - )); - $this->assertFalse($this->helper->hasActionContext('foo', 'xml')); - $this->assertTrue($this->helper->hasActionContext('foo', 'json')); - $this->assertFalse($this->helper->hasActionContext('bar', 'json')); - $this->assertTrue($this->helper->hasActionContext('bar', 'xml')); - } - - public function testCanRemoveOneOrMoreActionContexts() - { - $this->assertTrue($this->helper->hasActionContext('bar', 'json')); - $this->assertTrue($this->helper->hasActionContext('bar', 'xml')); - $this->helper->removeActionContext('bar', 'xml'); - $this->assertTrue($this->helper->hasActionContext('bar', 'json')); - $this->assertFalse($this->helper->hasActionContext('bar', 'xml')); - } - - public function testCanClearAllContextsForASingleAction() - { - $this->assertTrue($this->helper->hasActionContext('bar', 'json')); - $this->assertTrue($this->helper->hasActionContext('bar', 'xml')); - $this->helper->clearActionContexts('bar'); - $this->assertFalse($this->helper->hasActionContext('bar', 'json')); - $this->assertFalse($this->helper->hasActionContext('bar', 'xml')); - } - - public function testCanClearAllActionContexts() - { - $this->helper->clearActionContexts(); - $contexts = $this->helper->getActionContexts(); - $this->assertTrue(empty($contexts)); - } - - public function getOptions() - { - $options = array( - 'contexts' => array('ajax' => array('suffix' => 'ajax', 'headers' => array('Content-Type' => 'text/x-html')), 'json' => array('suffix' => 'json', 'headers' => array('Content-Type' => 'application/json'), 'callbacks' => array('init' => 'initJsonCallback', 'post' => 'postJsonCallback'))), - 'autoJsonSerialization' => false, - 'suffix' => array('json' => array('suffix' => 'js', 'prependViewRendererSuffix' => false)), - 'headers' => array('json' => array('Content-Type' => 'text/js')), - 'callbacks' => array('json' => array('init' => 'htmlentities')), - 'contextParam' => 'foobar', - 'defaultContext' => 'json', - 'autoDisableLayout' => false, - ); - return $options; - } - - public function checkOptionsAreSet() - { - $this->assertFalse($this->helper->getAutoJsonSerialization()); - $this->assertEquals('js', $this->helper->getSuffix('json')); - $this->assertEquals('text/js', $this->helper->getHeader('json', 'Content-Type')); - $this->assertEquals('htmlentities', $this->helper->getCallback('json', 'init')); - $this->assertEquals('foobar', $this->helper->getContextParam()); - $this->assertEquals('json', $this->helper->getDefaultContext()); - $this->assertFalse($this->helper->getAutoDisableLayout()); - $this->assertTrue($this->helper->hasContext('ajax')); - } - - public function testCanSetOptionsViaArray() - { - $this->helper->setOptions($this->getOptions()); - $this->checkOptionsAreSet(); - } - - public function testCanSetOptionsViaConfig() - { - $config = new Zend_Config($this->getOptions()); - $this->helper->setConfig($config); - $this->checkOptionsAreSet(); - } - - public function testOptionsPassedToConstructorShouldSetInstanceState() - { - $this->helper = new Zend_Controller_Action_Helper_ContextSwitch($this->getOptions()); - $this->checkOptionsAreSet(); - } - - public function testConfigPassedToConstructorShouldSetInstanceState() - { - $config = new Zend_Config($this->getOptions()); - $this->helper = new Zend_Controller_Action_Helper_ContextSwitch($config); - $this->checkOptionsAreSet(); - } -} - -class Zend_Controller_Action_Helper_ContextSwitchTestController extends Zend_Controller_Action -{ - public $contextSwitch; - - /* - public $contexts = array( - 'foo' => array('xml'), // only XML context - 'bar' => array('xml', 'json'), // only XML and JSON contexts - 'baz' => array(), // no contexts - 'all' => true, // all contexts - ); - */ - - public function setupContexts() - { - $this->_helper->contextSwitch()->setActionContexts(array( - 'foo' => 'xml', - 'bar' => array('xml', 'json'), - 'all' => true - )); - } - - public function postDispatch() - { - $this->_helper->viewRenderer->setNoRender(); - } - - public function barAction() - { - $this->_helper->contextSwitch->initContext(); - $this->view->foo = 'bar'; - $this->view->bar = 'baz'; - } -} - -class Zend_Controller_Action_Helper_ContextSwitchTest_LayoutOverride extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_Controller_Action_Helper_ContextSwitchTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_ContextSwitchTest::main") { - Zend_Controller_Action_Helper_ContextSwitchTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/FlashMessengerTest.php b/tests/Zend/Controller/Action/Helper/FlashMessengerTest.php deleted file mode 100644 index 7569f91d0b0ac8f3b3bf3b8416b95c4ee660aabf..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/FlashMessengerTest.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -// Call Zend_Controller_Action_Helper_FlashMessengerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_FlashMessengerTest::main"); -} - -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Action/Helper/FlashMessenger.php'; -require_once 'Zend/Session.php'; -require_once dirname(dirname(dirname(__FILE__))) . '/_files/HelperFlashMessengerController.php'; - -class Zend_Controller_Action_Helper_FlashMessengerTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Controller_Action - */ - public $controller; - - /** - * @var Zend_Controller_Front - */ - public $front; - - /** - * @var Zend_Controller_Action_Helper_FlashMessenger - */ - public $helper; - - /** - * @var Zend_Controller_Request_Http - */ - public $request; - - /** - * @var Zend_Controller_Response_Cli - */ - public $response; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_FlashMessengerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $savePath = ini_get('session.save_path'); - if (strpos($savePath, ';')) { - $savePath = explode(';', $savePath); - $savePath = array_pop($savePath); - } - if (empty($savePath)) { - $this->markTestSkipped('Cannot test FlashMessenger due to unavailable session save path'); - } - - if (headers_sent()) { - $this->markTestSkipped('Cannot test FlashMessenger: cannot start session because headers already sent'); - } - Zend_Session::start(); - - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->setControllerDirectory(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . '_files'); - $this->front->returnResponse(true); - $this->request = new Zend_Controller_Request_Http(); - $this->request->setControllerName('helper-flash-messenger'); - $this->response = new Zend_Controller_Response_Cli(); - $this->controller = new HelperFlashMessengerController($this->request, $this->response, array()); - $this->helper = new Zend_Controller_Action_Helper_FlashMessenger($this->controller); - } - - public function testLoadFlashMessenger() - { - $this->markTestSkipped(); - $response = $this->front->dispatch($this->request); - $this->assertEquals('Zend_Controller_Action_Helper_FlashMessenger123456', $response->getBody()); - } - - public function testClearMessages() - { - $this->markTestSkipped(); - $this->helper->addMessage('foo'); - $this->helper->addMessage('bar'); - $this->assertTrue($this->helper->hasMessages()); - $this->assertEquals(2, count($this->helper)); - - $this->helper->clearMessages(); - $this->assertFalse($this->helper->hasMessages()); - $this->assertEquals(0, count($this->helper)); - } - - public function testDirectProxiesToAddMessage() - { - $this->markTestSkipped(); - $this->helper->direct('foo'); - $this->assertTrue($this->helper->hasMessages()); - $this->assertEquals(1, count($this->helper)); - } -} - -// Call Zend_Controller_Action_Helper_FlashMessengerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_FlashMessengerTest::main") { - Zend_Controller_Action_Helper_FlashMessengerTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/JsonTest.php b/tests/Zend/Controller/Action/Helper/JsonTest.php deleted file mode 100644 index 49fbcafa86038458fa6789805b34505a8ac287c1..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/JsonTest.php +++ /dev/null @@ -1,165 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_JsonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_JsonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action/Helper/Json.php'; - -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Response/Http.php'; -require_once 'Zend/Json.php'; -require_once 'Zend/Layout.php'; - -/** - * Test class for Zend_Controller_Action_Helper_Json - */ -class Zend_Controller_Action_Helper_JsonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_JsonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Controller_Action_Helper_JsonTest_Layout::$_mvcInstance = null; - - $this->response = new Zend_Controller_Response_Http(); - $this->response->headersSentThrowsException = false; - - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - $front->setResponse($this->response); - - $this->viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(); - Zend_Controller_Action_HelperBroker::addHelper($this->viewRenderer); - $this->helper = new Zend_Controller_Action_Helper_Json(); - $this->helper->suppressExit = true; - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function verifyJsonHeader() - { - $headers = $this->response->getHeaders(); - - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - $found = true; - $value = $header['value']; - break; - } - } - $this->assertTrue($found); - $this->assertEquals('application/json', $value); - } - - public function testJsonHelperSetsResponseHeader() - { - $this->helper->encodeJson('foobar'); - $this->verifyJsonHeader(); - } - - public function testJsonHelperReturnsJsonEncodedString() - { - $data = $this->helper->encodeJson(array('foobar')); - $this->assertTrue(is_string($data)); - $this->assertEquals(array('foobar'), Zend_Json::decode($data)); - } - - public function testJsonHelperDisablesLayoutsAndViewRendererByDefault() - { - $layout = Zend_Layout::startMvc(); - $this->assertTrue($layout->isEnabled()); - $this->assertFalse($this->viewRenderer->getNoRender()); - $this->testJsonHelperReturnsJsonEncodedString(); - $this->assertFalse($layout->isEnabled()); - $this->assertTrue($this->viewRenderer->getNoRender()); - } - - public function testJsonHelperDoesNotDisableLayoutsAndViewRendererWhenKeepLayoutFlagTrue() - { - $layout = Zend_Layout::startMvc(); - $this->assertTrue($layout->isEnabled()); - $this->assertFalse($this->viewRenderer->getNoRender()); - $data = $this->helper->encodeJson(array('foobar'), true); - $this->assertTrue($layout->isEnabled()); - $this->assertFalse($this->viewRenderer->getNoRender()); - } - - public function testSendJsonSendsResponse() - { - $this->helper->sendJson(array('foobar')); - $this->verifyJsonHeader(); - $response = $this->response->getBody(); - $this->assertSame(array('foobar'), Zend_Json::decode($response)); - } - - public function testDirectProxiesToSendJsonByDefault() - { - $this->helper->direct(array('foobar')); - $this->verifyJsonHeader(); - $response = $this->response->getBody(); - $this->assertSame(array('foobar'), Zend_Json::decode($response)); - } - - public function testCanPreventDirectSendingResponse() - { - $data = $this->helper->direct(array('foobar'), false); - $this->assertSame(array('foobar'), Zend_Json::decode($data)); - $this->verifyJsonHeader(); - $response = $this->response->getBody(); - $this->assertTrue(empty($response)); - } - - public function testCanKeepLayoutsWhenUsingDirect() - { - $layout = Zend_Layout::startMvc(); - $data = $this->helper->direct(array('foobar'), false, true); - $this->assertTrue($layout->isEnabled()); - $this->assertFalse($this->viewRenderer->getNoRender()); - } -} - -/** - * Zend_Layout subclass to allow resetting MVC instance - */ -class Zend_Controller_Action_Helper_JsonTest_Layout extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_Controller_Action_Helper_JsonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_JsonTest::main") { - Zend_Controller_Action_Helper_JsonTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/RedirectorTest.php b/tests/Zend/Controller/Action/Helper/RedirectorTest.php deleted file mode 100644 index 3186d7afff97f62f57f5084e04812d69436746b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/RedirectorTest.php +++ /dev/null @@ -1,452 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_RedirectorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_RedirectorTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Action.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Action/Helper/Redirector.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Http.php'; - -/** - * Test class for Zend_Controller_Action_Helper_Redirector. - */ -class Zend_Controller_Action_Helper_RedirectorTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Controller_Action_Helper_Redirector - */ - public $redirector; - - /** - * @var Zend_Controller_Request_Http - */ - public $request; - - /** - * @var Zend_Controller_Response_Http - */ - public $response; - - /** - * @var Zend_Controller_Action - */ - public $controller; - - /** - * Runs the test methods of this class. - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_RedirectorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Set up redirector - * - * Creates request, response, and action controller objects; sets action - * controller in redirector, and sets exit to false. - * - * Also resets the front controller instance. - */ - public function setUp() - { - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - - $this->redirector = new Zend_Controller_Action_Helper_Redirector(); - $this->router = $front->getRouter(); - $this->request = new Zend_Controller_Request_Http(); - $this->response = new Zend_Controller_Response_Http(); - $this->controller = new Zend_Controller_Action_Helper_Redirector_TestController( - $this->request, - $this->response, - array() - ); - - // Add default routes - $this->router->addDefaultRoutes(); - - // do this so setting headers does not throw exceptions - $this->response->headersSentThrowsException = false; - - $this->redirector->setExit(false) - ->setActionController($this->controller); - $this->_server = $_SERVER; - } - - /** - * Unset all properties - */ - public function tearDown() - { - unset($this->redirector); - unset($this->controller); - unset($this->request); - unset($this->response); - $_SERVER = $this->_server; - } - - public function testCode() - { - $this->assertEquals(302, $this->redirector->getCode(), 'Default code should be 302'); - $this->redirector->setCode(301); - $this->assertEquals(301, $this->redirector->getCode()); - - try { - $this->redirector->setCode(251); - $this->fail('Invalid redirect code should throw exception'); - } catch (Exception $e) { - } - - try { - $this->redirector->setCode(351); - $this->fail('Invalid redirect code should throw exception'); - } catch (Exception $e) { - } - } - - public function testCodeAsAStringIsAllowed() - { - $this->redirector->setCode('303'); - $this->assertEquals(303, $this->redirector->getCode()); - - try { - $this->redirector->setCode('251'); - $this->fail('Invalid redirect code should throw exception'); - } catch (Exception $e) { - } - - try { - $this->redirector->setCode('351'); - $this->fail('Invalid redirect code should throw exception'); - } catch (Exception $e) { - } - } - - public function testRedirectorShouldOnlyAllowValidHttpRedirectCodes() - { - try { - $this->redirector->setCode('306'); - $this->fail('Invalid redirect code should throw exception'); - } catch (Zend_Controller_Action_Exception $e) { - } - try { - $this->redirector->setCode('304'); - $this->fail('Invalid redirect code should throw exception'); - } catch (Zend_Controller_Action_Exception $e) { - } - } - - public function testExit() - { - $this->assertFalse($this->redirector->getExit()); - $this->redirector->setExit(true); - $this->assertTrue($this->redirector->getExit()); - } - - public function testPrependBase() - { - $this->assertTrue($this->redirector->getPrependBase()); - $this->redirector->setPrependBase(false); - $this->assertFalse($this->redirector->getPrependBase()); - } - - public function testGetRedirectUrlNullByDefault() - { - $this->assertNull($this->redirector->getRedirectUrl()); - } - - public function testSetGotoWithActionOnly() - { - $request = $this->request; - $request->setModuleName('blog') - ->setControllerName('list') - ->setActionName('all'); - - $this->redirector->setGoto('error'); - $this->assertEquals('/blog/list/error', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoWithActionAndController() - { - $request = $this->request; - $request->setModuleName('blog') - ->setControllerName('list') - ->setActionName('all'); - - $this->redirector->setGoto('item', 'view'); - $this->assertEquals('/blog/view/item', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoWithActionControllerAndModule() - { - $request = $this->request; - $request->setModuleName('blog') - ->setControllerName('list') - ->setActionName('all'); - - $this->redirector->setGoto('item', 'view', 'news'); - $this->assertEquals('/news/view/item', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoWithActionControllerModuleAndParams() - { - $request = $this->request; - $request->setModuleName('blog') - ->setControllerName('list') - ->setActionName('all'); - - $this->redirector->setGoto('item', 'view', 'news', array('id' => 42)); - $this->assertEquals('/news/view/item/id/42', $this->redirector->getRedirectUrl()); - } - - /** - * ZF-2351 - */ - public function testGotoDoesNotUtilizeDefaultSegments() - { - $request = $this->request; - $request->setModuleName('default'); - $this->redirector->setGoto('index', 'index'); - $this->assertEquals('/', $this->redirector->getRedirectUrl()); - - $this->redirector->setGoto('index', 'blog'); - $this->assertEquals('/blog', $this->redirector->getRedirectUrl()); - } - - - public function testSetGotoRoute() - { - $router = Zend_Controller_Front::getInstance()->getRouter(); - $route = new Zend_Controller_Router_Route( - 'blog/archive/:id', - array('controller' => 'blog', 'action' => 'view', 'id' => false), - array('id' => '\d+') - ); - $router->addRoute('blogArchive', $route); - - $this->redirector->setGotoRoute( - array('id' => 281), - 'blogArchive' - ); - - $this->assertEquals('/blog/archive/281', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoUrl() - { - $this->redirector->setGotoUrl('/foo/bar'); - $this->assertEquals('/foo/bar', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoUrlWithBaseUrlUsingPrependBaseProperty() - { - $this->request->setBaseUrl('/my'); - $this->redirector->setPrependBase(true); - $this->redirector->setGotoUrl('/foo/bar'); - $this->assertEquals('/my/foo/bar', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoUrlWithBaseUrlUsingPrependBaseOption() - { - $this->request->setBaseUrl('/my'); - $this->redirector->setGotoUrl('/foo/bar', array('prependBase' => true)); - $this->assertEquals('/my/foo/bar', $this->redirector->getRedirectUrl()); - } - - public function testSetGotoUrlWithHttpCodeUsingCodeProperty() - { - $this->redirector->setCode(301); - $this->redirector->setGotoUrl('/foo/bar'); - $this->assertEquals('/foo/bar', $this->redirector->getRedirectUrl()); - $this->assertEquals(301, $this->response->getHttpResponseCode()); - } - - public function testSetGotoUrlWithHttpCodeUsingCodeOption() - { - $this->redirector->setGotoUrl('/foo/bar', array('code' => 301)); - $this->assertEquals('/foo/bar', $this->redirector->getRedirectUrl()); - $this->assertEquals(301, $this->response->getHttpResponseCode()); - } - - /** - * goto() is an alias for setGoto(); just do a single test case - */ - public function testGoto() - { - $request = $this->request; - $request->setModuleName('blog') - ->setControllerName('list') - ->setActionName('all'); - - $this->redirector->goto('error'); - $this->assertEquals('/blog/list/error', $this->redirector->getRedirectUrl()); - } - - public function testGotoAndExit() - { - $this->markTestSkipped( - "Testing Zend_Controller_Action_Helper_Redirector::gotoAndExit() would break the test suite" - ); - } - - /** - * gotoRoute() is an alias for setGotoRoute() - */ - public function testGotoRoute() - { - $router = Zend_Controller_Front::getInstance()->getRouter(); - $route = new Zend_Controller_Router_Route( - 'blog/archive/:id', - array('controller' => 'blog', 'action' => 'view', 'id' => false), - array('id' => '\d+') - ); - $router->addRoute('blogArchive', $route); - - $this->redirector->gotoRoute( - array('id' => 281), - 'blogArchive' - ); - - $this->assertEquals('/blog/archive/281', $this->redirector->getRedirectUrl()); - } - - public function testGotoRouteAndExit() - { - $this->markTestSkipped( - "Testing Zend_Controller_Action_Helper_Redirector::gotoRouteAndExit() would break the test suite" - ); - } - - /** - * gotoUrl() is an alias for setGotoUrl() - */ - public function testGotoUrl() - { - $this->redirector->gotoUrl('/foo/bar'); - $this->assertEquals('/foo/bar', $this->redirector->getRedirectUrl()); - } - - public function testGotoUrlAndExit() - { - $this->markTestSkipped( - "Testing Zend_Controller_Action_Helper_Redirector::gotoUrlAndExit() would break the test suite" - ); - } - - public function testRedirectAndExit() - { - $this->markTestSkipped( - "Testing Zend_Controller_Action_Helper_Redirector::redirectAndExit() would break the test suite" - ); - } - - /** - * direct() is an alias for goto(), which is an alias for setGoto() - */ - public function testDirect() - { - $request = $this->request; - $request->setModuleName('blog') - ->setControllerName('list') - ->setActionName('all'); - - $this->redirector->direct('error'); - $this->assertEquals('/blog/list/error', $this->redirector->getRedirectUrl()); - } - - public function testUseAbsoluteUriFlag() - { - $this->assertFalse($this->redirector->getUseAbsoluteUri()); - $this->redirector->setUseAbsoluteUri(true); - $this->assertTrue($this->redirector->getUseAbsoluteUri()); - } - - public function testUseAbsoluteUriSetsFullUriInResponse() - { - $_SERVER['HTTP_HOST'] = 'foobar.example.com'; - $_SERVER['SERVER_PORT'] = '4443'; - $_SERVER['HTTPS'] = 1; - $this->redirector->setUseAbsoluteUri(true); - $this->redirector->gotoUrl('/bar/baz'); - $headers = $this->response->getHeaders(); - $uri = false; - foreach ($headers as $header) { - if ('Location' == $header['name']) { - $uri = $header['value']; - } - } - if (!$uri) { - $this->fail('No redirect header set in response'); - } - - $this->assertEquals('https://foobar.example.com:4443/bar/baz', $uri); - } - - /** - * ZF-2602 - */ - public function testPassingEmptyStringToGotoUrlRedirectsToRoot() - { - $this->redirector->gotoUrl(''); - $this->assertEquals('/', $this->redirector->getRedirectUrl()); - } - - /**#@+ - * @see ZF-1734 - */ - public function testPassingNullActionAndNullControllerWithModuleShouldGoToDefaultControllerAndActions() - { - $this->request->setModuleName('admin') - ->setControllerName('class') - ->setActionName('view'); - $this->redirector->gotoSimple(null, null, 'admin'); - $test = $this->redirector->getRedirectUrl(); - $this->assertEquals('/admin', $test, $test); - } - - public function testPassingNullActionShouldGoToDefaultActionOfCurrentController() - { - $this->request->setModuleName('admin') - ->setControllerName('class') - ->setActionName('view'); - $this->redirector->gotoSimple(null); - $test = $this->redirector->getRedirectUrl(); - $this->assertEquals('/admin/class', $test, $test); - } - - public function testPassingDefaultModuleShouldNotRenderModuleNameInRedirectUrl() - { - $this->request->setModuleName('admin') - ->setControllerName('class') - ->setActionName('view'); - $this->redirector->gotoSimple('login', 'account', 'default'); - $test = $this->redirector->getRedirectUrl(); - $this->assertEquals('/account/login', $test, $test); - } - /**#@-*/ -} - -/** - * Test controller for use with redirector tests - */ -class Zend_Controller_Action_Helper_Redirector_TestController extends Zend_Controller_Action -{ -} - -// Call Zend_Controller_Action_Helper_RedirectorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_RedirectorTest::main") { - Zend_Controller_Action_Helper_RedirectorTest::main(); -} - - diff --git a/tests/Zend/Controller/Action/Helper/UrlTest.php b/tests/Zend/Controller/Action/Helper/UrlTest.php deleted file mode 100644 index d9520a5aca52d17f9b027ab84184d857ed863cad..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/UrlTest.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_UrlTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_UrlTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action/Helper/Url.php'; - -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; - -/** - * Test class for Zend_Controller_Action_Helper_Url. - */ -class Zend_Controller_Action_Helper_UrlTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_UrlTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->setRequest(new Zend_Controller_Request_Http()); - $this->helper = new Zend_Controller_Action_Helper_Url(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testSimpleWithAllParamsProducesAppropriateUrl() - { - $url = $this->helper->simple('baz', 'bar', 'foo', array('bat' => 'foo', 'ho' => 'hum')); - $this->assertEquals('/foo/bar/baz', substr($url, 0, 12)); - $this->assertContains('/bat/foo', $url); - $this->assertContains('/ho/hum', $url); - } - - public function testSimpleWithMissingControllerAndModuleProducesAppropriateUrl() - { - $request = $this->front->getRequest(); - $request->setModuleName('foo') - ->setControllerName('bar'); - $url = $this->helper->simple('baz', null, null, array('bat' => 'foo', 'ho' => 'hum')); - $this->assertEquals('/foo/bar/baz', substr($url, 0, 12)); - $this->assertContains('/bat/foo', $url); - $this->assertContains('/ho/hum', $url); - } - - public function testSimpleWithDefaultModuleProducesUrlWithoutModuleSegment() - { - $url = $this->helper->simple('baz', 'bar', 'default', array('bat' => 'foo', 'ho' => 'hum')); - $this->assertEquals('/bar/baz', substr($url, 0, 8)); - } - - public function testUrlMethodCreatesUrlBasedOnNamedRouteAndPassedParameters() - { - $router = $this->front->getRouter(); - $route = new Zend_Controller_Router_Route( - 'foo/:action/:page', - array( - 'module' => 'default', - 'controller' => 'foobar', - 'action' => 'bazbat', - 'page' => 1 - ) - ); - $router->addRoute('foo', $route); - $url = $this->helper->url(array('action' => 'bar', 'page' => 3), 'foo'); - $this->assertEquals('/foo/bar/3', $url); - } - - public function testUrlMethodCreatesUrlBasedOnNamedRouteAndDefaultParameters() - { - $router = $this->front->getRouter(); - $route = new Zend_Controller_Router_Route( - 'foo/:action/:page', - array( - 'module' => 'default', - 'controller' => 'foobar', - 'action' => 'bazbat', - 'page' => 1 - ) - ); - $router->addRoute('foo', $route); - $url = $this->helper->url(array(), 'foo'); - $this->assertEquals('/foo', $url); - } - - public function testUrlMethodCreatesUrlBasedOnPassedParametersUsingDefaultRouteWhenNoNamedRoutePassed() - { - $this->front->getRouter()->addDefaultRoutes(); - $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules'); - $url = $this->helper->url(array( - 'module' => 'foo', - 'controller' => 'bar', - 'action' => 'baz', - 'bat' => 'foo', - 'ho' => 'hum' - )); - $this->assertEquals('/foo/bar/baz', substr($url, 0, 12)); - $this->assertContains('/bat/foo', $url); - $this->assertContains('/ho/hum', $url); - } - - public function testDirectProxiesToSimple() - { - $url = $this->helper->direct('baz', 'bar', 'foo', array('bat' => 'foo', 'ho' => 'hum')); - $this->assertEquals('/foo/bar/baz', substr($url, 0, 12)); - $this->assertContains('/bat/foo', $url); - $this->assertContains('/ho/hum', $url); - } -} - -// Call Zend_Controller_Action_Helper_UrlTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_UrlTest::main") { - Zend_Controller_Action_Helper_UrlTest::main(); -} diff --git a/tests/Zend/Controller/Action/Helper/ViewRendererTest.php b/tests/Zend/Controller/Action/Helper/ViewRendererTest.php deleted file mode 100644 index 37f77a5ed462ebb3d9d178f8e45e527834955080..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/Helper/ViewRendererTest.php +++ /dev/null @@ -1,812 +0,0 @@ -<?php -// Call Zend_Controller_Action_Helper_ViewRendererTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_Helper_ViewRendererTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Http.php'; -require_once 'Zend/Filter/Inflector.php'; -require_once 'Zend/View.php'; - -require_once dirname(__FILE__) . '/../../_files/modules/foo/controllers/IndexController.php'; -require_once dirname(__FILE__) . '/../../_files/modules/bar/controllers/IndexController.php'; - -/** - * Test class for Zend_Controller_Action_Helper_ViewRenderer. - */ -class Zend_Controller_Action_Helper_ViewRendererTest extends PHPUnit_Framework_TestCase -{ - /** - * Base path to controllers, views - * @var string - */ - public $basePath; - - /** - * Front controller object - * @var Zend_Controller_Front - */ - public $front; - - /** - * ViewRenderer helper - * @var Zend_Controller_Action_Helper_ViewRenderer - */ - public $helper; - - /** - * Request object - * @var Zend_Controller_Request_Http - */ - public $request; - - /** - * Response object - * @var Zend_Controller_Response_Http - */ - public $response; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_Helper_ViewRendererTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->basePath = realpath(dirname(__FILE__) . str_repeat(DIRECTORY_SEPARATOR . '..', 2)); - $this->request = new Zend_Controller_Request_Http(); - $this->response = new Zend_Controller_Response_Http(); - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->addModuleDirectory($this->basePath . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules') - ->setRequest($this->request) - ->setResponse($this->response); - - $this->helper = new Zend_Controller_Action_Helper_ViewRenderer(); - Zend_Controller_Action_HelperBroker::addHelper($this->helper); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - Zend_Controller_Action_HelperBroker::resetHelpers(); - } - - public function testConstructorSetsViewWhenPassed() - { - $view = new Zend_View(); - $helper = new Zend_Controller_Action_Helper_ViewRenderer($view); - $this->assertNotNull(isset($helper->view)); - $this->assertSame($view, $helper->view); - } - - public function testConstructorSetsOptionsWhenPassed() - { - $helper = new Zend_Controller_Action_Helper_ViewRenderer(null, array( - 'neverRender' => true, - 'noRender' => true, - 'noController' => true, - 'viewSuffix' => 'php', - 'scriptAction' => 'foo', - 'responseSegment' => 'baz' - )); - - $this->assertTrue($helper->getNeverRender()); - $this->assertTrue($helper->getNoRender()); - $this->assertTrue($helper->getNoController()); - $this->assertEquals('php', $helper->getViewSuffix()); - $this->assertEquals('foo', $helper->getScriptAction()); - $this->assertEquals('baz', $helper->getResponseSegment()); - } - - public function testSetView() - { - $view = new Zend_View(); - $this->helper->setView($view); - $this->assertSame($view, $this->helper->view); - } - - public function testGetFrontController() - { - $this->assertSame($this->front, $this->helper->getFrontController()); - } - - protected function _checkDefaults($module = 'foo', $count = 1) - { - $this->assertTrue(isset($this->helper->view)); - $this->assertTrue($this->helper->view instanceof Zend_View); - $this->assertFalse($this->helper->getNeverRender()); - $this->assertFalse($this->helper->getNoRender()); - $this->assertNull($this->helper->getResponseSegment()); - $this->assertNull($this->helper->getScriptAction()); - - $scriptPaths = $this->helper->view->getScriptPaths(); - $this->assertEquals($count, count($scriptPaths), var_export($scriptPaths, 1)); - $this->assertContains($module, $scriptPaths[0]); - - $helperPaths = $this->helper->view->getHelperPaths(); - $test = ucfirst($module) . '_View_Helper_'; - $found = false; - foreach ($helperPaths as $prefix => $paths) { - if ($test == $prefix) { - $found = true; - } - } - $this->assertTrue($found, 'Did not find auto-initialized helper path: ' . var_export($helperPaths, 1)); - - $filterPaths = $this->helper->view->getFilterPaths(); - $test = ucfirst($module) . '_View_Filter_'; - $found = false; - foreach ($filterPaths as $prefix => $paths) { - if ($test == $prefix) { - $found = true; - } - } - $this->assertTrue($found, 'Did not find auto-initialized filter path: ' . var_export($filterPaths, 1)); - } - - public function testInitViewWithDefaults() - { - $this->request->setModuleName('foo') - ->setControllerName('index'); - - $controller = new Foo_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $this->helper->initView(); - $this->_checkDefaults(); - } - - public function testInitViewWillNotRegisterSameViewPathTwice() - { - $this->request->setModuleName('foo') - ->setControllerName('index'); - $controller = new Foo_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - - $this->helper->initView(); - - $moduleDir = dirname($this->front->getControllerDirectory('foo')); - $this->helper->initView($moduleDir . '/views', 'Foo', array('encoding' => 'ISO-8858-1')); - $this->_checkDefaults(); - } - - public function testInitViewCanBeCalledAfterPostDispatch() - { - $this->request->setModuleName('foo') - ->setControllerName('index'); - $controller = new Foo_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - - $this->helper->initView(); - $this->helper->setNoRender(); - $this->helper->postDispatch(); - $this->request->setModuleName('bar') - ->setControllerName('index'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $this->helper->initView(); - $this->_checkDefaults('bar', 2); - } - - public function testPreDispatchWithDefaults() - { - $this->request->setModuleName('foo') - ->setControllerName('index'); - $controller = new Foo_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - - $this->helper->preDispatch(); - $this->_checkDefaults(); - } - - public function testInitViewWithOptions() - { - $this->request->setModuleName('foo') - ->setControllerName('index'); - $controller = new Foo_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - - $viewDir = dirname(__FILE__) . str_repeat(DIRECTORY_SEPARATOR . '..', 2) . DIRECTORY_SEPARATOR . 'views'; - $this->helper->initView($viewDir, 'Baz_Bat', array( - 'neverRender' => true, - 'noRender' => true, - 'noController' => true, - 'viewSuffix' => 'php', - 'scriptAction' => 'foo', - 'responseSegment' => 'baz' - )); - - $this->assertTrue($this->helper->getNeverRender()); - $this->assertTrue($this->helper->getNoRender()); - $this->assertTrue($this->helper->getNoController()); - $this->assertEquals('php', $this->helper->getViewSuffix()); - $this->assertEquals('foo', $this->helper->getScriptAction()); - $this->assertEquals('baz', $this->helper->getResponseSegment()); - - $scriptPaths = $this->helper->view->getScriptPaths(); - $scriptPath = $scriptPaths[0]; - $this->assertContains($viewDir, $scriptPath); - - $helperPaths = $this->helper->view->getHelperPaths(); - $found = false; - foreach ($helperPaths as $prefix => $paths) { - if ('Baz_Bat_Helper_' == $prefix) { - $found = true; - } - } - $this->assertTrue($found, 'Helper prefix not set according to spec: ' . var_export($helperPaths, 1)); - - $filterPaths = $this->helper->view->getFilterPaths(); - $found = false; - foreach ($filterPaths as $prefix => $paths) { - if ('Baz_Bat_Filter_' == $prefix) { - $found = true; - } - } - $this->assertTrue($found, 'Filter prefix not set according to spec' . var_export($filterPaths, 1)); - } - - public function testNeverRenderFlag() - { - $this->assertFalse($this->helper->getNeverRender()); - $this->helper->setNeverRender(); - $this->assertTrue($this->helper->getNeverRender()); - $this->helper->setNeverRender(false); - $this->assertFalse($this->helper->getNeverRender()); - $this->helper->setNeverRender(true); - $this->assertTrue($this->helper->getNeverRender()); - } - - public function testNeverRenderFlagDisablesRendering() - { - $this->helper->setNeverRender(); - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test') - ->setDispatched(true); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $this->helper->postDispatch(); - - $content = $this->response->getBody(); - $this->assertNotContains('Rendered index/test.phtml', $this->response->getBody()); - } - - public function testNoRenderFlag() - { - $this->assertFalse($this->helper->getNoRender()); - $this->helper->setNoRender(); - $this->assertTrue($this->helper->getNoRender()); - $this->helper->setNoRender(false); - $this->assertFalse($this->helper->getNoRender()); - $this->helper->setNoRender(true); - $this->assertTrue($this->helper->getNoRender()); - } - - public function testScriptActionProperty() - { - $this->assertNull($this->helper->getScriptAction()); - $this->helper->setScriptAction('foo'); - $this->assertEquals('foo', $this->helper->getScriptAction()); - $this->helper->setScriptAction('foo/bar'); - $this->assertEquals('foo/bar', $this->helper->getScriptAction()); - } - - public function testResponseSegmentProperty() - { - $this->assertNull($this->helper->getResponseSegment()); - $this->helper->setResponseSegment('foo'); - $this->assertEquals('foo', $this->helper->getResponseSegment()); - $this->helper->setResponseSegment('foo/bar'); - $this->assertEquals('foo/bar', $this->helper->getResponseSegment()); - } - - public function testNoControllerFlag() - { - $this->assertFalse($this->helper->getNoController()); - $this->helper->setNoController(); - $this->assertTrue($this->helper->getNoController()); - $this->helper->setNoController(false); - $this->assertFalse($this->helper->getNoController()); - $this->helper->setNoController(true); - $this->assertTrue($this->helper->getNoController()); - } - - public function testNeverControllerFlag() - { - $this->assertFalse($this->helper->getNeverController()); - $this->helper->setNeverController(); - $this->assertTrue($this->helper->getNeverController()); - $this->helper->setNeverController(false); - $this->assertFalse($this->helper->getNeverController()); - $this->helper->setNeverController(true); - $this->assertTrue($this->helper->getNeverController()); - } - - protected function _checkRenderProperties() - { - $this->assertEquals('foo', $this->helper->getScriptAction()); - $this->assertEquals('bar', $this->helper->getResponseSegment()); - $this->assertTrue($this->helper->getNoController()); - } - - public function testSetRenderSetsProperties() - { - $this->helper->setRender('foo', 'bar', true); - $this->_checkRenderProperties(); - } - - public function testPostDispatchRendersAppropriateScript() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test') - ->setDispatched(true); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $this->helper->postDispatch(); - - $content = $this->response->getBody(); - $this->assertContains('Rendered index/test.phtml in bar module', $content); - } - - public function testPostDispatchDoesNothingOnForward() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test') - ->setDispatched(false); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $this->helper->postDispatch(); - - $content = $this->response->getBody(); - $this->assertNotContains('Rendered index/test.phtml in bar module', $content); - $this->assertTrue(empty($content)); - } - - public function testPostDispatchDoesNothingOnRedirect() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test') - ->setDispatched(true); - $this->response->setHttpResponseCode(302); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $this->helper->postDispatch(); - - $content = $this->response->getBody(); - $this->assertNotContains('Rendered index/test.phtml in bar module', $content); - $this->assertTrue(empty($content)); - } - - public function testPostDispatchDoesNothingWithNoController() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test') - ->setDispatched(true); - $this->helper->postDispatch(); - - $content = $this->response->getBody(); - $this->assertNotContains('Rendered index/test.phtml in bar module', $content); - $this->assertTrue(empty($content)); - } - - public function testPostDispatchDoesNothingWithNeverController() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test') - ->setDispatched(true); - $this->helper->setNeverController(true); - $this->helper->postDispatch(); - - $content = $this->response->getBody(); - $this->assertNotContains('Rendered index/test.phtml in bar module', $content); - $this->assertTrue(empty($content)); - } - - public function testDirectProxiesToSetRender() - { - $this->helper->direct('foo', 'bar', true); - $this->_checkRenderProperties(); - } - - public function testViewBasePathSpecDefault() - { - $this->assertEquals(':moduleDir/views', $this->helper->getViewBasePathSpec()); - } - - public function testSettingViewBasePathSpec() - { - $this->helper->setViewBasePathSpec(':moduleDir/views/:controller'); - $this->assertEquals(':moduleDir/views/:controller', $this->helper->getViewBasePathSpec()); - } - - public function testViewScriptPathSpecDefault() - { - $this->assertEquals(':controller/:action.:suffix', $this->helper->getViewScriptPathSpec()); - } - - public function testSettingViewScriptPathSpec() - { - $this->helper->setViewScriptPathSpec(':moduleDir/views/:controller'); - $this->assertEquals(':moduleDir/views/:controller', $this->helper->getViewScriptPathSpec()); - } - - public function testViewScriptPathNoControllerSpecDefault() - { - $this->assertEquals(':action.:suffix', $this->helper->getViewScriptPathNoControllerSpec()); - } - - public function testSettingViewScriptPathNoControllerSpec() - { - $this->helper->setViewScriptPathNoControllerSpec(':module/:action.:suffix'); - $this->assertEquals(':module/:action.:suffix', $this->helper->getViewScriptPathNoControllerSpec()); - } - - public function testGetViewScriptWithDefaults() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $expected = 'index/test.phtml'; - $this->assertEquals($expected, $this->helper->getViewScript()); - } - - public function testGetViewScriptWithSpecifiedAction() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $expected = 'index/baz.phtml'; - $this->assertEquals($expected, $this->helper->getViewScript('baz')); - } - - public function testGetViewScriptWithSpecifiedVars() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $expected = 'baz/bat.php'; - $this->assertEquals( - $expected, - $this->helper->getViewScript( - null, - array('controller' => 'baz', 'action' => 'bat', 'suffix' => 'php') - ) - ); - } - - public function testGetViewScriptWithNoControllerSet() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setNoController(); - $expected = 'test.phtml'; - $this->assertEquals($expected, $this->helper->getViewScript()); - } - - public function testRenderScript() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->renderScript('index/test.phtml'); - $body = $this->response->getBody(); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testRenderScriptToNamedResponseSegment() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->renderScript('index/test.phtml', 'foo'); - $body = $this->response->getBody('foo'); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testRenderScriptToPreviouslyNamedResponseSegment() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setResponseSegment('foo'); - $this->helper->renderScript('index/test.phtml'); - $body = $this->response->getBody('foo'); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testRenderWithDefaults() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->render(); - $body = $this->response->getBody(); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testRenderToSpecifiedAction() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('index'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->render('test'); - $body = $this->response->getBody(); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testRenderWithNoController() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->render(null, null, true); - $body = $this->response->getBody(); - $this->assertContains('Rendered test.phtml in bar module', $body); - } - - public function testRenderToNamedSegment() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->render(null, 'foo'); - $body = $this->response->getBody('foo'); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testRenderBySpec() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('index'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->renderBySpec('foo', array('controller' => 'test', 'suffix' => 'php')); - $body = $this->response->getBody(); - $this->assertContains('Rendered test/foo.php', $body); - } - - public function testRenderBySpecToNamedResponseSegment() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('index'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->renderBySpec('foo', array('controller' => 'test', 'suffix' => 'php'), 'foo'); - $body = $this->response->getBody('foo'); - $this->assertContains('Rendered test/foo.php', $body); - } - - public function testInitDoesNotInitViewWhenNoViewRendererSet() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('index'); - $this->front->setParam('noViewRenderer', true); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->assertNull($controller->view); - } - - public function testPostDispatchDoesNotRenderViewWhenNoViewRendererSet() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('index'); - $this->front->setParam('noViewRenderer', true); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->postDispatch(); - $body = $this->response->getBody(); - $this->assertTrue(empty($body)); - } - - public function testRenderNormalizationIsCorrect() - { - $this->request->setModuleName('default') - ->setControllerName('foo') - ->setActionName('myBar'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $scriptName = $this->helper->getViewScript(); - $this->assertEquals('foo/my-bar.phtml', $scriptName); - - $this->request->setModuleName('default') - ->setControllerName('foo') - ->setActionName('baz__bat'); - $scriptName = $this->helper->getViewScript(); - $this->assertEquals('foo/baz-bat.phtml', $scriptName); - - $this->request->setModuleName('default') - ->setControllerName('Foo_Bar') - ->setActionName('bar__baz'); - $scriptName = $this->helper->getViewScript(); - $this->assertEquals('foo/bar/bar-baz.phtml', $scriptName); - } - - public function testGetInflectorGetsDefaultInflectorWhenNoneProvided() - { - $inflector = $this->helper->getInflector(); - $this->assertTrue($inflector instanceof Zend_Filter_Inflector); - $rules = $inflector->getRules(); - $this->assertTrue(isset($rules['module'])); - $this->assertTrue(isset($rules['moduleDir'])); - $this->assertTrue(isset($rules['controller'])); - $this->assertTrue(isset($rules['action'])); - $this->assertTrue(isset($rules['suffix'])); - } - - public function testInflectorAccessorsAllowSwappingInflectors() - { - $inflector = $this->helper->getInflector(); - $this->assertTrue($inflector instanceof Zend_Filter_Inflector); - $newInflector = new Zend_Filter_Inflector(); - $this->helper->setInflector($newInflector); - $receivedInflector = $this->helper->getInflector(); - $this->assertSame($newInflector, $receivedInflector); - $this->assertNotSame($newInflector, $inflector); - } - - public function testCustomInflectorCanUseItsOwnTarget() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('index'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - - $this->helper->view->addBasePath($this->basePath . '/_files/modules/bar/views'); - - $inflector = new Zend_Filter_Inflector('test.phtml'); - $inflector->addFilterRule(':controller', array('Word_CamelCaseToDash')); - $this->helper->setInflector($inflector); - - $this->helper->render(); - $body = $this->response->getBody(); - $this->assertContains('Rendered test.phtml in bar module', $body); - } - - public function testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('test'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - - $this->helper->view->addBasePath($this->basePath . '/_files/modules/bar/views'); - - require_once 'Zend/Filter/PregReplace.php'; - require_once 'Zend/Filter/Word/UnderscoreToSeparator.php'; - - $inflector = new Zend_Filter_Inflector('test.phtml'); - $inflector->addRules(array( - ':module' => array('Word_CamelCaseToDash', 'stringToLower'), - ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator(DIRECTORY_SEPARATOR), 'StringToLower'), - ':action' => array( - 'Word_CamelCaseToDash', - new Zend_Filter_PregReplace('/[^a-z0-9]+/i', '-'), - 'StringToLower' - ), - )); - $this->helper->setInflector($inflector, true); - - $this->helper->render(); - $body = $this->response->getBody(); - $this->assertContains('Rendered index/test.phtml in bar module', $body); - } - - public function testStockInflectorAllowsSubDirectoryViewScripts() - { - $this->request->setModuleName('bar') - ->setControllerName('index') - ->setActionName('layout/admin'); - $this->assertEquals('index/layout/admin.phtml', $this->helper->getViewScript()); - } - - /** - * @see ZF-2443 - */ - public function testStockInflectorWorksWithViewBaseSpec() - { - $this->request->setModuleName('bar') // bar must exist so the ViewRendere doesnt throw an exception - ->setControllerName('index') - ->setActionName('admin'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - - $this->helper->setViewBasePathSpec(':moduleDir/:module'); - $this->helper->initView(); - - $viewScriptPaths = $this->helper->view->getAllPaths(); - - // we need this until View decides to not use DIRECTORY_SEPARATOR - $expectedPathRegex = (DIRECTORY_SEPARATOR == '\\') ? '#modules\\\\bar\\\\bar\\\\scripts\\\\$#' : '#modules/bar/bar/scripts/$#'; - $this->assertRegExp($expectedPathRegex, $viewScriptPaths['script'][0]); - $this->assertEquals($this->helper->getViewScript(), 'index/admin.phtml'); - } - - /** - * @see ZF-2738 - */ - public function testStockInflectorWorksWithDottedRequestParts() - { - $this->request->setModuleName('foo') - ->setControllerName('car.bar') - ->setActionName('baz'); - $controller = new Bar_IndexController($this->request, $this->response, array()); - $this->helper->setActionController($controller); - $viewScriptPaths = $this->helper->view->getAllPaths(); - - $expectedPathRegex = (DIRECTORY_SEPARATOR == '\\') ? '#modules\\\\foo\\\\views\\\\scripts\\\\$#' : '#modules/foo/views/scripts/$#'; - $this->assertRegExp($expectedPathRegex, $viewScriptPaths['script'][0]); - $this->assertEquals($this->helper->getViewScript(), 'car-bar/baz.phtml'); - } - - public function testCorrectViewHelperPathShouldBePropagatedWhenSubControllerInvoked() - { - require_once $this->basePath . '/_files/modules/foo/controllers/Admin/IndexController.php'; - $this->request->setModuleName('foo') - ->setControllerName('admin_index') - ->setActionName('use-helper'); - $controller = new Foo_Admin_IndexController($this->request, $this->response, array()); - - $this->helper->render(); - $body = $this->response->getBody(); - $this->assertContains('fooUseHelper invoked', $body, 'Received ' . $body); - } - - public function testCorrectViewHelperPathShouldBePropagatedWhenSubControllerInvokedInDefaultModule() - { - require_once $this->basePath . '/_files/modules/default/controllers/Admin/HelperController.php'; - $this->request->setControllerName('admin_helper') - ->setActionName('render'); - $controller = new Admin_HelperController($this->request, $this->response, array()); - - $this->helper->render(); - $body = $this->response->getBody(); - $this->assertContains('SampleZfHelper invoked', $body, 'Received ' . $body); - } -} - -// Call Zend_Controller_Action_Helper_ViewRendererTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_Helper_ViewRendererTest::main") { - Zend_Controller_Action_Helper_ViewRendererTest::main(); -} - diff --git a/tests/Zend/Controller/Action/HelperBroker/PriorityStackTest.php b/tests/Zend/Controller/Action/HelperBroker/PriorityStackTest.php deleted file mode 100644 index 3fb56fb1c542f9bfefa08b69d1fd3f4ff753c34d..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/HelperBroker/PriorityStackTest.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -// Call Zend_Controller_Action_HelperBrokerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_HelperBrokerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; -require_once 'Zend/Controller/Action/Helper/Redirector.php'; - -class Zend_Controller_Action_HelperBroker_PriorityStackTest extends PHPUnit_Framework_TestCase -{ - - /** - * @var Zend_Controller_Action_HelperBroker_PriorityStack - */ - public $stack = null; - - public function setUp() - { - $this->stack = new Zend_Controller_Action_HelperBroker_PriorityStack(); - } - - public function testStackMaintainsLifo() - { - $this->stack->push(new Zend_Controller_Action_Helper_ViewRenderer()); - $this->stack->push(new Zend_Controller_Action_Helper_Redirector()); - $this->assertEquals(2, count($this->stack)); - $iterator = $this->stack->getIterator(); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class(current($iterator))); - next($iterator); - $this->assertEquals('Zend_Controller_Action_Helper_ViewRenderer', get_class(current($iterator))); - } - - public function testStackPrioritiesWithDefaults() - { - $this->stack->push(new Zend_Controller_Action_Helper_ViewRenderer()); - $this->stack->push(new Zend_Controller_Action_Helper_Redirector()); - $this->assertEquals(3, $this->stack->getNextFreeHigherPriority()); - $this->assertEquals(0, $this->stack->getNextFreeLowerPriority()); - $this->assertEquals(2, $this->stack->getHighestPriority()); - $this->assertEquals(1, $this->stack->getLowestPriority()); - } - - - public function testStackMaintainsReturnsCorrectNextPriorityWithSetPriorities() - { - $this->stack->offsetSet(10, new Zend_Controller_Action_Helper_ViewRenderer()); - $this->stack->offsetSet(11, new Zend_Controller_Action_Helper_Redirector()); - $this->assertEquals(12, $this->stack->getNextFreeHigherPriority(10)); - $this->assertEquals(9, $this->stack->getNextFreeLowerPriority(10)); - $this->assertEquals(11, $this->stack->getHighestPriority()); - $this->assertEquals(10, $this->stack->getLowestPriority()); - } - - public function testStackMaintainsReturnsCorrectNextPriorityWithSetPrioritiesSplit() - { - $this->stack->offsetSet(10, new Zend_Controller_Action_Helper_ViewRenderer()); - $this->stack->offsetSet(20, new Zend_Controller_Action_Helper_Redirector()); - $this->assertEquals(11, $this->stack->getNextFreeHigherPriority(10)); - $this->assertEquals(9, $this->stack->getNextFreeLowerPriority(10)); - - $this->assertEquals(11, $this->stack->getNextFreeHigherPriority(11)); - $this->assertEquals(11, $this->stack->getNextFreeLowerPriority(11)); - - $this->assertEquals(21, $this->stack->getNextFreeHigherPriority(20)); - $this->assertEquals(19, $this->stack->getNextFreeLowerPriority(20)); - - $this->assertEquals(20, $this->stack->getHighestPriority()); - $this->assertEquals(10, $this->stack->getLowestPriority()); - } - - public function testStackAccessors() - { - $this->stack->push(new Zend_Controller_Action_Helper_ViewRenderer()); - $this->stack->push(new Zend_Controller_Action_Helper_Redirector()); - unset($this->stack->ViewRenderer); - $this->assertEquals(1, count($this->stack)); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class(current($this->stack->getIterator()))); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class($this->stack->Redirector)); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class($this->stack->offsetGet('Redirector'))); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', get_class($this->stack->offsetGet(2))); - } - -} \ No newline at end of file diff --git a/tests/Zend/Controller/Action/HelperBrokerTest.php b/tests/Zend/Controller/Action/HelperBrokerTest.php deleted file mode 100644 index 748a9db2c717ea06f2b18d11ba088dfba83d392e..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Action/HelperBrokerTest.php +++ /dev/null @@ -1,311 +0,0 @@ -<?php -// Call Zend_Controller_Action_HelperBrokerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Action_HelperBrokerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; - -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; -require_once 'Zend/Controller/Action/Helper/Redirector.php'; - -class Zend_Controller_Action_HelperBrokerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Action_HelperBrokerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->front = Zend_Controller_Front::getInstance(); - $this->front->resetInstance(); - $this->front->setParam('noViewRenderer', true) - ->setParam('noErrorHandler', true) - ->throwExceptions(true); - Zend_Controller_Action_HelperBroker::resetHelpers(); - - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $viewRenderer->setActionController(); - } - - public function testLoadingAndReturningHelper() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-get-redirector/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - $response = $this->front->dispatch($request); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', $response->getBody()); - } - - public function testLoadingAndReturningHelperStatically() - { - $helper = new Zend_Controller_Action_HelperBroker_TestHelper(); - Zend_Controller_Action_HelperBroker::addHelper($helper); - $received = Zend_Controller_Action_HelperBroker::getExistingHelper('testHelper'); - $this->assertSame($received, $helper); - } - - public function testGetExistingHelperThrowsExceptionWithUnregisteredHelper() - { - try { - $received = Zend_Controller_Action_HelperBroker::getExistingHelper('testHelper'); - $this->fail('Retrieving unregistered helpers should throw an exception'); - } catch (Exception $e) { - // success - } - } - - public function testLoadingHelperOnlyInitializesOnce() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('default') - ->setControllerName('zend_controller_action_helper-broker') - ->setActionName('index'); - $response = new Zend_Controller_Response_Cli(); - $this->front->setResponse($response); - - $helper = new Zend_Controller_Action_HelperBroker_TestHelper(); - Zend_Controller_Action_HelperBroker::addHelper($helper); - - $controller = new Zend_Controller_Action_HelperBrokerController($request, $response, array()); - $controller->test(); - $received = $controller->getHelper('testHelper'); - $this->assertSame($helper, $received); - $this->assertEquals(1, $helper->count); - } - - public function testLoadingAndCheckingHelpersStatically() - { - $helper = new Zend_Controller_Action_Helper_Redirector(); - Zend_Controller_Action_HelperBroker::addHelper($helper); - - $this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper('redirector')); - } - - public function testLoadingAndRemovingHelpersStatically() - { - $helper = new Zend_Controller_Action_Helper_Redirector(); - Zend_Controller_Action_HelperBroker::addHelper($helper); - - $this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper('redirector')); - Zend_Controller_Action_HelperBroker::removeHelper('redirector'); - $this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('redirector')); - } - public function testReturningHelper() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-get-redirector/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - $response = $this->front->dispatch($request); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', $response->getBody()); - } - - public function testReturningHelperViaMagicGet() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-helper-via-magic-get/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - $response = $this->front->dispatch($request); - $this->assertEquals('Zend_Controller_Action_Helper_Redirector', $response->getBody()); - } - - public function testReturningHelperViaMagicCall() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-helper-via-magic-call/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - - require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files/Helpers/TestHelper.php'; - Zend_Controller_Action_HelperBroker::addHelper(new MyApp_TestHelper()); - - $response = $this->front->dispatch($request); - $this->assertEquals('running direct call', $response->getBody()); - } - - public function testNonExistentHelper() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-bad-helper/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - $response = $this->front->dispatch($request); - $this->assertEquals('Action Helper by name NonExistentHelper not found.', $response->getBody()); - } - - public function testCustomHelperRegistered() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-custom-helper/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - - require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files/Helpers/TestHelper.php'; - Zend_Controller_Action_HelperBroker::addHelper(new MyApp_TestHelper()); - - $response = $this->front->dispatch($request); - $this->assertEquals('MyApp_TestHelper', $response->getBody()); - } - - public function testCustomHelperFromPath() - { - $this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-custom-helper/'); - $this->front->setResponse(new Zend_Controller_Response_Cli()); - - $this->front->returnResponse(true); - - Zend_Controller_Action_HelperBroker::addPath( - dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Helpers', - 'MyApp' - ); - - $response = $this->front->dispatch($request); - $this->assertEquals('MyApp_TestHelper', $response->getBody()); - } - - public function testGetExistingHelpers() - { - Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Redirector()); - // already included in setup, techinically we shouldnt be able to do this, but until 2.0 - its allowed - Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer()); // @todo in future this should throw an exception - - $helpers = Zend_Controller_Action_HelperBroker::getExistingHelpers(); - $this->assertTrue(is_array($helpers)); - $this->assertEquals(2, count($helpers)); - $this->assertContains('ViewRenderer', array_keys($helpers)); - $this->assertContains('Redirector', array_keys($helpers)); - } - - public function testGetHelperStatically() - { - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $this->assertTrue($helper instanceof Zend_Controller_Action_Helper_ViewRenderer); - - $helpers = Zend_Controller_Action_HelperBroker::getExistingHelpers(); - $this->assertTrue(is_array($helpers)); - $this->assertEquals(1, count($helpers)); - } - - public function testHelperPullsResponseFromRegisteredActionController() - { - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - - $aRequest = new Zend_Controller_Request_Http(); - $aRequest->setModuleName('default') - ->setControllerName('zend_controller_action_helper-broker') - ->setActionName('index'); - $aResponse = new Zend_Controller_Response_Cli(); - $controller = new Zend_Controller_Action_HelperBrokerController($aRequest, $aResponse, array()); - - $fRequest = new Zend_Controller_Request_Http(); - $fRequest->setModuleName('foo') - ->setControllerName('foo-bar') - ->setActionName('baz'); - $fResponse = new Zend_Controller_Response_Cli(); - $this->front->setRequest($fRequest) - ->setResponse($fResponse); - - $helper->setActionController($controller); - - $hRequest = $helper->getRequest(); - $this->assertSame($hRequest, $aRequest); - $this->assertNotSame($hRequest, $fRequest); - $hResponse = $helper->getResponse(); - $this->assertSame($hResponse, $aResponse); - $this->assertNotSame($hResponse, $fResponse); - } - - public function testHelperPullsResponseFromFrontControllerWithNoRegisteredActionController() - { - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $this->assertNull($helper->getActionController()); - - $aRequest = new Zend_Controller_Request_Http(); - $aRequest->setModuleName('default') - ->setControllerName('zend_controller_action_helper-broker') - ->setActionName('index'); - $aResponse = new Zend_Controller_Response_Cli(); - - $fRequest = new Zend_Controller_Request_Http(); - $fRequest->setModuleName('foo') - ->setControllerName('foo-bar') - ->setActionName('baz'); - $fResponse = new Zend_Controller_Response_Cli(); - $this->front->setRequest($fRequest) - ->setResponse($fResponse); - - $hRequest = $helper->getRequest(); - $this->assertNotSame($hRequest, $aRequest); - $this->assertSame($hRequest, $fRequest); - $hResponse = $helper->getResponse(); - $this->assertNotSame($hResponse, $aResponse); - $this->assertSame($hResponse, $fResponse); - } - - public function testHelperPathStackIsLifo() - { - Zend_Controller_Action_HelperBroker::addPath( - dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Helpers', - 'MyApp' - ); - - $urlHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('url'); - $this->assertTrue($urlHelper instanceof MyApp_Url); - } -} - -class Zend_Controller_Action_HelperBroker_TestHelper extends Zend_Controller_Action_Helper_Abstract -{ - public $count = 0; - - public function init() - { - ++$this->count; - } -} - -class Zend_Controller_Action_HelperBrokerController extends Zend_Controller_Action -{ - public $helper; - - public function init() - { - $this->helper = $this->_helper->getHelper('testHelper'); - } - - public function test() - { - $this->_helper->getHelper('testHelper'); - } -} - -// Call Zend_Controller_Action_HelperBrokerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Action_HelperBrokerTest::main") { - Zend_Controller_Action_HelperBrokerTest::main(); -} diff --git a/tests/Zend/Controller/ActionTest.php b/tests/Zend/Controller/ActionTest.php deleted file mode 100644 index 6b6d5acd001e0b3f6dbe65b117fcda6db4f7f889..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/ActionTest.php +++ /dev/null @@ -1,526 +0,0 @@ -<?php -// Call Zend_Controller_ActionTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_ActionTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Action.php'; -require_once 'Zend/Controller/Action/Helper/Redirector.php'; -require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; - -class Zend_Controller_ActionTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_ActionTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->_controller = new Zend_Controller_ActionTest_TestController( - new Zend_Controller_Request_Http(), - new Zend_Controller_Response_Cli(), - array( - 'foo' => 'bar', - 'bar' => 'baz' - ) - ); - Zend_Controller_Front::getInstance()->resetInstance(); - Zend_Controller_Action_HelperBroker::resetHelpers(); - $redirector = $this->_controller->getHelper('redirector'); - $redirector->setExit(false); - } - - public function tearDown() - { - unset($this->_controller); - } - - public function testInit() - { - $this->assertEquals('bar', $this->_controller->initArgs['foo']); - $this->assertEquals('baz', $this->_controller->initArgs['bar']); - } - - public function testPreRun() - { - $this->_controller->preDispatch(); - $this->assertNotContains('Prerun ran', $this->_controller->getResponse()->getBody()); - - $this->_controller->getRequest()->setParam('prerun', true); - $this->_controller->preDispatch(); - $this->assertContains('Prerun ran', $this->_controller->getResponse()->getBody()); - } - - public function testPostRun() - { - $this->_controller->postDispatch(); - $this->assertNotContains('Postrun ran', $this->_controller->getResponse()->getBody()); - - $this->_controller->getRequest()->setParam('postrun', true); - $this->_controller->postDispatch(); - $this->assertContains('Postrun ran', $this->_controller->getResponse()->getBody()); - } - - public function testGetRequest() - { - $this->assertTrue($this->_controller->getRequest() instanceof Zend_Controller_Request_Abstract); - } - - public function testGetResponse() - { - $this->assertTrue($this->_controller->getResponse() instanceof Zend_Controller_Response_Abstract); - } - - public function testGetInvokeArgs() - { - $expected = array('foo' => 'bar', 'bar' => 'baz'); - $this->assertSame($expected, $this->_controller->getInvokeArgs()); - } - - public function testGetInvokeArg() - { - $this->assertSame('bar', $this->_controller->getInvokeArg('foo')); - $this->assertSame('baz', $this->_controller->getInvokeArg('bar')); - } - - public function testForwardActionOnly() - { - $this->_controller->forward('forwarded'); - $this->assertEquals('forwarded', $this->_controller->getRequest()->getActionName()); - $this->assertFalse($this->_controller->getRequest()->isDispatched()); - } - - public function testForwardActionKeepsController() - { - $request = $this->_controller->getRequest(); - $request->setControllerName('foo') - ->setActionName('bar'); - $this->_controller->forward('forwarded'); - $this->assertEquals('forwarded', $request->getActionName()); - $this->assertEquals('foo', $request->getControllerName()); - $this->assertFalse($request->isDispatched()); - } - - public function testForwardActionAndController() - { - $request = $this->_controller->getRequest(); - $request->setControllerName('foo') - ->setActionName('bar'); - $this->_controller->forward('forwarded', 'bar'); - $this->assertEquals('forwarded', $request->getActionName()); - $this->assertEquals('bar', $request->getControllerName()); - $this->assertFalse($request->isDispatched()); - } - - public function testForwardActionControllerAndModule() - { - $request = $this->_controller->getRequest(); - $request->setControllerName('foo') - ->setActionName('bar') - ->setModuleName('admin'); - $this->_controller->forward('forwarded', 'bar'); - $this->assertEquals('forwarded', $request->getActionName()); - $this->assertEquals('bar', $request->getControllerName()); - $this->assertEquals('admin', $request->getModuleName()); - $this->assertFalse($request->isDispatched()); - } - - public function testForwardCanSetParams() - { - $request = $this->_controller->getRequest(); - $request->setParams(array('admin' => 'batman')); - $this->_controller->forward('forwarded', null, null, array('foo' => 'bar')); - $this->assertEquals('forwarded', $request->getActionName()); - $received = $request->getParams(); - $this->assertTrue(isset($received['foo'])); - $this->assertEquals('bar', $received['foo']); - $this->assertFalse($request->isDispatched()); - } - - public function testRun() - { - $response = $this->_controller->run(); - $body = $response->getBody(); - $this->assertContains('In the index action', $body, var_export($this->_controller->getRequest(), 1)); - $this->assertNotContains('Prerun ran', $body, $body); - } - - public function testRun2() - { - $this->_controller->getRequest()->setActionName('bar'); - try { - $response = $this->_controller->run(); - $this->fail('Should not be able to call bar as action'); - } catch (Exception $e) { - //success! - } - } - - public function testRun3() - { - $this->_controller->getRequest()->setActionName('foo'); - $response = $this->_controller->run(); - $this->assertContains('In the foo action', $response->getBody()); - $this->assertNotContains('Prerun ran', $this->_controller->getResponse()->getBody()); - } - - public function testHasParam() - { - $request = $this->_controller->getRequest(); - $request->setParam('foo', 'bar'); - $request->setParam('baz', 'bal'); - - $this->assertTrue($this->_controller->hasParam('foo')); - $this->assertTrue($this->_controller->hasParam('baz')); - } - - public function testSetParam() - { - $this->_controller->setParam('foo', 'bar'); - $params = $this->_controller->getParams(); - $this->assertTrue(isset($params['foo'])); - $this->assertEquals('bar', $params['foo']); - } - - public function testGetParams() - { - $this->_controller->setParam('foo', 'bar'); - $this->_controller->setParam('bar', 'baz'); - $this->_controller->setParam('boo', 'bah'); - - $params = $this->_controller->getParams(); - $this->assertEquals('bar', $params['foo']); - $this->assertEquals('baz', $params['bar']); - $this->assertEquals('bah', $params['boo']); - } - - public function testRedirect() - { - $response = $this->_controller->getResponse(); - $response->headersSentThrowsException = false; - $this->_controller->redirect('/baz/foo'); - $this->_controller->redirect('/foo/bar'); - $headers = $response->getHeaders(); - $found = 0; - $url = ''; - foreach ($headers as $header) { - if ('Location' == $header['name']) { - ++$found; - $url = $header['value']; - break; - } - } - $this->assertEquals(1, $found); - $this->assertContains('/foo/bar', $url); - } - - public function testInitView() - { - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController( - new Zend_Controller_Request_Http(), - new Zend_Controller_Response_Cli() - ); - $view = $controller->initView(); - $this->assertTrue($view instanceof Zend_View); - $scriptPath = $view->getScriptPaths(); - $this->assertTrue(is_array($scriptPath)); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR, $scriptPath[0]); - } - - public function testRender() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('index'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->indexAction(); - $this->assertContains('In the index action view', $response->getBody()); - } - - public function testRenderByName() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('test'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->testAction(); - $this->assertContains('In the index action view', $response->getBody()); - } - - public function testRenderOutsideControllerSubdir() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('site'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->siteAction(); - $this->assertContains('In the sitewide view', $response->getBody()); - } - - public function testRenderNamedSegment() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('name'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->nameAction(); - $this->assertContains('In the name view', $response->getBody('name')); - } - - public function testRenderNormalizesScriptName() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('foo.bar') - ->setActionName('baz_bat'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'FooBarController.php'; - $controller = new FooBarController($request, $response); - - $controller->bazBatAction(); - $this->assertContains('Inside foo-bar/baz-bat.phtml', $response->getBody()); - } - - public function testGetViewScript() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('test'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $script = $controller->getViewScript(); - $this->assertContains('view' . DIRECTORY_SEPARATOR . 'test.phtml', $script); - - $script = $controller->getViewScript('foo'); - $this->assertContains('view' . DIRECTORY_SEPARATOR . 'foo.phtml', $script); - } - - public function testGetViewScriptDoesNotOverwriteNoControllerFlagWhenNullPassed() - { - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('test'); - $response = new Zend_Controller_Response_Cli(); - $controller = new ViewController($request, $response); - - $this->assertSame($viewRenderer->getActionController(), $controller); - $viewRenderer->setNoController(true); - - $this->assertTrue($viewRenderer->getNoController()); - - $script = $controller->getViewScript(); - - $this->assertTrue($viewRenderer->getNoController()); - } - - public function testRenderScript() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('script'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->scriptAction(); - $this->assertContains('Inside custom/renderScript.php', $response->getBody()); - } - - public function testRenderScriptToNamedResponseSegment() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('script-name'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->scriptNameAction(); - - $this->assertContains('Inside custom/renderScript.php', $response->getBody('foo')); - } - - public function testGetHelper() - { - $redirector = $this->_controller->getHelper('redirector'); - $this->assertTrue($redirector instanceof Zend_Controller_Action_Helper_Abstract); - $this->assertTrue($redirector instanceof Zend_Controller_Action_Helper_Redirector); - } - - public function testGetHelperCopy() - { - $redirector = $this->_controller->getHelper('redirector'); - $copy = $this->_controller->getHelperCopy('redirector'); - $this->assertNotSame($redirector, $copy); - $this->assertTrue($copy instanceof Zend_Controller_Action_Helper_Redirector); - } - - public function testViewInjectionUsingViewRenderer() - { - Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer()); - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('script'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - $this->assertNotNull($controller->view); - } - - public function testRenderUsingViewRenderer() - { - Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer()); - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('view') - ->setActionName('script'); - $response = new Zend_Controller_Response_Cli(); - Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php'; - $controller = new ViewController($request, $response); - - $controller->scriptAction(); - $this->assertContains('Inside custom/renderScript.php', $response->getBody()); - } - - public function testMissingActionExceptionsDifferFromMissingMethods() - { - try { - $this->_controller->bogusAction(); - $this->fail('Invalid action should throw exception'); - } catch (Zend_Controller_Exception $e) { - $this->assertRegexp('/^Action.*?(does not exist and was not trapped in __call\(\))$/', $e->getMessage()); - $this->assertContains('bogus', $e->getMessage()); - $this->assertNotContains('bogusAction', $e->getMessage()); - $this->assertEquals(404, $e->getCode()); - } - - try { - $this->_controller->bogus(); - $this->fail('Invalid method should throw exception'); - } catch (Zend_Controller_Exception $e) { - $this->assertRegexp('/^Method.*?(does not exist and was not trapped in __call\(\))$/', $e->getMessage()); - $this->assertContains('bogus', $e->getMessage()); - $this->assertEquals(500, $e->getCode()); - } - } -} - -class Zend_Controller_ActionTest_TestController extends Zend_Controller_Action -{ - public $initArgs = array(); - - public function init() - { - $this->initArgs['foo'] = $this->getInvokeArg('foo'); - $this->initArgs['bar'] = $this->getInvokeArg('bar'); - } - - public function preDispatch() - { - if (false !== ($param = $this->_getParam('prerun', false))) { - $this->getResponse()->appendBody("Prerun ran\n"); - } - } - - public function postDispatch() - { - if (false !== ($param = $this->_getParam('postrun', false))) { - $this->getResponse()->appendBody("Postrun ran\n"); - } - } - - public function noRouteAction() - { - return $this->indexAction(); - } - - public function indexAction() - { - $this->getResponse()->appendBody("In the index action\n"); - } - - public function fooAction() - { - $this->getResponse()->appendBody("In the foo action\n"); - } - - public function bar() - { - $this->getResponse()->setBody("Should never see this\n"); - } - - public function forward($action, $controller = null, $module = null, array $params = null) - { - $this->_forward($action, $controller, $module, $params); - } - - public function hasParam($param) - { - return $this->_hasParam($param); - } - - public function getParams() - { - return $this->_getAllParams(); - } - - public function setParam($key, $value) - { - $this->_setParam($key, $value); - return $this; - } - - public function redirect($url, $code = 302, $prependBase = true) - { - $this->_redirect($url, array('code' => $code, 'prependBase' => $prependBase)); - } -} - -// Call Zend_Controller_ActionTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_ActionTest::main") { - Zend_Controller_ActionTest::main(); -} diff --git a/tests/Zend/Controller/AllTests.php b/tests/Zend/Controller/AllTests.php deleted file mode 100644 index 1271e538ac63e866b1c44b4d9231ba317fccc26e..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/AllTests.php +++ /dev/null @@ -1,95 +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_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Controller_AllTests::main'); -} - -require_once 'ActionTest.php'; -require_once 'Action/HelperBrokerTest.php'; -require_once 'Action/Helper/AllTests.php'; -require_once 'Dispatcher/StandardTest.php'; -require_once 'FrontTest.php'; -require_once 'Plugin/ActionStackTest.php'; -require_once 'Plugin/BrokerTest.php'; -require_once 'Plugin/ErrorHandlerTest.php'; -require_once 'Request/Apache404Test.php'; -require_once 'Request/HttpTest.php'; -require_once 'Request/HttpTestCaseTest.php'; -require_once 'Request/SimpleTest.php'; -require_once 'Response/HttpTest.php'; -require_once 'Response/HttpTestCaseTest.php'; -require_once 'Router/RouteTest.php'; -require_once 'Router/Route/ModuleTest.php'; -require_once 'Router/Route/RegexTest.php'; -require_once 'Router/Route/StaticTest.php'; -require_once 'Router/RewriteTest.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Controller_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Controller'); - - $suite->addTestSuite('Zend_Controller_ActionTest'); - $suite->addTestSuite('Zend_Controller_Action_HelperBrokerTest'); - $suite->addTest(Zend_Controller_Action_Helper_AllTests::suite()); - $suite->addTestSuite('Zend_Controller_Dispatcher_StandardTest'); - $suite->addTestSuite('Zend_Controller_FrontTest'); - $suite->addTestSuite('Zend_Controller_Plugin_ActionStackTest'); - $suite->addTestSuite('Zend_Controller_Plugin_BrokerTest'); - $suite->addTestSuite('Zend_Controller_Plugin_ErrorHandlerTest'); - $suite->addTestSuite('Zend_Controller_Request_Apache404Test'); - $suite->addTestSuite('Zend_Controller_Request_HttpTest'); - $suite->addTestSuite('Zend_Controller_Request_HttpTestCaseTest'); - $suite->addTestSuite('Zend_Controller_Request_SimpleTest'); - $suite->addTestSuite('Zend_Controller_Response_HttpTest'); - $suite->addTestSuite('Zend_Controller_Response_HttpTestCaseTest'); - $suite->addTestSuite('Zend_Controller_Router_RouteTest'); - $suite->addTestSuite('Zend_Controller_Router_Route_ModuleTest'); - $suite->addTestSuite('Zend_Controller_Router_Route_RegexTest'); - $suite->addTestSuite('Zend_Controller_Router_Route_StaticTest'); - $suite->addTestSuite('Zend_Controller_Router_RewriteTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Controller_AllTests::main') { - Zend_Controller_AllTests::main(); -} diff --git a/tests/Zend/Controller/Dispatcher/StandardTest.php b/tests/Zend/Controller/Dispatcher/StandardTest.php deleted file mode 100644 index 5cc176bbd2f8a477f1671d59727b1d39f9d17cb5..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Dispatcher/StandardTest.php +++ /dev/null @@ -1,589 +0,0 @@ -<?php -// Call Zend_Controller_Dispatcher_StandardTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Dispatcher_StandardTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Controller/Dispatcher/Standard.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Request/Simple.php'; -require_once 'Zend/Controller/Response/Cli.php'; - -class Zend_Controller_Dispatcher_StandardTest extends PHPUnit_Framework_TestCase -{ - protected $_dispatcher; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Dispatcher_StandardTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - if (isset($this->error)) { - unset($this->error); - } - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - $this->_dispatcher = new Zend_Controller_Dispatcher_Standard(); - $this->_dispatcher->setControllerDirectory(array( - 'default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files', - 'admin' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin' - )); - } - - public function tearDown() - { - unset($this->_dispatcher); - } - - public function testFormatControllerName() - { - $this->assertEquals('IndexController', $this->_dispatcher->formatControllerName('index')); - $this->assertEquals('Site_CustomController', $this->_dispatcher->formatControllerName('site_custom')); - } - - public function testFormatActionName() - { - $this->assertEquals('indexAction', $this->_dispatcher->formatActionName('index')); - $this->assertEquals('myindexAction', $this->_dispatcher->formatActionName('myIndex')); - $this->assertEquals('myindexAction', $this->_dispatcher->formatActionName('my_index')); - $this->assertEquals('myIndexAction', $this->_dispatcher->formatActionName('my.index')); - $this->assertEquals('myIndexAction', $this->_dispatcher->formatActionName('my-index')); - } - - public function testSetGetControllerDirectory() - { - $expected = array( - 'default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files', - 'admin' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin' - ); - $dirs = $this->_dispatcher->getControllerDirectory(); - $this->assertEquals($expected, $dirs); - } - - public function testIsDispatchable() - { - $request = new Zend_Controller_Request_Http(); - - $this->assertFalse($this->_dispatcher->isDispatchable($request)); - - $request->setControllerName('index'); - $this->assertTrue($this->_dispatcher->isDispatchable($request)); - - $request->setControllerName('foo'); - $this->assertTrue($this->_dispatcher->isDispatchable($request)); - - // True, because it will dispatch to default controller - $request->setControllerName('bogus'); - $this->assertFalse($this->_dispatcher->isDispatchable($request)); - } - - public function testModuleIsDispatchable() - { - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - $request->setControllerName('foo'); - $request->setActionName('bar'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $request->setModuleName('bogus'); - $request->setControllerName('bogus'); - $request->setActionName('bar'); - $this->assertFalse($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - } - - public function testSetGetResponse() - { - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->setResponse($response); - $this->assertTrue($response === $this->_dispatcher->getResponse()); - } - - public function testSetGetDefaultControllerName() - { - $this->assertEquals('index', $this->_dispatcher->getDefaultControllerName()); - - $this->_dispatcher->setDefaultControllerName('foo'); - $this->assertEquals('foo', $this->_dispatcher->getDefaultControllerName()); - } - - public function testSetGetDefaultAction() - { - $this->assertEquals('index', $this->_dispatcher->getDefaultAction()); - - $this->_dispatcher->setDefaultAction('bar'); - $this->assertEquals('bar', $this->_dispatcher->getDefaultAction()); - } - - public function testDispatchValidControllerDefaultAction() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('index'); - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - - $this->assertContains('Index action called', $this->_dispatcher->getResponse()->getBody()); - } - - public function testDispatchValidControllerAndAction() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('index'); - $request->setActionName('index'); - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - - $this->assertContains('Index action called', $this->_dispatcher->getResponse()->getBody()); - } - - public function testDispatchValidControllerWithInvalidAction() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('index'); - $request->setActionName('foo'); - $response = new Zend_Controller_Response_Cli(); - - try { - $this->_dispatcher->dispatch($request, $response); - $this->fail('Exception should be raised by __call'); - } catch (Exception $e) { - // success - } - } - - public function testDispatchInvalidController() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('bogus'); - $response = new Zend_Controller_Response_Cli(); - - try { - $this->_dispatcher->dispatch($request, $response); - $this->fail('Exception should be raised; no such controller'); - } catch (Exception $e) { - // success - } - } - - public function testDispatchInvalidControllerUsingDefaults() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('bogus'); - $response = new Zend_Controller_Response_Cli(); - - $this->_dispatcher->setParam('useDefaultControllerAlways', true); - - try { - $this->_dispatcher->dispatch($request, $response); - $this->assertEquals('index', $request->getControllerName()); - $this->assertEquals('index', $request->getActionName()); - } catch (Exception $e) { - $this->fail('Exception should not be raised when useDefaultControllerAlways set; message: ' . $e->getMessage()); - } - } - - public function testDispatchInvalidControllerUsingDefaultsWithDefaultModule() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('bogus') - ->setModuleName('default'); - $response = new Zend_Controller_Response_Cli(); - - $this->_dispatcher->setParam('useDefaultControllerAlways', true); - - try { - $this->_dispatcher->dispatch($request, $response); - $this->assertSame('default', $request->getModuleName()); - $this->assertSame('index', $request->getControllerName()); - $this->assertSame('index', $request->getActionName()); - } catch (Exception $e) { - $this->fail('Exception should not be raised when useDefaultControllerAlways set; exception: ' . $e->getMessage()); - } - } - - public function testDispatchValidControllerWithPrePostDispatch() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('foo'); - $request->setActionName('bar'); - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains('Bar action called', $body); - $this->assertContains('preDispatch called', $body); - $this->assertContains('postDispatch called', $body); - } - - public function testDispatchNoControllerUsesDefaults() - { - $request = new Zend_Controller_Request_Http(); - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - - $this->assertEquals('index', $request->getControllerName()); - $this->assertEquals('index', $request->getActionName()); - } - - /** - * Tests ZF-637 -- action names with underscores not being correctly changed to camelCase - */ - public function testZf637() - { - $test = $this->_dispatcher->formatActionName('view_entry'); - $this->assertEquals('viewentryAction', $test); - } - - public function testWordDelimiter() - { - $this->assertEquals(array('-', '.'), $this->_dispatcher->getWordDelimiter()); - $this->_dispatcher->setWordDelimiter(':'); - $this->assertEquals(array(':'), $this->_dispatcher->getWordDelimiter()); - } - - public function testPathDelimiter() - { - $this->assertEquals('_', $this->_dispatcher->getPathDelimiter()); - $this->_dispatcher->setPathDelimiter(':'); - $this->assertEquals(':', $this->_dispatcher->getPathDelimiter()); - } - - /** - * Test that classes are found in modules, using a prefix - */ - public function testModules() - { - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - $request->setControllerName('foo'); - $request->setActionName('bar'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains("Admin_Foo::bar action called", $body, $body); - } - - public function testModuleControllerInSubdirWithCamelCaseAction() - { - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - $request->setControllerName('foo-bar'); - $request->setActionName('baz.bat'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains("Admin_FooBar::bazBat action called", $body, $body); - } - - public function testUseModuleDefaultController() - { - $this->_dispatcher->setDefaultControllerName('foo') - ->setParam('useDefaultControllerAlways', true); - - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains("Admin_Foo::index action called", $body, $body); - } - - public function testNoModuleOrControllerDefaultsCorrectly() - { - $request = new Zend_Controller_Request_Http('http://example.com/'); - - $this->assertFalse($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains("Index action called", $body, $body); - } - - public function testOutputBuffering() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('ob'); - $request->setActionName('index'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains("OB index action called", $body, $body); - } - - public function testDisableOutputBuffering() - { - if (!defined('TESTS_ZEND_CONTROLLER_DISPATCHER_OB') || !TESTS_ZEND_CONTROLLER_DISPATCHER_OB) { - $this->markTestSkipped('Skipping output buffer disabling in Zend_Controller_Dispatcher_Standard'); - } - - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('ob'); - $request->setActionName('index'); - $this->_dispatcher->setParam('disableOutputBuffering', true); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertEquals('', $body, $body); - } - - public function testModuleSubdirControllerFound() - { - Zend_Controller_Front::getInstance() - ->setDispatcher($this->_dispatcher) - ->addControllerDirectory( - dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'controllers', - 'foo' - ); - - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('foo'); - $request->setControllerName('admin_index'); - $request->setActionName('index'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertContains("Foo_Admin_IndexController::indexAction() called", $body, $body); - } - - public function testDefaultModule() - { - $this->assertEquals('default', $this->_dispatcher->getDefaultModule()); - $this->_dispatcher->setDefaultModule('foobar'); - $this->assertEquals('foobar', $this->_dispatcher->getDefaultModule()); - } - - public function testModuleValid() - { - $this->assertTrue($this->_dispatcher->isValidModule('default')); - $this->assertTrue($this->_dispatcher->isValidModule('admin')); - $this->assertFalse($this->_dispatcher->isValidModule('bogus')); - $this->assertFalse($this->_dispatcher->isValidModule(null)); - $this->assertFalse($this->_dispatcher->isValidModule($this)); - $this->assertFalse($this->_dispatcher->isValidModule(array())); - } - - /** - * @see ZF-3034 - */ - public function testIsValidModuleShouldNormalizeModuleName() - { - $this->assertTrue($this->_dispatcher->isValidModule('Admin')); - } - - public function testSanelyDiscardOutputBufferOnException() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('ob'); - $request->setActionName('exception'); - - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - try { - $this->_dispatcher->dispatch($request, $response); - $this->fail('Exception should have been rethrown'); - } catch (Exception $e) { - } - $body = $this->_dispatcher->getResponse()->getBody(); - $this->assertNotContains("In exception action", $body, $body); - $this->assertNotContains("Foo", $body, $body); - } - - public function testGetDefaultControllerClassResetsRequestObject() - { - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('foobar') - ->setControllerName('bazbatbegone') - ->setActionName('bebop'); - $this->_dispatcher->getDefaultControllerClass($request); - $this->assertEquals($this->_dispatcher->getDefaultModule(), $request->getModuleName()); - $this->assertEquals($this->_dispatcher->getDefaultControllerName(), $request->getControllerName()); - $this->assertNull($request->getActionName()); - } - - public function testLoadClassLoadsControllerInDefaultModuleWithoutModulePrefix() - { - $request = new Zend_Controller_Request_Simple(); - $request->setControllerName('empty'); - $class = $this->_dispatcher->getControllerClass($request); - $this->assertEquals('EmptyController', $class); - $test = $this->_dispatcher->loadClass($class); - $this->assertEquals($class, $test); - $this->assertTrue(class_exists($class)); - } - - public function testLoadClassLoadsControllerInSpecifiedModuleWithModulePrefix() - { - Zend_Controller_Front::getInstance() - ->setDispatcher($this->_dispatcher) - ->addModuleDirectory(dirname(__FILE__) . '/../_files/modules'); - $request = new Zend_Controller_Request_Simple(); - $request->setControllerName('index') - ->setModuleName('bar'); - $class = $this->_dispatcher->getControllerClass($request); - $this->assertEquals('IndexController', $class); - $test = $this->_dispatcher->loadClass($class); - $this->assertEquals('Bar_IndexController', $test); - $this->assertTrue(class_exists($test)); - } - - public function testLoadClassLoadsControllerInDefaultModuleWithModulePrefixWhenRequested() - { - Zend_Controller_Front::getInstance() - ->setDispatcher($this->_dispatcher) - ->addModuleDirectory(dirname(__FILE__) . '/../_files/modules'); - $this->_dispatcher->setDefaultModule('foo') - ->setParam('prefixDefaultModule', true); - $request = new Zend_Controller_Request_Simple(); - $request->setControllerName('index'); - $class = $this->_dispatcher->getControllerClass($request); - $this->assertEquals('IndexController', $class); - $test = $this->_dispatcher->loadClass($class); - $this->assertEquals('Foo_IndexController', $test); - $this->assertTrue(class_exists($test)); - } - - /** - * ZF-2435 - */ - public function testCanRemoveControllerDirectory() - { - Zend_Controller_Front::getInstance() - ->setDispatcher($this->_dispatcher) - ->addModuleDirectory(dirname(__FILE__) . '/../_files/modules'); - $dirs = $this->_dispatcher->getControllerDirectory(); - $this->_dispatcher->removeControllerDirectory('foo'); - $test = $this->_dispatcher->getControllerDirectory(); - $this->assertNotEquals($dirs, $test); - $this->assertFalse(array_key_exists('foo', $test)); - } - - /** - * ZF-2693 - */ - public function testCamelCasedActionsNotRequestedWithWordSeparatorsShouldNotResolve() - { - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - $request->setControllerName('foo-bar'); - $request->setActionName('bazBat'); - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - try { - $this->_dispatcher->dispatch($request, $response); - $this->fail('Invalid camelCased action should raise exception'); - } catch (Zend_Controller_Exception $e) { - $this->assertContains('does not exist', $e->getMessage()); - } - } - - /** - * ZF-2693 - */ - public function testCamelCasedActionsNotRequestedWithWordSeparatorsShouldResolveIfForced() - { - $this->_dispatcher->setParam('useCaseSensitiveActions', true); - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - $request->setControllerName('foo-bar'); - $request->setActionName('bazBat'); - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - $oldLevel = error_reporting(0); - try { - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - error_reporting($oldLevel); - $this->assertContains("Admin_FooBar::bazBat action called", $body, $body); - } catch (Zend_Controller_Exception $e) { - error_reporting($oldLevel); - $this->fail('camelCased actions should succeed when forced'); - } - } - - public function handleErrors($errno, $errstr) - { - $this->error = $errstr; - } - - /** - * @see ZF-2693 - */ - public function testForcingCamelCasedActionsNotRequestedWithWordSeparatorsShouldRaiseNotices() - { - $this->_dispatcher->setParam('useCaseSensitiveActions', true); - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('admin'); - $request->setControllerName('foo-bar'); - $request->setActionName('bazBat'); - $this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1)); - - $response = new Zend_Controller_Response_Cli(); - set_error_handler(array($this, 'handleErrors')); - try { - $this->_dispatcher->dispatch($request, $response); - $body = $this->_dispatcher->getResponse()->getBody(); - restore_error_handler(); - $this->assertTrue(isset($this->error)); - $this->assertContains('deprecated', $this->error); - } catch (Zend_Controller_Exception $e) { - restore_error_handler(); - $this->fail('camelCased actions should succeed when forced'); - } - } - - /** - * @see ZF-2887 - */ - public function testGetControllerClassThrowsExceptionIfNoDefaultModuleDefined() - { - $this->_dispatcher->setControllerDirectory(array()); - - $request = new Zend_Controller_Request_Simple(); - $request->setControllerName('empty'); - try { - $class = $this->_dispatcher->getControllerClass($request); - } catch (Zend_Controller_Exception $e) { - $this->assertContains('No default module', $e->getMessage()); - } - } -} - -// Call Zend_Controller_Dispatcher_StandardTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Dispatcher_StandardTest::main") { - Zend_Controller_Dispatcher_StandardTest::main(); -} diff --git a/tests/Zend/Controller/FrontTest.php b/tests/Zend/Controller/FrontTest.php deleted file mode 100644 index 77fcfed30d81f1c2fa817ad7f586a6b7945f6ff7..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/FrontTest.php +++ /dev/null @@ -1,684 +0,0 @@ -<?php -// Call Zend_Controller_FrontTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_FrontTest::main"); - - $basePath = realpath(dirname(__FILE__) . str_repeat(DIRECTORY_SEPARATOR . '..', 3)); - - set_include_path( - $basePath . DIRECTORY_SEPARATOR . 'tests' - . PATH_SEPARATOR . $basePath . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . get_include_path() - ); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Cli.php'; -require_once 'Zend/Controller/Dispatcher/Standard.php'; -require_once 'Zend/Controller/Router/Rewrite.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Action/Helper/Url.php'; -require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; - -class Zend_Controller_FrontTest extends PHPUnit_Framework_TestCase -{ - protected $_controller = null; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_FrontTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->_controller = Zend_Controller_Front::getInstance(); - $this->_controller->resetInstance(); - $this->_controller->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files') - ->setParam('noErrorHandler', true) - ->setParam('noViewRenderer', true) - ->returnResponse(true) - ->throwExceptions(false); - Zend_Controller_Action_HelperBroker::resetHelpers(); - } - - public function tearDown() - { - unset($this->_controller); - } - - public function testResetInstance() - { - $this->_controller->setParam('foo', 'bar'); - $this->assertEquals('bar', $this->_controller->getParam('foo')); - - $this->_controller->resetInstance(); - $this->assertNull($this->_controller->getParam('bar')); - $this->assertSame(array(), $this->_controller->getParams()); - $this->assertSame(array(), $this->_controller->getControllerDirectory()); - } - - /** - * @see ZF-3145 - */ - public function testResetInstanceShouldResetHelperBroker() - { - Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer()); - Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Url()); - $helpers = Zend_Controller_Action_HelperBroker::getExistingHelpers(); - $this->assertTrue(is_array($helpers)); - $this->assertFalse(empty($helpers)); - - $this->_controller->resetInstance(); - $helpers = Zend_Controller_Action_HelperBroker::getExistingHelpers(); - $this->assertTrue(is_array($helpers)); - $this->assertTrue(empty($helpers)); - } - - public function testSetGetRequest() - { - $request = new Zend_Controller_Request_Http(); - $this->_controller->setRequest($request); - $this->assertTrue($request === $this->_controller->getRequest()); - - $this->_controller->resetInstance(); - $this->_controller->setRequest('Zend_Controller_Request_Http'); - $request = $this->_controller->getRequest(); - $this->assertTrue($request instanceof Zend_Controller_Request_Http); - } - - public function testSetRequestThrowsExceptionWithBadRequest() - { - try { - $this->_controller->setRequest('Zend_Controller_Response_Cli'); - $this->fail('Should not be able to set invalid request class'); - } catch (Exception $e) { - // success - } - } - - public function testSetGetResponse() - { - $response = new Zend_Controller_Response_Cli(); - $this->_controller->setResponse($response); - $this->assertTrue($response === $this->_controller->getResponse()); - - $this->_controller->resetInstance(); - $this->_controller->setResponse('Zend_Controller_Response_Cli'); - $response = $this->_controller->getResponse(); - $this->assertTrue($response instanceof Zend_Controller_Response_Cli); - } - - public function testSetResponseThrowsExceptionWithBadResponse() - { - try { - $this->_controller->setResponse('Zend_Controller_Request_Http'); - $this->fail('Should not be able to set invalid response class'); - } catch (Exception $e) { - // success - } - } - - public function testSetGetRouter() - { - $router = new Zend_Controller_Router_Rewrite(); - $this->_controller->setRouter($router); - $this->assertTrue($router === $this->_controller->getRouter()); - - $this->_controller->resetInstance(); - $this->_controller->setRouter('Zend_Controller_Router_Rewrite'); - $router = $this->_controller->getRouter(); - $this->assertTrue($router instanceof Zend_Controller_Router_Rewrite); - } - - public function testSetRouterThrowsExceptionWithBadRouter() - { - try { - $this->_controller->setRouter('Zend_Controller_Request_Http'); - $this->fail('Should not be able to set invalid router class'); - } catch (Exception $e) { - // success - } - } - - public function testSetGetDispatcher() - { - $dispatcher = new Zend_Controller_Dispatcher_Standard(); - $this->_controller->setDispatcher($dispatcher); - - $this->assertTrue($dispatcher === $this->_controller->getDispatcher()); - } - - public function testSetGetControllerDirectory() - { - $test = $this->_controller->getControllerDirectory(); - $expected = array('default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - $this->assertSame($expected, $test); - } - - public function testGetSetParam() - { - $this->_controller->setParam('foo', 'bar'); - $this->assertEquals('bar', $this->_controller->getParam('foo')); - - $this->_controller->setParam('bar', 'baz'); - $this->assertEquals('baz', $this->_controller->getParam('bar')); - } - - public function testGetSetParams() - { - $this->_controller->setParams(array('foo' => 'bar')); - $params = $this->_controller->getParams(); - $this->assertTrue(isset($params['foo'])); - $this->assertEquals('bar', $params['foo']); - - $this->_controller->setParam('baz', 'bat'); - $params = $this->_controller->getParams(); - $this->assertTrue(isset($params['foo'])); - $this->assertEquals('bar', $params['foo']); - $this->assertTrue(isset($params['baz'])); - $this->assertEquals('bat', $params['baz']); - - $this->_controller->setParams(array('foo' => 'bug')); - $params = $this->_controller->getParams(); - $this->assertTrue(isset($params['foo'])); - $this->assertEquals('bug', $params['foo']); - $this->assertTrue(isset($params['baz'])); - $this->assertEquals('bat', $params['baz']); - } - - public function testClearParams() - { - $this->_controller->setParams(array('foo' => 'bar', 'baz' => 'bat')); - $params = $this->_controller->getParams(); - $this->assertTrue(isset($params['foo'])); - $this->assertTrue(isset($params['baz'])); - - $this->_controller->clearParams('foo'); - $params = $this->_controller->getParams(); - $this->assertFalse(isset($params['foo'])); - $this->assertTrue(isset($params['baz'])); - - $this->_controller->clearParams(); - $this->assertSame(array(), $this->_controller->getParams()); - - $this->_controller->setParams(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat')); - $this->assertSame(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat'), $this->_controller->getParams()); - $this->_controller->clearParams(array('foo', 'baz')); - $this->assertSame(array('bar' => 'baz'), $this->_controller->getParams()); - } - - public function testSetGetDefaultControllerName() - { - $this->assertEquals('index', $this->_controller->getDefaultControllerName()); - - $this->_controller->setDefaultControllerName('foo'); - $this->assertEquals('foo', $this->_controller->getDefaultControllerName()); - } - - public function testSetGetDefaultAction() - { - $this->assertEquals('index', $this->_controller->getDefaultAction()); - - $this->_controller->setDefaultAction('bar'); - $this->assertEquals('bar', $this->_controller->getDefaultAction()); - } - - /** - * Test default action on valid controller - */ - public function testDispatch() - { - $request = new Zend_Controller_Request_Http('http://example.com/index'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $this->assertContains('Index action called', $response->getBody()); - } - - /** - * Test valid action on valid controller - */ - public function testDispatch1() - { - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $this->assertContains('Index action called', $response->getBody()); - } - - /** - * Test invalid action on valid controller - */ - /* - public function testDispatch2() - { - $request = new Zend_Controller_Request_Http('http://example.com/index/foo'); - - try { - $this->_controller->dispatch($request); - $this->fail('Exception should be raised by __call'); - } catch (Exception $e) { - // success - } - } - */ - - /** - * Test invalid controller - */ - /* - public function testDispatch3() - { - $request = new Zend_Controller_Request_Http('http://example.com/baz'); - - try { - $this->_controller->dispatch($request); - $this->fail('Exception should be raised; no such controller'); - } catch (Exception $e) { - // success - } - } - */ - - /** - * Test valid action on valid controller; test pre/postDispatch - */ - public function testDispatch4() - { - $request = new Zend_Controller_Request_Http('http://example.com/foo/bar'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $body = $response->getBody(); - $this->assertContains('Bar action called', $body, $body); - $this->assertContains('preDispatch called', $body, $body); - $this->assertContains('postDispatch called', $body, $body); - } - - /** - * Test that extra arguments get passed - */ - public function testDispatch5() - { - $request = new Zend_Controller_Request_Http('http://example.com/index/args'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $this->_controller->setParam('foo', 'bar'); - $this->_controller->setParam('baz', 'bat'); - $response = $this->_controller->dispatch($request); - - $body = $response->getBody(); - $this->assertContains('foo: bar', $body, $body); - $this->assertContains('baz: bat', $body); - } - - /** - * Test using router - */ - public function testDispatch6() - { - $request = new Zend_Controller_Request_Http('http://framework.zend.com/foo/bar/var1/baz'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $this->_controller->setRouter(new Zend_Controller_Router_Rewrite()); - $response = $this->_controller->dispatch($request); - - $body = $response->getBody(); - $this->assertContains('Bar action called', $body); - $params = $request->getParams(); - $this->assertTrue(isset($params['var1'])); - $this->assertEquals('baz', $params['var1']); - } - - /** - * Test without router, using GET params - */ - public function testDispatch7() - { - if ('cli' == strtolower(php_sapi_name())) { - $this->markTestSkipped('Issues with $_GET in CLI interface prevents test from passing'); - } - $request = new Zend_Controller_Request_Http('http://framework.zend.com/index.php?controller=foo&action=bar'); - - $response = new Zend_Controller_Response_Cli(); - $response = $this->_controller->dispatch($request, $response); - - $body = $response->getBody(); - $this->assertContains('Bar action called', $body); - } - - /** - * Test that run() throws exception when called from object instance - */ - public function _testRunThrowsException() - { - try { - $this->_controller->run(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - $this->fail('Should not be able to call run() from object instance'); - } catch (Exception $e) { - // success - } - } - - /** - * Test that set/getBaseUrl() functionality works - */ - public function testSetGetBaseUrl() - { - $this->assertNull($this->_controller->getBaseUrl()); - $this->_controller->setBaseUrl('/index.php'); - $this->assertEquals('/index.php', $this->_controller->getBaseUrl()); - } - - public function testSetGetBaseUrlPopulatesRequest() - { - $request = new Zend_Controller_Request_Http(); - $this->_controller->setRequest($request); - $this->_controller->setBaseUrl('/index.php'); - $this->assertEquals('/index.php', $request->getBaseUrl()); - - $this->assertEquals($request->getBaseUrl(), $this->_controller->getBaseUrl()); - } - - public function testSetBaseUrlThrowsExceptionOnNonString() - { - try { - $this->_controller->setBaseUrl(array()); - $this->fail('Should not be able to set non-string base URL'); - } catch (Exception $e) { - // success - } - } - - /** - * Test that a set base URL is pushed to the request during the dispatch - * process - */ - public function testBaseUrlPushedToRequest() - { - $this->_controller->setBaseUrl('/index.php'); - $request = new Zend_Controller_Request_Http('http://example.com/index'); - $response = new Zend_Controller_Response_Cli(); - $response = $this->_controller->dispatch($request, $response); - - $this->assertContains('index.php', $request->getBaseUrl()); - } - - /** - * Test that throwExceptions() sets and returns value properly - */ - public function testThrowExceptions() - { - $this->_controller->throwExceptions(true); - $this->assertTrue($this->_controller->throwExceptions()); - $this->_controller->throwExceptions(false); - $this->assertFalse($this->_controller->throwExceptions()); - } - - public function testThrowExceptionsFluentInterface() - { - $result = $this->_controller->throwExceptions(true); - $this->assertSame($this->_controller, $result); - } - - /** - * Test that with throwExceptions() set, an exception is thrown - */ - public function testThrowExceptionsThrows() - { - $this->_controller->throwExceptions(true); - $this->_controller->setControllerDirectory(dirname(__FILE__)); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/bogus/baz'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $this->_controller->setRouter(new Zend_Controller_Router_Rewrite()); - - try { - $response = $this->_controller->dispatch($request); - $this->fail('Invalid controller should throw exception'); - } catch (Exception $e) { - // success - } - } - - /** - * Test that returnResponse() sets and returns value properly - */ - public function testReturnResponse() - { - $this->_controller->returnResponse(true); - $this->assertTrue($this->_controller->returnResponse()); - $this->_controller->returnResponse(false); - $this->assertFalse($this->_controller->returnResponse()); - } - - public function testReturnResponseFluentInterface() - { - $result = $this->_controller->returnResponse(true); - $this->assertSame($this->_controller, $result); - } - - /** - * Test that with returnResponse set to false, output is echoed and equals that in the response - */ - public function testReturnResponseReturnsResponse() - { - $request = new Zend_Controller_Request_Http('http://framework.zend.com/foo/bar/var1/baz'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $this->_controller->setRouter(new Zend_Controller_Router_Rewrite()); - $this->_controller->returnResponse(false); - - ob_start(); - $this->_controller->dispatch($request); - $body = ob_get_clean(); - - $actual = $this->_controller->getResponse()->getBody(); - $this->assertContains($actual, $body); - } - - public function testRunStatically() - { - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setRequest($request); - Zend_Controller_Front::run(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - } - - public function testRunDynamically() - { - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setRequest($request); - $this->_controller->run(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'); - } - - public function testModulePathDispatched() - { - $this->_controller->addControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '/Admin', 'admin'); - $request = new Zend_Controller_Request_Http('http://example.com/admin/foo/bar'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $body = $response->getBody(); - $this->assertContains('Admin_Foo::bar action called', $body, $body); - } - - public function testModuleControllerDirectoryName() - { - $this->assertEquals('controllers', $this->_controller->getModuleControllerDirectoryName()); - $this->_controller->setModuleControllerDirectoryName('foobar'); - $this->assertEquals('foobar', $this->_controller->getModuleControllerDirectoryName()); - } - - public function testAddModuleDirectory() - { - $moduleDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules'; - $this->_controller->addModuleDirectory($moduleDir); - $controllerDirs = $this->_controller->getControllerDirectory(); - $this->assertTrue(isset($controllerDirs['foo'])); - $this->assertTrue(isset($controllerDirs['bar'])); - $this->assertTrue(isset($controllerDirs['default'])); - $this->assertFalse(isset($controllerDirs['.svn'])); - - $this->assertContains('modules' . DIRECTORY_SEPARATOR . 'foo', $controllerDirs['foo']); - $this->assertContains('modules' . DIRECTORY_SEPARATOR . 'bar', $controllerDirs['bar']); - $this->assertContains('modules' . DIRECTORY_SEPARATOR . 'default', $controllerDirs['default']); - } - - /**#@+ - * @see ZF-2910 - */ - public function testShouldAllowRetrievingCurrentModuleDirectory() - { - $this->testAddModuleDirectory(); - $request = new Zend_Controller_Request_Http(); - $request->setModuleName('bar'); - $this->_controller->setRequest($request); - $dir = $this->_controller->getModuleDirectory(); - $this->assertContains('modules' . DIRECTORY_SEPARATOR . 'bar', $dir); - $this->assertNotContains('controllers', $dir); - } - - public function testShouldAllowRetrievingSpecifiedModuleDirectory() - { - $this->testAddModuleDirectory(); - $dir = $this->_controller->getModuleDirectory('foo'); - $this->assertContains('modules' . DIRECTORY_SEPARATOR . 'foo', $dir); - $this->assertNotContains('controllers', $dir); - } - - public function testShouldReturnNullWhenRetrievingNonexistentModuleDirectory() - { - $this->testAddModuleDirectory(); - $this->assertNull($this->_controller->getModuleDirectory('bogus-foo-bar')); - } - /**#@-*/ - - /** - * ZF-2435 - */ - public function testCanRemoveIndividualModuleDirectory() - { - $moduleDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules'; - $this->_controller->addModuleDirectory($moduleDir); - $controllerDirs = $this->_controller->getControllerDirectory(); - $this->_controller->removeControllerDirectory('foo'); - $test = $this->_controller->getControllerDirectory(); - $this->assertNotEquals($controllerDirs, $test); - $this->assertFalse(array_key_exists('foo', $test)); - } - - public function testAddModuleDirectoryThrowsExceptionForInvalidDirectory() - { - $moduleDir = 'doesntexist'; - try { - $this->_controller->addModuleDirectory($moduleDir); - $this->fail('Exception expected but not thrown'); - }catch(Exception $e){ - $this->assertType('Zend_Exception',$e); - $this->assertRegExp('/Directory \w+ not readable/',$e->getMessage()); - } - } - - public function testGetControllerDirectoryByModuleName() - { - $moduleDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules'; - $this->_controller->addModuleDirectory($moduleDir); - $barDir = $this->_controller->getControllerDirectory('bar'); - $this->assertNotNull($barDir); - $this->assertContains('modules' . DIRECTORY_SEPARATOR . 'bar', $barDir); - } - - public function testGetControllerDirectoryByModuleNameReturnsNullOnBadModule() - { - $moduleDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules'; - $this->_controller->addModuleDirectory($moduleDir); - $dir = $this->_controller->getControllerDirectory('_bazbat'); - $this->assertNull($dir); - } - - public function testDefaultModule() - { - $dispatcher = $this->_controller->getDispatcher(); - $this->assertEquals($dispatcher->getDefaultModule(), $this->_controller->getDefaultModule()); - $this->_controller->setDefaultModule('foobar'); - $this->assertEquals('foobar', $this->_controller->getDefaultModule()); - $this->assertEquals($dispatcher->getDefaultModule(), $this->_controller->getDefaultModule()); - } - - public function testErrorHandlerPluginRegisteredWhenDispatched() - { - $this->assertFalse($this->_controller->hasPlugin('Zend_Controller_Plugin_ErrorHandler')); - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setParam('noErrorHandler', false) - ->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $this->assertTrue($this->_controller->hasPlugin('Zend_Controller_Plugin_ErrorHandler')); - } - - public function testErrorHandlerPluginNotRegisteredIfNoErrorHandlerSet() - { - $this->assertFalse($this->_controller->hasPlugin('Zend_Controller_Plugin_ErrorHandler')); - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setParam('noErrorHandler', true) - ->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $this->assertFalse($this->_controller->hasPlugin('Zend_Controller_Plugin_ErrorHandler')); - } - - public function testReplaceRequestAndResponseMidStream() - { - $request = new Zend_Controller_Request_Http('http://example.com/index/replace'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = new Zend_Controller_Response_Http(); - $responsePost = $this->_controller->dispatch($request, $response); - - $requestPost = $this->_controller->getRequest(); - - $this->assertNotSame($request, $requestPost); - $this->assertNotSame($response, $responsePost); - - $this->assertContains('Reset action called', $responsePost->getBody()); - $this->assertNotContains('Reset action called', $response->getBody()); - } - - public function testViewRendererHelperRegisteredWhenDispatched() - { - $this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')); - $this->_controller->setParam('noViewRenderer', false); - - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')); - } - - public function testViewRendererHelperNotRegisteredIfNoViewRendererSet() - { - $this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')); - $this->_controller->setParam('noViewRenderer', true); - - $request = new Zend_Controller_Request_Http('http://example.com/index/index'); - $this->_controller->setResponse(new Zend_Controller_Response_Cli()); - $response = $this->_controller->dispatch($request); - - $this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')); - } -} - -// Call Zend_Controller_FrontTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_FrontTest::main") { - Zend_Controller_FrontTest::main(); -} diff --git a/tests/Zend/Controller/Plugin/ActionStackTest.php b/tests/Zend/Controller/Plugin/ActionStackTest.php deleted file mode 100644 index e08327ea806fbbecea210188d82aac916cb59f13..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Plugin/ActionStackTest.php +++ /dev/null @@ -1,352 +0,0 @@ -<?php -// Call Zend_Controller_Plugin_ActionStackTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Plugin_ActionStackTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Plugin/ActionStack.php'; -require_once 'Zend/Controller/Request/Simple.php'; -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_Controller_Plugin_ActionStack. - */ -class Zend_Controller_Plugin_ActionStackTest extends PHPUnit_Framework_TestCase -{ - public $key = 'Zend_Controller_Plugin_ActionStack'; - public $registry; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Plugin_ActionStackTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->removeRegistryEntry(); - $this->registry = Zend_Registry::getInstance(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - $this->removeRegistryEntry(); - } - - /** - * Ensure registry is clean - * - * @return void - */ - public function removeRegistryEntry() - { - $registry = Zend_Registry::getInstance(); - if (isset($registry[$this->key])) { - unset($registry[$this->key]); - } - } - - public function testConstructorCreatesRegistryEntry() - { - $registry = Zend_Registry::getInstance(); - $this->assertFalse(isset($registry[$this->key])); - - $plugin = new Zend_Controller_Plugin_ActionStack(); - $key = $plugin->getRegistryKey(); - $this->assertTrue(isset($registry[$key])); - } - - public function testKeyPassedToConstructorUsedAsRegistryKey() - { - $this->key = $key = 'foobar'; - $registry = Zend_Registry::getInstance(); - $this->assertFalse(isset($registry[$key])); - - $plugin = new Zend_Controller_Plugin_ActionStack(null, $key); - $this->assertTrue(isset($registry[$key])); - } - - public function testRegistryPassedToConstructorUsedByPlugin() - { - $registry = new Zend_Controller_Plugin_ActionStack_Registry(); - $plugin = new Zend_Controller_Plugin_ActionStack($registry); - $registered = $plugin->getRegistry(); - $this->assertNotSame($this->registry, $registered); - $this->assertSame($registry, $registered); - } - - /** - * @return void - */ - public function testRegistryAccessorsWork() - { - $registry = new Zend_Controller_Plugin_ActionStack_Registry(); - $plugin = new Zend_Controller_Plugin_ActionStack(); - $original = $plugin->getRegistry(); - - $plugin->setRegistry($registry); - $registered = $plugin->getRegistry(); - - $this->assertSame($registry, $registered); - $this->assertNotSame($original, $registered); - } - - public function testRegistryKeyHasDefaultValue() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $key = $plugin->getRegistryKey(); - $this->assertNotNull($key); - $this->assertEquals($this->key, $key); - } - - /** - * @return void - */ - public function testRegistryKeyAccessorsWork() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $plugin->setRegistryKey('foobar'); - $key = $plugin->getRegistryKey(); - $this->assertEquals('foobar', $key); - } - - /** - * @return void - */ - public function testGetStackInitiallyReturnsEmptyArray() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $stack = $plugin->getStack(); - $this->assertTrue(is_array($stack)); - $this->assertTrue(empty($stack)); - } - - /** - * @return void - */ - public function testPushStackAppendsToStack() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - - $request1 = new Zend_Controller_Request_Simple(); - $plugin->pushStack($request1); - $received = $plugin->getStack(); - $this->assertTrue(is_array($received)); - $this->assertEquals(1, count($received)); - $this->assertSame($request1, $received[0]); - - $request2 = new Zend_Controller_Request_Simple(); - $plugin->pushStack($request2); - $received = $plugin->getStack(); - $this->assertTrue(is_array($received)); - $this->assertEquals(2, count($received)); - $this->assertSame($request2, $received[1]); - $this->assertSame($request1, $received[0]); - } - - public function getNewRequest() - { - $request = new Zend_Controller_Request_Simple(); - $request->setActionName('baz') - ->setControllerName('bar') - ->setModuleName('foo'); - return $request; - } - - /** - * @return void - */ - public function testPopStackPullsFromEndOfStack() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request1 = $this->getNewRequest(); - $request2 = $this->getNewRequest(); - $request3 = $this->getNewRequest(); - $plugin->pushStack($request1) - ->pushStack($request2) - ->pushStack($request3); - $stack = $plugin->getStack(); - $this->assertEquals(3, count($stack)); - - $received = $plugin->popStack(); - $stack = $plugin->getStack(); - $this->assertSame($request3, $received); - $this->assertEquals(2, count($stack)); - } - - public function testPopEmptyStackReturnsFalse() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $received = $plugin->popStack(); - $this->assertFalse($received); - } - - public function testPopStackPopsMultipleItemsWhenRequestActionEmpty() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request1 = $this->getNewRequest(); - $request2 = new Zend_Controller_Request_Simple(); - $plugin->pushStack($request1) - ->pushStack($request2); - $stack = $plugin->getStack(); - $this->assertEquals(2, count($stack)); - - $received = $plugin->popStack(); - $stack = $plugin->getStack(); - $this->assertSame($request1, $received); - $this->assertEquals(0, count($stack)); - } - - public function testPopStackPopulatesControllerAndModuleFromRequestIfEmpty() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request = $this->getNewRequest(); - $plugin->setRequest($request); - - $request1 = new Zend_Controller_Request_Simple(); - $request1->setActionName('blah'); - $plugin->pushStack($request1); - - $next = $plugin->popStack(); - $this->assertTrue($next instanceof Zend_Controller_Request_Simple); - $this->assertEquals($request1->getActionName(), $next->getActionName()); - $this->assertEquals($request->getControllerName(), $next->getControllerName()); - $this->assertEquals($request->getModuleName(), $next->getModuleName()); - } - - public function testForwardResetsInternalRequestStateFromGivenRequest() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request = new Zend_Controller_Request_Simple(); - $plugin->setRequest($request); - - $next = $this->getNewRequest(); - $plugin->forward($next); - - $this->assertEquals($next->getActionName(), $request->getActionName()); - $this->assertEquals($next->getControllerName(), $request->getControllerName()); - $this->assertEquals($next->getModuleName(), $request->getModuleName()); - $this->assertFalse($request->isDispatched()); - } - - /** - * @return void - */ - public function testPostDispatchResetsInternalRequestFromLastRequestOnStack() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request = new Zend_Controller_Request_Simple(); - $request->setDispatched(true); - $plugin->setRequest($request); - - $request1 = $this->getNewRequest(); - $request2 = $this->getNewRequest(); - $request3 = $this->getNewRequest(); - $request3->setActionName('foobar') - ->setControllerName('bazbat') - ->setModuleName('bogus'); - $plugin->pushStack($request1) - ->pushStack($request2) - ->pushStack($request3); - - $plugin->postDispatch($request); - - $this->assertEquals($request3->getActionName(), $request->getActionName()); - $this->assertEquals($request3->getControllerName(), $request->getControllerName()); - $this->assertEquals($request3->getModuleName(), $request->getModuleName()); - $this->assertFalse($request->isDispatched()); - } - - public function testPostDispatchDoesNothingWithEmptyStack() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - - $request = $this->getNewRequest(); - $request->setDispatched(true); - - $clone = clone $request; - - $plugin->postDispatch($request); - - $this->assertEquals($clone->getActionName(), $request->getActionName()); - $this->assertEquals($clone->getControllerName(), $request->getControllerName()); - $this->assertEquals($clone->getModuleName(), $request->getModuleName()); - $this->assertTrue($request->isDispatched()); - } - - public function testPostDispatchDoesNothingWithStackThatEvaluatesToEmpty() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request = new Zend_Controller_Request_Simple(); - $request->setDispatched(true); - $plugin->setRequest($request); - - $request1 = new Zend_Controller_Request_Simple(); - $request2 = new Zend_Controller_Request_Simple(); - $request3 = new Zend_Controller_Request_Simple(); - $plugin->pushStack($request1) - ->pushStack($request2) - ->pushStack($request3); - - $clone = clone $request; - $plugin->postDispatch($request); - - $this->assertEquals($clone->getActionName(), $request->getActionName()); - $this->assertEquals($clone->getControllerName(), $request->getControllerName()); - $this->assertEquals($clone->getModuleName(), $request->getModuleName()); - $this->assertTrue($request->isDispatched()); - } - - public function testPostDispatchDoesNothingWithExistingForwardRequest() - { - $plugin = new Zend_Controller_Plugin_ActionStack(); - $request = new Zend_Controller_Request_Simple(); - $request->setDispatched(false); - $plugin->setRequest($request); - - $request1 = new Zend_Controller_Request_Simple(); - $request2 = new Zend_Controller_Request_Simple(); - $request3 = new Zend_Controller_Request_Simple(); - $plugin->pushStack($request1) - ->pushStack($request2) - ->pushStack($request3); - - $plugin->postDispatch($request); - $stack = $plugin->getStack(); - $this->assertEquals(3, count($stack)); - } -} - -class Zend_Controller_Plugin_ActionStack_Registry extends Zend_Registry -{ - protected static $_registryClassName = 'Zend_Controller_Plugin_ActionStack_Registry'; -} - -// Call Zend_Controller_Plugin_ActionStackTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Plugin_ActionStackTest::main") { - Zend_Controller_Plugin_ActionStackTest::main(); -} diff --git a/tests/Zend/Controller/Plugin/BrokerTest.php b/tests/Zend/Controller/Plugin/BrokerTest.php deleted file mode 100644 index d501c95ce77051e1ebd597746ed4a6dc5d0fc5c0..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Plugin/BrokerTest.php +++ /dev/null @@ -1,319 +0,0 @@ -<?php -// Call Zend_Controller_Plugin_BrokerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Plugin_BrokerTest::main"); - - $basePath = realpath(dirname(__FILE__) . str_repeat(DIRECTORY_SEPARATOR . '..', 3)); - - set_include_path( - $basePath . DIRECTORY_SEPARATOR . 'tests' - . PATH_SEPARATOR . $basePath . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . get_include_path() - ); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Request/Simple.php'; -require_once 'Zend/Controller/Response/Cli.php'; - -class Zend_Controller_Plugin_BrokerTest extends PHPUnit_Framework_TestCase -{ - public $controller; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Plugin_BrokerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->controller = Zend_Controller_Front::getInstance(); - $this->controller->resetInstance(); - $this->controller->setParam('noViewRenderer', true) - ->setParam('noErrorHandler', true); - } - - public function testDuplicatePlugin() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - try { - $broker->registerPlugin($plugin); - $this->fail('Duplicate registry of plugin object should be disallowed'); - } catch (Exception $expected) { - $this->assertContains('already', $expected->getMessage()); - } - } - - - public function testUsingFrontController() - { - $this->controller->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files'); - $request = new Zend_Controller_Request_Http('http://framework.zend.com/empty'); - $this->controller->setResponse(new Zend_Controller_Response_Cli()); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $this->controller->registerPlugin($plugin); - $this->controller->returnResponse(true); - $response = $this->controller->dispatch($request); - $this->assertEquals('123456', $response->getBody()); - $this->assertEquals('123456', $plugin->getResponse()->getBody()); - } - - public function testUnregisterPluginWithObject() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - $plugins = $broker->getPlugins(); - $this->assertEquals(1, count($plugins)); - $broker->unregisterPlugin($plugin); - $plugins = $broker->getPlugins(); - $this->assertEquals(0, count($plugins)); - } - - public function testUnregisterPluginByClassName() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - $plugins = $broker->getPlugins(); - $this->assertEquals(1, count($plugins)); - $broker->unregisterPlugin('Zend_Controller_Plugin_BrokerTest_TestPlugin'); - $plugins = $broker->getPlugins(); - $this->assertEquals(0, count($plugins)); - } - - public function testGetPlugins() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - $plugins = $broker->getPlugins(); - $this->assertEquals(1, count($plugins)); - $this->assertSame($plugin, $plugins[0]); - } - - public function testGetPluginByName() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - $retrieved = $broker->getPlugin('Zend_Controller_Plugin_BrokerTest_TestPlugin'); - $this->assertTrue($retrieved instanceof Zend_Controller_Plugin_BrokerTest_TestPlugin); - $this->assertSame($plugin, $retrieved); - } - - public function testGetPluginByNameReturnsFalseWithBadClassName() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - $retrieved = $broker->getPlugin('TestPlugin'); - $this->assertFalse($retrieved); - } - - public function testGetPluginByNameReturnsArray() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - - $plugin2 = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin2); - - $retrieved = $broker->getPlugin('Zend_Controller_Plugin_BrokerTest_TestPlugin'); - $this->assertTrue(is_array($retrieved)); - $this->assertEquals(2, count($retrieved)); - $this->assertSame($plugin, $retrieved[0]); - $this->assertSame($plugin2, $retrieved[1]); - } - - public function testHasPlugin() - { - $broker = new Zend_Controller_Plugin_Broker(); - $this->assertFalse($broker->hasPlugin('Zend_Controller_Plugin_BrokerTest_TestPlugin')); - - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - $this->assertTrue($broker->hasPlugin('Zend_Controller_Plugin_BrokerTest_TestPlugin')); - } - - public function testBrokerCatchesExceptions() - { - $request = new Zend_Controller_Request_Http('http://framework.zend.com/empty'); - $response = new Zend_Controller_Response_Cli(); - $broker = new Zend_Controller_Plugin_Broker(); - $broker->setResponse($response); - $broker->registerPlugin(new Zend_Controller_Plugin_BrokerTest_ExceptionTestPlugin()); - try { - $broker->routeStartup($request); - $broker->routeShutdown($request); - $broker->dispatchLoopStartup($request); - $broker->preDispatch($request); - $broker->postDispatch($request); - $broker->dispatchLoopShutdown(); - } catch (Exception $e) { - $this->fail('Broker should catch exceptions'); - } - - $this->assertTrue($response->hasExceptionOfMessage('routeStartup triggered exception')); - $this->assertTrue($response->hasExceptionOfMessage('routeShutdown triggered exception')); - $this->assertTrue($response->hasExceptionOfMessage('dispatchLoopStartup triggered exception')); - $this->assertTrue($response->hasExceptionOfMessage('preDispatch triggered exception')); - $this->assertTrue($response->hasExceptionOfMessage('postDispatch triggered exception')); - $this->assertTrue($response->hasExceptionOfMessage('dispatchLoopShutdown triggered exception')); - } - - public function testRegisterPluginStackOrderIsSane() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin1 = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $plugin2 = new Zend_Controller_Plugin_BrokerTest_ExceptionTestPlugin(); - $plugin3 = new Zend_Controller_Plugin_BrokerTest_TestPlugin2(); - $broker->registerPlugin($plugin1, 5); - $broker->registerPlugin($plugin2, -5); - $broker->registerPlugin($plugin3, 2); - - $plugins = $broker->getPlugins(); - $expected = array(-5 => $plugin2, 2 => $plugin3, 5 => $plugin1); - $this->assertSame($expected, $plugins); - } - - public function testRegisterPluginThrowsExceptionOnDuplicateStackIndex() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin1 = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $plugin2 = new Zend_Controller_Plugin_BrokerTest_ExceptionTestPlugin(); - $broker->registerPlugin($plugin1, 5); - try { - $broker->registerPlugin($plugin2, 5); - $this->fail('Registering plugins with same stack index should raise exception'); - } catch (Exception $e) { - } - } - - public function testRegisterPluginStackOrderWithAutmaticNumbersIncrementsCorrectly() - { - $broker = new Zend_Controller_Plugin_Broker(); - $plugin1 = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $plugin2 = new Zend_Controller_Plugin_BrokerTest_ExceptionTestPlugin(); - $plugin3 = new Zend_Controller_Plugin_BrokerTest_TestPlugin2(); - $broker->registerPlugin($plugin1, 2); - $broker->registerPlugin($plugin2, 3); - $broker->registerPlugin($plugin3); - - $plugins = $broker->getPlugins(); - $expected = array(2 => $plugin1, 3 => $plugin2, 4 => $plugin3); - $this->assertSame($expected, $plugins); - } - - /** - * Test for ZF-2305 - * @return void - */ - public function testRegisterPluginSetsRequestAndResponse() - { - $broker = new Zend_Controller_Plugin_Broker(); - $request = new Zend_Controller_Request_Simple(); - $response = new Zend_Controller_Response_Cli(); - $broker->setRequest($request); - $broker->setResponse($response); - - $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); - $broker->registerPlugin($plugin); - - $this->assertSame($request, $plugin->getRequest()); - $this->assertSame($response, $plugin->getResponse()); - } -} - -class Zend_Controller_Plugin_BrokerTest_TestPlugin extends Zend_Controller_Plugin_Abstract -{ - public function routeStartup(Zend_Controller_Request_Abstract $request) - { - $this->getResponse()->appendBody('1'); - } - - public function routeShutdown(Zend_Controller_Request_Abstract $request) - { - $this->getResponse()->appendBody('2'); - } - - public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) - { - $this->getResponse()->appendBody('3'); - } - - public function preDispatch(Zend_Controller_Request_Abstract $request) - { - $this->getResponse()->appendBody('4'); - } - - public function postDispatch(Zend_Controller_Request_Abstract $request) - { - $this->getResponse()->appendBody('5'); - } - - public function dispatchLoopShutdown() - { - $this->getResponse()->appendBody('6'); - } -} - -class Zend_Controller_Plugin_BrokerTest_TestPlugin2 extends Zend_Controller_Plugin_BrokerTest_TestPlugin -{ -} - -class Zend_Controller_Plugin_BrokerTest_ExceptionTestPlugin extends Zend_Controller_Plugin_Abstract -{ - public function routeStartup(Zend_Controller_Request_Abstract $request) - { - throw new Exception('routeStartup triggered exception'); - } - - public function routeShutdown(Zend_Controller_Request_Abstract $request) - { - throw new Exception('routeShutdown triggered exception'); - } - - public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) - { - throw new Exception('dispatchLoopStartup triggered exception'); - } - - public function preDispatch(Zend_Controller_Request_Abstract $request) - { - throw new Exception('preDispatch triggered exception'); - } - - public function postDispatch(Zend_Controller_Request_Abstract $request) - { - throw new Exception('postDispatch triggered exception'); - } - - public function dispatchLoopShutdown() - { - throw new Exception('dispatchLoopShutdown triggered exception'); - } -} - - -// Call Zend_Controller_Plugin_BrokerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Plugin_BrokerTest::main") { - Zend_Controller_Plugin_BrokerTest::main(); -} diff --git a/tests/Zend/Controller/Plugin/ErrorHandlerTest.php b/tests/Zend/Controller/Plugin/ErrorHandlerTest.php deleted file mode 100644 index 6bcaa91fc9fddcad958cead8215aa830e9229670..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Plugin/ErrorHandlerTest.php +++ /dev/null @@ -1,257 +0,0 @@ -<?php -// Call Zend_Controller_Plugin_ErrorHandlerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) -{ - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Plugin_ErrorHandlerTest::main"); - $basePath = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); - set_include_path( - $basePath . DIRECTORY_SEPARATOR . 'tests' - . PATH_SEPARATOR . $basePath . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . get_include_path() - ); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Plugin/ErrorHandler.php'; -require_once 'Zend/Controller/Request/Http.php'; -require_once 'Zend/Controller/Response/Http.php'; - -require_once 'Zend/Controller/Dispatcher/Exception.php'; -require_once 'Zend/Controller/Action/Exception.php'; - -require_once 'Zend/Controller/Front.php'; - -/** - * Test class for Zend_Controller_Plugin_ErrorHandler. - * Generated by PHPUnit_Util_Skeleton on 2007-05-15 at 09:50:21. - */ -class Zend_Controller_Plugin_ErrorHandlerTest extends PHPUnit_Framework_TestCase -{ - /** - * Request object - * @var Zend_Controller_Request_Http - */ - public $request; - - /** - * Response object - * @var Zend_Controller_Response_Http - */ - public $response; - - /** - * Error handler plugin - * @var Zend_Controller_Plugin_ErrorHandler - */ - public $plugin; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Plugin_ErrorHandlerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - Zend_Controller_Front::getInstance()->resetInstance(); - $this->request = new Zend_Controller_Request_Http(); - $this->response = new Zend_Controller_Response_Http(); - $this->plugin = new Zend_Controller_Plugin_ErrorHandler(); - - $this->plugin->setRequest($this->request); - $this->plugin->setResponse($this->response); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - } - - public function testSetErrorHandler() - { - $this->plugin->setErrorHandler(array( - 'module' => 'myfoo', - 'controller' => 'bar', - 'action' => 'boobaz', - )); - - $this->assertEquals('myfoo', $this->plugin->getErrorHandlerModule()); - $this->assertEquals('bar', $this->plugin->getErrorHandlerController()); - $this->assertEquals('boobaz', $this->plugin->getErrorHandlerAction()); - } - - public function testSetErrorHandlerModule() - { - $this->plugin->setErrorHandlerModule('boobah'); - $this->assertEquals('boobah', $this->plugin->getErrorHandlerModule()); - } - - public function testSetErrorHandlerController() - { - $this->plugin->setErrorHandlerController('boobah'); - $this->assertEquals('boobah', $this->plugin->getErrorHandlerController()); - } - - public function testSetErrorHandlerAction() - { - $this->plugin->setErrorHandlerAction('boobah'); - $this->assertEquals('boobah', $this->plugin->getErrorHandlerAction()); - } - - public function testPostDispatchNoControllerException() - { - $this->response->setException(new Zend_Controller_Dispatcher_Exception('Testing controller exception')); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - $this->assertNotNull($this->request->getParam('error_handler')); - $errorHandler = $this->request->getParam('error_handler'); - $this->assertTrue($errorHandler instanceof ArrayObject); - $this->assertEquals(Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER, $errorHandler->type); - - $this->assertEquals('error', $this->request->getActionName()); - $this->assertEquals('error', $this->request->getControllerName()); - $this->assertEquals('default', $this->request->getModuleName()); - } - - public function testPostDispatchNoActionException() - { - $this->response->setException(new Zend_Controller_Action_Exception('Testing action exception', 404)); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - $this->assertNotNull($this->request->getParam('error_handler')); - $errorHandler = $this->request->getParam('error_handler'); - $this->assertTrue($errorHandler instanceof ArrayObject); - $this->assertEquals(Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION, $errorHandler->type); - - $this->assertEquals('error', $this->request->getActionName()); - $this->assertEquals('error', $this->request->getControllerName()); - $this->assertEquals('default', $this->request->getModuleName()); - } - - public function testPostDispatchOtherException() - { - $this->response->setException(new Exception('Testing other exception')); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - $this->assertNotNull($this->request->getParam('error_handler')); - $errorHandler = $this->request->getParam('error_handler'); - $this->assertTrue($errorHandler instanceof ArrayObject); - $this->assertEquals(Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER, $errorHandler->type); - - $this->assertEquals('error', $this->request->getActionName()); - $this->assertEquals('error', $this->request->getControllerName()); - $this->assertEquals('default', $this->request->getModuleName()); - } - - public function testPostDispatchThrowsWhenCalledRepeatedly() - { - $this->response->setException(new Exception('Testing other exception')); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - $this->response->setException(new Zend_Controller_Dispatcher_Exception('Another exception')); - try { - $this->plugin->postDispatch($this->request); - $this->fail('Repeated calls with new exceptions should throw exceptions'); - } catch (Exception $e) { - $type = get_class($e); - $this->assertEquals('Zend_Controller_Dispatcher_Exception', $type); - $this->assertEquals('Another exception', $e->getMessage()); - } - } - - public function testPostDispatchDoesNothingWhenCalledRepeatedlyWithoutNewExceptions() - { - $this->response->setException(new Exception('Testing other exception')); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - try { - $this->plugin->postDispatch($this->request); - } catch (Exception $e) { - $this->fail('Repeated calls with no new exceptions should not throw exceptions'); - } - } - - public function testPostDispatchWithoutException() - { - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - $this->assertEquals('baz', $this->request->getActionName()); - $this->assertEquals('bar', $this->request->getControllerName()); - $this->assertEquals('foo', $this->request->getModuleName()); - } - - public function testPostDispatchErrorRequestIsClone() - { - $this->response->setException(new Zend_Controller_Dispatcher_Exception('Testing controller exception')); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - $this->assertNotNull($this->request->getParam('error_handler')); - $errorHandler = $this->request->getParam('error_handler'); - $this->assertTrue($errorHandler instanceof ArrayObject); - $this->assertTrue($errorHandler->request instanceof Zend_Controller_Request_Http); - $this->assertNotSame($this->request, $errorHandler->request); - } - - public function testPostDispatchQuitsWithFalseUserErrorHandlerParam() - { - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - $front->setParam('noErrorHandler', true); - - $this->response->setException(new Zend_Controller_Dispatcher_Exception('Testing controller exception')); - $this->request->setModuleName('foo') - ->setControllerName('bar') - ->setActionName('baz'); - $this->plugin->postDispatch($this->request); - - $this->assertNull($this->request->getParam('error_handler')); - } -} - -// Call Zend_Controller_Plugin_ErrorHandlerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Plugin_ErrorHandlerTest::main") -{ - Zend_Controller_Plugin_ErrorHandlerTest::main(); -} - diff --git a/tests/Zend/Controller/Request/Apache404Test.php b/tests/Zend/Controller/Request/Apache404Test.php deleted file mode 100644 index c67865f13c292c9e4d5d00f96d0bf8717228eed6..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Request/Apache404Test.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php -// Call Zend_Controller_Request_Apache404Test::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Request_Apache404Test::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Request/Apache404.php'; - -/** - * Test class for Zend_Controller_Request_Apache404. - * Generated by PHPUnit_Util_Skeleton on 2007-06-25 at 08:20:40. - */ -class Zend_Controller_Request_Apache404Test extends PHPUnit_Framework_TestCase -{ - /** - * Copy of $_SERVER - * @var array - */ - protected $_server; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_Apache404Test"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->_server = $_SERVER; - } - - public function tearDown() - { - $_SERVER = $this->_server; - } - - public function testRedirectUrlSelectedOverRequestUri() - { - $_SERVER['REDIRECT_URL'] = '/foo/bar'; - $_SERVER['REQUEST_URI'] = '/baz/bat'; - - $request = new Zend_Controller_Request_Apache404(); - $requestUri = $request->getRequestUri(); - $this->assertEquals('/foo/bar', $requestUri); - } -} - -// Call Zend_Controller_Request_Apache404Test::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_Apache404Test::main") { - Zend_Controller_Request_Apache404Test::main(); -} diff --git a/tests/Zend/Controller/Request/HttpTest.php b/tests/Zend/Controller/Request/HttpTest.php deleted file mode 100644 index 4acaede2f31ea12cb0e734e951cd3af49b4727ee..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Request/HttpTest.php +++ /dev/null @@ -1,608 +0,0 @@ -<?php -// Call Zend_Controller_Request_HttpTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Request_HttpTest::main"); -} -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Controller/Request/Http.php'; - -class Zend_Controller_Request_HttpTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Controller_Request_Http - */ - protected $_request; - - /** - * Original $_SERVER - * @var array - */ - protected $_origServer; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_HttpTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->_origServer = $_SERVER; - $_GET = array(); - $_POST = array(); - $this->_request = new Zend_Controller_Request_Http('http://framework.zend.com/news/3?var1=val1&var2=val2#anchor'); - } - - public function tearDown() - { - unset($this->_request); - $_SERVER = $this->_origServer; - } - - public function testSetGetControllerKey() - { - $this->_request->setControllerKey('controller'); - $this->assertEquals('controller', $this->_request->getControllerKey()); - - $this->_request->setControllerKey('foo'); - $this->assertEquals('foo', $this->_request->getControllerKey()); - } - - public function testSetGetActionKey() - { - $this->_request->setActionKey('action'); - $this->assertEquals('action', $this->_request->getActionKey()); - - $this->_request->setActionKey('foo'); - $this->assertEquals('foo', $this->_request->getActionKey()); - } - - public function testSetGetControllerName() - { - $this->_request->setControllerName('foo'); - $this->assertEquals('foo', $this->_request->getControllerName()); - - $this->_request->setControllerName('bar'); - $this->assertEquals('bar', $this->_request->getControllerName()); - } - - public function testSetGetActionName() - { - $this->_request->setActionName('foo'); - $this->assertEquals('foo', $this->_request->getActionName()); - - $this->_request->setActionName('bar'); - $this->assertEquals('bar', $this->_request->getActionName()); - } - - public function test__Get() - { - $_POST['baz'] = 'boo'; - $_COOKIE['bal'] = 'peen'; - $this->_request->setParam('foo', 'bar'); - - foreach ($_ENV as $envKey => $expected) { - if (isset($_ENV[$envKey]) && !empty($_ENV[$envKey])) { - $expEnvKey = $envKey; - break; - } - } - - $this->assertEquals('bar', $this->_request->foo); - $this->assertEquals('val1', $this->_request->var1); - $this->assertEquals('boo', $this->_request->baz); - $this->assertEquals('peen', $this->_request->bal); - $this->assertEquals($_SERVER['REQUEST_TIME'], $this->_request->REQUEST_TIME); - $this->assertEquals($this->_request->getPathInfo(), $this->_request->PATH_INFO, $this->_request->PATH_INFO); - $this->assertEquals($this->_request->getRequestUri(), $this->_request->REQUEST_URI, $this->_request->REQUEST_URI); - if (isset($expEnvKey)) { - $this->assertEquals($expected, $this->_request->$expEnvKey); - } - } - - public function testGetIsAlias() - { - $this->assertEquals('val1', $this->_request->get('var1')); - } - - public function testSetIsAlias() - { - try { - $this->_request->set('foo', 'bar'); - $this->fail('set() should alias to __set(), and throw an exception'); - } catch (Exception $e) { - // success - } - } - - public function test__Isset() - { - $_POST['baz'] = 'boo'; - $_COOKIE['bal'] = 'peen'; - $this->_request->setParam('foo', 'bar'); - - foreach ($_ENV as $envKey => $expected) { - if (isset($_ENV[$envKey]) && !empty($_ENV[$envKey])) { - $expEnvKey = $envKey; - break; - } - } - - $this->assertTrue(isset($this->_request->foo)); - $this->assertTrue(isset($this->_request->var1)); - $this->assertTrue(isset($this->_request->baz)); - $this->assertTrue(isset($this->_request->bal)); - $this->assertTrue(isset($this->_request->REQUEST_TIME)); - $this->assertFalse(isset($this->_request->bogosity)); - if (isset($expEnvKey)) { - $this->assertTrue(isset($this->_request->$expEnvKey)); - } - } - - public function testHasIsAlias() - { - $this->assertTrue($this->_request->has('var1')); - } - - public function test__SetThrowsException() - { - try { - $this->_request->foo = 'bar'; - $this->fail('__set() should throw an exception'); - } catch (Exception $e) { - // success - } - } - - public function testSetGetParam() - { - $this->_request->setParam('foo', 'bar'); - $this->assertEquals('bar', $this->_request->getParam('foo')); - } - - public function testSetGetParams() - { - $params = array( - 'foo' => 'bar', - 'boo' => 'bah', - 'fee' => 'fi' - ); - $this->_request->setParams($params); - $received = $this->_request->getParams(); - $this->assertSame($params, array_intersect_assoc($params, $received)); - } - - public function testGetParamsWithNoGetOrPost() - { - unset($_GET, $_POST); - $params = array( - 'foo' => 'bar', - 'boo' => 'bah', - 'fee' => 'fi' - ); - $this->_request->setParams($params); - $received = $this->_request->getParams(); - $this->assertSame($params, array_intersect_assoc($params, $received)); - } - - public function testGetParamsWithGetAndPost() - { - $_GET = array( - 'get' => true - ); - $_POST = array( - 'post' => true - ); - $params = array( - 'foo' => 'bar', - 'boo' => 'bah', - 'fee' => 'fi' - ); - $this->_request->setParams($params); - - $expected = $params + $_GET + $_POST; - $received = $this->_request->getParams(); - $this->assertSame($params, array_intersect_assoc($params, $received)); - } - - public function testConstructSetsRequestUri() - { - $_SERVER['REQUEST_URI'] = '/mycontroller/myaction?foo=bar'; - $request = new Zend_Controller_Request_Http(); - $this->assertEquals('/mycontroller/myaction?foo=bar', $request->getRequestUri()); - } - - public function testSetRequestUriDoesNotPassUriThroughUrldecode() - { - $request = new Zend_Controller_Request_Http(); - $request->setRequestUri('/foo/bar?foo=bar%20baz'); - $requestUri = $request->getRequestUri(); - $this->assertNotEquals('/foo/bar?foo=bar baz', $requestUri); - $this->assertEquals('/foo/bar?foo=bar%20baz', $requestUri); - } - - public function testGetMethod() - { - $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->assertEquals('POST', $this->_request->getMethod()); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertEquals('GET', $this->_request->getMethod()); - } - - public function testIsPost() - { - $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->assertTrue($this->_request->isPost()); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertFalse($this->_request->isPost()); - } - - public function testIsGet() - { - $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertTrue($this->_request->isGet()); - $this->assertFalse($this->_request->isPost()); - } - - public function testIsPut() - { - $_SERVER['REQUEST_METHOD'] = 'PUT'; - $this->assertTrue($this->_request->isPut()); - $this->assertFalse($this->_request->isGet()); - } - - public function testIsDelete() - { - $_SERVER['REQUEST_METHOD'] = 'DELETE'; - $this->assertTrue($this->_request->isDelete()); - $this->assertFalse($this->_request->isGet()); - } - - public function testIsHead() - { - $_SERVER['REQUEST_METHOD'] = 'HEAD'; - $this->assertTrue($this->_request->isHead()); - $this->assertFalse($this->_request->isGet()); - } - - public function testIsOptions() - { - $_SERVER['REQUEST_METHOD'] = 'OPTIONS'; - $this->assertTrue($this->_request->isOptions()); - $this->assertFalse($this->_request->isGet()); - } - - public function testGetRawBodyReturnsFalseWithNoPost() - { - $this->assertFalse($this->_request->getRawBody()); - } - - public function testGetQuery() - { - $this->assertEquals('val1', $this->_request->getQuery('var1')); - - $this->assertEquals('foo', $this->_request->getQuery('BAR', 'foo')); - - $expected = array('var1' => 'val1', 'var2' => 'val2'); - $this->assertEquals( $expected, $this->_request->getQuery()); - } - - - public function testGetPost() - { - $_POST['post1'] = 'val1'; - $this->assertEquals('val1', $this->_request->getPost('post1')); - - $this->assertEquals('foo', $this->_request->getPost('BAR', 'foo')); - - $_POST['post2'] = 'val2'; - $expected = array('post1' => 'val1', 'post2' => 'val2'); - $this->assertEquals($expected, $this->_request->getPost()); - - } - - public function testGetPathInfo() - { - $this->assertEquals('/news/3', $this->_request->getPathInfo(), 'Base URL: ' . var_export($this->_request->getBaseUrl(), 1)); - } - - public function testSetPathInfo() - { - $this->_request->setPathInfo('/archives/past/4'); - $this->assertEquals('/archives/past/4', $this->_request->getPathInfo()); - } - - public function testPathInfoNeedingBaseUrl() - { - $request = new Zend_Controller_Request_Http('http://localhost/test/index.php/ctrl-name/act-name'); - $this->assertEquals('/test/index.php/ctrl-name/act-name', $request->getRequestUri()); - $request->setBaseUrl('/test/index.php'); - $this->assertEquals('/test/index.php', $request->getBaseUrl()); - - $requestUri = $request->getRequestUri(); - $baseUrl = $request->getBaseUrl(); - $pathInfo = substr($requestUri, strlen($baseUrl)); - $this->assertTrue($pathInfo ? true : false); - - $this->assertEquals('/ctrl-name/act-name', $request->getPathInfo(), "Expected $pathInfo;"); - } - - public function testGetSetAlias() - { - $this->_request->setAlias('controller', 'var1'); - $this->assertEquals('var1', $this->_request->getAlias('controller')); - } - - public function testGetAliases() - { - $this->_request->setAlias('controller', 'var1'); - $this->_request->setAlias('action', 'var2'); - $this->assertSame(array('controller' => 'var1', 'action' => 'var2'), $this->_request->getAliases()); - } - - public function testGetRequestUri() - { - $this->assertEquals('/news/3?var1=val1&var2=val2', $this->_request->getRequestUri()); - } - - public function testSetRequestUri() - { - $this->_request->setRequestUri('/archives/past/4?set=this&unset=that'); - $this->assertEquals('/archives/past/4?set=this&unset=that', $this->_request->getRequestUri()); - $this->assertEquals('this', $this->_request->getQuery('set')); - $this->assertEquals('that', $this->_request->getQuery('unset')); - } - - public function testGetBaseUrl() - { - $this->assertSame('', $this->_request->getBaseUrl()); - } - - public function testSetBaseUrl() - { - $this->_request->setBaseUrl('/news'); - $this->assertEquals('/news', $this->_request->getBaseUrl()); - } - - public function testSetBaseUrlUsingPhpSelf() - { - $_SERVER['REQUEST_URI'] = '/index.php/news/3?var1=val1&var2=val2'; - $_SERVER['SCRIPT_NAME'] = '/home.php'; - $_SERVER['PHP_SELF'] = '/index.php/news/3'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/html/index.php'; - $_GET = array( - 'var1' => 'val1', - 'var2' => 'val2' - ); - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/index.php', $request->getBaseUrl()); - } - - public function testSetBaseUrlUsingOrigScriptName() - { - $_SERVER['REQUEST_URI'] = '/index.php/news/3?var1=val1&var2=val2'; - $_SERVER['SCRIPT_NAME'] = '/home.php'; - $_SERVER['PHP_SELF'] = '/home.php'; - $_SERVER['ORIG_SCRIPT_NAME']= '/index.php'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/html/index.php'; - $_GET = array( - 'var1' => 'val1', - 'var2' => 'val2' - ); - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/index.php', $request->getBaseUrl()); - } - - public function testSetBaseUrlAutoDiscoveryUsingRequestUri() - { - $_SERVER['REQUEST_URI'] = '/index.php/news/3?var1=val1&var2=val2'; - $_SERVER['PHP_SELF'] = '/index.php/news/3'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/html/index.php'; - $_GET = array( - 'var1' => 'val1', - 'var2' => 'val2' - ); - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/index.php', $request->getBaseUrl()); - } - - public function testSetBaseUrlAutoDiscoveryUsingXRewriteUrl() - { - unset($_SERVER['REQUEST_URI']); - $_SERVER['HTTP_X_REWRITE_URL'] = '/index.php/news/3?var1=val1&var2=val2'; - $_SERVER['PHP_SELF'] = '/index.php/news/3'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/html/index.php'; - $_GET = array( - 'var1' => 'val1', - 'var2' => 'val2' - ); - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/index.php', $request->getBaseUrl()); - } - - public function testSetBaseUrlAutoDiscoveryUsingOrigPathInfo() - { - unset($_SERVER['REQUEST_URI']); - $_SERVER['ORIG_PATH_INFO'] = '/index.php/news/3'; - $_SERVER['QUERY_STRING'] = 'var1=val1&var2=val2'; - $_SERVER['PHP_SELF'] = '/index.php/news/3'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/html/index.php'; - $_GET = array( - 'var1' => 'val1', - 'var2' => 'val2' - ); - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/index.php', $request->getBaseUrl()); - } - - public function testGetSetBasePath() - { - $this->_request->setBasePath('/news'); - $this->assertEquals('/news', $this->_request->getBasePath()); - } - - public function testBasePathAutoDiscovery() - { - $_SERVER['REQUEST_URI'] = '/html/index.php/news/3?var1=val1&var2=val2'; - $_SERVER['PHP_SELF'] = '/html/index.php/news/3'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/html/index.php'; - $_GET = array( - 'var1' => 'val1', - 'var2' => 'val2' - ); - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/html', $request->getBasePath(), $request->getBaseUrl()); - } - - public function testBasePathAutoDiscoveryWithPhpFile() - { - $_SERVER['REQUEST_URI'] = '/dir/action'; - $_SERVER['PHP_SELF'] = '/dir/index.php'; - $_SERVER['SCRIPT_FILENAME'] = '/var/web/dir/index.php'; - $request = new Zend_Controller_Request_Http(); - - $this->assertEquals('/dir', $request->getBasePath(), $request->getBaseUrl()); - } - - public function testGetCookie() - { - $_COOKIE['foo'] = 'bar'; - $this->assertSame('bar', $this->_request->getCookie('foo')); - $this->assertEquals('foo', $this->_request->getCookie('BAR', 'foo')); - $this->assertEquals($_COOKIE, $this->_request->getCookie()); - } - - public function testGetServer() - { - if (isset($_SERVER['REQUEST_METHOD'])) { - $this->assertEquals($_SERVER['REQUEST_METHOD'], $this->_request->getServer('REQUEST_METHOD')); - } - $this->assertEquals('foo', $this->_request->getServer('BAR', 'foo')); - $this->assertEquals($_SERVER, $this->_request->getServer()); - } - - public function testGetEnv() - { - if (isset($_ENV['PATH'])) { - $this->assertEquals($_ENV['PATH'], $this->_request->getEnv('PATH')); - } - $this->assertEquals('foo', $this->_request->getEnv('BAR', 'foo')); - $this->assertEquals($_ENV, $this->_request->getEnv()); - } - - public function testGetHeader() - { - $_SERVER['HTTP_ACCEPT_ENCODING'] = 'UTF-8'; - $_SERVER['HTTP_CONTENT_TYPE'] = 'text/json'; - - $this->assertEquals('UTF-8', $this->_request->getHeader('Accept-Encoding')); - $this->assertEquals('text/json', $this->_request->getHeader('Content-Type')); - - $this->assertFalse($this->_request->getHeader('X-No-Such-Thing')); - } - - public function testGetHeaderThrowsExceptionWithNoInput() - { - try { - // Suppressing warning - $header = @$this->_request->getHeader(); - $this->fail('getHeader() should fail with no arguments)'); - } catch (Exception $e) { - // success - } - } - - public function testIsXmlHttpRequest() - { - $this->assertFalse($this->_request->isXmlHttpRequest()); - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - $this->assertTrue($this->_request->isXmlHttpRequest()); - } - - public function testSetNullParamUnsetsKey() - { - $this->_request->setParam('foo', 'bar'); - $this->assertEquals('bar', $this->_request->getParam('foo')); - $this->_request->setParam('foo', null); - $params = $this->_request->getParams(); - $this->assertFalse(isset($params['foo'])); - } - - public function testSetNullParamsUnsetsKeys() - { - $this->_request->setParams(array('foo' => 'bar', 'bar' => 'baz')); - $this->assertEquals('bar', $this->_request->getParam('foo')); - $this->assertEquals('baz', $this->_request->getParam('bar')); - $this->_request->setParams(array('foo' => null)); - $params = $this->_request->getParams(); - $this->assertFalse(isset($params['foo'])); - $this->assertTrue(isset($params['bar'])); - } - - public function testGetAliasedParamZF2455() - { - $this->_request->setParam('controller', 'value'); - $this->_request->setAlias('var1', 'controller'); - - $this->assertEquals('value', $this->_request->getParam('controller')); - $this->assertEquals('value', $this->_request->getParam('var1')); - } - - public function testCanDetectFlashRequests() - { - $this->assertFalse($this->_request->isFlashRequest()); - $_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash'; - $this->assertTrue($this->_request->isFlashRequest()); - } - - /** - * ZF-1798 - */ - public function testGetAndPostBothInDefaultParamSources() - { - $this->assertEquals(array('_GET', '_POST'), $this->_request->getParamSources()); - } - - /** - * ZF-1798 - */ - public function testCanSetParamSources() - { - $this->testGetAndPostBothInDefaultParamSources(); - $this->_request->setParamSources(array()); - $this->assertSame(array(), $this->_request->getParamSources()); - $this->_request->setParamSources(array('_GET')); - $this->assertSame(array('_GET'), $this->_request->getParamSources()); - } - - /** - * ZF-1798 - */ - public function testParamSourcesHonoredByGetParam() - { - $_GET = array('foo' => 'bar'); - $_POST = array('foo' => 'baz'); - $this->_request->setParamSources(array('_POST')); - $this->assertEquals('baz', $this->_request->getParam('foo')); - } -} - -// Call Zend_Controller_Request_HttpTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_HttpTest::main") { - Zend_Controller_Request_HttpTest::main(); -} diff --git a/tests/Zend/Controller/Request/HttpTestCaseTest.php b/tests/Zend/Controller/Request/HttpTestCaseTest.php deleted file mode 100644 index ce405aa88ab112d01e808aa79b59ece0732ed343..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Request/HttpTestCaseTest.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php -// Call Zend_Controller_Request_HttpTestCaseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Request_HttpTestCaseTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Controller_Request_HttpTestCase */ -require_once 'Zend/Controller/Request/HttpTestCase.php'; - -/** - * Test class for Zend_Controller_Request_HttpTestCase. - */ -class Zend_Controller_Request_HttpTestCaseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_HttpTestCaseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->request = new Zend_Controller_Request_HttpTestCase(); - $_GET = array(); - $_POST = array(); - $_COOKIE = array(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testGetRequestUriShouldNotAttemptToAutoDiscoverFromEnvironment() - { - $this->assertNull($this->request->getRequestUri()); - } - - public function testGetPathInfoShouldNotAttemptToAutoDiscoverFromEnvironment() - { - $pathInfo = $this->request->getPathInfo(); - $this->assertTrue(empty($pathInfo)); - } - - public function testGetShouldBeEmptyByDefault() - { - $post = $this->request->getQuery(); - $this->assertTrue(is_array($post)); - $this->assertTrue(empty($post)); - } - - public function testShouldAllowSpecifyingGetParameters() - { - $this->testGetShouldBeEmptyByDefault(); - $expected = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - ); - $this->request->setQuery($expected); - - $test = $this->request->getQuery(); - $this->assertSame($expected, $test); - - $this->request->setQuery('bat', 'bogus'); - $this->assertEquals('bogus', $this->request->getQuery('bat')); - $test = $this->request->getQuery(); - $this->assertEquals(4, count($test)); - foreach ($expected as $key => $value) { - $this->assertEquals($value, $test[$key]); - } - } - - public function testShouldPopulateGetSuperglobal() - { - $this->testShouldAllowSpecifyingGetParameters(); - $expected = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - 'bat' => 'bogus', - ); - $this->assertEquals($expected, $_GET); - } - - public function testShouldAllowClearingQuery() - { - $this->testShouldPopulateGetSuperglobal(); - $this->request->clearQuery(); - $test = $this->request->getQuery(); - $this->assertTrue(is_array($test)); - $this->assertTrue(empty($test)); - } - - public function testPostShouldBeEmptyByDefault() - { - $post = $this->request->getPost(); - $this->assertTrue(is_array($post)); - $this->assertTrue(empty($post)); - } - - public function testShouldAllowSpecifyingPostParameters() - { - $this->testPostShouldBeEmptyByDefault(); - $expected = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - ); - $this->request->setPost($expected); - - $test = $this->request->getPost(); - $this->assertSame($expected, $test); - - $this->request->setPost('bat', 'bogus'); - $this->assertEquals('bogus', $this->request->getPost('bat')); - $test = $this->request->getPost(); - $this->assertEquals(4, count($test)); - foreach ($expected as $key => $value) { - $this->assertEquals($value, $test[$key]); - } - } - - public function testShouldPopulatePostSuperglobal() - { - $this->testShouldAllowSpecifyingPostParameters(); - $expected = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - 'bat' => 'bogus', - ); - $this->assertEquals($expected, $_POST); - } - - public function testShouldAllowClearingPost() - { - $this->testShouldPopulatePostSuperglobal(); - $this->request->clearPost(); - $test = $this->request->getPost(); - $this->assertTrue(is_array($test)); - $this->assertTrue(empty($test)); - } - - public function testRawPostBodyShouldBeNullByDefault() - { - $this->assertNull($this->request->getRawBody()); - } - - public function testShouldAllowSpecifyingRawPostBody() - { - $this->request->setRawBody('Some content for the body'); - $this->assertEquals('Some content for the body', $this->request->getRawBody()); - } - - public function testShouldAllowClearingRawPostBody() - { - $this->testShouldAllowSpecifyingRawPostBody(); - $this->request->clearRawBody(); - $this->assertNull($this->request->getRawBody()); - } - - public function testHeadersShouldBeEmptyByDefault() - { - $headers = $this->request->getHeaders(); - $this->assertTrue(is_array($headers)); - $this->assertTrue(empty($headers)); - } - - public function testShouldAllowSpecifyingRequestHeaders() - { - $headers = array( - 'Content-Type' => 'text/html', - 'Content-Encoding' => 'utf-8', - ); - $this->request->setHeaders($headers); - $test = $this->request->getHeaders(); - $this->assertTrue(is_array($test)); - $this->assertEquals(2, count($test)); - foreach ($headers as $key => $value) { - $this->assertEquals($value, $this->request->getHeader($key)); - } - $this->request->setHeader('X-Requested-With', 'XMLHttpRequest'); - $test = $this->request->getHeaders(); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test)); - $this->assertEquals('XMLHttpRequest', $this->request->getHeader('X-Requested-With')); - } - - public function testShouldAllowClearingRequestHeaders() - { - $this->testShouldAllowSpecifyingRequestHeaders(); - $this->request->clearHeaders(); - $headers = $this->request->getHeaders(); - $this->assertTrue(is_array($headers)); - $this->assertTrue(empty($headers)); - } - - public function testCookiesShouldBeEmptyByDefault() - { - $cookies = $this->request->getCookie(); - $this->assertTrue(is_array($cookies)); - $this->assertTrue(empty($cookies)); - } - - public function testShouldAllowSpecifyingCookies() - { - $cookies = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat' - ); - $this->request->setCookies($cookies); - $test = $this->request->getCookie(); - $this->assertEquals($cookies, $test); - - $this->request->setCookie('bat', 'bogus'); - $this->assertEquals('bogus', $this->request->getCookie('bat')); - } - - public function testShouldPopulateCookieSuperGlobal() - { - $cookies = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - 'bat' => 'bogus', - ); - $this->testShouldAllowSpecifyingCookies(); - $this->assertEquals($cookies, $_COOKIE); - } - - public function testShouldAllowClearingAllCookies() - { - $this->testShouldAllowSpecifyingCookies(); - $this->request->clearCookies(); - $test = $this->request->getCookie(); - $this->assertTrue(is_array($test)); - $this->assertTrue(empty($test)); - } - - public function testRequestMethodShouldBeNullByDefault() - { - $this->assertNull($this->request->getMethod()); - } - - public function testShouldAllowSpecifyingRequestMethod() - { - $this->testRequestMethodShouldBeNullByDefault(); - $this->request->setMethod('GET'); - $this->assertTrue($this->request->isGet()); - $this->request->setMethod('POST'); - $this->assertTrue($this->request->isPost()); - $this->request->setMethod('PUT'); - $this->assertTrue($this->request->isPut()); - $this->request->setMethod('OPTIONS'); - $this->assertTrue($this->request->isOptions()); - $this->request->setMethod('HEAD'); - $this->assertTrue($this->request->isHead()); - $this->request->setMethod('DELETE'); - $this->assertTrue($this->request->isDelete()); - } -} - -// Call Zend_Controller_Request_HttpTestCaseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_HttpTestCaseTest::main") { - Zend_Controller_Request_HttpTestCaseTest::main(); -} diff --git a/tests/Zend/Controller/Request/SimpleTest.php b/tests/Zend/Controller/Request/SimpleTest.php deleted file mode 100644 index a94a161ab36512242f2240a012b2f62cfe4f9339..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Request/SimpleTest.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -// Call Zend_Controller_Request_SimpleTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Request_SimpleTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Controller/Request/Simple.php'; - -/** - * Test class for Zend_Controller_Request_Simple. - */ -class Zend_Controller_Request_SimpleTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_SimpleTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testSimpleRequestIsOfAbstractRequestType() - { - $request = new Zend_Controller_Request_Simple(); - $this->assertTrue($request instanceof Zend_Controller_Request_Abstract); - } - - public function testSimpleReqestRetainsValuesPassedFromConstructor() - { - $request = new Zend_Controller_Request_Simple('test1', 'test2', 'test3', array('test4' => 'test5')); - $this->assertEquals($request->getActionName(), 'test1'); - $this->assertEquals($request->getControllerName(), 'test2'); - $this->assertEquals($request->getModuleName(), 'test3'); - $this->assertEquals($request->getParam('test4'), 'test5'); - } - -} - -// Call Zend_Controller_Request_SimpleTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_SimpleTest::main") { - Zend_Controller_Request_SimpleTest::main(); -} diff --git a/tests/Zend/Controller/Response/HttpTest.php b/tests/Zend/Controller/Response/HttpTest.php deleted file mode 100644 index c100970b5f5d8b3cf0753a33ead617dbc290f0be..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Response/HttpTest.php +++ /dev/null @@ -1,610 +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_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HttpTest.php 8533 2008-03-04 18:40:32Z ralph $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -// Call Zend_Controller_Response_HttpTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Controller_Response_HttpTest::main'); -} - -require_once 'Zend/Controller/Response/Http.php'; -require_once 'Zend/Controller/Response/Exception.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Controller_Response_HttpTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Http_Response - */ - protected $_response; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Response_HttpTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->_response = new Zend_Controller_Response_Http(); - $this->_response->headersSentThrowsException = false; - } - - public function tearDown() - { - unset($this->_response); - } - - public function testSetHeader() - { - $expected = array(array('name' => 'Content-Type', 'value' => 'text/xml', 'replace' => false)); - $this->_response->setHeader('Content-Type', 'text/xml'); - $this->assertSame($expected, $this->_response->getHeaders()); - - $expected[] =array('name' => 'Content-Type', 'value' => 'text/html', 'replace' => false); - $this->_response->setHeader('Content-Type', 'text/html'); - $this->assertSame($expected, $this->_response->getHeaders()); - - $expected = array(array('name' => 'Content-Type', 'value' => 'text/plain', 'replace' => true)); - $this->_response->setHeader('Content-Type', 'text/plain', true); - $count = 0; - foreach ($this->_response->getHeaders() as $header) { - if ('Content-Type' == $header['name']) { - if ('text/plain' == $header['value']) { - ++$count; - } else { - $this->fail('Found header, but incorrect value'); - } - } - } - $this->assertEquals(1, $count); - } - - public function testNoDuplicateLocationHeader() - { - $this->_response->setRedirect('http://www.example.com/foo/bar'); - $this->_response->setRedirect('http://www.example.com/bar/baz'); - $headers = $this->_response->getHeaders(); - $location = 0; - foreach ($headers as $header) { - if ('Location' == $header['name']) { - ++$location; - } - } - $this->assertEquals(1, $location); - } - - public function testClearHeaders() - { - $this->_response->setHeader('Content-Type', 'text/xml'); - $headers = $this->_response->getHeaders(); - $this->assertEquals(1, count($headers)); - - $this->_response->clearHeaders(); - $headers = $this->_response->getHeaders(); - $this->assertEquals(0, count($headers)); - } - - public function testSetRawHeader() - { - $this->_response->setRawHeader('HTTP/1.0 404 Not Found'); - $headers = $this->_response->getRawHeaders(); - $this->assertContains('HTTP/1.0 404 Not Found', $headers); - } - - public function testClearRawHeaders() - { - $this->_response->setRawHeader('HTTP/1.0 404 Not Found'); - $headers = $this->_response->getRawHeaders(); - $this->assertContains('HTTP/1.0 404 Not Found', $headers); - - $this->_response->clearRawHeaders(); - $headers = $this->_response->getRawHeaders(); - $this->assertTrue(empty($headers)); - } - - public function testClearAllHeaders() - { - $this->_response->setRawHeader('HTTP/1.0 404 Not Found'); - $this->_response->setHeader('Content-Type', 'text/xml'); - - $headers = $this->_response->getHeaders(); - $this->assertFalse(empty($headers)); - - $headers = $this->_response->getRawHeaders(); - $this->assertFalse(empty($headers)); - - $this->_response->clearAllHeaders(); - $headers = $this->_response->getHeaders(); - $this->assertTrue(empty($headers)); - $headers = $this->_response->getRawHeaders(); - $this->assertTrue(empty($headers)); - } - - public function testSetHttpResponseCode() - { - $this->assertEquals(200, $this->_response->getHttpResponseCode()); - $this->_response->setHttpResponseCode(302); - $this->assertEquals(302, $this->_response->getHttpResponseCode()); - } - - public function testSetBody() - { - $expected = 'content for the response body'; - $this->_response->setBody($expected); - $this->assertEquals($expected, $this->_response->getBody()); - - $expected = 'new content'; - $this->_response->setBody($expected); - $this->assertEquals($expected, $this->_response->getBody()); - } - - public function testAppendBody() - { - $expected = 'content for the response body'; - $this->_response->setBody($expected); - - $additional = '; and then there was more'; - $this->_response->appendBody($additional); - $this->assertEquals($expected . $additional, $this->_response->getBody()); - } - - /** - * SKIPPED - This test is untestable in the CLI environment. PHP ignores all - * header() calls (which are used by Http_Abstract::setHeader()), thus, anything - * that is expected to be found in http headers when inserted via header(), will - * not be found. In addition, headers_sent() should always return false, until - * real output is sent to the console. - */ - public function test__toString() - { - - //$skipHeadersTest = headers_sent(); - - $this->_response->setHeader('Content-Type', 'text/plain'); - $this->_response->setBody('Content'); - $this->_response->appendBody('; and more content.'); - - $expected = 'Content; and more content.'; - $result = $this->_response->__toString(); - - $this->assertSame($expected, $result); - return; - - // header checking will not work - - if (!$skipHeadersTest) { - $this->assertTrue(headers_sent()); - $headers = headers_list(); - $found = false; - foreach ($headers as $header) { - if ('Content-Type: text/plain' == $header) { - $found = true; - } - } - $this->assertTrue($found, var_export($headers, 1)); - } - } - - public function testRenderExceptions() - { - $this->assertFalse($this->_response->renderExceptions()); - $this->assertTrue($this->_response->renderExceptions(true)); - $this->assertTrue($this->_response->renderExceptions()); - $this->assertFalse($this->_response->renderExceptions(false)); - $this->assertFalse($this->_response->renderExceptions()); - } - - public function testGetException() - { - $e = new Exception('Test'); - $this->_response->setException($e); - - $test = $this->_response->getException(); - $found = false; - foreach ($test as $t) { - if ($t === $e) { - $found = true; - } - } - $this->assertTrue($found); - } - - public function testSendResponseWithExceptions() - { - $e = new Exception('Test exception rendering'); - $this->_response->setException($e); - $this->_response->renderExceptions(true); - - ob_start(); - $this->_response->sendResponse(); - $string = ob_get_clean(); - $this->assertContains('Test exception rendering', $string); - } - - public function testSetResponseCodeThrowsExceptionWithBadCode() - { - try { - $this->_response->setHttpResponseCode(99); - $this->fail('Should not accept response codes < 100'); - } catch (Exception $e) { - } - - try { - $this->_response->setHttpResponseCode(600); - $this->fail('Should not accept response codes > 599'); - } catch (Exception $e) { - } - - try { - $this->_response->setHttpResponseCode('bogus'); - $this->fail('Should not accept non-integer response codes'); - } catch (Exception $e) { - } - } - - /** - * Same problem as test__toString() - * - * Specifically for this test, headers_sent will always be false, so canSentHeaders() will - * never actually throw an exception since the conditional exception code will never trigger - */ - public function testCanSendHeadersIndicatesFileAndLine() - { - $this->markTestSkipped(); - return; - - $this->_response->headersSentThrowsException = true; - try { - $this->_response->canSendHeaders(true); - $this->fail('canSendHeaders() should throw exception'); - } catch (Exception $e) { - var_dump($e->getMessage()); - $this->assertRegExp('/headers already sent in .+, line \d+$/', $e->getMessage()); - } - } - - public function testAppend() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('more', "more content\n"); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "some content\n", - 'more' => "more content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testAppendUsingExistingSegmentOverwrites() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('some', "more content\n"); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "more content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testPrepend() - { - $this->_response->prepend('some', "some content\n"); - $this->_response->prepend('more', "more content\n"); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'more' => "more content\n", - 'some' => "some content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testPrependUsingExistingSegmentOverwrites() - { - $this->_response->prepend('some', "some content\n"); - $this->_response->prepend('some', "more content\n"); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "more content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testInsert() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('more', "more content\n"); - $this->_response->insert('foobar', "foobar content\n", 'some'); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "some content\n", - 'foobar' => "foobar content\n", - 'more' => "more content\n" - ); - $this->assertSame($expected, $content); - } - - public function testInsertBefore() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('more', "more content\n"); - $this->_response->insert('foobar', "foobar content\n", 'some', true); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'foobar' => "foobar content\n", - 'some' => "some content\n", - 'more' => "more content\n" - ); - $this->assertSame($expected, $content); - } - - public function testInsertWithFalseParent() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('more', "more content\n"); - $this->_response->insert('foobar', "foobar content\n", 'baz', true); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "some content\n", - 'more' => "more content\n", - 'foobar' => "foobar content\n" - ); - $this->assertSame($expected, $content); - } - - public function testSetBodyNamedSegment() - { - $this->_response->append('some', "some content\n"); - $this->_response->setBody("more content\n", 'some'); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "more content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testSetBodyOverwritesWithDefaultSegment() - { - $this->_response->append('some', "some content\n"); - $this->_response->setBody("more content\n"); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'default' => "more content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testAppendBodyAppendsDefaultSegment() - { - $this->_response->setBody("some content\n"); - $this->_response->appendBody("more content\n"); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'default' => "some content\nmore content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testAppendBodyAppendsExistingSegment() - { - $this->_response->setBody("some content\n", 'some'); - $this->_response->appendBody("more content\n", 'some'); - - $content = $this->_response->getBody(true); - $this->assertTrue(is_array($content)); - $expected = array( - 'some' => "some content\nmore content\n" - ); - $this->assertEquals($expected, $content); - } - - public function testGetBodyNamedSegment() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('more', "more content\n"); - - $this->assertEquals("more content\n", $this->_response->getBody('more')); - $this->assertEquals("some content\n", $this->_response->getBody('some')); - } - - public function testGetBodyAsArray() - { - $string1 = 'content for the response body'; - $string2 = 'more content for the response body'; - $string3 = 'even more content for the response body'; - $this->_response->appendBody($string1, 'string1'); - $this->_response->appendBody($string2, 'string2'); - $this->_response->appendBody($string3, 'string3'); - - $expected = array( - 'string1' => $string1, - 'string2' => $string2, - 'string3' => $string3 - ); - - $this->assertEquals($expected, $this->_response->getBody(true)); - } - - public function testClearBody() - { - $this->_response->append('some', "some content\n"); - - $this->assertTrue($this->_response->clearBody()); - $body = $this->_response->getBody(true); - $this->assertTrue(is_array($body)); - $this->assertEquals(0, count($body)); - } - - public function testClearBodySegment() - { - $this->_response->append('some', "some content\n"); - $this->_response->append('more', "more content\n"); - $this->_response->append('superfluous', "superfluous content\n"); - - $this->assertFalse($this->_response->clearBody('many')); - $this->assertTrue($this->_response->clearBody('more')); - $body = $this->_response->getBody(true); - $this->assertTrue(is_array($body)); - $this->assertEquals(2, count($body)); - $this->assertTrue(isset($body['some'])); - $this->assertTrue(isset($body['superfluous'])); - } - - public function testIsRedirectInitiallyFalse() - { - $this->assertFalse($this->_response->isRedirect()); - } - - public function testIsRedirectWhenRedirectSet() - { - $this->_response->setRedirect('http://framework.zend.com/'); - $this->assertTrue($this->_response->isRedirect()); - } - - public function testIsRedirectWhenRawLocationHeaderSet() - { - $this->_response->setRawHeader('Location: http://framework.zend.com/'); - $this->assertTrue($this->_response->isRedirect()); - } - - public function testIsRedirectWhen3xxResponseCodeSet() - { - $this->_response->setHttpResponseCode(301); - $this->assertTrue($this->_response->isRedirect()); - } - - public function testIsNotRedirectWithSufficientlyLarge3xxResponseCodeSet() - { - $this->_response->setHttpResponseCode(309); - $this->assertFalse($this->_response->isRedirect()); - } - - public function testHasExceptionOfType() - { - $this->assertFalse($this->_response->hasExceptionOfType('Zend_Controller_Response_Exception')); - $this->_response->setException(new Zend_Controller_Response_Exception()); - $this->assertTrue($this->_response->hasExceptionOfType('Zend_Controller_Response_Exception')); - } - - public function testHasExceptionOfMessage() - { - $this->assertFalse($this->_response->hasExceptionOfMessage('FooBar')); - $this->_response->setException(new Zend_Controller_Response_Exception('FooBar')); - $this->assertTrue($this->_response->hasExceptionOfMessage('FooBar')); - } - - public function testHasExceptionOfCode() - { - $this->assertFalse($this->_response->hasExceptionOfCode(200)); - $this->_response->setException(new Zend_Controller_Response_Exception('FooBar', 200)); - $this->assertTrue($this->_response->hasExceptionOfCode(200)); - } - - public function testGetExceptionByType() - { - $this->assertFalse($this->_response->getExceptionByType('Zend_Controller_Response_Exception')); - $this->_response->setException(new Zend_Controller_Response_Exception()); - $exceptions = $this->_response->getExceptionByType('Zend_Controller_Response_Exception'); - $this->assertTrue(0 < count($exceptions)); - $this->assertTrue($exceptions[0] instanceof Zend_Controller_Response_Exception); - } - - public function testGetExceptionByMessage() - { - $this->assertFalse($this->_response->getExceptionByMessage('FooBar')); - $this->_response->setException(new Zend_Controller_Response_Exception('FooBar')); - $exceptions = $this->_response->getExceptionByMessage('FooBar'); - $this->assertTrue(0 < count($exceptions)); - $this->assertEquals('FooBar', $exceptions[0]->getMessage()); - } - - public function testGetExceptionByCode() - { - $this->assertFalse($this->_response->getExceptionByCode(200)); - $this->_response->setException(new Zend_Controller_Response_Exception('FooBar', 200)); - $exceptions = $this->_response->getExceptionByCode(200); - $this->assertTrue(0 < count($exceptions)); - $this->assertEquals(200, $exceptions[0]->getCode()); - } - - public function testHeaderNamesAreCaseInsensitive() - { - $this->_response->setHeader('X-Foo_Bar-Baz', 'value'); - $this->_response->setHeader('X-FOO_bar-bAz', 'bat'); - - $headers = $this->_response->getHeaders(); - $names = array(); - foreach ($headers as $header) { - $names[] = $header['name']; - } - $this->assertTrue(in_array('X-Foo-Bar-Baz', $names), var_export($headers, 1)); - $this->assertFalse(in_array('X-Foo_Bar-Baz', $names)); - $this->assertFalse(in_array('X-FOO_bar-bAz', $names)); - } -} - -require_once 'Zend/Controller/Action.php'; -class Zend_Controller_Response_HttpTest_Action extends Zend_Controller_Action -{} - -// Call Zend_Controller_Response_HttpTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Response_HttpTest::main") { - Zend_Controller_Response_HttpTest::main(); -} diff --git a/tests/Zend/Controller/Response/HttpTestCaseTest.php b/tests/Zend/Controller/Response/HttpTestCaseTest.php deleted file mode 100644 index 6de11b238d1ad23b7c58670eadca8a92fbad7230..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Response/HttpTestCaseTest.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -// Call Zend_Controller_Response_HttpTestCaseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Response_HttpTestCaseTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Controller_Response_HttpTestCase */ -require_once 'Zend/Controller/Response/HttpTestCase.php'; - -/** - * Test class for Zend_Controller_Response_HttpTestCase. - */ -class Zend_Controller_Response_HttpTestCaseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Response_HttpTestCaseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->response = new Zend_Controller_Response_HttpTestCase(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testToStringAndSendResponseShouldNotEchoOutput() - { - $this->response->setHeader('X-Foo-Bar', 'baz') - ->setBody('Body to emit'); - ob_start(); - $this->response->sendResponse(); - $test = ob_get_clean(); - $this->assertTrue(empty($test)); - } - - public function testSendResponseShouldRenderHeaders() - { - $this->response->setHeader('X-Foo-Bar', 'baz') - ->setBody('Body to emit'); - $test = $this->response->sendResponse(); - $this->assertContains("X-Foo-Bar: baz\n\nBody to emit", $test); - } - - public function testOutputBodyShouldReturnStringInsteadOfEchoingOutput() - { - $this->response->append('foo', "Foo Content\n") - ->append('bar', "Bar Content\n") - ->prepend('baz', "Baz Content\n"); - ob_start(); - $content = $this->response->outputBody(); - $test = ob_get_clean(); - $this->assertTrue(empty($test)); - $this->assertFalse(empty($content)); - $this->assertContains("Baz Content\nFoo Content\nBar Content\n", $content, $content); - } - - public function testSendHeadersShouldReturnArrayOfHeadersInsteadOfSendingHeaders() - { - $this->response->setRawHeader('200 OK') - ->setHeader('Content-Type', 'text/xml') - ->setHeader('Content-Type', 'text/html', true) - ->setHeader('X-Foo-Bar', 'baz'); - $test = $this->response->sendHeaders(); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test)); - $this->assertNotContains('Content-Type: text/xml', $test); - $this->assertContains('Content-Type: text/html', $test); - $this->assertContains('X-Foo-Bar: baz', $test); - $this->assertContains('200 OK', $test); - } - - public function testCanSendHeadersShouldAlwaysReturnTrue() - { - $this->assertTrue($this->response->canSendHeaders()); - } -} - -// Call Zend_Controller_Response_HttpTestCaseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Response_HttpTestCaseTest::main") { - Zend_Controller_Response_HttpTestCaseTest::main(); -} diff --git a/tests/Zend/Controller/Router/RewriteTest.php b/tests/Zend/Controller/Router/RewriteTest.php deleted file mode 100644 index 57fe049739cce28397e0828375af19f2e09f6be5..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/RewriteTest.php +++ /dev/null @@ -1,708 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -/** Zend_Controller_Router_Rewrite */ -require_once 'Zend/Controller/Router/Rewrite.php'; - -/** Zend_Controller_Dispatcher_Standard */ -require_once 'Zend/Controller/Dispatcher/Standard.php'; - -/** Zend_Controller_Front */ -require_once 'Zend/Controller/Front.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** Zend_Controller_Router_Route */ -require_once 'Zend/Controller/Router/Route.php'; - -/** Zend_Controller_Router_Route_Chain */ -require_once 'Zend/Controller/Router/Route/Chain.php'; - -/** Zend_Controller_Router_Route_Hostname */ -require_once 'Zend/Controller/Router/Route/Hostname.php'; - -/** PHPUnit test case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -// require_once 'PHPUnit/Runner/Version.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_RewriteTest extends PHPUnit_Framework_TestCase -{ - protected $_router; - - public function setUp() { - $this->_router = new Zend_Controller_Router_Rewrite(); - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - $front->setDispatcher(new Zend_Controller_Router_RewriteTest_Dispatcher()); - $front->setRequest(new Zend_Controller_Router_RewriteTest_Request()); - $this->_router->setFrontController($front); - } - - public function tearDown() { - unset($this->_router); - } - - public function testAddRoute() - { - $this->_router->addRoute('archive', new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+'))); - $routes = $this->_router->getRoutes(); - - $this->assertEquals(1, count($routes)); - $this->assertType('Zend_Controller_Router_Route', $routes['archive']); - - $this->_router->addRoute('register', new Zend_Controller_Router_Route('register/:action', array('controller' => 'profile', 'action' => 'register'))); - $routes = $this->_router->getRoutes(); - - $this->assertEquals(2, count($routes)); - $this->assertType('Zend_Controller_Router_Route', $routes['register']); - } - - public function testAddRoutes() - { - $routes = array( - 'archive' => new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+')), - 'register' => new Zend_Controller_Router_Route('register/:action', array('controller' => 'profile', 'action' => 'register')) - ); - $this->_router->addRoutes($routes); - - $values = $this->_router->getRoutes(); - - $this->assertEquals(2, count($values)); - $this->assertType('Zend_Controller_Router_Route', $values['archive']); - $this->assertType('Zend_Controller_Router_Route', $values['register']); - } - - public function testHasRoute() - { - $this->_router->addRoute('archive', new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+'))); - - $this->assertEquals(true, $this->_router->hasRoute('archive')); - $this->assertEquals(false, $this->_router->hasRoute('bogus')); - } - - public function testGetRoute() - { - $archive = new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+')); - $this->_router->addRoute('archive', $archive); - - $route = $this->_router->getRoute('archive'); - - $this->assertType('Zend_Controller_Router_Route', $route); - $this->assertSame($route, $archive); - } - - public function testRemoveRoute() - { - $this->_router->addRoute('archive', new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+'))); - - $route = $this->_router->getRoute('archive'); - - $this->_router->removeRoute('archive'); - - $routes = $this->_router->getRoutes(); - $this->assertEquals(0, count($routes)); - - try { - $route = $this->_router->removeRoute('archive'); - } catch (Zend_Controller_Router_Exception $e) { - $this->assertType('Zend_Controller_Router_Exception', $e); - return true; - } - - $this->fail(); - } - - public function testGetNonExistentRoute() - { - try { - $route = $this->_router->getRoute('bogus'); - } catch (Zend_Controller_Router_Exception $e) { - $this->assertType('Zend_Controller_Router_Exception', $e); - return true; - } - - $this->fail(); - } - - public function testRoute() - { - $request = new Zend_Controller_Router_RewriteTest_Request(); - - $token = $this->_router->route($request); - - $this->assertType('Zend_Controller_Request_Http', $token); - } - - public function testRouteWithIncorrectRequest() - { - $request = new Zend_Controller_Router_RewriteTest_Request_Incorrect(); - - try { - $token = $this->_router->route($request); - $this->fail('Should throw an Exception'); - } catch (Exception $e) { - $this->assertType('Zend_Controller_Router_Exception', $e); - } - } - - public function testDefaultRoute() - { - $request = new Zend_Controller_Router_RewriteTest_Request(); - - $token = $this->_router->route($request); - - $routes = $this->_router->getRoutes(); - $this->assertType('Zend_Controller_Router_Route_Module', $routes['default']); - } - - public function testDefaultRouteWithEmptyAction() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/ctrl'); - - $token = $this->_router->route($request); - - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('defact', $token->getActionName()); - } - - public function testEmptyRoute() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/'); - - $this->_router->removeDefaultRoutes(); - $this->_router->addRoute('empty', new Zend_Controller_Router_Route('', array('controller' => 'ctrl', 'action' => 'act'))); - - $token = $this->_router->route($request); - - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('act', $token->getActionName()); - } - - public function testEmptyPath() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/'); - - $this->_router->removeDefaultRoutes(); - $this->_router->addRoute('catch-all', new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'ctrl', 'action' => 'act'))); - - $token = $this->_router->route($request); - - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('act', $token->getActionName()); - } - - public function testEmptyPathWithWildcardRoute() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/'); - - $this->_router->removeDefaultRoutes(); - $this->_router->addRoute('catch-all', new Zend_Controller_Router_Route('*', array('controller' => 'ctrl', 'action' => 'act'))); - - $token = $this->_router->route($request); - - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('act', $token->getActionName()); - } - - public function testRouteNotMatched() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/archive/action/bogus'); - - $this->_router->addRoute('default', new Zend_Controller_Router_Route(':controller/:action')); - - $token = $this->_router->route($request); - - $this->assertNull($token->getControllerName()); - $this->assertNull($token->getActionName()); - } - - public function testDefaultRouteMatched() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/ctrl/act'); - - $token = $this->_router->route($request); - - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('act', $token->getActionName()); - } - - public function testDefaultRouteMatchedWithControllerOnly() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/ctrl'); - - $token = $this->_router->route($request); - - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('defact', $token->getActionName()); - } - - public function testFirstRouteMatched() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/archive/2006'); - - $this->_router->addRoute('archive', new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+'))); - $this->_router->addRoute('register', new Zend_Controller_Router_Route('register/:action', array('controller' => 'profile', 'action' => 'register'))); - - $token = $this->_router->route($request); - - $this->assertEquals('archive', $token->getControllerName()); - $this->assertEquals('show', $token->getActionName()); - } - - public function testGetCurrentRoute() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/ctrl/act'); - - try { - $route = $this->_router->getCurrentRoute(); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Controller_Router_Exception', $e); - } - - try { - $route = $this->_router->getCurrentRouteName(); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Controller_Router_Exception', $e); - } - - $token = $this->_router->route($request); - - try { - $route = $this->_router->getCurrentRoute(); - $name = $this->_router->getCurrentRouteName(); - } catch (Exception $e) { - $this->fail('Current route is not set'); - } - - $this->assertEquals('default', $name); - $this->assertType('Zend_Controller_Router_Route_Module', $route); - } - - public function testAddConfig() - { - require_once 'Zend/Config/Ini.php'; - $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'routes.ini'; - $config = new Zend_Config_Ini($file, 'testing'); - - $this->_router->addConfig($config, 'routes'); - - $this->assertType('Zend_Controller_Router_Route_Static', $this->_router->getRoute('news')); - $this->assertType('Zend_Controller_Router_Route', $this->_router->getRoute('archive')); - - try { - $this->_router->addConfig($config, 'database'); - } catch (Exception $e) { - $this->assertType('Zend_Controller_Router_Exception', $e); - return true; - } - } - - public function testAddConfigWithoutSection() - { - require_once 'Zend/Config/Ini.php'; - $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'routes.ini'; - $config = new Zend_Config_Ini($file, 'testing'); - - $this->_router->addConfig($config->routes); - - $this->assertType('Zend_Controller_Router_Route_Static', $this->_router->getRoute('news')); - $this->assertType('Zend_Controller_Router_Route', $this->_router->getRoute('archive')); - } - - public function testAddConfigWithRootNode() - { - require_once 'Zend/Config/Ini.php'; - $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'routes-root.ini'; - $config = new Zend_Config_Ini($file, 'routes'); - - $this->_router->addConfig($config); - - $this->assertType('Zend_Controller_Router_Route_Static', $this->_router->getRoute('news')); - $this->assertType('Zend_Controller_Router_Route', $this->_router->getRoute('archive')); - } - - public function testRemoveDefaultRoutes() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/ctrl/act'); - $this->_router->removeDefaultRoutes(); - - $token = $this->_router->route($request); - - $routes = $this->_router->getRoutes(); - $this->assertEquals(0, count($routes)); - } - - public function testDefaultRouteMatchedWithModules() - { - Zend_Controller_Front::getInstance()->setControllerDirectory(array( - 'default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files', - 'mod' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin', - )); - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/mod/ctrl/act'); - $token = $this->_router->route($request); - - $this->assertEquals('mod', $token->getModuleName()); - $this->assertEquals('ctrl', $token->getControllerName()); - $this->assertEquals('act', $token->getActionName()); - } - - public function testRouteCompatDefaults() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/'); - - $token = $this->_router->route($request); - - $this->assertEquals('default', $token->getModuleName()); - $this->assertEquals('defctrl', $token->getControllerName()); - $this->assertEquals('defact', $token->getActionName()); - } - - public function testDefaultRouteWithEmptyControllerAndAction() - { - Zend_Controller_Front::getInstance()->setControllerDirectory(array( - 'default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files', - 'mod' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin', - )); - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/mod'); - - $token = $this->_router->route($request); - - $this->assertEquals('mod', $token->getModuleName()); - $this->assertEquals('defctrl', $token->getControllerName()); - $this->assertEquals('defact', $token->getActionName()); - } - - public function testNumericallyIndexedReturnParams() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/archive/2006'); - - $this->_router->addRoute('test', new Zend_Controller_Router_Route_Mockup()); - - $token = $this->_router->route($request); - - $this->assertEquals('index', $token->getControllerName()); - $this->assertEquals('index', $token->getActionName()); - $this->assertEquals('first_parameter_value', $token->getParam(0)); - } - - public function testUrlValuesHandling1() // See ZF-3212 and ZF-3219 - { - $this->_router->addRoute('foo', new Zend_Controller_Router_Route(':lang/foo', array('lang' => 'nl', 'controller' => 'index', 'action' => 'index'))); - $this->_router->addRoute('bar', new Zend_Controller_Router_Route(':lang/bar', array('lang' => 'nl', 'controller' => 'index', 'action' => 'index'))); - - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/nl/bar'); - $token = $this->_router->route($request); - - $this->assertEquals('nl/foo', $this->_router->getRoute('foo')->assemble()); - $this->assertEquals('nl/bar', $this->_router->getRoute('bar')->assemble()); - } - - public function testUrlValuesHandling2() // See ZF-3212 and ZF-3219 - { - $this->_router->addRoute('foo', new Zend_Controller_Router_Route(':lang/foo', array('lang' => 'nl', 'controller' => 'index', 'action' => 'index'))); - $this->_router->addRoute('bar', new Zend_Controller_Router_Route(':lang/bar', array('lang' => 'nl', 'controller' => 'index', 'action' => 'index'))); - - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/en/foo'); - $token = $this->_router->route($request); - - $this->assertEquals('en/foo', $this->_router->getRoute('foo')->assemble()); - $this->assertEquals('nl/bar', $this->_router->getRoute('bar')->assemble()); - } - - public function testUrlValuesHandling3() // See ZF-3212 and ZF-3219 - { - $this->_router->addRoute('foo', new Zend_Controller_Router_Route(':lang/foo', array('lang' => 'nl', 'controller' => 'index', 'action' => 'index'))); - $this->_router->addRoute('bar', new Zend_Controller_Router_Route(':lang/bar', array('lang' => 'nl', 'controller' => 'index', 'action' => 'index'))); - - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/en/bar'); - $token = $this->_router->route($request); - - $this->assertEquals('nl/foo', $this->_router->getRoute('foo')->assemble()); - $this->assertEquals('en/bar', $this->_router->getRoute('bar')->assemble()); - } - - public function testRouteRequestInterface() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/en/foo'); - $front = $this->_router->getFrontController()->setRequest($request); - - $this->_router->addRoute('req', new Zend_Controller_Router_Route_Interface_Mockup()); - $routeRequest = $this->_router->getRoute('req')->getRequest(); - - $this->assertType('Zend_Controller_Request_Abstract', $request); - $this->assertType('Zend_Controller_Request_Abstract', $routeRequest); - $this->assertSame($request, $routeRequest); - } - - public function testRoutingVersion2Routes() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/en/bar'); - $request->setParam('path', 'v2test'); - - $route = new Zend_Controller_RouterTest_RouteV2_Stub('not-important'); - $this->_router->addRoute('foo', $route); - - $token = $this->_router->route($request); - - $this->assertEquals('v2test', $token->getParam('path')); - } - - public function testRoutingChainedRoutes() - { - $this->markTestSkipped('Route features not ready'); - - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/foo/bar'); - - $foo = new Zend_Controller_Router_Route('foo', array('foo' => true)); - $bar = new Zend_Controller_Router_Route('bar', array('bar' => true, 'controller' => 'foo', 'action' => 'bar')); - - $chain = new Zend_Controller_Router_Route_Chain(); - $chain->chain($foo)->chain($bar); - - $this->_router->addRoute('foo-bar', $chain); - - $token = $this->_router->route($request); - - $this->assertEquals('foo', $token->getControllerName()); - $this->assertEquals('bar', $token->getActionName()); - $this->assertEquals(true, $token->getParam('foo')); - $this->assertEquals(true, $token->getParam('bar')); - } - - public function testRouteWithHostnameChain() - { - $request = new Zend_Controller_Router_RewriteTest_Request('http://www.zend.com/bar'); - - $foo = new Zend_Controller_Router_Route_Hostname('nope.zend.com', array('module' => 'nope-bla', 'bogus' => 'bogus')); - $bar = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('module' => 'www-bla')); - - $bla = new Zend_Controller_Router_Route_Static('bar', array('controller' => 'foo', 'action' => 'bar')); - - $chainMatch = new Zend_Controller_Router_Route_Chain(); - $chainMatch->chain($bar)->chain($bla); - - $chainNoMatch = new Zend_Controller_Router_Route_Chain(); - $chainNoMatch->chain($foo)->chain($bla); - - $this->_router->addRoute('match', $chainMatch); - $this->_router->addRoute('no-match', $chainNoMatch); - - $token = $this->_router->route($request); - - $this->assertEquals('www-bla', $token->getModuleName()); - $this->assertEquals('foo', $token->getControllerName()); - $this->assertEquals('bar', $token->getActionName()); - $this->assertNull($token->getParam('bogus')); - } - - public function testAssemblingWithHostnameHttp() - { - $this->markTestSkipped('Router features not ready'); - - $route = new Zend_Controller_Router_Route_Hostname('www.zend.com'); - - $this->_router->addRoute('hostname-route', $route); - - $this->assertEquals('http://www.zend.com', $this->_router->assemble(array(), 'hostname-route')); - } - - public function testAssemblingWithHostnameHttps() - { - $this->markTestSkipped('Router features not ready'); - - $backupServer = $_SERVER; - $_SERVER['HTTPS'] = 'on'; - - $route = new Zend_Controller_Router_Route_Hostname('www.zend.com'); - - $this->_router->addRoute('hostname-route', $route); - - $this->assertEquals('https://www.zend.com', $this->_router->assemble(array(), 'hostname-route')); - - $_SERVER = $backupServer; - } - - public function testAssemblingWithHostnameThroughChainHttp() - { - $this->markTestSkipped('Router features not ready'); - - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com'); - $bar = new Zend_Controller_Router_Route_Static('bar'); - - $chain = new Zend_Controller_Router_Route_Chain(); - $chain->chain($foo)->chain($bar); - - $this->_router->addRoute('foo-bar', $chain); - - $this->assertEquals('http://www.zend.com/bar', $this->_router->assemble(array(), 'foo-bar')); - } - - public function testAssemblingWithHostnameWithChainHttp() - { - $this->markTestSkipped('Router features not ready'); - - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com'); - $bar = new Zend_Controller_Router_Route_Static('bar'); - - $chain = $foo->chain($bar); - - $this->_router->addRoute('foo-bar', $chain); - - $this->assertEquals('http://www.zend.com/bar', $this->_router->assemble(array(), 'foo-bar')); - } - - public function testAssemblingWithNonFirstHostname() - { - $this->markTestSkipped('Router features not ready'); - - $foo = new Zend_Controller_Router_Route_Static('bar'); - $bar = new Zend_Controller_Router_Route_Hostname('www.zend.com'); - - $foo->chain($bar); - - $this->_router->addRoute('foo-bar', $foo); - - $this->assertEquals('bar/www.zend.com', $this->_router->assemble(array(), 'foo-bar')); - } - - /** - * @see ZF-3922 - */ - public function testRouteShouldMatchEvenWithTrailingSlash() - { - $route = new Zend_Controller_Router_Route( - 'blog/articles/:id', - array( - 'controller' => 'blog', - 'action' => 'articles', - 'id' => 0, - ), - array( - 'id' => '[0-9]+', - ) - ); - $this->_router->addRoute('article-id', $route); - - $request = new Zend_Controller_Router_RewriteTest_Request('http://localhost/blog/articles/2006/'); - $token = $this->_router->route($request); - - $this->assertSame('article-id', $this->_router->getCurrentRouteName()); - - $this->assertEquals('2006', $token->getParam('id', false)); - } -} - - -/** - * Zend_Controller_Router_RewriteTest_Request - request object for router testing - * - * @uses Zend_Controller_Request_Interface - */ -class Zend_Controller_Router_RewriteTest_Request extends Zend_Controller_Request_Http -{ - protected $_host; - protected $_port; - - public function __construct($uri = null) - { - if (null === $uri) { - $uri = 'http://localhost/foo/bar/baz/2'; - } - - $uri = Zend_Uri_Http::fromString($uri); - $this->_host = $uri->getHost(); - $this->_port = $uri->getPort(); - - parent::__construct($uri); - } - - public function getHttpHost() { - $return = $this->_host; - if ($this->_port) $return .= ':' . $this->_port; - return $return; - } -} - -/** - * Zend_Controller_RouterTest_Dispatcher - */ -class Zend_Controller_Router_RewriteTest_Dispatcher extends Zend_Controller_Dispatcher_Standard -{ - public function getDefaultControllerName() - { - return 'defctrl'; - } - - public function getDefaultAction() - { - return 'defact'; - } -} - -/** - * Zend_Controller_RouterTest_Request_Incorrect - request object for router testing - * - * @uses Zend_Controller_Request_Abstract - */ -class Zend_Controller_Router_RewriteTest_Request_Incorrect extends Zend_Controller_Request_Abstract -{ -} - -/** - * Zend_Controller_RouterTest_RouteV2_Stub - request object for router testing - * - * @uses Zend_Controller_Request_Abstract - */ -class Zend_Controller_RouterTest_RouteV2_Stub implements Zend_Controller_Router_Route_Interface -{ - public function getVersion() { return 2; } - public function match($request) { - return array('path', $request->getParam('path')); - } - - public static function getInstance(Zend_Config $config) {} - public function assemble($data = array(), $reset = false, $encode = false) {} -} - -class Zend_Controller_Router_Route_Mockup implements Zend_Controller_Router_Route_Interface -{ - public function match($path, $partial = null) - { - return array( - "controller" => "index", - "action" => "index", - 0 => "first_parameter_value" - ); - } - public static function getInstance(Zend_Config $config) {} - public function assemble($data = array(), $reset = false, $encode = false) {} -} - -class Zend_Controller_Router_Route_Interface_Mockup implements Zend_Controller_Router_Route_Interface -{ - protected $_request; - - public function match($path, $partial = null) {} - public static function getInstance(Zend_Config $config) {} - public function assemble($data = array(), $reset = false, $encode = false) {} - - public function setRequest($request) { - $this->_request = $request; - } - public function getRequest() { - return $this->_request; - } -} diff --git a/tests/Zend/Controller/Router/Route/ChainTest.php b/tests/Zend/Controller/Router/Route/ChainTest.php deleted file mode 100644 index 4e6751189ffbb879ff31ee2ab6074be887d6ba06..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/Route/ChainTest.php +++ /dev/null @@ -1,256 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Controller_Router_Route_ChainTest::main'); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Controller_Router_Route_Chain */ -require_once 'Zend/Controller/Router/Route/Chain.php'; - -/** Zend_Controller_Router_Route */ -require_once 'Zend/Controller/Router/Route.php'; - -/** Zend_Controller_Router_Route_Static */ -require_once 'Zend/Controller/Router/Route/Static.php'; - -/** Zend_Controller_Router_Route_Static */ -require_once 'Zend/Controller/Router/Route/Regex.php'; - -/** Zend_Controller_Router_Route_Hostname */ -require_once 'Zend/Controller/Router/Route/Hostname.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** Zend_Uri_Http */ -require_once 'Zend/Uri/Http.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_Route_ChainTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Router_Route_ChainTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testChaining() - { - $request = new Zend_Controller_Router_ChainTest_Request('http://localhost/foo/bar'); - - $foo = new Zend_Controller_Router_Route('foo'); - $bar = new Zend_Controller_Router_Route('bar'); - - $chain = $foo->chain($bar); - - $this->assertType('Zend_Controller_Router_Route_Chain', $chain); - } - - public function testChainingMatch() - { - $chain = new Zend_Controller_Router_Route_Chain(); - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 1)); - $bar = new Zend_Controller_Router_Route_Static('bar', array('bar' => 2)); - - $chain->chain($foo)->chain($bar); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bla'); - $res = $chain->match($request); - - $this->assertFalse($res); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bar'); - $res = $chain->match($request); - - $this->assertEquals(1, $res['foo']); - $this->assertEquals(2, $res['bar']); - } - - public function testChainingShortcutMatch() - { - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 1)); - $bar = new Zend_Controller_Router_Route_Static('bar', array('bar' => 2, 'controller' => 'foo', 'action' => 'bar')); - - $chain = $foo->chain($bar); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bar'); - $res = $chain->match($request); - - $this->assertEquals(1, $res['foo']); - $this->assertEquals(2, $res['bar']); - } - - public function testChainingMatchFailure() - { - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 1)); - $bar = new Zend_Controller_Router_Route_Static('bar', array('bar' => 2, 'controller' => 'foo', 'action' => 'bar')); - - $chain = $foo->chain($bar); - - $request = new Zend_Controller_Router_ChainTest_Request('http://nope.zend.com/bar'); - $res = $chain->match($request); - - $this->assertFalse($res); - } - - public function testChainingVariableOverriding() - { - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 1, 'controller' => 'foo', 'module' => 'foo')); - $bar = new Zend_Controller_Router_Route('bar', array('bar' => 2, 'controller' => 'bar', 'action' => 'bar')); - - $chain = $foo->chain($bar); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bar'); - $res = $chain->match($request); - - $this->assertEquals('foo', $res['module']); - $this->assertEquals('bar', $res['controller']); - $this->assertEquals('bar', $res['action']); - } - - public function testChainingSeparatorOverriding() - { - $this->markTestSkipped('Route features not ready'); - - $foo = new Zend_Controller_Router_Route('foo', array('foo' => 1)); - $bar = new Zend_Controller_Router_Route('bar', array('bar' => 2)); - $baz = new Zend_Controller_Router_Route('baz', array('baz' => 3)); - - $chain = $foo->chain($bar, '.'); - - $res = $chain->match('foo.bar'); - $this->assertType('array', $res); - - $res = $chain->match('foo/bar'); - $this->assertEquals(false, $res); - - $chain->chain($baz, ':'); - - $res = $chain->match('foo.bar:baz'); - $this->assertType('array', $res); - } - - public function testI18nChaining() - { - $this->markTestSkipped('Route features not ready'); - - $lang = new Zend_Controller_Router_Route(':lang', array('lang' => 'en')); - $profile = new Zend_Controller_Router_Route('user/:id', array('controller' => 'foo', 'action' => 'bar')); - - $chain = $lang->chain($profile); - - $res = $chain->match('en/user/1'); - - $this->assertEquals('en', $res['lang']); - $this->assertEquals('1', $res['id']); - } - - public function testChainingAssembleWithStatic() - { - $chain = new Zend_Controller_Router_Route_Chain(); - - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 'foo')); - $bar = new Zend_Controller_Router_Route_Static('bar', array('bar' => 'bar')); - - $chain->chain($foo)->chain($bar); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bar'); - $res = $chain->match($request); - - $this->assertType('array', $res); - $this->assertRegexp('#[^a-z0-9]?www\.zend\.com/bar$#i', $chain->assemble()); - } - - public function testChainingAssembleWithRegex() - { - $chain = new Zend_Controller_Router_Route_Chain(); - - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 'foo')); - $bar = new Zend_Controller_Router_Route_Regex('bar', array('bar' => 'bar'), array(), 'bar'); - - $chain->chain($foo)->chain($bar); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bar'); - $res = $chain->match($request); - - $this->assertType('array', $res); - $this->assertRegexp('#[^a-z0-9]?www\.zend\.com/bar$#i', $chain->assemble()); - } - - public function testChainingReuse() - { - $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 'foo')); - $profile = new Zend_Controller_Router_Route('user/:id', array('controller' => 'prof')); - $article = new Zend_Controller_Router_Route('article/:id', array('controller' => 'art', 'action' => 'art')); - - $profileChain = $foo->chain($profile); - $articleChain = $foo->chain($article); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/user/1'); - $res = $profileChain->match($request); - - $this->assertType('array', $res); - $this->assertEquals('prof', $res['controller']); - - $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/article/1'); - $res = $articleChain->match($request); - - $this->assertType('array', $res); - $this->assertEquals('art', $res['controller']); - $this->assertEquals('art', $res['action']); - } - -} - -/** - * Zend_Controller_Router_ChainTest_Request - request object for router testing - * - * @uses Zend_Controller_Request_Interface - */ -class Zend_Controller_Router_ChainTest_Request extends Zend_Controller_Request_Http -{ - protected $_host; - protected $_port; - - public function __construct($uri = null) - { - if (null === $uri) { - $uri = 'http://localhost/foo/bar/baz/2'; - } - - $uri = Zend_Uri_Http::fromString($uri); - $this->_host = $uri->getHost(); - $this->_port = $uri->getPort(); - - parent::__construct($uri); - } - - public function getHttpHost() { - $return = $this->_host; - if ($this->_port) $return .= ':' . $this->_port; - return $return; - } -} - -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Router_Route_ChainTest::main") { - Zend_Controller_Router_Route_ChainTest::main(); -} diff --git a/tests/Zend/Controller/Router/Route/HostnameTest.php b/tests/Zend/Controller/Router/Route/HostnameTest.php deleted file mode 100644 index 4979e5342dcac59f99a6d0a7995513a25777f8b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/Route/HostnameTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -/** Test helper */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Controller_Router_Route_Hostname */ -require_once 'Zend/Controller/Router/Route/Hostname.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** PHPUnit test case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Controller_Router_Route_HostnameTest::main'); -} - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_Route_HostnameTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Router_Route_HostnameTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testCorrectStaticHostMatch() - { - $route = $this->_getStaticHostRoute(); - - $values = $route->match($this->_getRequest('www.zend.com')); - $this->assertEquals('ctrl', $values['controller']); - } - - public function testHostMatchWithPort() - { - $route = $this->_getStaticHostRoute(); - - $values = $route->match($this->_getRequest('www.zend.com:666')); - $this->assertEquals('ctrl', $values['controller']); - } - - public function testWrongStaticHostMatch() - { - $route = $this->_getStaticHostRoute(); - - $values = $route->match($this->_getRequest('foo.zend.com')); - $this->assertFalse($values); - } - - public function testCorrectHostMatch() - { - $route = $this->_getHostRoute(); - - $values = $route->match($this->_getRequest('foo.zend.com')); - $this->assertEquals('ctrl', $values['controller']); - } - - public function testWrongHostMatch() - { - $route = $this->_getHostRoute(); - - $values = $route->match($this->_getRequest('www.zend.com')); - $this->assertFalse($values); - } - - public function testAssembleStaticHost() - { - $route = $this->_getStaticHostRoute(); - - $this->assertRegexp('/[^a-z0-9]?www\.zend\.com$/i', $route->assemble()); - } - - public function testAssembleHost() - { - $route = $this->_getHostRoute(); - - $this->assertRegexp('/[^a-z0-9]?foo\.zend\.com$/i', $route->assemble(array('subdomain' => 'foo'))); - } - - public function testAssembleHostWithMissingParam() - { - $route = $this->_getHostRoute(); - - try { - $route->assemble(); - $this->fail('An expected Zend_Controller_Router_Exception has not been raised'); - } catch (Zend_Controller_Router_Exception $expected) { - $this->assertContains('subdomain is not specified', $expected->getMessage()); - } - } - - public function testAssembleHostWithDefaultParam() - { - $route = $this->_getHostRouteWithDefault(); - - $this->assertRegexp('/[^a-z0-9]?bar\.zend\.com$/i', $route->assemble()); - } - - public function testHostGetDefault() - { - $route = $this->_getHostRouteWithDefault(); - - $this->assertEquals('bar', $route->getDefault('subdomain')); - } - - public function testHostGetNonExistentDefault() - { - $route = $this->_getHostRouteWithDefault(); - - $this->assertEquals(null, $route->getDefault('blah')); - } - - public function testHostGetDefaults() - { - $route = $this->_getHostRouteWithDefault(); - $defaults = $route->getDefaults(); - - $this->assertEquals('bar', $defaults['subdomain']); - } - - public function testRouteWithHostname() - { - $_SERVER['SERVER_NAME'] = 'www.zend.com'; - $request = new Zend_Controller_Router_RewriteTest_Request_Stub('www.zend.com'); - - $route = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('controller' => 'host-foo', 'action' => 'host-bar')); - - $values = $route->match($request); - - $this->assertEquals('host-foo', $values['controller']); - $this->assertEquals('host-bar', $values['action']); - } - - protected function _getStaticHostRoute() - { - $route = new Zend_Controller_Router_Route_Hostname('www.zend.com', - array('controller' => 'ctrl', - 'action' => 'act')); - - return $route; - } - - protected function _getHostRoute() - { - $route = new Zend_Controller_Router_Route_Hostname(':subdomain.zend.com', - array('controller' => 'ctrl', - 'action' => 'act'), - array('subdomain' => '(foo|bar)')); - - return $route; - } - - protected function _getHostRouteWithDefault() - { - $route = new Zend_Controller_Router_Route_Hostname(':subdomain.zend.com', - array('controller' => 'ctrl', - 'action' => 'act', - 'subdomain' => 'bar'), - array('subdomain' => '(foo|bar)')); - - return $route; - } - - protected function _getRequest($host) { - return new Zend_Controller_Router_RewriteTest_Request_Stub($host); - } - -} - -/** - * Zend_Controller_RouterTest_Request_Stub - request object for route testing - */ -class Zend_Controller_Router_RewriteTest_Request_Stub extends Zend_Controller_Request_Abstract -{ - protected $_host; - - public function __construct($host) { - $this->_host = $host; - } - - public function getHttpHost() { - return $this->_host; - } -} - -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Router_Route_HostnameTest::main") { - Zend_Controller_Router_Route_HostnameTest::main(); -} diff --git a/tests/Zend/Controller/Router/Route/ModuleTest.php b/tests/Zend/Controller/Router/Route/ModuleTest.php deleted file mode 100644 index 67c281266b2d86611ce1671f3c00a8a34e0babe2..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/Route/ModuleTest.php +++ /dev/null @@ -1,443 +0,0 @@ -<?php -// Call Zend_Controller_Router_Route_ModuleTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Controller_Router_Route_ModuleTest::main"); - - $basePath = realpath(dirname(__FILE__) . str_repeat(DIRECTORY_SEPARATOR . '..', 4)); - - set_include_path( - $basePath . DIRECTORY_SEPARATOR . 'tests' - . PATH_SEPARATOR . $basePath . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . get_include_path() - ); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -/** Zend_Controller_Router_Route_Module */ -require_once 'Zend/Controller/Router/Route/Module.php'; - -/** Zend_Controller_Front */ -require_once 'Zend/Controller/Front.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_Route_ModuleTest extends PHPUnit_Framework_TestCase -{ - - protected $_request; - protected $_dispatcher; - protected $route; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Router_Route_ModuleTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - $front->setParam('noErrorHandler', true) - ->setParam('noViewRenderer', true); - - $this->_dispatcher = $front->getDispatcher(); - - $this->_dispatcher->setControllerDirectory(array( - 'default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files', - 'mod' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin', - )); - - $defaults = array( - 'controller' => 'defctrl', - 'action' => 'defact', - 'module' => 'default' - ); - - require_once 'Zend/Controller/Request/Http.php'; - $this->_request = new Zend_Controller_Request_Http(); - $front->setRequest($this->_request); - - $this->route = new Zend_Controller_Router_Route_Module($defaults, $this->_dispatcher, $this->_request); - } - - public function testModuleMatch() - { - $values = $this->route->match('mod'); - - $this->assertType('array', $values); - $this->assertTrue(isset($values['module'])); - $this->assertEquals('mod', $values['module']); - } - - public function testModuleAndControllerMatch() - { - $values = $this->route->match('mod/con'); - $this->assertType('array', $values); - $this->assertTrue(isset($values['module'])); - $this->assertEquals('mod', $values['module']); - $this->assertTrue(isset($values['controller'])); - $this->assertEquals('con', $values['controller']); - } - - public function testModuleControllerAndActionMatch() - { - $values = $this->route->match('mod/con/act'); - $this->assertType('array', $values); - $this->assertTrue(isset($values['module'])); - $this->assertEquals('mod', $values['module']); - $this->assertTrue(isset($values['controller'])); - $this->assertEquals('con', $values['controller']); - $this->assertTrue(isset($values['action'])); - $this->assertEquals('act', $values['action']); - } - - public function testModuleControllerActionAndParamsMatch() - { - $values = $this->route->match('mod/con/act/var/val/foo'); - $this->assertType('array', $values); - $this->assertTrue(isset($values['module'])); - $this->assertEquals('mod', $values['module']); - $this->assertTrue(isset($values['controller'])); - $this->assertEquals('con', $values['controller']); - $this->assertTrue(isset($values['action'])); - $this->assertEquals('act', $values['action']); - $this->assertTrue(isset($values['var'])); - $this->assertEquals('val', $values['var']); - $this->assertTrue(array_key_exists('foo', $values), var_export($values, 1)); - $this->assertTrue(empty($values['foo'])); - } - - public function testControllerOnlyMatch() - { - $values = $this->route->match('con'); - $this->assertType('array', $values); - $this->assertTrue(isset($values['controller'])); - $this->assertEquals('con', $values['controller']); - } - - public function testControllerOnlyAndActionMatch() - { - $values = $this->route->match('con/act'); - $this->assertType('array', $values); - $this->assertTrue(isset($values['controller'])); - $this->assertEquals('con', $values['controller']); - $this->assertTrue(isset($values['action'])); - $this->assertEquals('act', $values['action']); - } - - public function testControllerOnlyActionAndParamsMatch() - { - $values = $this->route->match('con/act/var/val/foo'); - $this->assertType('array', $values); - $this->assertTrue(isset($values['controller'])); - $this->assertEquals('con', $values['controller']); - $this->assertTrue(isset($values['action'])); - $this->assertEquals('act', $values['action']); - $this->assertTrue(isset($values['var'])); - $this->assertEquals('val', $values['var']); - $this->assertTrue(array_key_exists('foo', $values), var_export($values, 1)); - $this->assertTrue(empty($values['foo'])); - } - - public function testModuleMatchWithControlKeysChange() - { - $this->_request->setModuleKey('m'); - $this->_request->setControllerKey('c'); - $this->_request->setActionKey('a'); - - $this->route = new Zend_Controller_Router_Route_Module(array(), $this->_dispatcher, $this->_request); - - $values = $this->route->match('mod/ctrl'); - - $this->assertType('array', $values); - $this->assertSame('mod', $values['m']); - $this->assertSame('ctrl', $values['c']); - $this->assertSame('index', $values['a']); - } - - public function testModuleMatchWithLateControlKeysChange() - { - $this->_request->setModuleKey('m'); - $this->_request->setControllerKey('c'); - $this->_request->setActionKey('a'); - - $values = $this->route->match('mod/ctrl'); - - $this->assertType('array', $values); - $this->assertSame('mod', $values['m'], var_export(array_keys($values), 1)); - $this->assertSame('ctrl', $values['c'], var_export(array_keys($values), 1)); - $this->assertSame('index', $values['a'], var_export(array_keys($values), 1)); - } - - public function testAssembleNoModuleOrController() - { - $params = array( - 'action' => 'act', - 'foo' => 'bar' - ); - $url = $this->route->assemble($params); - $this->assertEquals('defctrl/act/foo/bar', $url); - } - - public function testAssembleControllerOnly() - { - $params = array( - 'foo' => 'bar', - 'action' => 'act', - 'controller' => 'con' - ); - $url = $this->route->assemble($params); - - $this->assertEquals('con/act/foo/bar', $url); - } - - public function testAssembleModuleAndController() - { - $params = array( - 'foo' => 'bar', - 'action' => 'act', - 'controller' => 'con', - 'module' => 'mod' - ); - $url = $this->route->assemble($params); - $this->assertEquals('mod/con/act/foo/bar', $url); - } - - public function testAssembleNoController() - { - $params = array( - 'foo' => 'bar', - 'action' => 'act', - 'module' => 'mod' - ); - $url = $this->route->assemble($params); - $this->assertEquals('mod/defctrl/act/foo/bar', $url); - } - - public function testAssembleNoAction() - { - $params = array( - 'module' => 'mod', - 'controller' => 'ctrl' - ); - $url = $this->route->assemble($params); - $this->assertEquals('mod/ctrl', $url); - } - - public function testAssembleNoActionWithParams() - { - $params = array( - 'foo' => 'bar', - 'module' => 'mod', - 'controller' => 'ctrl' - ); - $url = $this->route->assemble($params); - $this->assertEquals('mod/ctrl/defact/foo/bar', $url); - } - - public function testAssembleNoModuleOrControllerMatched() - { - $this->route->match(''); - - $params = array( - 'action' => 'act', - 'foo' => 'bar' - ); - $url = $this->route->assemble($params); - $this->assertEquals('defctrl/act/foo/bar', $url); - } - - public function testAssembleControllerOnlyMatched() - { - $this->route->match('ctrl'); - - $params = array( - 'foo' => 'bar', - 'action' => 'act', - 'controller' => 'con' - ); - $url = $this->route->assemble($params); - - $this->assertEquals('con/act/foo/bar', $url); - } - - public function testAssembleModuleAndControllerMatched() - { - $this->route->match('mod/ctrl'); - - $params = array( - 'foo' => 'bar', - 'action' => 'act', - 'module' => 'm' - ); - $url = $this->route->assemble($params); - $this->assertEquals('m/ctrl/act/foo/bar', $url); - } - - public function testAssembleNoControllerMatched() - { - $this->route->match('mod'); - - $params = array( - 'foo' => 'bar', - 'action' => 'act', - 'module' => 'mod' - ); - $url = $this->route->assemble($params); - $this->assertEquals('mod/defctrl/act/foo/bar', $url); - } - - public function testAssembleNoActionMatched() - { - $this->route->match('mod/ctrl'); - - $params = array( - 'module' => 'def', - 'controller' => 'con' - ); - $url = $this->route->assemble($params); - $this->assertEquals('def/con', $url); - } - - public function testAssembleWithReset() - { - $values = $this->route->match('mod/con/act/sort/name'); - - $url = $this->route->assemble(array('action' => 'new'), true); - - $this->assertSame('defctrl/new', $url); - } - - public function testAssembleWithReset2() - { - $values = $this->route->match('mod/con/act/sort/name'); - - $url = $this->route->assemble(array('controller' => 'new'), true); - - $this->assertSame('new', $url); - } - - public function testAssembleWithReset3() - { - $values = $this->route->match('mod/con/act/sort/name'); - - $url = $this->route->assemble(array('controller' => 'new', 'action' => 'test'), true); - - $this->assertSame('new/test', $url); - } - - public function testAssembleResetOneVariable() - { - $values = $this->route->match('mod/con/act'); - - $url = $this->route->assemble(array('action' => null), false); - - $this->assertSame('mod/con', $url); - } - - public function testAssembleResetOneVariable2() - { - $values = $this->route->match('mod/con/act'); - - $url = $this->route->assemble(array('controller' => null), false); - - $this->assertSame('mod/defctrl/act', $url); - } - - public function testAssembleResetOneVariable3() - { - $values = $this->route->match('mod/con/act'); - - $url = $this->route->assemble(array('module' => null), false); - - $this->assertSame('con/act', $url); - } - - public function testAssembleDefaultModuleResetZF1415() - { - $values = $this->route->match('con/act'); - - $url = $this->route->assemble(array('controller' => 'foo', 'action' => 'bar'), true); - - $this->assertSame('foo/bar', $url); - } - - public function testAssembleDefaultModuleZF1415() - { - $values = $this->route->match('con/act'); - - $url = $this->route->assemble(array('controller' => 'foo', 'action' => 'bar'), false); - - $this->assertSame('foo/bar', $url); - } - - public function testAssembleDefaultModuleZF1415_2() - { - $values = $this->route->match('default/defctrl/defact'); - $url = $this->route->assemble(); - $this->assertSame('', $url); - - $values = $this->route->match('mod/defctrl/defact'); - $url = $this->route->assemble(); - $this->assertSame('mod', $url); - } - - public function testGetInstance() - { - require_once 'Zend/Config.php'; - - $routeConf = array( - 'defaults' => array( - 'controller' => 'ctrl' - ) - ); - - $config = new Zend_Config($routeConf); - $route = Zend_Controller_Router_Route_Module::getInstance($config); - - $this->assertType('Zend_Controller_Router_Route_Module', $route); - } - - public function testEncode() - { - $url = $this->route->assemble(array('controller' => 'My Controller'), false, true); - $this->assertEquals('My+Controller', $url); - - $url = $this->route->assemble(array('controller' => 'My Controller'), false, false); - $this->assertEquals('My Controller', $url); - - $token = $this->route->match('en/foo/id/My Value'); - - $url = $this->route->assemble(array(), false, true); - $this->assertEquals('en/foo/id/My+Value', $url); - - $url = $this->route->assemble(array('id' => 'My Other Value'), false, true); - $this->assertEquals('en/foo/id/My+Other+Value', $url); - - } - -} - -// Call Zend_Controller_Router_Route_ModuleTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Controller_Router_Route_ModuleTest::main") { - Zend_Controller_Router_Route_ModuleTest::main(); -} diff --git a/tests/Zend/Controller/Router/Route/RegexTest.php b/tests/Zend/Controller/Router/Route/RegexTest.php deleted file mode 100644 index f2fc0bf95986a9d27ab1cfc1e2ea3db1f038cc77..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/Route/RegexTest.php +++ /dev/null @@ -1,425 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Controller_Router_Route_Regex */ -require_once 'Zend/Controller/Router/Route/Regex.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_Route_RegexTest extends PHPUnit_Framework_TestCase -{ - - public function testStaticMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/all'); - $values = $route->match('users/all'); - - $this->assertSame(array(), $values); - } - - public function testStaticUTFMatch() - { - $route = new Zend_Controller_Router_Route_Regex('żółć'); - $values = $route->match('żółć'); - - $this->assertSame(array(), $values); - } - - public function testURLDecode() - { - $route = new Zend_Controller_Router_Route_Regex('żółć'); - $values = $route->match('%C5%BC%C3%B3%C5%82%C4%87'); - - $this->assertSame(array(), $values); - } - - public function testStaticNoMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/a/martel'); - $values = $route->match('users/a'); - - $this->assertSame(false, $values); - } - - public function testStaticMatchWithDefaults() - { - $route = new Zend_Controller_Router_Route_Regex('users/all', array('controller' => 'ctrl')); - $values = $route->match('users/all'); - - $this->assertSame(1, count($values)); - $this->assertSame('ctrl', $values['controller']); - } - - public function testRootRoute() - { - $route = new Zend_Controller_Router_Route_Regex(''); - $values = $route->match('/'); - - $this->assertSame(array(), $values); - } - - public function testVariableMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)'); - $values = $route->match('users/martel'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values[1]); - } - - public function testDoubleMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(user_(\d+).html)'); - $values = $route->match('users/user_1354.html'); - - $this->assertSame(2, count($values)); - $this->assertSame('user_1354.html', $values[1]); - $this->assertSame('1354', $values[2]); - } - - public function testNegativeMatch() - { - - $route = new Zend_Controller_Router_Route_Regex('((?!admin|moderator).+)', - array('module' => 'index', 'controller' => 'index'), - array(1 => 'action') - ); - - $values = $route->match('users'); - - $this->assertSame(3, count($values)); - $this->assertSame('index', $values['module']); - $this->assertSame('index', $values['controller']); - $this->assertSame('users', $values['action']); - } - - public function testNumericDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array(1 => 'martel')); - $values = $route->match('users'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values[1]); - } - - public function testVariableMatchWithNumericDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array(1 => 'martel')); - $values = $route->match('users/vicki'); - - $this->assertSame(1, count($values)); - $this->assertSame('vicki', $values[1]); - } - - public function testNamedVariableMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(?P<username>.+)'); - $values = $route->match('users/martel'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values[1]); - } - - public function testMappedVariableMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, array(1 => 'username')); - $values = $route->match('users/martel'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values['username']); - } - - public function testMappedVariableWithDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users(?:/(.+))?', array('username' => 'martel'), array(1 => 'username')); - $values = $route->match('users'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values['username']); - } - - public function testMappedVariableWithNamedSubpattern() - { - $route = new Zend_Controller_Router_Route_Regex('users/(?P<name>.+)', null, array(1 => 'username')); - $values = $route->match('users/martel'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values['username']); - } - - public function testOptionalVar() - { - $route = new Zend_Controller_Router_Route_Regex('users/(\w+)/?(?:p/(\d+))?', null, array(1 => 'username', 2 => 'page')); - $values = $route->match('users/martel/p/1'); - - $this->assertSame(2, count($values)); - $this->assertSame('martel', $values['username']); - $this->assertSame('1', $values['page']); - } - - public function testEmptyOptionalVar() - { - $route = new Zend_Controller_Router_Route_Regex('users/(\w+)/?(?:p/(\d+))?', null, array(1 => 'username', 2 => 'page')); - $values = $route->match('users/martel'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values['username']); - } - - public function testMixedMap() - { - $route = new Zend_Controller_Router_Route_Regex('users/(\w+)/?(?:p/(\d+))?', null, array(1 => 'username')); - $values = $route->match('users/martel/p/1'); - - $this->assertSame(2, count($values)); - $this->assertSame('martel', $values['username']); - $this->assertSame('1', $values[2]); - } - - public function testNumericDefaultWithMap() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array(1 => 'martel'), array(1 => 'username')); - $values = $route->match('users'); - - $this->assertSame(1, count($values)); - $this->assertSame('martel', $values['username']); - } - - public function testMixedMapWithDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/(\w+)/?(?:p/(\d+))?', array(2 => '1'), array(1 => 'username')); - $values = $route->match('users/martel/p/10'); - - $this->assertSame(2, count($values)); - $this->assertSame('martel', $values['username']); - $this->assertSame('10', $values[2]); - } - - public function testMixedMapWithDefaults2() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(\w+)?/?(?:p/(\d+))?', array(2 => '1', 'username' => 'martel'), array(1 => 'username')); - $values = $route->match('users'); - - $this->assertSame(2, count($values)); - $this->assertSame('martel', $values['username']); - $this->assertSame('1', $values[2]); - } - - public function testOptionalVarWithMapAndDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/(\w+)/?(?:p/(\d+))?', array('page' => '1', 'username' => 'martel'), array(1 => 'username', 2 => 'page')); - $values = $route->match('users/martel'); - - $this->assertSame(2, count($values)); - $this->assertSame('martel', $values['username']); - $this->assertSame('1', $values['page']); - } - - public function testOptionalVarWithMapAndNumericDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/(\w+)/?(?:p/(\d+))?', array(2 => '1'), array(2 => 'page')); - $values = $route->match('users/martel'); - - $this->assertSame(2, count($values)); - $this->assertSame('martel', $values[1]); - $this->assertSame('1', $values['page']); - } - - public function testMappedAndNumericDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(\w+)?', array(1 => 'martel', 'username' => 'vicki'), array(1 => 'username')); - $values = $route->match('users'); - - // Matches both defaults but the one defined last is used - - $this->assertSame(1, count($values)); - $this->assertSame('vicki', $values['username']); - } - - public function testAssemble() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, array(1 => 'username'), 'users/%s'); - $values = $route->match('users/martel'); - - $url = $route->assemble(); - $this->assertSame('users/martel', $url); - } - - public function testAssembleWithDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array(1 => 'martel'), null, 'users/%s'); - $values = $route->match('users'); - - $url = $route->assemble(); - $this->assertSame('users/martel', $url); - } - - public function testAssembleWithMappedDefault() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array('username' => 'martel'), array(1 => 'username'), 'users/%s'); - $values = $route->match('users'); - - $url = $route->assemble(); - $this->assertSame('users/martel', $url); - } - - public function testAssembleWithData() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, null, 'users/%s'); - $values = $route->match('users/martel'); - - $url = $route->assemble(array(1 => 'vicki')); - $this->assertSame('users/vicki', $url); - } - - public function testAssembleWithMappedVariable() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, array(1 => 'username'), 'users/%s'); - $values = $route->match('users/martel'); - - $url = $route->assemble(array('username' => 'vicki')); - $this->assertSame('users/vicki', $url); - } - - public function testAssembleWithMappedVariableAndNumericKey() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, array(1 => 'username'), 'users/%s'); - $values = $route->match('users/martel'); - - $url = $route->assemble(array(1 => 'vicki')); - $this->assertSame('users/vicki', $url); - } - - public function testAssembleWithoutMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, null, 'users/%s'); - - try { - $url = $route->assemble(); - $this->fail(); - } catch (Exception $e) {} - } - - public function testAssembleWithDefaultWithoutMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array(1 => 'martel'), null, 'users/%s'); - - $url = $route->assemble(); - $this->assertSame('users/martel', $url); - } - - public function testAssembleWithMappedDefaultWithoutMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/?(.+)?', array('username' => 'martel'), array(1 => 'username'), 'users/%s'); - - $url = $route->assemble(); - $this->assertSame('users/martel', $url); - } - - public function testAssembleWithDataWithoutMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, null, 'users/%s'); - - $url = $route->assemble(array(1 => 'vicki')); - $this->assertSame('users/vicki', $url); - } - - public function testAssembleWithMappedVariableWithoutMatch() - { - $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, array(1 => 'username'), 'users/%s'); - - $url = $route->assemble(array('username' => 'vicki')); - $this->assertSame('users/vicki', $url); - } - - - public function testAssembleZF1332() - { - $route = new Zend_Controller_Router_Route_Regex( - '(.+)\.([0-9]+)-([0-9]+)\.html', - array('module' => 'default', 'controller' => 'content.item', 'action' => 'forward'), - array(1 => 'name', 2 => 'id', 3 => 'class'), - '%s.%s-%s.html' - ); - - $route->match('uml-explained-composition.72-3.html'); - - $url = $route->assemble(); - - $this->assertSame('uml-explained-composition.72-3.html', $url); - - $url = $route->assemble(array('name' => 'post_name', 'id' => '12', 'class' => 5)); - - $this->assertSame('post_name.12-5.html', $url); - } - - public function testGetInstance() - { - require_once 'Zend/Config.php'; - - $routeConf = array( - 'route' => 'forum/(\d+)', - 'reverse' => 'forum/%d', - 'defaults' => array( - 'controller' => 'ctrl' - ) - ); - /* numeric Zend_Config indexes don't work at the moment - 'map' => array( - '1' => 'forum_id' - ) - */ - - $config = new Zend_Config($routeConf); - $route = Zend_Controller_Router_Route_Regex::getInstance($config); - - $this->assertType('Zend_Controller_Router_Route_Regex', $route); - - $values = $route->match('forum/1'); - - $this->assertSame('ctrl', $values['controller']); - - } - - /** - * @issue ZF-2301 - */ - public function testAssemblyOfRouteWithMergedMatchedParts() - { - $route = new Zend_Controller_Router_Route_Regex( - 'itemlist(?:/(\d+))?', - array('page' => 1), // Defaults - array(1 => 'page'), // Parameter map - 'itemlist/%d' - ); - - // make sure defaults work - $this->assertEquals(array('page' => 1), $route->match('/itemlist/')); - - // make sure default assembly work - $this->assertEquals('itemlist/1', $route->assemble()); - - // make sure the route is parsed correctly - $this->assertEquals(array('page' => 2), $route->match('/itemlist/2')); - - // check to make sure that the default assembly will return with default 1 (previously defined) - $this->assertEquals('itemlist/2', $route->assemble()); - - // check to make sure that the assembly will return with provided page=3 in the correct place - $this->assertEquals('itemlist/3', $route->assemble(array('page' => 3))); - - // check to make sure that the assembly can reset a single parameter - $this->assertEquals('itemlist/1', $route->assemble(array('page' => null))); - - } - -} diff --git a/tests/Zend/Controller/Router/Route/StaticTest.php b/tests/Zend/Controller/Router/Route/StaticTest.php deleted file mode 100644 index 2f3e6b2184ee910afc14ffe91da38f40df7f80f3..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/Route/StaticTest.php +++ /dev/null @@ -1,116 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -/** Zend_Controller_Router_Route */ -require_once 'Zend/Controller/Router/Route/Static.php'; - -/** PHPUnit test case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_Route_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testStaticMatch() - { - $route = new Zend_Controller_Router_Route_Static('users/all'); - $values = $route->match('users/all'); - - $this->assertType('array', $values); - } - - public function testStaticMatchFailure() - { - $route = new Zend_Controller_Router_Route_Static('archive/2006'); - $values = $route->match('users/all'); - - $this->assertSame(false, $values); - } - - public function testStaticMatchWithDefaults() - { - $route = new Zend_Controller_Router_Route_Static('users/all', - array('controller' => 'ctrl', 'action' => 'act')); - $values = $route->match('users/all'); - - $this->assertType('array', $values); - $this->assertSame('ctrl', $values['controller']); - $this->assertSame('act', $values['action']); - } - - public function testStaticUTFMatch() - { - $route = new Zend_Controller_Router_Route_Static('żółć'); - $values = $route->match('żółć'); - - $this->assertType('array', $values); - } - - public function testRootRoute() - { - $route = new Zend_Controller_Router_Route_Static('/'); - $values = $route->match(''); - - $this->assertSame(array(), $values); - } - - public function testAssemble() - { - $route = new Zend_Controller_Router_Route_Static('/about'); - $url = $route->assemble(); - - $this->assertSame('about', $url); - } - - public function testGetDefaults() - { - $route = new Zend_Controller_Router_Route_Static('users/all', - array('controller' => 'ctrl', 'action' => 'act')); - - $values = $route->getDefaults(); - - $this->assertType('array', $values); - $this->assertSame('ctrl', $values['controller']); - $this->assertSame('act', $values['action']); - } - - public function testGetDefault() - { - $route = new Zend_Controller_Router_Route_Static('users/all', - array('controller' => 'ctrl', 'action' => 'act')); - - $this->assertSame('ctrl', $route->getDefault('controller')); - $this->assertSame(null, $route->getDefault('bogus')); - } - - public function testGetInstance() - { - require_once 'Zend/Config.php'; - - $routeConf = array( - 'route' => 'users/all', - 'defaults' => array( - 'controller' => 'ctrl' - ) - ); - - $config = new Zend_Config($routeConf); - $route = Zend_Controller_Router_Route_Static::getInstance($config); - - $this->assertType('Zend_Controller_Router_Route_Static', $route); - - $values = $route->match('users/all'); - - $this->assertSame('ctrl', $values['controller']); - - } - -} diff --git a/tests/Zend/Controller/Router/RouteTest.php b/tests/Zend/Controller/Router/RouteTest.php deleted file mode 100644 index 1ea2dbc220b5eab9414b6e317057783699772446..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/Router/RouteTest.php +++ /dev/null @@ -1,591 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ - -/** @see Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** @see Zend_Controller_Router_Route */ -require_once 'Zend/Controller/Router/Route.php'; - -/** PHPUnit test case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - */ -class Zend_Controller_Router_RouteTest extends PHPUnit_Framework_TestCase -{ - /** - * Server backup - * - * @var array - */ - protected $_server = array(); - - /** - * Setup test - * - * @return void - */ - public function setUp() - { - // Backup server array - $this->_server = $_SERVER; - - // Clean host env - unset($_SERVER['HTTP_HOST'], - $_SERVER['HTTPS'], $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']); - } - - /** - * Clean - * - * @return void - */ - public function tearDown() - { - // Restore server array - $_SERVER = $this->_server; - } - - public function testStaticMatch() - { - $route = new Zend_Controller_Router_Route('users/all'); - $values = $route->match('users/all'); - - $this->assertSame(array(), $values); - } - - public function testStaticUTFMatch() - { - $route = new Zend_Controller_Router_Route('żółć'); - $values = $route->match('żółć'); - - $this->assertSame(array(), $values); - } - - public function testURLDecode() - { - $route = new Zend_Controller_Router_Route('żółć'); - $values = $route->match('%C5%BC%C3%B3%C5%82%C4%87'); - - $this->assertSame(array(), $values); - } - - public function testStaticPathShorterThanParts() - { - $route = new Zend_Controller_Router_Route('users/a/martel'); - $values = $route->match('users/a'); - - $this->assertSame(false, $values); - } - - public function testStaticPathLongerThanParts() - { - $route = new Zend_Controller_Router_Route('users/a'); - $values = $route->match('users/a/martel'); - - $this->assertEquals(false, $values); - } - - public function testStaticMatchWithDefaults() - { - $route = new Zend_Controller_Router_Route('users/all', array('controller' => 'ctrl')); - $values = $route->match('users/all'); - - $this->assertEquals('ctrl', $values['controller']); - } - - public function testNotMatched() - { - $route = new Zend_Controller_Router_Route('users/all'); - $values = $route->match('users/martel'); - - $this->assertEquals(false, $values); - } - - public function testNotMatchedWithVariablesAndDefaults() - { - $route = new Zend_Controller_Router_Route(':controller/:action', array('controller' => 'index', 'action' => 'index')); - $values = $route->match('archive/action/bogus'); - - $this->assertEquals(false, $values); - } - - - public function testNotMatchedWithVariablesAndStatic() - { - $route = new Zend_Controller_Router_Route('archive/:year/:month'); - $values = $route->match('ctrl/act/2000'); - - $this->assertEquals(false, $values); - } - - public function testStaticMatchWithWildcard() - { - $route = new Zend_Controller_Router_Route('news/view/*', array('controller' => 'news', 'action' => 'view')); - $values = $route->match('news/view/show/all/year/2000/empty'); - - $this->assertEquals('news', $values['controller']); - $this->assertEquals('view', $values['action']); - $this->assertEquals('all', $values['show']); - $this->assertEquals('2000', $values['year']); - $this->assertEquals(null, $values['empty']); - } - - public function testWildcardWithUTF() - { - $route = new Zend_Controller_Router_Route('news/*', array('controller' => 'news', 'action' => 'view')); - $values = $route->match('news/klucz/wartość/wskaźnik/wartość'); - - $this->assertEquals('news', $values['controller']); - $this->assertEquals('view', $values['action']); - $this->assertEquals('wartość', $values['klucz']); - $this->assertEquals('wartość', $values['wskaźnik']); - } - - public function testWildcardURLDecode() - { - $route = new Zend_Controller_Router_Route('news/*', array('controller' => 'news', 'action' => 'view')); - $values = $route->match('news/wska%C5%BAnik/warto%C5%9B%C4%87'); - - $this->assertEquals('news', $values['controller']); - $this->assertEquals('view', $values['action']); - $this->assertEquals('wartość', $values['wskaźnik']); - } - - public function testVariableValues() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year'); - $values = $route->match('ctrl/act/2000'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertEquals('2000', $values['year']); - } - - public function testVariableUTFValues() - { - $route = new Zend_Controller_Router_Route('test/:param'); - $values = $route->match('test/aä'); - - $this->assertEquals('aä', $values['param']); - } - - public function testOneVariableValue() - { - $route = new Zend_Controller_Router_Route(':action', array('controller' => 'ctrl', 'action' => 'action')); - $values = $route->match('act'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - } - - public function testVariablesWithDefault() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', array('year' => '2006')); - $values = $route->match('ctrl/act'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertEquals('2006', $values['year']); - } - - public function testVariablesWithNullDefault() // Kevin McArthur - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', array('year' => null)); - $values = $route->match('ctrl/act'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertNull($values['year']); - } - - public function testVariablesWithDefaultAndValue() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', array('year' => '2006')); - $values = $route->match('ctrl/act/2000'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertEquals('2000', $values['year']); - } - - public function testVariablesWithRequirementAndValue() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', null, array('year' => '\d+')); - $values = $route->match('ctrl/act/2000'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertEquals('2000', $values['year']); - } - - public function testVariablesWithRequirementAndIncorrectValue() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', null, array('year' => '\d+')); - $values = $route->match('ctrl/act/2000t'); - - $this->assertEquals(false, $values); - } - - public function testVariablesWithDefaultAndRequirement() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', array('year' => '2006'), array('year' => '\d+')); - $values = $route->match('ctrl/act/2000'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertEquals('2000', $values['year']); - } - - public function testVariablesWithDefaultAndRequirementAndIncorrectValue() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', array('year' => '2006'), array('year' => '\d+')); - $values = $route->match('ctrl/act/2000t'); - - $this->assertEquals(false, $values); - } - - public function testVariablesWithDefaultAndRequirementAndWithoutValue() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:year', array('year' => '2006'), array('year' => '\d+')); - $values = $route->match('ctrl/act'); - - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - $this->assertEquals('2006', $values['year']); - } - - public function testVariablesWithWildcardAndNumericKey() - { - $route = new Zend_Controller_Router_Route(':controller/:action/:next/*'); - $values = $route->match('c/a/next/2000/show/all/sort/name'); - - $this->assertEquals('c', $values['controller']); - $this->assertEquals('a', $values['action']); - $this->assertEquals('next', $values['next']); - $this->assertTrue(array_key_exists('2000', $values)); - } - - public function testRootRoute() - { - $route = new Zend_Controller_Router_Route('/'); - $values = $route->match(''); - - $this->assertEquals(array(), $values); - } - - public function testAssemble() - { - $route = new Zend_Controller_Router_Route('authors/:name'); - $url = $route->assemble(array('name' => 'martel')); - - $this->assertEquals('authors/martel', $url); - } - - public function testAssembleWithoutValue() - { - $route = new Zend_Controller_Router_Route('authors/:name'); - try { - $url = $route->assemble(); - } catch (Exception $e) { - return true; - } - - $this->fail(); - } - - public function testAssembleWithDefault() - { - $route = new Zend_Controller_Router_Route('authors/:name', array('name' => 'martel')); - $url = $route->assemble(); - - $this->assertEquals('authors', $url); - } - - public function testAssembleWithDefaultAndValue() - { - $route = new Zend_Controller_Router_Route('authors/:name', array('name' => 'martel')); - $url = $route->assemble(array('name' => 'mike')); - - $this->assertEquals('authors/mike', $url); - } - - public function testAssembleWithWildcardMap() - { - $route = new Zend_Controller_Router_Route('authors/:name/*'); - $url = $route->assemble(array('name' => 'martel')); - - $this->assertEquals('authors/martel', $url); - } - - public function testAssembleWithReset() - { - $route = new Zend_Controller_Router_Route('archive/:year/*', array('controller' => 'archive', 'action' => 'show')); - $values = $route->match('archive/2006/show/all/sort/name'); - - $url = $route->assemble(array('year' => '2005'), true); - - $this->assertEquals('archive/2005', $url); - } - - public function testAssembleWithReset2() - { - $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'archive', 'action' => 'show')); - $values = $route->match('users/list'); - - $url = $route->assemble(array(), true); - - $this->assertEquals('', $url); - } - - public function testAssembleWithReset3() - { - $route = new Zend_Controller_Router_Route('archive/:year/*', array('controller' => 'archive', 'action' => 'show', 'year' => 2005)); - $values = $route->match('archive/2006/show/all/sort/name'); - - $url = $route->assemble(array(), true); - - $this->assertEquals('archive', $url); - } - - public function testAssembleWithReset4() - { - $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'archive', 'action' => 'show')); - $values = $route->match('users/list'); - - $url = $route->assemble(array('action' => 'display'), true); - - $this->assertEquals('archive/display', $url); - } - - public function testAssembleWithReset5() - { - $route = new Zend_Controller_Router_Route('*', array('controller' => 'index', 'action' => 'index')); - $values = $route->match('key1/value1/key2/value2'); - - $url = $route->assemble(array('key1' => 'newvalue'), true); - - $this->assertEquals('key1/newvalue', $url); - } - - public function testAssembleWithWildcardAndAdditionalParameters() - { - $route = new Zend_Controller_Router_Route('authors/:name/*'); - $url = $route->assemble(array('name' => 'martel', 'var' => 'value')); - - $this->assertEquals('authors/martel/var/value', $url); - } - - public function testAssembleWithUrlVariablesReuse() - { - $route = new Zend_Controller_Router_Route('archives/:year/:month'); - $values = $route->match('archives/2006/07'); - $this->assertType('array', $values); - - $url = $route->assemble(array('month' => '03')); - $this->assertEquals('archives/2006/03', $url); - } - - public function testWildcardUrlVariablesOverwriting() - { - $route = new Zend_Controller_Router_Route('archives/:year/:month/*', array('controller' => 'archive')); - $values = $route->match('archives/2006/07/controller/test/year/10000/sort/author'); - $this->assertType('array', $values); - - $this->assertEquals('archive', $values['controller']); - $this->assertEquals('2006', $values['year']); - $this->assertEquals('07', $values['month']); - $this->assertEquals('author', $values['sort']); - } - - public function testGetDefaults() - { - $route = new Zend_Controller_Router_Route('users/all', - array('controller' => 'ctrl', 'action' => 'act')); - - $values = $route->getDefaults(); - - $this->assertType('array', $values); - $this->assertEquals('ctrl', $values['controller']); - $this->assertEquals('act', $values['action']); - } - - public function testGetDefault() - { - $route = new Zend_Controller_Router_Route('users/all', - array('controller' => 'ctrl', 'action' => 'act')); - - $this->assertEquals('ctrl', $route->getDefault('controller')); - $this->assertEquals(null, $route->getDefault('bogus')); - } - - public function testGetInstance() - { - require_once 'Zend/Config.php'; - - $routeConf = array( - 'route' => 'users/all', - 'defaults' => array( - 'controller' => 'ctrl' - ) - ); - - $config = new Zend_Config($routeConf); - $route = Zend_Controller_Router_Route::getInstance($config); - - $this->assertType('Zend_Controller_Router_Route', $route); - - $values = $route->match('users/all'); - - $this->assertEquals('ctrl', $values['controller']); - - } - - public function testAssembleResetDefaults() - { - $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index')); - - $values = $route->match('news/view/id/3'); - - $url = $route->assemble(array('controller' => null)); - $this->assertEquals('index/view/id/3', $url); - - $url = $route->assemble(array('action' => null)); - $this->assertEquals('news/index/id/3', $url); - - $url = $route->assemble(array('action' => null, 'id' => null)); - $this->assertEquals('news', $url); - } - - public function testAssembleWithRemovedDefaults() // Test for ZF-1197 - { - $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index')); - - $url = $route->assemble(array('id' => 3)); - $this->assertEquals('index/index/id/3', $url); - - $url = $route->assemble(array('action' => 'test')); - $this->assertEquals('index/test', $url); - - $url = $route->assemble(array('action' => 'test', 'id' => 3)); - $this->assertEquals('index/test/id/3', $url); - - $url = $route->assemble(array('controller' => 'test')); - $this->assertEquals('test', $url); - - $url = $route->assemble(array('controller' => 'test', 'action' => 'test')); - $this->assertEquals('test/test', $url); - - $url = $route->assemble(array('controller' => 'test', 'id' => 3)); - $this->assertEquals('test/index/id/3', $url); - - $url = $route->assemble(array()); - $this->assertEquals('', $url); - - $route->match('ctrl'); - - $url = $route->assemble(array('id' => 3)); - $this->assertEquals('ctrl/index/id/3', $url); - - $url = $route->assemble(array('action' => 'test')); - $this->assertEquals('ctrl/test', $url); - - $url = $route->assemble(); - $this->assertEquals('ctrl', $url); - - $route->match('index'); - - $url = $route->assemble(); - $this->assertEquals('', $url); - } - - /** - * Test guarding performance. Test may be failing on slow systems and shouldn't be failing on production. - * This test is not critical in nature - it allows keeping changes performant. - */ - public function testRoutePerformance() - { - $count = 10000; - $expectedTime = 1; - - $info = "This test may be failing on slow systems and shouldn't be failing on production. Tests if " . ($count / 10) . " complicated routes can be matched in a tenth of a second. Actual test matches " . $count . " times to make the test more reliable."; - - $route = new Zend_Controller_Router_Route('archives/:year/:month/*', array('controller' => 'archive')); - - $time_start = microtime(true); - - for ($i = 1; $i <= $count; $i++) { - $values = $route->match('archives/2006/' . $i . '/controller/test/year/' . $i . '/sort/author'); - } - - $time_end = microtime(true); - $time = $time_end - $time_start; - - $this->assertLessThan($expectedTime, $time, $info); - } - - public function testForZF2543() - { - $route = new Zend_Controller_Router_Route('families/:action/*', array('module' => 'default', 'controller' => 'categories', 'action' => 'index')); - $this->assertEquals('families', $route->assemble()); - - $values = $route->match('families/edit/id/4'); - $this->assertType('array', $values); - - $this->assertEquals('families/edit/id/4', $route->assemble()); - } - - public function testEncode() - { - $route = new Zend_Controller_Router_Route(':controller/:action/*', array('controller' => 'index', 'action' => 'index')); - - $url = $route->assemble(array('controller' => 'My Controller'), false, true); - $this->assertEquals('My+Controller', $url); - - $url = $route->assemble(array('controller' => 'My Controller'), false, false); - $this->assertEquals('My Controller', $url); - - $token = $route->match('en/foo/id/My Value'); - - $url = $route->assemble(array(), false, true); - $this->assertEquals('en/foo/id/My+Value', $url); - - $url = $route->assemble(array('id' => 'My Other Value'), false, true); - $this->assertEquals('en/foo/id/My+Other+Value', $url); - - $route = new Zend_Controller_Router_Route(':controller/*', array('controller' => 'My Controller')); - $url = $route->assemble(array('id' => 1), false, true); - $this->assertEquals('My+Controller/id/1', $url); - } - - public function testPartialMatch() - { - $this->markTestSkipped('Route features not ready'); - - $route = new Zend_Controller_Router_Route(':lang/:temp', array('lang' => 'pl'), array('temp' => '\d+')); - - $values = $route->match('en/tmp/ctrl/action/id/1', true); - - $this->assertFalse($values); - - $route = new Zend_Controller_Router_Route(':lang/:temp', array('lang' => 'pl')); - - $values = $route->match('en/tmp/ctrl/action/id/1', true); - - $this->assertType('array', $values); - $this->assertEquals('en', $values['lang']); - $this->assertEquals('tmp', $values['temp']); - $this->assertEquals(6, $values[null]); - - } - - -} diff --git a/tests/Zend/Controller/_files/Admin/BazController.php b/tests/Zend/Controller/_files/Admin/BazController.php deleted file mode 100644 index dc2b9616fc91360831936d043464567260f50bd5..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/Admin/BazController.php +++ /dev/null @@ -1,70 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BazController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Admin_BazController extends Zend_Controller_Action -{ - - /** - * Test Function for PreDispatch - * - * @return void - */ - public function preDispatch() - { - $this->_response->appendBody("preDispatch called\n"); - } - - /** - * Test Function for postDispatch - * - * @return void - */ - public function postDispatch() - { - $this->_response->appendBody("postDispatch called\n"); - } - - /** - * Test Function for barAction - * - * @return void - */ - public function barAction() - { - $this->_response->appendBody("Admin's Baz::bar action called\n"); - } - -} diff --git a/tests/Zend/Controller/_files/Admin/FooBarController.php b/tests/Zend/Controller/_files/Admin/FooBarController.php deleted file mode 100644 index 57aa5b0f3a209f6488b368b53bb6b9ba57f07629..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/Admin/FooBarController.php +++ /dev/null @@ -1,51 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FooBarController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; -require_once dirname(__FILE__) . '/../FooController.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Admin_FooBarController extends FooController -{ - - /** - * Test Function for bazBatAction - * - * @return void - */ - public function bazBatAction() - { - $this->_response->appendBody("Admin_FooBar::bazBat action called\n"); - } - -} diff --git a/tests/Zend/Controller/_files/Admin/FooController.php b/tests/Zend/Controller/_files/Admin/FooController.php deleted file mode 100644 index 9999dbbc92096b713bfb56a146b3c7d0ef88cc4c..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/Admin/FooController.php +++ /dev/null @@ -1,61 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FooController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; -require_once dirname(__FILE__) . '/../FooController.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Admin_FooController extends FooController -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $this->_response->appendBody("Admin_Foo::index action called\n"); - } - - /** - * Test Function for barAction - * - * @return void - */ - public function barAction() - { - $this->_response->appendBody("Admin_Foo::bar action called\n"); - } - -} diff --git a/tests/Zend/Controller/_files/BazController.php b/tests/Zend/Controller/_files/BazController.php deleted file mode 100644 index 54197297202e49f31e97b4e40a2c11cd5002072b..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/BazController.php +++ /dev/null @@ -1,70 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BazController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class BazController extends Zend_Controller_Action -{ - - /** - * Test Function for preDispatch - * - * @return void - */ - public function preDispatch() - { - $this->_response->appendBody("preDispatch called\n"); - } - - /** - * Test Function for postDispatch - * - * @return void - */ - public function postDispatch() - { - $this->_response->appendBody("postDispatch called\n"); - } - - /** - * Test Function for barAction - * - * @return void - */ - public function barAction() - { - $this->_response->appendBody("Default Baz::bar action called\n"); - } - -} diff --git a/tests/Zend/Controller/_files/EmptyController.php b/tests/Zend/Controller/_files/EmptyController.php deleted file mode 100644 index 69447ba99f3590bc6b2701cb98ce7dc8b0bb0693..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/EmptyController.php +++ /dev/null @@ -1,49 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EmptyController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class EmptyController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - } - -} diff --git a/tests/Zend/Controller/_files/FooBarController.php b/tests/Zend/Controller/_files/FooBarController.php deleted file mode 100644 index 40f2d21ed2ac80b2f66001f64d3c400be8d8ffc7..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/FooBarController.php +++ /dev/null @@ -1,50 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FooBarController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class FooBarController extends Zend_Controller_Action -{ - - /** - * Test Function for bazBatAction - * - * @return void - */ - public function bazBatAction() - { - $this->render(); - } - -} diff --git a/tests/Zend/Controller/_files/FooController.php b/tests/Zend/Controller/_files/FooController.php deleted file mode 100644 index 305a1b51a266989a0932f116ab2a9f56c7bdceb4..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/FooController.php +++ /dev/null @@ -1,70 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FooController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class FooController extends Zend_Controller_Action -{ - - /** - * Test Function for preDispatch - * - * @return void - */ - public function preDispatch() - { - $this->_response->appendBody("preDispatch called\n"); - } - - /** - * Test Function for postDispatch - * - * @return void - */ - public function postDispatch() - { - $this->_response->appendBody("postDispatch called\n"); - } - - /** - * Test Function for barAction - * - * @return void - */ - public function barAction() - { - $this->_response->appendBody("Bar action called\n"); - } - -} diff --git a/tests/Zend/Controller/_files/HelperBrokerController.php b/tests/Zend/Controller/_files/HelperBrokerController.php deleted file mode 100644 index 0dbebfc60969547dd85b47faa4bfd95d5520aaf6..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/HelperBrokerController.php +++ /dev/null @@ -1,95 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class HelperBrokerController extends Zend_Controller_Action -{ - - /** - * Test Function for testGetRedirectorAction - * - * @return void - */ - public function testGetRedirectorAction() - { - $redirector = $this->_helper->getHelper('Redirector'); - $this->getResponse()->appendBody(get_class($redirector)); - } - - /** - * Test Function for testHelperViaMagicGetAction - * - * @return void - */ - public function testHelperViaMagicGetAction() - { - $redirector = $this->_helper->Redirector; - $this->getResponse()->appendBody(get_class($redirector)); - } - - /** - * Test Function for testHelperViaMagicCallAction - * - * @return void - */ - public function testHelperViaMagicCallAction() - { - $this->getResponse()->appendBody($this->_helper->TestHelper()); - } - - /** - * Test Function for testBadHelperAction - * - * @return void - */ - public function testBadHelperAction() - { - try { - $this->_helper->getHelper('NonExistentHelper'); - } catch (Exception $e) { - $this->getResponse()->appendBody($e->getMessage()); - } - } - - /** - * Test Function for testCustomHelperAction - * - * @return void - */ - public function testCustomHelperAction() - { - $this->getResponse()->appendBody(get_class($this->_helper->TestHelper)); - } - -} diff --git a/tests/Zend/Controller/_files/HelperFlashMessengerController.php b/tests/Zend/Controller/_files/HelperFlashMessengerController.php deleted file mode 100644 index 2154bceb0024713bbd9df20332d62bdf6c73563a..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/HelperFlashMessengerController.php +++ /dev/null @@ -1,76 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class HelperFlashMessengerController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $flashmessenger = $this->_helper->FlashMessenger; - $this->getResponse()->appendBody(get_class($flashmessenger)); - - $messages = $flashmessenger->getCurrentMessages(); - if (count($messages) === 0) { - $this->getResponse()->appendBody('1'); - } - - $flashmessenger->addMessage('My message'); - $messages = $flashmessenger->getCurrentMessages(); - - if (implode('', $messages) === 'My message') { - $this->getResponse()->appendBody('2'); - } - - if ($flashmessenger->count() === 0) { - $this->getResponse()->appendBody('3'); - } - - if ($flashmessenger->hasMessages() === false) { - $this->getResponse()->appendBody('4'); - } - - if ($flashmessenger->getRequest() === $this->getRequest()) { - $this->getResponse()->appendBody('5'); - } - - if ($flashmessenger->getResponse() === $this->getResponse()) { - $this->getResponse()->appendBody('6'); - } - - } - -} diff --git a/tests/Zend/Controller/_files/Helpers/TestHelper.php b/tests/Zend/Controller/_files/Helpers/TestHelper.php deleted file mode 100644 index aee7215fbb12bb7ce5bd5af103c89e46a7643b57..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/Helpers/TestHelper.php +++ /dev/null @@ -1,47 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class MyApp_TestHelper extends Zend_Controller_Action_Helper_Abstract -{ - - /** - * Test Function for direct - * - * @return void - */ - public function direct() - { - $this->getResponse()->appendBody('running direct call'); - } - -} diff --git a/tests/Zend/Controller/_files/Helpers/Url.php b/tests/Zend/Controller/_files/Helpers/Url.php deleted file mode 100644 index 684780ea2791d0c35d8c76e51f13526423030126..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/Helpers/Url.php +++ /dev/null @@ -1,47 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Url.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class MyApp_Url extends Zend_Controller_Action_Helper_Abstract -{ - - /** - * Test Function for direct - * - * @return void - */ - public function direct() - { - $this->getResponse()->appendBody('running direct call'); - } - -} diff --git a/tests/Zend/Controller/_files/IndexController.php b/tests/Zend/Controller/_files/IndexController.php deleted file mode 100644 index 82218a6b545a44001c06f60a82bd0cee1c324088..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/IndexController.php +++ /dev/null @@ -1,102 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IndexController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class IndexController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $this->_response->appendBody("Index action called\n"); - } - - /** - * Test Function for prefixAction - * - * @return void - */ - public function prefixAction() - { - $this->_response->appendBody("Prefix action called\n"); - } - - /** - * Test Function for argsAction - * - * @return void - */ - public function argsAction() - { - $args = ''; - foreach ($this->getInvokeArgs() as $key => $value) { - $args .= $key . ': ' . $value . '; '; - } - - $this->_response->appendBody('Args action called with params ' . $args . "\n"); - } - - /** - * Test Function for replaceAction - * - * @return void - */ - public function replaceAction() - { - $request = new Zend_Controller_Request_Http(); - $request->setControllerName('index') - ->setActionName('reset') - ->setDispatched(false); - $response = new Zend_Controller_Response_Http(); - $front = Zend_Controller_Front::getInstance(); - $front->setRequest($request) - ->setResponse($response); - } - - /** - * Test Function for resetAction - * - * @return void - */ - public function resetAction() - { - $this->_response->appendBody('Reset action called'); - } - -} diff --git a/tests/Zend/Controller/_files/ObController.php b/tests/Zend/Controller/_files/ObController.php deleted file mode 100644 index 174e5b900e6fc1732553a770e3823da789c972d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/ObController.php +++ /dev/null @@ -1,64 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ObController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; -require_once 'Zend/View.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class ObController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - echo "OB index action called\n"; - } - - /** - * Test Function for exceptionAction - * - * @return void - */ - public function exceptionAction() - { - echo "In exception action\n"; - $view = new Zend_View(); - $view->addBasePath(dirname(dirname(__FILE__)) . '/views'); - $view->render('ob.phtml'); - } - -} diff --git a/tests/Zend/Controller/_files/ViewController.php b/tests/Zend/Controller/_files/ViewController.php deleted file mode 100644 index 9526dd0c0631bbf9ab4769c833d96b07af06734c..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/ViewController.php +++ /dev/null @@ -1,100 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ViewController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class ViewController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $this->render(); - } - - /** - * Test Function for testAction - * - * @return void - */ - public function testAction() - { - $this->render('index'); - } - - /** - * Test Function for siteAction - * - * @return void - */ - public function siteAction() - { - $this->render('site', null, true); - } - - /** - * Test Function for nameAction - * - * @return void - */ - public function nameAction() - { - $this->render(null, 'name'); - } - - /** - * Test Function for scriptAction - * - * @return void - */ - public function scriptAction() - { - $this->renderScript('custom/renderScript.php'); - } - - /** - * Test Function for scriptNameAction - * - * @return void - */ - public function scriptNameAction() - { - $this->renderScript('custom/renderScript.php', 'foo'); - } - -} diff --git a/tests/Zend/Controller/_files/modules/bar/controllers/IndexController.php b/tests/Zend/Controller/_files/modules/bar/controllers/IndexController.php deleted file mode 100644 index 91bd7d5b7192c7cd980f0ca53474e7dad35d00ee..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/bar/controllers/IndexController.php +++ /dev/null @@ -1,59 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IndexController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Bar_IndexController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $this->_response->appendBody("Bar_IndexController::indexAction() called\n"); - } - - /** - * Test Function for testAction - * - * @return void - */ - public function testAction() - { - } - -} diff --git a/tests/Zend/Controller/_files/modules/bar/views/scripts/index/test.phtml b/tests/Zend/Controller/_files/modules/bar/views/scripts/index/test.phtml deleted file mode 100644 index 71012a587d6f08146629acab7c39e8f9fbe7c3ef..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/bar/views/scripts/index/test.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -Rendered index/test.phtml in bar module diff --git a/tests/Zend/Controller/_files/modules/bar/views/scripts/test.phtml b/tests/Zend/Controller/_files/modules/bar/views/scripts/test.phtml deleted file mode 100644 index 82c38f02b8dfc531f680a73ffe102af267cd3517..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/bar/views/scripts/test.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -Rendered test.phtml in bar module diff --git a/tests/Zend/Controller/_files/modules/bar/views/scripts/test/foo.php b/tests/Zend/Controller/_files/modules/bar/views/scripts/test/foo.php deleted file mode 100644 index 036aa15433970a0431583756e646d1d8c6fa922a..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/bar/views/scripts/test/foo.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -echo 'Rendered test/foo.php'; diff --git a/tests/Zend/Controller/_files/modules/default/controllers/Admin/HelperController.php b/tests/Zend/Controller/_files/modules/default/controllers/Admin/HelperController.php deleted file mode 100644 index 64d2ea59a8524a4ea8ddaf0cc8120670e260c391..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/default/controllers/Admin/HelperController.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -require_once 'Zend/Controller/Action.php'; - -class Admin_HelperController extends Zend_Controller_Action -{ - public function renderAction() - { - } -} diff --git a/tests/Zend/Controller/_files/modules/default/views/helpers/SampleZfHelper.php b/tests/Zend/Controller/_files/modules/default/views/helpers/SampleZfHelper.php deleted file mode 100644 index 523e0903066caec72c6458312db8e6c0b10e9aad..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/default/views/helpers/SampleZfHelper.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -require_once 'Zend/View/Helper/Abstract.php'; - -class Zend_View_Helper_SampleZfHelper extends Zend_View_Helper_Abstract -{ - public function sampleZfHelper() - { - return 'SampleZfHelper invoked'; - } -} diff --git a/tests/Zend/Controller/_files/modules/default/views/scripts/admin/helper/render.phtml b/tests/Zend/Controller/_files/modules/default/views/scripts/admin/helper/render.phtml deleted file mode 100644 index a7196e90d77319dd62f074f8f0e5120a107fd8bd..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/default/views/scripts/admin/helper/render.phtml +++ /dev/null @@ -1 +0,0 @@ -<?= $this->sampleZfHelper() ?> diff --git a/tests/Zend/Controller/_files/modules/foo/controllers/Admin/IndexController.php b/tests/Zend/Controller/_files/modules/foo/controllers/Admin/IndexController.php deleted file mode 100644 index 76aa217763754c2d99cddf6d5b672f9edca4e619..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/foo/controllers/Admin/IndexController.php +++ /dev/null @@ -1,53 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IndexController.php 10524 2008-07-29 01:10:15Z matthew $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Foo_Admin_IndexController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $this->_response->appendBody("Foo_Admin_IndexController::indexAction() called\n"); - } - - public function useHelperAction() - { - } -} diff --git a/tests/Zend/Controller/_files/modules/foo/controllers/IndexController.php b/tests/Zend/Controller/_files/modules/foo/controllers/IndexController.php deleted file mode 100644 index 0930f4a7f92c9d5e01bbbc7ded38031738571c7f..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/foo/controllers/IndexController.php +++ /dev/null @@ -1,50 +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_Controller - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IndexController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Foo_IndexController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - $this->_response->appendBody("Foo_IndexController::indexAction() called\n"); - } - -} diff --git a/tests/Zend/Controller/_files/modules/foo/views/helpers/FooUseHelper.php b/tests/Zend/Controller/_files/modules/foo/views/helpers/FooUseHelper.php deleted file mode 100644 index 4e9415521362d5ea3346f70a659b8bfaaf9304b9..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/foo/views/helpers/FooUseHelper.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -require_once 'Zend/View/Helper/Abstract.php'; - -class Foo_View_Helper_FooUseHelper extends Zend_View_Helper_Abstract -{ - public function fooUseHelper() - { - return __FUNCTION__ . ' invoked'; - } -} diff --git a/tests/Zend/Controller/_files/modules/foo/views/scripts/admin/index/use-helper.phtml b/tests/Zend/Controller/_files/modules/foo/views/scripts/admin/index/use-helper.phtml deleted file mode 100644 index 5fb9c4ce298ed32e2470220ae956de804cd3df6f..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/modules/foo/views/scripts/admin/index/use-helper.phtml +++ /dev/null @@ -1 +0,0 @@ -<?= $this->fooUseHelper() ?> diff --git a/tests/Zend/Controller/_files/routes-root.ini b/tests/Zend/Controller/_files/routes-root.ini deleted file mode 100644 index 7305b930f3b77b0226014b1357019f91c60a5092..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/routes-root.ini +++ /dev/null @@ -1,12 +0,0 @@ -[routes] - -archive.route = "archive/:year/*" -archive.defaults.controller = archive -archive.defaults.action = show -archive.defaults.year = 2000 -archive.reqs.year = "\d+" - -news.type = "Zend_Controller_Router_Route_Static" -news.route = "news" -news.defaults.controller = "news" -news.defaults.action = "list" diff --git a/tests/Zend/Controller/_files/routes.ini b/tests/Zend/Controller/_files/routes.ini deleted file mode 100644 index 38b804b82dd1ea78e13f79c69453826e03ba016c..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/_files/routes.ini +++ /dev/null @@ -1,12 +0,0 @@ -[testing] - -routes.archive.route = "archive/:year/*" -routes.archive.defaults.controller = archive -routes.archive.defaults.action = show -routes.archive.defaults.year = 2000 -routes.archive.reqs.year = "\d+" - -routes.news.type = "Zend_Controller_Router_Route_Static" -routes.news.route = "news" -routes.news.defaults.controller = "news" -routes.news.defaults.action = "list" diff --git a/tests/Zend/Controller/views/scripts/custom/renderScript.php b/tests/Zend/Controller/views/scripts/custom/renderScript.php deleted file mode 100644 index 013735bb4c87dad9bc0443511743076872a9b007..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/views/scripts/custom/renderScript.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -Inside custom/renderScript.php diff --git a/tests/Zend/Controller/views/scripts/foo-bar/baz-bat.phtml b/tests/Zend/Controller/views/scripts/foo-bar/baz-bat.phtml deleted file mode 100644 index 6907023176d63c44621b8427e763123f157962e2..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/views/scripts/foo-bar/baz-bat.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -Inside foo-bar/baz-bat.phtml diff --git a/tests/Zend/Controller/views/scripts/ob.phtml b/tests/Zend/Controller/views/scripts/ob.phtml deleted file mode 100644 index 9581fddb480d22aa0ad6c652fdb5c7b4b1ced88f..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/views/scripts/ob.phtml +++ /dev/null @@ -1,3 +0,0 @@ -Foo -Bar -<?php throw new Exception('interrupting output buffer'); ?> diff --git a/tests/Zend/Controller/views/scripts/site.phtml b/tests/Zend/Controller/views/scripts/site.phtml deleted file mode 100644 index 30857c6348f1516331abcb33c38da4aa64830268..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/views/scripts/site.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -In the sitewide view diff --git a/tests/Zend/Controller/views/scripts/view/index.phtml b/tests/Zend/Controller/views/scripts/view/index.phtml deleted file mode 100644 index cd766b89c407fb58f9061f50107e384a14b38054..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/views/scripts/view/index.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -In the index action view diff --git a/tests/Zend/Controller/views/scripts/view/name.phtml b/tests/Zend/Controller/views/scripts/view/name.phtml deleted file mode 100644 index 215f4f5a2b0b91229a9b9ddd312b4d7b10cddf0d..0000000000000000000000000000000000000000 --- a/tests/Zend/Controller/views/scripts/view/name.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -In the name view diff --git a/tests/Zend/CurrencyTest.php b/tests/Zend/CurrencyTest.php deleted file mode 100644 index f6585b619cd7b6ea39fbc0d1f689325127f8e17d..0000000000000000000000000000000000000000 --- a/tests/Zend/CurrencyTest.php +++ /dev/null @@ -1,557 +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_Currency - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DataTest.php 3776 2007-03-06 22:50:56Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * Zend_Currency - */ -require_once 'Zend/Locale.php'; -require_once 'Zend/Currency.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * @package Zend_Currency - * @subpackage UnitTests - */ -class Zend_CurrencyTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - require_once 'Zend/Cache.php'; - $cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 120, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/_files/')); - Zend_Currency::setCache($cache); - } - - /** - * tests the creation of Zend_Currency - */ - public function testSingleCreation() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $locale = new Zend_Locale('de_AT'); - - try { - $currency = new Zend_Currency(); - $this->assertTrue($currency instanceof Zend_Currency); - } catch (Zend_Currency_Exception $e) { - $this->assertContains('No region found within the locale', $e->getMessage()); - } - - $currency = new Zend_Currency('de_AT'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('€ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('de_DE'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('1.000,00 €', $currency->toCurrency(1000)); - - $currency = new Zend_Currency($locale); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('€ 1.000,00', $currency->toCurrency(1000)); - - try { - $currency = new Zend_Currency('de_XX'); - $this->fail("locale should always include region and therefor not been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - try { - $currency = new Zend_Currency('xx_XX'); - $this->fail("unknown locale should not have been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - - try { - $currency = new Zend_Currency('EUR'); - $this->assertTrue($currency instanceof Zend_Currency); - } catch (Zend_Currency_Exception $e) { - $this->assertContains('No region found within the locale', $e->getMessage()); - } - - try { - $currency = new Zend_Currency('USD'); - $this->assertTrue($currency instanceof Zend_Currency); - } catch (Zend_Currency_Exception $e) { - $this->assertContains('No region found within the locale', $e->getMessage()); - } - - try { - $currency = new Zend_Currency('AWG'); - $this->assertTrue($currency instanceof Zend_Currency); - } catch (Zend_Currency_Exception $e) { - $this->assertContains('No region found within the locale', $e->getMessage()); - } - - try { - $currency = new Zend_Currency('XYZ'); - $this->fail("unknown shortname should not have been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - } - - - /** - * tests the creation of Zend_Currency - */ - public function testDualCreation() - { - $locale = new Zend_Locale('de_AT'); - - $currency = new Zend_Currency('USD', 'de_AT'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('USD', $locale); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('de_AT', 'USD'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency($locale, 'USD'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('EUR', 'de_AT'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('€ 1.000,00', $currency->toCurrency(1000)); - - try { - $currency = new Zend_Currency('EUR', 'xx_YY'); - $this->fail("unknown locale should not have been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - } - - - /** - * tests the creation of Zend_Currency - */ - public function testTripleCreation() - { - $locale = new Zend_Locale('de_AT'); - - $currency = new Zend_Currency('USD', 'de_AT'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('USD', $locale); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - try { - $currency = new Zend_Currency('XXX', 'Latin', $locale); - $this->fail("unknown shortname should not have been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - try { - $currency = new Zend_Currency('USD', 'Xyzz', $locale); - $this->fail("unknown script should not have been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - try { - $currency = new Zend_Currency('USD', 'Latin', 'xx_YY'); - $this->fail("unknown locale should not have been recognised"); - } catch (Zend_Currency_Exception $e) { - // success - } - - $currency = new Zend_Currency('USD', 'de_AT'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('Euro', 'de_AT'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('EUR 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('USD', $locale); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('de_AT', 'EUR'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('€ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency($locale, 'USD'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1.000,00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('EUR', 'en_US'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('€ 1,000.00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency('en_US', 'USD'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('$ 1,000.00', $currency->toCurrency(1000)); - - $currency = new Zend_Currency($locale, 'EUR'); - $this->assertTrue($currency instanceof Zend_Currency); - $this->assertSame('€ 1.000,00', $currency->toCurrency(1000)); - } - - - /** - * tests failed creation of Zend_Currency - */ - public function testFailedCreation() - { - $locale = new Zend_Locale('de_AT'); - - try { - $currency = new Zend_Currency('de_AT', 'en_US'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - try { - $currency = new Zend_Currency('USD', 'EUR'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - try { - $currency = new Zend_Currency('Arab', 'Latn'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - try { - $currency = new Zend_Currency('EUR'); - $currency->toCurrency('value'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - - $currency = new Zend_Currency('EUR', 'de_AT'); - $currency->setFormat(array('display' => 'SIGN')); - $this->assertSame('SIGN 1.000,00', $currency->toCurrency(1000)); - - try { - $currency = new Zend_Currency('EUR'); - $currency->setFormat(array('format' => 'xy_ZY')); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - } - - - /* - * testing toCurrency - */ - public function testToCurrency() - { - $USD = new Zend_Currency('USD','en_US'); - $EGP = new Zend_Currency('EGP','ar_EG'); - - $this->assertSame('$ 53,292.18', $USD->toCurrency(53292.18 )); - $this->assertSame('$ ٥٣,٢٩٢.١٨', $USD->toCurrency(53292.18, array('script' => 'Arab' ))); - $this->assertSame('$ ٥٣.٢٩٢,١٨', $USD->toCurrency(53292.18, array('script' => 'Arab', 'format' => 'de_AT'))); - $this->assertSame('$ 53.292,18', $USD->toCurrency(53292.18, array('format' => 'de_AT'))); - - $this->assertSame('ج.Ù….†53Ù¬292Ù«18', $EGP->toCurrency(53292.18 )); - $this->assertSame('ج.Ù….†٥٣٬٢٩٢٫١٨', $EGP->toCurrency(53292.18, array('script' => 'Arab' ))); - $this->assertSame('ج.Ù….†٥٣.٢٩٢,١٨', $EGP->toCurrency(53292.18, array('script' =>'Arab', 'format' => 'de_AT'))); - $this->assertSame('ج.Ù….†53.292,18', $EGP->toCurrency(53292.18, array('format' => 'de_AT'))); - - $USD = new Zend_Currency('en_US'); - $this->assertSame('$ 53,292.18', $USD->toCurrency(53292.18)); - try { - $this->assertSame('$ 53,292.18', $USD->toCurrency('nocontent')); - $this->fail("No currency expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("has to be numeric", $e->getMessage()); - } - } - - - /** - * testing setFormat - * - */ - public function testSetFormat() - { - $locale = new Zend_Locale('en_US'); - $USD = new Zend_Currency('USD','en_US'); - - $USD->setFormat(array('script' => 'Arab')); - $this->assertSame('$ ٥٣,٢٩٢.١٨', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('script' => 'Arab', 'format' => 'de_AT')); - $this->assertSame('$ ٥٣.٢٩٢,١٨', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('script' => 'Latn', 'format' => 'de_AT')); - $this->assertSame('$ 53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('script' => 'Latn', 'format' => $locale)); - $this->assertSame('$ 53,292.18', $USD->toCurrency(53292.18)); - - // allignment of currency signs - $USD->setFormat(array('position' => Zend_Currency::RIGHT, 'format' => 'de_AT')); - $this->assertSame('53.292,18 $', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('position' => Zend_Currency::RIGHT, 'format' => $locale)); - $this->assertSame('53,292.18 $', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('position' => Zend_Currency::LEFT, 'format' => 'de_AT')); - $this->assertSame('$ 53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('position' => Zend_Currency::LEFT, 'format' => $locale)); - $this->assertSame('$ 53,292.18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('position' => Zend_Currency::STANDARD, 'format' => 'de_AT')); - $this->assertSame('$ 53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('position' => Zend_Currency::STANDARD, 'format' => $locale)); - $this->assertSame('$ 53,292.18', $USD->toCurrency(53292.18)); - - // enable/disable currency symbols & currency names - $USD->setFormat(array('display' => Zend_Currency::NO_SYMBOL, 'format' => 'de_AT')); - $this->assertSame('53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::NO_SYMBOL, 'format' => $locale)); - $this->assertSame('53,292.18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::USE_SHORTNAME, 'format' => 'de_AT')); - $this->assertSame('USD 53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::USE_SHORTNAME, 'format' => $locale)); - $this->assertSame('USD 53,292.18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::USE_NAME, 'format' => 'de_AT')); - $this->assertSame('US Dollar 53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::USE_NAME, 'format' => $locale)); - $this->assertSame('US Dollar 53,292.18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::USE_SYMBOL, 'format' => 'de_AT')); - $this->assertSame('$ 53.292,18', $USD->toCurrency(53292.18)); - - $USD->setFormat(array('display' => Zend_Currency::USE_SYMBOL, 'format' => $locale)); - $this->assertSame('$ 53,292.18', $USD->toCurrency(53292.18)); - - try { - $USD->setFormat(array('position' => 'unknown')); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("Unknown position", $e->getMessage()); - } - - try { - $USD->setFormat(array('format' => 'unknown')); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("is not a known locale", $e->getMessage()); - } - - try { - $USD->setFormat(array('display' => -14)); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("Unknown display", $e->getMessage()); - } - - try { - $USD->setFormat(array('script' => 'unknown')); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("Unknown script", $e->getMessage()); - } - - try { - $USD->setFormat(array('unknown' => 'unknown')); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("Unknown option", $e->getMessage()); - } - - $USD->setFormat(array('precision' => null)); - - try { - $USD->setFormat(array('precision' => -14)); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("precision has to be between", $e->getMessage()); - } - } - - - /** - * test getSign - */ - public function testGetSign() - { - $locale = new Zend_Locale('ar_EG'); - $currency = new Zend_Currency('ar_EG'); - - $this->assertSame('ج.Ù….â€', $currency->getSymbol('EGP','ar_EG')); - $this->assertSame('€', $currency->getSymbol('EUR','de_AT')); - $this->assertSame('ج.Ù….â€', $currency->getSymbol('ar_EG' )); - $this->assertSame('€', $currency->getSymbol('de_AT' )); - $this->assertSame('ج.Ù….â€', $currency->getSymbol()); - - try { - $currency->getSymbol('EGP', 'de_XX'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - } - - - /** - * test getName - */ - public function testGetName() - { - $locale = new Zend_Locale('ar_EG'); - $currency = new Zend_Currency('ar_EG'); - - $this->assertSame('جنيه مصرى', $currency->getName('EGP','ar_EG')); - $this->assertSame('Estnische Krone', $currency->getName('EEK','de_AT')); - $this->assertSame('جنيه مصرى', $currency->getName('EGP',$locale)); - $this->assertSame('جنيه مصرى', $currency->getName('ar_EG' )); - $this->assertSame('Euro', $currency->getName('de_AT' )); - $this->assertSame('جنيه مصرى', $currency->getName()); - - try { - $currency->getName('EGP', 'xy_XY'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - } - - - /** - * test getShortName - */ - public function testGetShortName() - { - $locale = new Zend_Locale('de_AT'); - $currency = new Zend_Currency('de_AT'); - - $this->assertSame('EUR', $currency->getShortName('Euro', 'de_AT')); - $this->assertSame('EUR', $currency->getShortName('Euro', $locale)); - $this->assertSame('USD', $currency->getShortName('US-Dollar','de_AT')); - $this->assertSame('EUR', $currency->getShortName('de_AT' )); - $this->assertSame('EUR', $currency->getShortName()); - - try { - $currency->getShortName('EUR', 'xy_ZT'); - $this->fail("exception expected"); - } catch (Zend_Currency_Exception $e) { - // success - } - } - - - /** - * testing getRegionList - */ - public function testGetRegionList() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - try { - $currency = new Zend_Currency('USD'); - $this->assertTrue(is_array($currency->getRegionList())); - } catch (Zend_Currency_Exception $e) { - $this->assertContains('No region found within the locale', $e->getMessage()); - } - - $currency = new Zend_Currency('USD', 'en_US'); - $currency->setFormat(array('currency' => null)); - try { - $this->assertEquals('US', $currency->getRegionList()); - $this->fail("Exception expected"); - } catch (Zend_Currency_Exception $e) { - $this->assertContains("No currency defined", $e->getMessage()); - } - - $currency = new Zend_Currency('USD', 'en_US'); - $this->assertEquals(array(0 => 'AS', 1 => 'EC', 2 => 'FM', 3 => 'GU', 4 => 'IO', 5 => 'MH', 6 => 'MP', - 7 => 'PR', 8 => 'PW', 9 => 'TC', 10 => 'TL', 11 => 'UM', 12 => 'US', 13 => 'VG', 14 => 'VI'), $currency->getRegionList()); - } - - - /** - * testing getCurrencyList - */ - public function testGetCurrencyList() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $currency = new Zend_Currency('ar_EG'); - $this->assertTrue(array_key_exists('EGP', $currency->getCurrencyList())); - } - - - /** - * testing toString - * - */ - public function testToString() - { - $USD = new Zend_Currency('USD','en_US'); - $this->assertSame('US Dollar', $USD->toString()); - $this->assertSame('US Dollar', $USD->__toString()); - } -} diff --git a/tests/Zend/Date/AllTests.php b/tests/Zend/Date/AllTests.php deleted file mode 100644 index ac6db52dec478abd0a97b1a9cbbabb478ded06ed..0000000000000000000000000000000000000000 --- a/tests/Zend/Date/AllTests.php +++ /dev/null @@ -1,55 +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_Date - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 2883 2007-01-18 05:56:31Z gavin $ - */ - -error_reporting( E_ALL | E_STRICT ); // now required for each test suite -// define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', false); // uncomment to disable use of bcmath extension by Zend_Date - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Date_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Date/DateObjectTest.php'; - -class Zend_Date_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Date_DateObject'); - - $suite->addTestSuite('Zend_Date_DateObjectTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Date_AllTests::main') { - Zend_Date_AllTests::main(); -} diff --git a/tests/Zend/Date/DateObjectTest.php b/tests/Zend/Date/DateObjectTest.php deleted file mode 100644 index 00ae455b3e42cbac16a9b97feba7e5a9123d48e0..0000000000000000000000000000000000000000 --- a/tests/Zend/Date/DateObjectTest.php +++ /dev/null @@ -1,593 +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_Date - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DateObjectTest.php 8542 2008-03-04 20:40:52Z darby $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Date - */ -require_once 'Zend/Date.php'; - - -/** - * @package Zend_Date - * @subpackage UnitTests - */ -class Zend_Date_DateObjectTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - date_default_timezone_set('Europe/Paris'); - require_once 'Zend/Cache.php'; - $cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 120, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/../_files/')); - Zend_Date_DateObjectTestHelper::setOptions(array('cache' => $cache)); - } - - /** - * Test for date object creation null value - */ - public function testCreationNull() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $date = new Zend_Date(0); - $this->assertTrue($date instanceof Zend_Date); - } - - /** - * Test for date object creation negative timestamp - */ - public function testCreationNegative() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $date = new Zend_Date(1000); - $this->assertTrue($date instanceof Zend_Date); - } - - /** - * Test for date object creation text given - */ - public function testCreationFailed() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - try { - $date = new Zend_Date("notimestamp"); - $this->fail("exception expected"); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for setUnixTimestamp - */ - public function testsetUnixTimestamp() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $diff = abs(time() - $date->getUnixTimestamp()); - $this->assertTrue(($diff < 2), "Zend_Date->setUnixTimestamp() returned a significantly " - . "different timestamp than expected: $diff seconds"); - $date->setUnixTimestamp(0); - $this->assertSame('0', (string)$date->setUnixTimestamp("12345678901234567890")); - $this->assertSame("12345678901234567890", (string)$date->setUnixTimestamp("12345678901234567890")); - - $date->setUnixTimestamp(); - $diff = abs(time() - $date->getUnixTimestamp()); - $this->assertTrue($diff < 2, "setUnixTimestamp has a significantly different time than returned by time()): $diff seconds"); - } - - /** - * Test for setUnixTimestampFailed - */ - public function testsetUnixTimestampFailed() - { - try { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $date->setUnixTimestamp("notimestamp"); - $this->fail("exception expected"); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for getUnixTimestamp - */ - public function testgetUnixTimestamp() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $result = $date->getUnixTimestamp(); - $diff = abs($result - time()); - $this->assertTrue($diff < 2, "Instance of Zend_Date_DateObject has a significantly different time than returned by setTime(): $diff seconds"); - } - - /** - * Test for mktime - */ - public function testMkTimeforDateValuesInPHPRange() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $this->assertSame( mktime(0, 0, 0, 12, 30, 2037), $date->mktime(0, 0, 0, 12, 30, 2037, false)); - $this->assertSame(gmmktime(0, 0, 0, 12, 30, 2037), $date->mktime(0, 0, 0, 12, 30, 2037, true )); - - $this->assertSame( mktime(0, 0, 0, 1, 1, 2000), $date->mktime(0, 0, 0, 1, 1, 2000, false)); - $this->assertSame(gmmktime(0, 0, 0, 1, 1, 2000), $date->mktime(0, 0, 0, 1, 1, 2000, true )); - - $this->assertSame( mktime(0, 0, 0, 1, 1, 1970), $date->mktime(0, 0, 0, 1, 1, 1970, false)); - $this->assertSame(gmmktime(0, 0, 0, 1, 1, 1970), $date->mktime(0, 0, 0, 1, 1, 1970, true )); - - $this->assertSame( mktime(0, 0, 0, 12, 30, 1902), $date->mktime(0, 0, 0, 12, 30, 1902, false)); - $this->assertSame(gmmktime(0, 0, 0, 12, 30, 1902), $date->mktime(0, 0, 0, 12, 30, 1902, true )); - } - - /** - * Test for mktime - */ - public function testMkTimeforDateValuesGreaterPHPRange() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $this->assertSame(2232658800, $date->mktime(0, 0, 0,10, 1, 2040, false)); - $this->assertSame(2232662400, $date->mktime(0, 0, 0,10, 1, 2040, true )); - $this->assertSame(7258114800, $date->mktime(0, 0, 0, 1, 1, 2200, false)); - $this->assertSame(7258118400, $date->mktime(0, 0, 0, 1, 1, 2200, true )); - $this->assertSame(16749586800, $date->mktime(0, 0, 0,10,10, 2500, false)); - $this->assertSame(16749590400, $date->mktime(0, 0, 0,10,10, 2500, true )); - $this->assertSame(32503676400, $date->mktime(0, 0, 0, 1, 1, 3000, false)); - $this->assertSame(32503680000, $date->mktime(0, 0, 0, 1, 1, 3000, true )); - $this->assertSame(95617580400, $date->mktime(0, 0, 0, 1, 1, 5000, false)); - $this->assertSame(95617584000, $date->mktime(0, 0, 0, 1, 1, 5000, true )); - - // test for different set external timezone - // the internal timezone should always be used for calculation - $date->setTimezone('Europe/Paris'); - $this->assertSame(1577833200, $date->mktime(0, 0, 0, 1, 1, 2020, false)); - $this->assertSame(1577836800, $date->mktime(0, 0, 0, 1, 1, 2020, true )); - date_default_timezone_set('Indian/Maldives'); - $this->assertSame(1577833200, $date->mktime(0, 0, 0, 1, 1, 2020, false)); - $this->assertSame(1577836800, $date->mktime(0, 0, 0, 1, 1, 2020, true )); - } - - /** - * Test for mktime - */ - public function testMkTimeforDateValuesSmallerPHPRange() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $this->assertSame(-2208992400, $date->mktime(0, 0, 0, 1, 1, 1900, false)); - $this->assertSame(-2208988800, $date->mktime(0, 0, 0, 1, 1, 1900, true )); - $this->assertSame(-8520339600, $date->mktime(0, 0, 0, 1, 1, 1700, false)); - $this->assertSame(-8520336000, $date->mktime(0, 0, 0, 1, 1, 1700, true )); - $this->assertSame(-14830995600, $date->mktime(0, 0, 0, 1, 1, 1500, false)); - $this->assertSame(-14830992000, $date->mktime(0, 0, 0, 1, 1, 1500, true )); - $this->assertSame(-12219321600, $date->mktime(0, 0, 0,10,10, 1582, false)); - $this->assertSame(-12219321600, $date->mktime(0, 0, 0,10,10, 1582, true )); - $this->assertSame(-30609795600, $date->mktime(0, 0, 0, 1, 1, 1000, false)); - $this->assertSame(-30609792000, $date->mktime(0, 0, 0, 1, 1, 1000, true )); - $this->assertSame(-62167395600, $date->mktime(0, 0, 0, 1, 1, 0, false)); - $this->assertSame(-62167392000, $date->mktime(0, 0, 0, 1, 1, 0, true )); - $this->assertSame(-125282595600, $date->mktime(0, 0, 0, 1, 1,-2000, false)); - $this->assertSame(-125282592000, $date->mktime(0, 0, 0, 1, 1,-2000, true)); - - $this->assertSame(-2208992400, $date->mktime(0, 0, 0, 13, 1, 1899, false)); - $this->assertSame(-2208988800, $date->mktime(0, 0, 0, 13, 1, 1899, true)); - $this->assertSame(-2208992400, $date->mktime(0, 0, 0,-11, 1, 1901, false)); - $this->assertSame(-2208988800, $date->mktime(0, 0, 0,-11, 1, 1901, true)); - } - - public function testIsLeapYear() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $this->assertTrue ($date->checkLeapYear(2000)); - $this->assertFalse($date->checkLeapYear(2002)); - $this->assertTrue ($date->checkLeapYear(2004)); - $this->assertFalse($date->checkLeapYear(1899)); - $this->assertTrue ($date->checkLeapYear(1500)); - $this->assertFalse($date->checkLeapYear(1455)); - } - - public function testWeekNumber() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $this->assertSame((int) date('W',mktime(0, 0, 0, 1, 1, 2000)), $date->weekNumber(2000, 1, 1)); - $this->assertSame((int) date('W',mktime(0, 0, 0, 10, 1, 2020)), $date->weekNumber(2020, 10, 1)); - $this->assertSame((int) date('W',mktime(0, 0, 0, 5, 15, 2005)), $date->weekNumber(2005, 5, 15)); - $this->assertSame((int) date('W',mktime(0, 0, 0, 11, 22, 1994)), $date->weekNumber(1994, 11, 22)); - $this->assertSame((int) date('W',mktime(0, 0, 0, 12, 31, 2000)), $date->weekNumber(2000, 12, 31)); - $this->assertSame(52, $date->weekNumber(2050, 12, 31)); - $this->assertSame(23, $date->weekNumber(2050, 6, 6)); - $this->assertSame(52, $date->weekNumber(2056, 1, 1)); - $this->assertSame(52, $date->weekNumber(2049, 12, 31)); - $this->assertSame(53, $date->weekNumber(2048, 12, 31)); - $this->assertSame( 1, $date->weekNumber(2047, 12, 31)); - } - - public function testDayOfWeek() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 1, 2000)), $date->dayOfWeekHelper(2000, 1, 1)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 2, 2000)), $date->dayOfWeekHelper(2000, 1, 2)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 3, 2000)), $date->dayOfWeekHelper(2000, 1, 3)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 4, 2000)), $date->dayOfWeekHelper(2000, 1, 4)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 5, 2000)), $date->dayOfWeekHelper(2000, 1, 5)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 6, 2000)), $date->dayOfWeekHelper(2000, 1, 6)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 7, 2000)), $date->dayOfWeekHelper(2000, 1, 7)); - $this->assertSame((int) date('w',mktime(0, 0, 0, 1, 8, 2000)), $date->dayOfWeekHelper(2000, 1, 8)); - $this->assertSame(6, $date->dayOfWeekHelper(2050, 1, 1)); - $this->assertSame(0, $date->dayOfWeekHelper(2050, 1, 2)); - $this->assertSame(1, $date->dayOfWeekHelper(2050, 1, 3)); - $this->assertSame(2, $date->dayOfWeekHelper(2050, 1, 4)); - $this->assertSame(3, $date->dayOfWeekHelper(2050, 1, 5)); - $this->assertSame(4, $date->dayOfWeekHelper(2050, 1, 6)); - $this->assertSame(5, $date->dayOfWeekHelper(2050, 1, 7)); - $this->assertSame(6, $date->dayOfWeekHelper(2050, 1, 8)); - $this->assertSame(4, $date->dayOfWeekHelper(1500, 1, 1)); - } - - public function testCalcSunInternal() - { - $date = new Zend_Date_DateObjectTestHelper(10000000); - $this->assertSame( 9961681, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, true )); - $this->assertSame(10010367, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, false)); - $this->assertSame( 9967006, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true )); - $this->assertSame(10005042, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false)); - $this->assertSame( 9947773, $date->calcSun(array('latitude' => 38.4, 'longitude' => 29), -0.0145439, true )); - $this->assertSame( 9996438, $date->calcSun(array('latitude' => 38.4, 'longitude' => 29), -0.0145439, false)); - $this->assertSame( 9953077, $date->calcSun(array('latitude' => -38.4, 'longitude' => 29), -0.0145439, true )); - $this->assertSame( 9991134, $date->calcSun(array('latitude' => -38.4, 'longitude' => 29), -0.0145439, false)); - $this->assertSame( 9923795, $date->calcSun(array('latitude' => 38.4, 'longitude' => 129), -0.0145439, true )); - $this->assertSame( 9972422, $date->calcSun(array('latitude' => 38.4, 'longitude' => 129), -0.0145439, false)); - $this->assertSame( 9929062, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true )); - $this->assertSame( 9967155, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false)); - $this->assertSame( 9985660, $date->calcSun(array('latitude' => 38.4, 'longitude' =>-129), -0.0145439, true )); - $this->assertSame(10034383, $date->calcSun(array('latitude' => 38.4, 'longitude' =>-129), -0.0145439, false)); - $this->assertSame( 9991022, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true )); - $this->assertSame(10029021, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false)); - - $date = new Zend_Date_DateObjectTestHelper(-148309884); - $this->assertSame(-148322663, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, true )); - $this->assertSame(-148274758, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, false)); - $this->assertSame(-148318117, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true )); - $this->assertSame(-148279304, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false)); - $this->assertSame(-148336570, $date->calcSun(array('latitude' => 38.4, 'longitude' => 29), -0.0145439, true )); - $this->assertSame(-148288687, $date->calcSun(array('latitude' => 38.4, 'longitude' => 29), -0.0145439, false)); - $this->assertSame(-148332046, $date->calcSun(array('latitude' => -38.4, 'longitude' => 29), -0.0145439, true )); - $this->assertSame(-148293211, $date->calcSun(array('latitude' => -38.4, 'longitude' => 29), -0.0145439, false)); - $this->assertSame(-148360548, $date->calcSun(array('latitude' => 38.4, 'longitude' => 129), -0.0145439, true )); - $this->assertSame(-148312703, $date->calcSun(array('latitude' => 38.4, 'longitude' => 129), -0.0145439, false)); - $this->assertSame(-148356061, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true )); - $this->assertSame(-148317189, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false)); - $this->assertSame(-148298686, $date->calcSun(array('latitude' => 38.4, 'longitude' =>-129), -0.0145439, true )); - $this->assertSame(-148250742, $date->calcSun(array('latitude' => 38.4, 'longitude' =>-129), -0.0145439, false)); - $this->assertSame(-148294101, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true )); - $this->assertSame(-148255327, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false)); - } - - public function testGetDate() - { - $date = new Zend_Date_DateObjectTestHelper(0); - $this->assertTrue(is_array($date->getDateParts())); - $this->assertTrue(is_array($date->getDateParts(1000000))); - - $test = array( 'seconds' => 40, 'minutes' => 46, - 'hours' => 14, 'mday' => 12, 'wday' => 1, - 'mon' => 1, 'year' => 1970, 'yday' => 11, - 'weekday' => 'Monday', 'month' => 'January', 0 => 1000000); - $result = $date->getDateParts(1000000); - - $this->assertSame((int) $test['seconds'], (int) $result['seconds']); - $this->assertSame((int) $test['minutes'], (int) $result['minutes']); - $this->assertSame((int) $test['hours'], (int) $result['hours'] ); - $this->assertSame((int) $test['mday'], (int) $result['mday'] ); - $this->assertSame((int) $test['wday'], (int) $result['wday'] ); - $this->assertSame((int) $test['mon'], (int) $result['mon'] ); - $this->assertSame((int) $test['year'], (int) $result['year'] ); - $this->assertSame((int) $test['yday'], (int) $result['yday'] ); - $this->assertSame( $test['weekday'], $result['weekday']); - $this->assertSame( $test['month'], $result['month'] ); - $this->assertSame( $test[0], $result[0] ); - - $test = array( 'seconds' => 20, 'minutes' => 33, - 'hours' => 11, 'mday' => 6, 'wday' => 3, - 'mon' => 3, 'year' => 1748, 'yday' => 65, - 'weekday' => 'Wednesday', 'month' => 'February', 0 => -7000000000); - $result = $date->getDateParts(-7000000000); - - $this->assertSame((int) $test['seconds'], (int) $result['seconds']); - $this->assertSame((int) $test['minutes'], (int) $result['minutes']); - $this->assertSame((int) $test['hours'], (int) $result['hours'] ); - $this->assertSame((int) $test['mday'], (int) $result['mday'] ); - $this->assertSame((int) $test['wday'], (int) $result['wday'] ); - $this->assertSame((int) $test['mon'], (int) $result['mon'] ); - $this->assertSame((int) $test['year'], (int) $result['year'] ); - $this->assertSame((int) $test['yday'], (int) $result['yday'] ); - $this->assertSame( $test['weekday'], $result['weekday']); - $this->assertSame( $test['month'], $result['month'] ); - $this->assertSame( $test[0], $result[0] ); - - $test = array( 'seconds' => 0, 'minutes' => 40, - 'hours' => 2, 'mday' => 26, 'wday' => 2, - 'mon' => 8, 'year' => 2188, 'yday' => 238, - 'weekday' => 'Tuesday', 'month' => 'July', 0 => 6900000000); - $result = $date->getDateParts(6900000000); - - $this->assertSame((int) $test['seconds'], (int) $result['seconds']); - $this->assertSame((int) $test['minutes'], (int) $result['minutes']); - $this->assertSame((int) $test['hours'], (int) $result['hours'] ); - $this->assertSame((int) $test['mday'], (int) $result['mday'] ); - $this->assertSame((int) $test['wday'], (int) $result['wday'] ); - $this->assertSame((int) $test['mon'], (int) $result['mon'] ); - $this->assertSame((int) $test['year'], (int) $result['year'] ); - $this->assertSame((int) $test['yday'], (int) $result['yday'] ); - $this->assertSame( $test['weekday'], $result['weekday']); - $this->assertSame( $test['month'], $result['month'] ); - $this->assertSame( $test[0], $result[0] ); - - $test = array( 'seconds' => 0, 'minutes' => 40, - 'hours' => 2, 'mday' => 26, 'wday' => 3, - 'mon' => 8, 'year' => 2188, 'yday' => 238, - 'weekday' => 'Wednesday', 'month' => 'July', 0 => 6900000000); - $result = $date->getDateParts(6900000000, true); - - $this->assertSame((int) $test['seconds'], (int) $result['seconds']); - $this->assertSame((int) $test['minutes'], (int) $result['minutes']); - $this->assertSame((int) $test['hours'], (int) $result['hours'] ); - $this->assertSame((int) $test['mday'], (int) $result['mday'] ); - $this->assertSame((int) $test['mon'], (int) $result['mon'] ); - $this->assertSame((int) $test['year'], (int) $result['year'] ); - $this->assertSame((int) $test['yday'], (int) $result['yday'] ); - } - - public function testDate() - { - $date = new Zend_Date_DateObjectTestHelper(0); - $this->assertTrue($date->date('U') > 0); - $this->assertSame( '0', $date->date('U',0 )); - $this->assertSame( '0', $date->date('U',0,false )); - $this->assertSame( '0', $date->date('U',0,true )); - $this->assertSame( '6900007200', $date->date('U',6900000000 )); - $this->assertSame( '-6999996400', $date->date('U',-7000000000)); - $this->assertSame( '06', $date->date('d',-7000000000)); - $this->assertSame( 'Wed', $date->date('D',-7000000000)); - $this->assertSame( '6', $date->date('j',-7000000000)); - $this->assertSame( 'Wednesday', $date->date('l',-7000000000)); - $this->assertSame( '3', $date->date('N',-7000000000)); - $this->assertSame( 'th', $date->date('S',-7000000000)); - $this->assertSame( '3', $date->date('w',-7000000000)); - $this->assertSame( '65', $date->date('z',-7000000000)); - $this->assertSame( '10', $date->date('W',-7000000000)); - $this->assertSame( 'March', $date->date('F',-7000000000)); - $this->assertSame( '03', $date->date('m',-7000000000)); - $this->assertSame( 'Mar', $date->date('M',-7000000000)); - $this->assertSame( '3', $date->date('n',-7000000000)); - $this->assertSame( '31', $date->date('t',-7000000000)); - $this->assertSame( 'CET', $date->date('T',-7000000000)); - $this->assertSame( '1', $date->date('L',-7000000000)); - $this->assertSame( '1748', $date->date('o',-7000000000)); - $this->assertSame( '1748', $date->date('Y',-7000000000)); - $this->assertSame( '48', $date->date('y',-7000000000)); - $this->assertSame( 'pm', $date->date('a',-7000000000)); - $this->assertSame( 'PM', $date->date('A',-7000000000)); - $this->assertSame( '523', $date->date('B',-7000000000)); - $this->assertSame( '12', $date->date('g',-7000000000)); - $this->assertSame( '12', $date->date('G',-7000000000)); - $this->assertSame( '12', $date->date('h',-7000000000)); - $this->assertSame( '12', $date->date('H',-7000000000)); - $this->assertSame( '33', $date->date('i',-7000000000)); - $this->assertSame( '20', $date->date('s',-7000000000)); - $this->assertSame('Europe/Paris', $date->date('e',-7000000000)); - $this->assertSame( '0', $date->date('I',-7000000000)); - $this->assertSame( '+0100', $date->date('O',-7000000000)); - $this->assertSame( '+01:00', $date->date('P',-7000000000)); - $this->assertSame( 'CET', $date->date('T',-7000000000)); - $this->assertSame( '3600', $date->date('Z',-7000000000)); - $this->assertSame( '1748-03-06T12:33:20+0100', $date->date('c',-7000000000)); - $this->assertSame('Wed, 06 Mar 1748 12:33:20 +0100', $date->date('r',-7000000000)); - $this->assertSame( '-6999996400', $date->date('U' ,-7000000000 )); - $this->assertSame( 'H', $date->date('\\H' ,-7000000000 )); - $this->assertSame( '.', $date->date('.' ,-7000000000 )); - $this->assertSame( '12:33:20', $date->date('H:i:s',-7000000000 )); - $this->assertSame( '06-Mar-1748', $date->date('d-M-Y',-7000000000 )); - $this->assertSame( '6900000000', $date->date('U',6900000000, true)); - $this->assertSame( '152', $date->date('B',6900000000, true)); - $this->assertSame( '12', $date->date('g',6899993000, true)); - $this->assertSame( '1', $date->date('g',6899997000, true)); - $this->assertSame( '1', $date->date('g',6900039200, true)); - $this->assertSame( '12', $date->date('h',6899993000, true)); - $this->assertSame( '01', $date->date('h',6899997000, true)); - $this->assertSame( '01', $date->date('h',6900040200, true)); - $this->assertSame( 'UTC', $date->date('e',-7000000000,true)); - $this->assertSame( '0', $date->date('I',-7000000000,true)); - $this->assertSame( 'GMT', $date->date('T',-7000000000,true)); - $this->assertSame( '6', $date->date('N',6899740800, true)); - $this->assertSame( 'st', $date->date('S',6900518000, true)); - $this->assertSame( 'nd', $date->date('S',6900604800, true)); - $this->assertSame( 'rd', $date->date('S',6900691200, true)); - $this->assertSame( '7', $date->date('N',6900432000, true)); - $date->setTimezone('Europe/Vienna'); - date_default_timezone_set('Indian/Maldives'); - $reference = $date->date('U'); - $this->assertTrue(abs($reference - time()) < 2); - $this->assertSame('69000000', $date->date('U',69000000)); - - // ISO Year (o) depends on the week number so 1.1. can be last year is week is 52/53 - $this->assertSame('1739', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1740))); - $this->assertSame('1740', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1741))); - $this->assertSame('1742', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1742))); - $this->assertSame('1743', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1743))); - $this->assertSame('1744', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1744))); - $this->assertSame('1744', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1745))); - $this->assertSame('1745', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1746))); - $this->assertSame('1746', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1747))); - $this->assertSame('1748', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1748))); - $this->assertSame('1749', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 1749))); - $this->assertSame('2049', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 2050))); - $this->assertSame('2050', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 2051))); - $this->assertSame('2052', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 2052))); - $this->assertSame('2053', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 2053))); - $this->assertSame('2054', $date->date('o',$date->mktime(0, 0, 0, 1, 1, 2054))); - } - - function testMktimeDay0And32() - { - // the following functionality is used by isTomorrow() and isYesterday() in Zend_Date. - $date = new Zend_Date_DateObjectTestHelper(0); - $this->assertSame('20060101', $date->date('Ymd', $date->mktime(0, 0, 0, 12, 32, 2005))); - $this->assertSame('20050301', $date->date('Ymd', $date->mktime(0, 0, 0, 2, 29, 2005))); - $this->assertSame('20051231', $date->date('Ymd', $date->mktime(0, 0, 0, 1, 0, 2006))); - $this->assertSame('20050131', $date->date('Ymd', $date->mktime(0, 0, 0, 2, 0, 2005))); - } - - /** - * Test for setTimezone() - */ - public function testSetTimezone() - { - $date = new Zend_Date_DateObjectTestHelper(0); - - date_default_timezone_set('Europe/Vienna'); - $this->assertTrue($date->setTimezone('Indian/Maldives')); - $this->assertSame('Indian/Maldives', $date->getTimezone()); - try { - $this->assertFalse($date->setTimezone('Unknown')); - // without new phpdate false timezones do not throw an exception ! - // known and expected behaviour - if (function_exists('timezone_open')) { - $this->fail("exception expected"); - } - } catch (Zend_Date_Exception $e) { - $this->assertRegexp('/not a known timezone/i', $e->getMessage()); - $this->assertSame('Unknown', $e->getOperand()); - } - $this->assertSame('Indian/Maldives', $date->getTimezone()); - $this->assertTrue($date->setTimezone()); - $this->assertSame('Europe/Vienna', $date->getTimezone()); - } - - /** - * Test for gmtOffset - */ - public function testgetGmtOffset() - { - $date = new Zend_Date_DateObjectTestHelper(0); - - date_default_timezone_set('Europe/Vienna'); - $date->setTimezone(); - - $this->assertSame(-3600, $date->getGmtOffset()); - $date->setTimezone('GMT'); - $this->assertSame( 0, $date->getGmtOffset()); - } - - /** - * Test for _getTime - */ - public function test_getTime() - { - $date = new Zend_Date_DateObjectTestHelper(Zend_Date::now()); - $time = $date->_getTime(); - $diff = abs(time() - $time); - $this->assertTrue(($diff < 2), "Zend_Date_DateObject->_getTime() returned a significantly " - . "different timestamp than expected: $diff seconds"); - } -} - -class Zend_Date_DateObjectTestHelper extends Zend_Date -{ - public function __construct($date = null, $part = null, $locale = null) - { - $this->setTimezone('Europe/Paris'); - parent::__construct($date, $part, $locale); - } - - public function mktime($hour, $minute, $second, $month, $day, $year, $dst= -1, $gmt = false) - { - return parent::mktime($hour, $minute, $second, $month, $day, $year, $dst, $gmt); - } - - public function getUnixTimestamp() - { - return parent::getUnixTimestamp(); - } - - public function setUnixTimestamp($timestamp = null) - { - return parent::setUnixTimestamp($timestamp); - } - - public function weekNumber($year, $month, $day) - { - return parent::weekNumber($year, $month, $day); - } - - public function dayOfWeekHelper($y, $m, $d) - { - return Zend_Date_DateObject::dayOfWeek($y, $m, $d); - } - - public function calcSun($location, $horizon, $rise = false) - { - return parent::calcSun($location, $horizon, $rise); - } - - public function date($format, $timestamp = null, $gmt = false) - { - return parent::date($format, $timestamp, $gmt); - } - - public function getDateParts($timestamp = null, $fast = null) - { - return parent::getDateParts($timestamp, $fast); - } - - public function _getTime($sync = null) - { - return parent::_getTime($sync); - } -} \ No newline at end of file diff --git a/tests/Zend/DateTest.php b/tests/Zend/DateTest.php deleted file mode 100644 index 3f9941beed28eb27b4b66a7059a044785ef3539e..0000000000000000000000000000000000000000 --- a/tests/Zend/DateTest.php +++ /dev/null @@ -1,5178 +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_Date - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * These const values control some testing behavior. - * They may be defined here or in TestConfiguration.php. - */ -if (!defined('TESTS_ZEND_LOCALE_BCMATH_ENABLED')) { - // Set to false to disable usage of bcmath extension by Zend_Date - define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', true); -} -if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE')) { - // Set to true to run full Zend_Date unit tests. - // Set to false to run a good subset of Zend_Date unit tests. - define('TESTS_ZEND_I18N_EXTENDED_COVERAGE', true); -} - -/** - * Zend_Date - */ -require_once 'Zend/Loader.php'; -require_once 'Zend/Date.php'; -require_once 'Zend/Locale.php'; -require_once 'Zend/Date/Cities.php'; -require_once 'Zend/TimeSync.php'; - -// echo "BCMATH is ", Zend_Locale_Math::isBcmathDisabled() ? 'disabled':'not disabled', "\n"; - -/** - * @category Zend - * @package Zend_Date - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_DateTest extends PHPUnit_Framework_TestCase -{ - - private $_cache = null; - - public function setUp() - { - date_default_timezone_set('Indian/Maldives'); - require_once 'Zend/Cache.php'; - $this->_cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 120, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/_files/')); - Zend_Date::setOptions(array('cache' => $this->_cache)); - } - - public function tearDown() - { - $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL); - } - - /** - * Test for date object creation - */ - public function testCreation() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $date = new Zend_Date(0); - $this->assertTrue($date instanceof Zend_Date); - } - - /** - * Test for date object creation using default format for a locale - */ - public function testCreationDefaultFormat() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $date = new Zend_Date('2006-01-01'); - $this->assertTrue($date instanceof Zend_Date); - $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Zend_Date::ISO_8601)); - - $date = new Zend_Date('2006-01-01', 'en_US'); - $this->assertTrue($date instanceof Zend_Date); - $this->assertSame('2006-01-01T00:00:00+05:00', $date->get(Zend_Date::ISO_8601)); - } - - /** - * Test for date object creation using default format for a locale - */ - public function testCreationDefaultFormatConsistency() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - date_default_timezone_set('America/New_York'); - $locale = 'en_US'; - //2006-01-01T00:00:00+05:00 - $date1 = new Zend_Date('2006-01-01 01:00:00', Zend_Date::ISO_8601, $locale); - $date1string = $date1->get(Zend_Date::ISO_8601); - - // en_US defines AM/PM, hour 0 does not exist - // ISO defines dates without AM, 0 exists instead of 12 PM - // therefor hour is set to 1 to verify - $date2 = new Zend_Date('2006-01-01', Zend_Date::DATES, $locale); - $date2->setTime('01:00:00'); - $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601)); - $date2 = new Zend_Date('01-01-2006', Zend_Date::DATES, $locale); - $date2->setTime('01:00:00'); - $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601)); - $date2 = new Zend_Date('2006-01-01', null, $locale); - $date2->setTime('01:00:00'); - $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601)); - $date2 = new Zend_Date('2006-01-01'); - $date2->setTime('01:00:00'); - $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601)); - $date2 = new Zend_Date('2006-01-01 01:00:00'); - $this->assertSame($date1string, $date2->get(Zend_Date::ISO_8601)); - } - - /** - * Test for creation with timestamp - */ - public function testCreationTimestamp() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $date = new Zend_Date('12345678'); - $this->assertTrue($date instanceof Zend_Date); - } - - /** - * Test for creation but only part of date - */ - public function testCreationDatePart() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $date = new Zend_Date('13',Zend_Date::HOUR); - $this->assertTrue($date instanceof Zend_Date); - - $date = new Zend_Date('20070802', 'YYYYMMdd'); - $this->assertSame("2007-08-02T00:00:00+05:00", $date->getIso()); - } - - /** - * Test for creation but only a defined locale - */ - public function testCreationLocale() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date('13',null,$locale); - $this->assertTrue($date instanceof Zend_Date); - } - - /** - * Test for creation but only part of date with locale - */ - public function testCreationLocalePart() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date('13',Zend_Date::HOUR,$locale); - $this->assertTrue($date instanceof Zend_Date); - } - - /** - * Test for date object creation using default format for a locale - */ - public function testCreationDefaultLoose() - { - // look if locale is detectable - try { - $locale = new Zend_Locale(); - } catch (Zend_Locale_Exception $e) { - $this->markTestSkipped('Autodetection of locale failed'); - return; - } - - $locale = 'de_AT'; - $date = new Zend_Date(); - - $date = $date->getTimestamp(); - $this->assertTrue(abs($date - time()) < 2); - - date_default_timezone_set('GMT'); - $date = new Zend_Date(Zend_Date::YEAR); - - $date = $date->getTimestamp(); - $reference = gmmktime(0,0,0,1,1,date('Y')); - $this->assertTrue($reference == $date); - - $date = new Zend_Date('ar_EG'); - $this->assertSame('ar_EG', $date->getLocale()); - $date = $date->getTimestamp(); - $this->assertTrue(abs($date - time()) < 2); - } - - /** - * Test for getTimestamp - */ - public function testGetTimestamp() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(10000000); - $this->assertSame(10000000, $date->getTimestamp()); - } - - /** - * Test for getUnixTimestamp - */ - public function testgetUnixTimestamp2() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(-100000000); - $this->assertSame(-100000000, $date->getTimestamp()); - } - - /** - * Test for setTimestamp - */ - public function testSetTimestamp() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,Zend_Date::TIMESTAMP,$locale); - $result = $date->setTimestamp(10000000); - $this->assertSame('10000000', (string)$result->getTimestamp()); - } - - /** - * Test for setTimestamp - */ - public function testSetTimestamp2() - { - try { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $result = $date->setTimestamp('notimestamp'); - $this->Fail("exception expected"); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for addTimestamp - */ - public function testAddTimestamp() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $result = $date->addTimestamp(10000000); - $this->assertSame('10000000', (string)$result->getTimestamp()); - - $result = $date->addTimestamp(array('timestamp' => 1000)); - $this->assertSame('10001000', (string)$result->getTimestamp()); - - try { - $result = $date->addTimestamp(array('notimestamp' => 1000)); - $this->fail("exception expected"); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for addTimestamp - */ - public function testAddTimestamp2() - { - try { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $result = $date->addTimestamp('notimestamp'); - $this->fail("exception expected"); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for subTimestamp - */ - public function testSubTimestamp() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $result = $date->subTimestamp(10000000); - $this->assertSame('-10000000', (string)$result->getTimestamp()); - } - - /** - * Test for subTimestamp - */ - public function testSubTimestamp2() - { - try { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $result = $date->subTimestamp('notimestamp'); - $this->fail("exception expected"); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for compareTimestamp - */ - public function testCompareTimestamp() - { - $locale = new Zend_Locale('de_AT'); - $date1 = new Zend_Date(0,null,$locale); - $date2 = new Zend_Date(0,null,$locale); - $this->assertSame(0, $date1->compareTimestamp($date2)); - - $date2 = new Zend_Date(100,null,$locale); - $this->assertSame(-1, $date1->compareTimestamp($date2)); - - $date2 = new Zend_Date(-100,null,$locale); - $this->assertSame(1, $date1->compareTimestamp($date2)); - } - - /** - * Test for __toString - */ - public function test_ToString() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $date->setTimezone(date_default_timezone_get()); - $this->assertSame('01.01.1970 05:00:00', $date->__toString()); - } - - /** - * Test for toString - */ - public function testToString() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $date->setTimezone(date_default_timezone_get()); - $this->assertSame('14.02.2009 04:31:30', $date->toString( )); - $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString('en_US' )); - $this->assertSame('Feb 14, 2009 4:31:30 AM', $date->toString(null, 'en_US')); - $this->assertSame('2009', $date->toString('yyy', null )); - $this->assertSame('14.02.2009 04:31:30', $date->toString(null, null )); - - $date->setTimeZone('UTC'); - $this->assertSame('Feb 13, 2009 11:31:30 PM', $date->toString(null, 'en_US')); - - $date->setTimeZone('Indian/Maldives'); - $this->assertSame( "xxyy'yyxx", $date->toString("xx'yy''yy'xx")); - $this->assertSame( 'n.', $date->toString("GGGGG")); - $this->assertSame( 'n. Chr.', $date->toString( "GGGG")); - $this->assertSame( 'n. Chr.', $date->toString( "GGG")); - $this->assertSame( 'n. Chr.', $date->toString( "GG")); - $this->assertSame( 'n. Chr.', $date->toString( "G")); - $this->assertSame( '02009', $date->toString("yyyyy")); - $this->assertSame( '2009', $date->toString( "yyyy")); - $this->assertSame( '2009', $date->toString( "yyy")); - $this->assertSame( '09', $date->toString( "yy")); - $this->assertSame( '2009', $date->toString( "y")); - $this->assertSame( '02009', $date->toString("YYYYY")); - $this->assertSame( '2009', $date->toString( "YYYY")); - $this->assertSame( '2009', $date->toString( "YYY")); - $this->assertSame( '09', $date->toString( "YY")); - $this->assertSame( '2009', $date->toString( "Y")); - $this->assertSame( 'F', $date->toString("MMMMM")); - $this->assertSame( 'Februar', $date->toString( "MMMM")); - $this->assertSame( 'Feb', $date->toString( "MMM")); - $this->assertSame( '02', $date->toString( "MM")); - $this->assertSame( '2', $date->toString( "M")); - $this->assertSame( '07', $date->toString( "ww")); - $this->assertSame( '07', $date->toString( "w")); - $this->assertSame( '14', $date->toString( "dd")); - $this->assertSame( '14', $date->toString( "d")); - $this->assertSame( '044', $date->toString( "DDD")); - $this->assertSame( '44', $date->toString( "DD")); - $this->assertSame( '44', $date->toString( "D")); - $this->assertSame( 'S', $date->toString("EEEEE")); - $this->assertSame( 'Samstag', $date->toString( "EEEE")); - $this->assertSame( 'Sam', $date->toString( "EEE")); - $this->assertSame( 'Sa', $date->toString( "EE")); - $this->assertSame( 'S', $date->toString( "E")); - $this->assertSame( '06', $date->toString( "ee")); - $this->assertSame( '6', $date->toString( "e")); - $this->assertSame( 'vorm.', $date->toString( "a")); - $this->assertSame( '04', $date->toString( "hh")); - $this->assertSame( '4', $date->toString( "h")); - $this->assertSame( '04', $date->toString( "HH")); - $this->assertSame( '4', $date->toString( "H")); - $this->assertSame( '31', $date->toString( "mm")); - $this->assertSame( '31', $date->toString( "m")); - $this->assertSame( '30', $date->toString( "ss")); - $this->assertSame( '30', $date->toString( "s")); - $this->assertSame( '0', $date->toString( "S")); - $this->assertSame('Indian/Maldives', $date->toString( "zzzz")); - $this->assertSame( 'MVT', $date->toString( "zzz")); - $this->assertSame( 'MVT', $date->toString( "zz")); - $this->assertSame( 'MVT', $date->toString( "z")); - $this->assertSame( '+05:00', $date->toString( "ZZZZ")); - $this->assertSame( '+0500', $date->toString( "ZZZ")); - $this->assertSame( '+0500', $date->toString( "ZZ")); - $this->assertSame( '+0500', $date->toString( "Z")); - $this->assertSame( '16290', $date->toString("AAAAA")); - $this->assertSame( '16290', $date->toString( "AAAA")); - $this->assertSame( '16290', $date->toString( "AAA")); - $this->assertSame( '16290', $date->toString( "AA")); - $this->assertSame( '16290', $date->toString( "A")); - - $date = new Zend_Date("1-1-1",null,$locale); - $date->setTimezone(date_default_timezone_get()); - $this->assertSame('01', $date->toString("yy")); - } - - /** - * Test for toValue - */ - public function testToValue() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $date->setTimezone(date_default_timezone_get()); - $this->assertSame(1234567890, $date->toValue() ); - $this->assertSame( 14, $date->toValue(Zend_Date::DAY)); - - $date->setTimezone('UTC'); - $this->assertSame( 13, $date->toValue(Zend_Date::DAY )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_SHORT )); - $this->assertSame( 13, $date->toValue(Zend_Date::DAY_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY )); - $this->assertSame( 5, $date->toValue(Zend_Date::WEEKDAY_8601 )); - $this->assertFalse( $date->toValue(Zend_Date::DAY_SUFFIX )); - $this->assertSame( 5, $date->toValue(Zend_Date::WEEKDAY_DIGIT )); - $this->assertSame( 43, $date->toValue(Zend_Date::DAY_OF_YEAR )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NARROW )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NAME )); - $this->assertSame( 7, $date->toValue(Zend_Date::WEEK )); - $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME )); - $this->assertSame( 2, $date->toValue(Zend_Date::MONTH )); - $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_SHORT )); - $this->assertSame( 2, $date->toValue(Zend_Date::MONTH_SHORT )); - $this->assertSame( 28, $date->toValue(Zend_Date::MONTH_DAYS )); - $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_NARROW)); - $this->assertSame( 0, $date->toValue(Zend_Date::LEAPYEAR )); - $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR_8601 )); - $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR )); - $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT )); - $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT_8601 )); - $this->assertFalse( $date->toValue(Zend_Date::MERIDIEM )); - $this->assertSame( 21, $date->toValue(Zend_Date::SWATCH )); - $this->assertSame( 11, $date->toValue(Zend_Date::HOUR_SHORT_AM )); - $this->assertSame( 23, $date->toValue(Zend_Date::HOUR_SHORT )); - $this->assertSame( 11, $date->toValue(Zend_Date::HOUR_AM )); - $this->assertSame( 23, $date->toValue(Zend_Date::HOUR )); - $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE )); - $this->assertSame( 30, $date->toValue(Zend_Date::SECOND )); - $this->assertSame( 0, $date->toValue(Zend_Date::MILLISECOND )); - $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE_SHORT )); - $this->assertSame( 30, $date->toValue(Zend_Date::SECOND_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE_NAME )); - $this->assertSame( 0, $date->toValue(Zend_Date::DAYLIGHT )); - $this->assertSame( 0, $date->toValue(Zend_Date::GMT_DIFF )); - $this->assertFalse( $date->toValue(Zend_Date::GMT_DIFF_SEP )); - $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE )); - $this->assertSame( 0, $date->toValue(Zend_Date::TIMEZONE_SECS )); - $this->assertFalse( $date->toValue(Zend_Date::ISO_8601 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_2822 )); - $this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP )); - $this->assertFalse( $date->toValue(Zend_Date::ERA )); - $this->assertFalse( $date->toValue(Zend_Date::ERA_NAME )); - $this->assertFalse( $date->toValue(Zend_Date::DATES )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_FULL )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_LONG )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_MEDIUM )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::TIMES )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_FULL )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_LONG )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_MEDIUM )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::ATOM )); - $this->assertFalse( $date->toValue(Zend_Date::COOKIE )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_822 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_850 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_1036 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_1123 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_3339 )); - $this->assertFalse( $date->toValue(Zend_Date::RSS )); - $this->assertFalse( $date->toValue(Zend_Date::W3C )); - - $date->setTimezone('Indian/Maldives'); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_SHORT )); - $this->assertSame( 14, $date->toValue(Zend_Date::DAY_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY )); - $this->assertSame( 6, $date->toValue(Zend_Date::WEEKDAY_8601 )); - $this->assertFalse( $date->toValue(Zend_Date::DAY_SUFFIX )); - $this->assertSame( 6, $date->toValue(Zend_Date::WEEKDAY_DIGIT )); - $this->assertSame( 44, $date->toValue(Zend_Date::DAY_OF_YEAR )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NARROW )); - $this->assertFalse( $date->toValue(Zend_Date::WEEKDAY_NAME )); - $this->assertSame( 7, $date->toValue(Zend_Date::WEEK )); - $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME )); - $this->assertSame( 2, $date->toValue(Zend_Date::MONTH )); - $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_SHORT )); - $this->assertSame( 2, $date->toValue(Zend_Date::MONTH_SHORT )); - $this->assertSame( 28, $date->toValue(Zend_Date::MONTH_DAYS )); - $this->assertFalse( $date->toValue(Zend_Date::MONTH_NAME_NARROW)); - $this->assertSame( 0, $date->toValue(Zend_Date::LEAPYEAR )); - $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR_8601 )); - $this->assertSame( 2009, $date->toValue(Zend_Date::YEAR )); - $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT )); - $this->assertSame( 9, $date->toValue(Zend_Date::YEAR_SHORT_8601 )); - $this->assertFalse( $date->toValue(Zend_Date::MERIDIEM )); - $this->assertSame( 21, $date->toValue(Zend_Date::SWATCH )); - $this->assertSame( 4, $date->toValue(Zend_Date::HOUR_SHORT_AM )); - $this->assertSame( 4, $date->toValue(Zend_Date::HOUR_SHORT )); - $this->assertSame( 4, $date->toValue(Zend_Date::HOUR_AM )); - $this->assertSame( 4, $date->toValue(Zend_Date::HOUR )); - $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE )); - $this->assertSame( 30, $date->toValue(Zend_Date::SECOND )); - $this->assertSame( 0, $date->toValue(Zend_Date::MILLISECOND )); - $this->assertSame( 31, $date->toValue(Zend_Date::MINUTE_SHORT )); - $this->assertSame( 30, $date->toValue(Zend_Date::SECOND_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE_NAME )); - $this->assertSame( 0, $date->toValue(Zend_Date::DAYLIGHT )); - $this->assertSame( 500, $date->toValue(Zend_Date::GMT_DIFF )); - $this->assertFalse( $date->toValue(Zend_Date::GMT_DIFF_SEP )); - $this->assertFalse( $date->toValue(Zend_Date::TIMEZONE )); - $this->assertSame( 18000, $date->toValue(Zend_Date::TIMEZONE_SECS )); - $this->assertFalse( $date->toValue(Zend_Date::ISO_8601 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_2822 )); - $this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP )); - $this->assertFalse( $date->toValue(Zend_Date::ERA )); - $this->assertFalse( $date->toValue(Zend_Date::ERA_NAME )); - $this->assertFalse( $date->toValue(Zend_Date::DATES )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_FULL )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_LONG )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_MEDIUM )); - $this->assertFalse( $date->toValue(Zend_Date::DATE_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::TIMES )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_FULL )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_LONG )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_MEDIUM )); - $this->assertFalse( $date->toValue(Zend_Date::TIME_SHORT )); - $this->assertFalse( $date->toValue(Zend_Date::ATOM )); - $this->assertFalse( $date->toValue(Zend_Date::COOKIE )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_822 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_850 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_1036 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_1123 )); - $this->assertFalse( $date->toValue(Zend_Date::RFC_3339 )); - $this->assertFalse( $date->toValue(Zend_Date::RSS )); - $this->assertFalse( $date->toValue(Zend_Date::W3C )); - } - - /** - * Test for toValue - */ - public function testGet() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - - $date->setTimezone('UTC'); - $this->assertSame( '13', $date->get(Zend_Date::DAY )); - $this->assertSame( 'Fre', $date->get(Zend_Date::WEEKDAY_SHORT )); - $this->assertSame( '13', $date->get(Zend_Date::DAY_SHORT )); - $this->assertSame( 'Freitag', $date->get(Zend_Date::WEEKDAY )); - $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_8601 )); - $this->assertSame( 'th', $date->get(Zend_Date::DAY_SUFFIX )); - $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_DIGIT )); - $this->assertSame( '43', $date->get(Zend_Date::DAY_OF_YEAR )); - $this->assertSame( 'F', $date->get(Zend_Date::WEEKDAY_NARROW )); - $this->assertSame( 'Fr', $date->get(Zend_Date::WEEKDAY_NAME )); - $this->assertSame( '07', $date->get(Zend_Date::WEEK )); - $this->assertSame( 'Februar', $date->get(Zend_Date::MONTH_NAME )); - $this->assertSame( '02', $date->get(Zend_Date::MONTH )); - $this->assertSame( 'Feb', $date->get(Zend_Date::MONTH_NAME_SHORT )); - $this->assertSame( '2', $date->get(Zend_Date::MONTH_SHORT )); - $this->assertSame( '28', $date->get(Zend_Date::MONTH_DAYS )); - $this->assertSame( 'F', $date->get(Zend_Date::MONTH_NAME_NARROW)); - $this->assertSame( '0', $date->get(Zend_Date::LEAPYEAR )); - $this->assertSame( '2009', $date->get(Zend_Date::YEAR_8601 )); - $this->assertSame( '2009', $date->get(Zend_Date::YEAR )); - $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT )); - $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT_8601 )); - $this->assertSame( 'nachm.', $date->get(Zend_Date::MERIDIEM )); - $this->assertSame( '021', $date->get(Zend_Date::SWATCH )); - $this->assertSame( '11', $date->get(Zend_Date::HOUR_SHORT_AM )); - $this->assertSame( '23', $date->get(Zend_Date::HOUR_SHORT )); - $this->assertSame( '11', $date->get(Zend_Date::HOUR_AM )); - $this->assertSame( '23', $date->get(Zend_Date::HOUR )); - $this->assertSame( '31', $date->get(Zend_Date::MINUTE )); - $this->assertSame( '30', $date->get(Zend_Date::SECOND )); - $this->assertSame( 0, $date->get(Zend_Date::MILLISECOND )); - $this->assertSame( '31', $date->get(Zend_Date::MINUTE_SHORT )); - $this->assertSame( '30', $date->get(Zend_Date::SECOND_SHORT )); - $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE_NAME )); - $this->assertSame( '0', $date->get(Zend_Date::DAYLIGHT )); - $this->assertSame( '+0000', $date->get(Zend_Date::GMT_DIFF )); - $this->assertSame( '+00:00', $date->get(Zend_Date::GMT_DIFF_SEP )); - $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE )); - $this->assertSame( '0', $date->get(Zend_Date::TIMEZONE_SECS )); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ISO_8601 )); - $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_2822 )); - $this->assertSame( 1234567890, $date->get(Zend_Date::TIMESTAMP )); - $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA )); - $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA_NAME )); - $this->assertSame( '13.02.2009', $date->get(Zend_Date::DATES )); - $this->assertSame( 'Freitag, 13. Februar 2009', $date->get(Zend_Date::DATE_FULL )); - $this->assertSame( '13. Februar 2009', $date->get(Zend_Date::DATE_LONG )); - $this->assertSame( '13.02.2009', $date->get(Zend_Date::DATE_MEDIUM )); - $this->assertSame( '13.02.09', $date->get(Zend_Date::DATE_SHORT )); - $this->assertSame( '23:31:30', $date->get(Zend_Date::TIMES )); - $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_FULL )); - $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_LONG )); - $this->assertSame( '23:31:30', $date->get(Zend_Date::TIME_MEDIUM )); - $this->assertSame( '23:31', $date->get(Zend_Date::TIME_SHORT )); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ATOM )); - $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::COOKIE )); - $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_822 )); - $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::RFC_850 )); - $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_1036 )); - $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_1123 )); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::RFC_3339 )); - $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RSS )); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C )); - - $this->assertSame( '13', $date->get(Zend_Date::DAY, 'es')); - $this->assertSame( 'vie', $date->get(Zend_Date::WEEKDAY_SHORT, 'es')); - $this->assertSame( '13', $date->get(Zend_Date::DAY_SHORT, 'es')); - $this->assertSame( 'viernes', $date->get(Zend_Date::WEEKDAY, 'es')); - $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_8601, 'es')); - $this->assertSame( 'th', $date->get(Zend_Date::DAY_SUFFIX, 'es')); - $this->assertSame( '5', $date->get(Zend_Date::WEEKDAY_DIGIT, 'es')); - $this->assertSame( '43', $date->get(Zend_Date::DAY_OF_YEAR, 'es')); - $this->assertSame( 'v', $date->get(Zend_Date::WEEKDAY_NARROW, 'es')); - $this->assertSame( 'vie', $date->get(Zend_Date::WEEKDAY_NAME, 'es')); - $this->assertSame( '07', $date->get(Zend_Date::WEEK, 'es')); - $this->assertSame( 'febrero', $date->get(Zend_Date::MONTH_NAME, 'es')); - $this->assertSame( '02', $date->get(Zend_Date::MONTH, 'es')); - $this->assertSame( 'feb', $date->get(Zend_Date::MONTH_NAME_SHORT, 'es')); - $this->assertSame( '2', $date->get(Zend_Date::MONTH_SHORT, 'es')); - $this->assertSame( '28', $date->get(Zend_Date::MONTH_DAYS, 'es')); - $this->assertSame( 'f', $date->get(Zend_Date::MONTH_NAME_NARROW, 'es')); - $this->assertSame( '0', $date->get(Zend_Date::LEAPYEAR, 'es')); - $this->assertSame( '2009', $date->get(Zend_Date::YEAR_8601, 'es')); - $this->assertSame( '2009', $date->get(Zend_Date::YEAR, 'es')); - $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT, 'es')); - $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT_8601, 'es')); - $this->assertSame( 'p.m.', $date->get(Zend_Date::MERIDIEM, 'es')); - $this->assertSame( '021', $date->get(Zend_Date::SWATCH, 'es')); - $this->assertSame( '11', $date->get(Zend_Date::HOUR_SHORT_AM, 'es')); - $this->assertSame( '23', $date->get(Zend_Date::HOUR_SHORT, 'es')); - $this->assertSame( '11', $date->get(Zend_Date::HOUR_AM, 'es')); - $this->assertSame( '23', $date->get(Zend_Date::HOUR, 'es')); - $this->assertSame( '31', $date->get(Zend_Date::MINUTE, 'es')); - $this->assertSame( '30', $date->get(Zend_Date::SECOND, 'es')); - $this->assertSame( 0, $date->get(Zend_Date::MILLISECOND, 'es')); - $this->assertSame( '31', $date->get(Zend_Date::MINUTE_SHORT, 'es')); - $this->assertSame( '30', $date->get(Zend_Date::SECOND_SHORT, 'es')); - $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE_NAME, 'es')); - $this->assertSame( '0', $date->get(Zend_Date::DAYLIGHT, 'es')); - $this->assertSame( '+0000', $date->get(Zend_Date::GMT_DIFF, 'es')); - $this->assertSame( '+00:00', $date->get(Zend_Date::GMT_DIFF_SEP, 'es')); - $this->assertSame( 'UTC', $date->get(Zend_Date::TIMEZONE, 'es')); - $this->assertSame( '0', $date->get(Zend_Date::TIMEZONE_SECS, 'es')); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ISO_8601, 'es')); - $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_2822, 'es')); - $this->assertSame( 1234567890, $date->get(Zend_Date::TIMESTAMP, 'es')); - $this->assertSame( 'd.C.', $date->get(Zend_Date::ERA, 'es')); - $this->assertSame( 'anno Dómini', $date->get(Zend_Date::ERA_NAME, 'es')); - $this->assertSame( '13/02/2009', $date->get(Zend_Date::DATES, 'es')); - $this->assertSame( 'viernes 13 de febrero de 2009', $date->get(Zend_Date::DATE_FULL, 'es')); - $this->assertSame( '13 de febrero de 2009', $date->get(Zend_Date::DATE_LONG, 'es')); - $this->assertSame( '13/02/2009', $date->get(Zend_Date::DATE_MEDIUM, 'es')); - $this->assertSame( '13/02/09', $date->get(Zend_Date::DATE_SHORT, 'es')); - $this->assertSame( '23:31:30', $date->get(Zend_Date::TIMES, 'es')); - $this->assertSame( '11:31:30 p.m. UTC', $date->get(Zend_Date::TIME_FULL, 'es')); - $this->assertSame( '23:31:30 UTC', $date->get(Zend_Date::TIME_LONG, 'es')); - $this->assertSame( '23:31:30', $date->get(Zend_Date::TIME_MEDIUM, 'es')); - $this->assertSame( '23:31', $date->get(Zend_Date::TIME_SHORT, 'es')); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::ATOM, 'es')); - $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::COOKIE, 'es')); - $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_822, 'es')); - $this->assertSame( 'Friday, 13-Feb-09 23:31:30 UTC', $date->get(Zend_Date::RFC_850, 'es')); - $this->assertSame( 'Fri, 13 Feb 09 23:31:30 +0000', $date->get(Zend_Date::RFC_1036, 'es')); - $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RFC_1123, 'es')); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::RFC_3339, 'es')); - $this->assertSame('Fri, 13 Feb 2009 23:31:30 +0000', $date->get(Zend_Date::RSS, 'es')); - $this->assertSame( '2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C, 'es')); - - $date->setTimezone('Indian/Maldives'); - $this->assertSame( 1234567890, $date->get( )); - $this->assertSame( '14', $date->get(Zend_Date::DAY )); - $this->assertSame( 'Sam', $date->get(Zend_Date::WEEKDAY_SHORT )); - $this->assertSame( '14', $date->get(Zend_Date::DAY_SHORT )); - $this->assertSame( 'Samstag', $date->get(Zend_Date::WEEKDAY )); - $this->assertSame( '6', $date->get(Zend_Date::WEEKDAY_8601 )); - $this->assertSame( 'th', $date->get(Zend_Date::DAY_SUFFIX )); - $this->assertSame( '6', $date->get(Zend_Date::WEEKDAY_DIGIT )); - $this->assertSame( '44', $date->get(Zend_Date::DAY_OF_YEAR )); - $this->assertSame( 'S', $date->get(Zend_Date::WEEKDAY_NARROW )); - $this->assertSame( 'Sa', $date->get(Zend_Date::WEEKDAY_NAME )); - $this->assertSame( '07', $date->get(Zend_Date::WEEK )); - $this->assertSame( 'Februar', $date->get(Zend_Date::MONTH_NAME )); - $this->assertSame( '02', $date->get(Zend_Date::MONTH )); - $this->assertSame( 'Feb', $date->get(Zend_Date::MONTH_NAME_SHORT )); - $this->assertSame( '2', $date->get(Zend_Date::MONTH_SHORT )); - $this->assertSame( '28', $date->get(Zend_Date::MONTH_DAYS )); - $this->assertSame( 'F', $date->get(Zend_Date::MONTH_NAME_NARROW)); - $this->assertSame( '0', $date->get(Zend_Date::LEAPYEAR )); - $this->assertSame( '2009', $date->get(Zend_Date::YEAR_8601 )); - $this->assertSame( '2009', $date->get(Zend_Date::YEAR )); - $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT )); - $this->assertSame( '09', $date->get(Zend_Date::YEAR_SHORT_8601 )); - $this->assertSame( 'vorm.', $date->get(Zend_Date::MERIDIEM )); - $this->assertSame( '021', $date->get(Zend_Date::SWATCH )); - $this->assertSame( '4', $date->get(Zend_Date::HOUR_SHORT_AM )); - $this->assertSame( '4', $date->get(Zend_Date::HOUR_SHORT )); - $this->assertSame( '04', $date->get(Zend_Date::HOUR_AM )); - $this->assertSame( '04', $date->get(Zend_Date::HOUR )); - $this->assertSame( '31', $date->get(Zend_Date::MINUTE )); - $this->assertSame( '30', $date->get(Zend_Date::SECOND )); - $this->assertSame( 0, $date->get(Zend_Date::MILLISECOND )); - $this->assertSame( '31', $date->get(Zend_Date::MINUTE_SHORT )); - $this->assertSame( '30', $date->get(Zend_Date::SECOND_SHORT )); - $this->assertSame( 'Indian/Maldives', $date->get(Zend_Date::TIMEZONE_NAME )); - $this->assertSame( '0', $date->get(Zend_Date::DAYLIGHT )); - $this->assertSame( '+0500', $date->get(Zend_Date::GMT_DIFF )); - $this->assertSame( '+05:00', $date->get(Zend_Date::GMT_DIFF_SEP )); - $this->assertSame( 'MVT', $date->get(Zend_Date::TIMEZONE )); - $this->assertSame( '18000', $date->get(Zend_Date::TIMEZONE_SECS )); - $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::ISO_8601 )); - $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date::RFC_2822 )); - $this->assertSame( 1234567890, $date->get(Zend_Date::TIMESTAMP )); - $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA )); - $this->assertSame( 'n. Chr.', $date->get(Zend_Date::ERA_NAME )); - $this->assertSame( '14.02.2009', $date->get(Zend_Date::DATES )); - $this->assertSame( 'Samstag, 14. Februar 2009', $date->get(Zend_Date::DATE_FULL )); - $this->assertSame( '14. Februar 2009', $date->get(Zend_Date::DATE_LONG )); - $this->assertSame( '14.02.2009', $date->get(Zend_Date::DATE_MEDIUM )); - $this->assertSame( '14.02.09', $date->get(Zend_Date::DATE_SHORT )); - $this->assertSame( '04:31:30', $date->get(Zend_Date::TIMES )); - $this->assertSame( '04:31:30 MVT', $date->get(Zend_Date::TIME_FULL )); - $this->assertSame( '04:31:30 MVT', $date->get(Zend_Date::TIME_LONG )); - $this->assertSame( '04:31:30', $date->get(Zend_Date::TIME_MEDIUM )); - $this->assertSame( '04:31', $date->get(Zend_Date::TIME_SHORT )); - $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::ATOM )); - $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Zend_Date::COOKIE )); - $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Zend_Date::RFC_822 )); - $this->assertSame('Saturday, 14-Feb-09 04:31:30 Indian/Maldives', $date->get(Zend_Date::RFC_850 )); - $this->assertSame( 'Sat, 14 Feb 09 04:31:30 +0500', $date->get(Zend_Date::RFC_1036 )); - $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date::RFC_1123 )); - $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::RFC_3339 )); - $this->assertSame( 'Sat, 14 Feb 2009 04:31:30 +0500', $date->get(Zend_Date::RSS )); - $this->assertSame( '2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C )); - - // when get() receives a format string it responses like toString(); - $date->setTimezone('Indian/Maldives'); - $this->assertSame('2009', $date->get('Y')); - } - - /** - * Test for toValue - */ - public function testGet2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(-62362925370,null,$locale); - $this->assertSame('v. Chr.', $date->get(Zend_Date::ERA)); - $this->assertSame('v. Chr.', $date->get(Zend_Date::ERA_NAME)); - } - - /** - * Test for set - */ - public function testSet() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - $date->setTimezone(date_default_timezone_get()); - $d2->setTimezone(date_default_timezone_get()); - - $retour = $date->set(1234567890); - $this->assertSame('1234567890', (string)$retour ); - $this->assertSame('1010101010', (string)$date->set($d2 )); - $this->assertSame('1234567891', (string)$date->set(1234567891)); - - try { - $date->set('noday', Zend_Date::DAY); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2, Zend_Date::DAY); - $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->set( 10, Zend_Date::DAY); - $this->assertSame('2009-02-10T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->set( 40, Zend_Date::DAY); - $this->assertSame('2009-03-12T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->set(-10, Zend_Date::DAY); - $this->assertSame('2009-02-18T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('UTC'); - $date->set( 10, Zend_Date::DAY); - $this->assertSame('2009-02-10T23:31:31+00:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set($d2, Zend_Date::DAY); - $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('UTC'); - $date->set( 10, Zend_Date::DAY, 'en_US'); - $this->assertSame('2009-02-10T23:31:31+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY, 'en_US'); - $this->assertSame('2009-02-04T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(-20, Zend_Date::DAY, 'en_US'); - $this->assertSame('2009-01-11T04:31:31+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY, 'en_US'); - $this->assertSame('2009-01-04T04:31:31+05:00', $date->get(Zend_Date::W3C)); - - $date->set('10.April.2007', 'dd.MMMM.YYYY'); - $this->assertSame('2007-04-10T00:00:00+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for set - */ - public function testSet2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - $date->setTimezone(date_default_timezone_get()); - $d2->setTimezone(date_default_timezone_get()); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::WEEKDAY_SHORT); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Son', Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Mon', Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('UTC'); - $date->set('Fre', Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('Thu', Zend_Date::WEEKDAY_SHORT, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_SHORT, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('UTC'); - $date->set('Wed', Zend_Date::WEEKDAY_SHORT , 'en_US'); - $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_SHORT, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('xxx', Zend_Date::DAY_SHORT); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DAY_SHORT); - $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 10, Zend_Date::DAY_SHORT); - $this->assertSame('2009-02-10T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 40, Zend_Date::DAY_SHORT); - $this->assertSame('2009-03-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-10, Zend_Date::DAY_SHORT); - $this->assertSame('2009-02-18T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 10, Zend_Date::DAY_SHORT); - $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY_SHORT); - $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 10, Zend_Date::DAY_SHORT, 'en_US'); - $this->assertSame('2009-02-10T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY_SHORT, 'en_US'); - $this->assertSame('2009-02-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::DAY_SHORT, 'en_US'); - $this->assertSame('2009-01-11T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY_SHORT, 'en_US'); - $this->assertSame('2009-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::WEEKDAY); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEKDAY); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Sonntag', Zend_Date::WEEKDAY); - $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Montag', Zend_Date::WEEKDAY); - $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('Freitag', Zend_Date::WEEKDAY); - $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('Wednesday', Zend_Date::WEEKDAY, 'en_US'); - $this->assertSame('2009-02-11T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('Thursday', Zend_Date::WEEKDAY, 'en_US'); - $this->assertSame('2009-02-12T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set(0, Zend_Date::WEEKDAY_8601); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - try { - $date->set('noday', Zend_Date::WEEKDAY_8601); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEKDAY_8601); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1, Zend_Date::WEEKDAY_8601); - $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(5, Zend_Date::WEEKDAY_8601); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(2, Zend_Date::WEEKDAY_8601); - $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_8601); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(4, Zend_Date::WEEKDAY_8601, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_8601, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(3, Zend_Date::WEEKDAY_8601, 'en_US'); - $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_8601, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set($d2, Zend_Date::DAY_SUFFIX); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set(7, Zend_Date::WEEKDAY_DIGIT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - try { - $date->set('noday', Zend_Date::WEEKDAY_DIGIT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(5, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(2, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2009-02-10T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(4, Zend_Date::WEEKDAY_DIGIT, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_DIGIT, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(3, Zend_Date::WEEKDAY_DIGIT, 'en_US'); - $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_DIGIT, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DAY_OF_YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 124, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2009-05-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 524, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2010-06-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-135, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2009-08-18T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 422, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2010-02-26T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2010-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 12, Zend_Date::DAY_OF_YEAR, 'en_US'); - $this->assertSame('2010-01-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY_OF_YEAR, 'en_US'); - $this->assertSame('2010-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-253, Zend_Date::DAY_OF_YEAR, 'en_US'); - $this->assertSame('2009-04-22T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::DAY_OF_YEAR, 'en_US'); - $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::WEEKDAY_NARROW); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('S', Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('M', Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('F', Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('W', Zend_Date::WEEKDAY_NARROW, 'en_US'); - $this->assertSame('2009-02-11T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_NARROW, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('W', Zend_Date::WEEKDAY_NARROW, 'en_US'); - $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_NARROW, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::WEEKDAY_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEKDAY_NAME); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('So', Zend_Date::WEEKDAY_NAME); - $this->assertSame('2009-02-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Mo', Zend_Date::WEEKDAY_NAME); - $this->assertSame('2009-02-09T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('Fr', Zend_Date::WEEKDAY_NAME); - $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_NAME); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('Thu', Zend_Date::WEEKDAY_NAME, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_NAME, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('Wed', Zend_Date::WEEKDAY_NAME, 'en_US'); - $this->assertSame('2009-02-11T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEKDAY_NAME, 'en_US'); - $this->assertSame('2009-02-13T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::WEEK); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::WEEK); - $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 1, Zend_Date::WEEK); - $this->assertSame('2009-01-03T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 55, Zend_Date::WEEK); - $this->assertSame('2010-01-16T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-57, Zend_Date::WEEK); - $this->assertSame('2008-11-29T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 50, Zend_Date::WEEK); - $this->assertSame('2008-12-12T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEK); - $this->assertSame('2008-01-05T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 10, Zend_Date::WEEK, 'en_US'); - $this->assertSame('2008-03-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEK, 'en_US'); - $this->assertSame('2008-01-05T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-25, Zend_Date::WEEK, 'en_US'); - $this->assertSame('2007-07-06T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::WEEK, 'en_US'); - $this->assertSame('2007-01-06T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MONTH_NAME); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MONTH_NAME); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('März', Zend_Date::MONTH_NAME); - $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Dezember', Zend_Date::MONTH_NAME); - $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('August', Zend_Date::MONTH_NAME); - $this->assertSame('2009-08-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('April', Zend_Date::MONTH_NAME, 'en_US'); - $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('July', Zend_Date::MONTH_NAME, 'en_US'); - $this->assertSame('2009-07-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MONTH); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MONTH); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('03', Zend_Date::MONTH); - $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 14, Zend_Date::MONTH); - $this->assertSame('2010-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::MONTH); - $this->assertSame('2009-06-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 10, Zend_Date::MONTH); - $this->assertSame('2009-10-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::MONTH, 'en_US'); - $this->assertSame('2009-09-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::MONTH, 'en_US'); - $this->assertSame('2007-04-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH, 'en_US'); - $this->assertSame('2007-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MONTH_NAME_SHORT); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Mär', Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Dez', Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('Aug', Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2009-08-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('Apr', Zend_Date::MONTH_NAME_SHORT, 'en_US'); - $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME_SHORT, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('Jul', Zend_Date::MONTH_NAME_SHORT, 'en_US'); - $this->assertSame('2009-07-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME_SHORT, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MONTH_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MONTH_SHORT); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::MONTH_SHORT); - $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 14, Zend_Date::MONTH_SHORT); - $this->assertSame('2010-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::MONTH_SHORT); - $this->assertSame('2009-06-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 10, Zend_Date::MONTH_SHORT); - $this->assertSame('2009-10-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_SHORT); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::MONTH_SHORT, 'en_US'); - $this->assertSame('2009-09-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_SHORT, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::MONTH_SHORT, 'en_US'); - $this->assertSame('2007-04-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_SHORT, 'en_US'); - $this->assertSame('2007-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set($d2, Zend_Date::MONTH_DAYS); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('xxday', Zend_Date::MONTH_NAME_NARROW); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('M', Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2009-03-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('D', Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2009-12-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('A', Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2009-04-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set('A', Zend_Date::MONTH_NAME_NARROW, 'en_US'); - $this->assertSame('2009-04-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME_NARROW, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set('J', Zend_Date::MONTH_NAME_NARROW, 'en_US'); - $this->assertSame('2009-01-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MONTH_NAME_NARROW, 'en_US'); - $this->assertSame('2009-01-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set($d2, Zend_Date::LEAPYEAR); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::YEAR_8601); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::YEAR_8601); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1970, Zend_Date::YEAR_8601); - $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(2020, Zend_Date::YEAR_8601); - $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(2040, Zend_Date::YEAR_8601); - $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(1900, Zend_Date::YEAR_8601); - $this->assertSame('1900-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_8601); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(2500, Zend_Date::YEAR_8601, 'en_US'); - $this->assertSame('2500-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_8601, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::YEAR_8601, 'en_US'); - $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_8601, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::YEAR); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1970, Zend_Date::YEAR); - $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(2020, Zend_Date::YEAR); - $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(2040, Zend_Date::YEAR); - $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(1900, Zend_Date::YEAR); - $this->assertSame('1900-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(2500, Zend_Date::YEAR, 'en_US'); - $this->assertSame('2500-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::YEAR, 'en_US'); - $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::YEAR_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::YEAR_SHORT); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(70, Zend_Date::YEAR_SHORT); - $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(20, Zend_Date::YEAR_SHORT); - $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(40, Zend_Date::YEAR_SHORT); - $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(0, Zend_Date::YEAR_SHORT); - $this->assertSame('2000-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_SHORT); - $date->setTimezone('Indian/Maldives'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(30, Zend_Date::YEAR_SHORT, 'en_US'); - $this->assertSame('2030-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_SHORT, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::YEAR_SHORT, 'en_US'); - $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_SHORT, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::YEAR_SHORT_8601); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(70, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('1970-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(20, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2020-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(40, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2040-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(0, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2000-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(30, Zend_Date::YEAR_SHORT_8601, 'en_US'); - $this->assertSame('2030-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_SHORT_8601, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-20, Zend_Date::YEAR_SHORT_8601, 'en_US'); - $this->assertSame('-20-02-14T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::YEAR_SHORT_8601, 'en_US'); - $this->assertSame('2002-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MERIDIEM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::SWATCH); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::SWATCH); - $this->assertSame('2009-02-14T00:36:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(0, Zend_Date::SWATCH); - $this->assertSame('2009-02-14T00:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(600, Zend_Date::SWATCH); - $this->assertSame('2009-02-14T14:23:59+05:00', $date->get(Zend_Date::W3C)); - $date->set(1700, Zend_Date::SWATCH); - $this->assertSame('2009-02-15T16:47:59+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(1900, Zend_Date::SWATCH); - $this->assertSame('2009-02-16T21:36:00+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SWATCH); - $this->assertSame('2009-02-17T00:36:00+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(3700, Zend_Date::SWATCH, 'en_US'); - $this->assertSame('2009-02-20T16:48:00+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SWATCH, 'en_US'); - $this->assertSame('2009-02-20T00:36:00+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-200, Zend_Date::SWATCH, 'en_US'); - $this->assertSame('2009-02-18T19:12:00+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SWATCH, 'en_US'); - $this->assertSame('2009-02-19T00:36:00+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::HOUR_SHORT_AM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 14, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::HOUR_SHORT_AM, 'en_US'); - $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_SHORT_AM, 'en_US'); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-26, Zend_Date::HOUR_SHORT_AM, 'en_US'); - $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_SHORT_AM, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::HOUR_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::HOUR_SHORT); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::HOUR_SHORT); - $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 14, Zend_Date::HOUR_SHORT); - $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::HOUR_SHORT); - $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::HOUR_SHORT); - $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_SHORT); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::HOUR_SHORT, 'en_US'); - $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_SHORT, 'en_US'); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-26, Zend_Date::HOUR_SHORT, 'en_US'); - $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_SHORT, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::HOUR_AM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::HOUR_AM); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::HOUR_AM); - $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 14, Zend_Date::HOUR_AM); - $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::HOUR_AM); - $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::HOUR_AM); - $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_AM); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::HOUR_AM, 'en_US'); - $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_AM, 'en_US'); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-26, Zend_Date::HOUR_AM, 'en_US'); - $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR_AM, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::HOUR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::HOUR); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::HOUR); - $this->assertSame('2009-02-14T03:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 14, Zend_Date::HOUR); - $this->assertSame('2009-02-14T14:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::HOUR); - $this->assertSame('2009-02-13T18:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::HOUR); - $this->assertSame('2009-02-14T06:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::HOUR, 'en_US'); - $this->assertSame('2009-02-14T09:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR, 'en_US'); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-26, Zend_Date::HOUR, 'en_US'); - $this->assertSame('2009-02-11T22:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::HOUR, 'en_US'); - $this->assertSame('2009-02-12T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MINUTE); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MINUTE); - $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::MINUTE); - $this->assertSame('2009-02-14T04:03:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 65, Zend_Date::MINUTE); - $this->assertSame('2009-02-14T05:05:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::MINUTE); - $this->assertSame('2009-02-14T04:54:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::MINUTE); - $this->assertSame('2009-02-13T23:30:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MINUTE); - $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::MINUTE, 'en_US'); - $this->assertSame('2009-02-14T04:09:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MINUTE, 'en_US'); - $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-65, Zend_Date::MINUTE, 'en_US'); - $this->assertSame('2009-02-13T21:55:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MINUTE, 'en_US'); - $this->assertSame('2009-02-14T02:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MINUTE_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MINUTE_SHORT); - $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::MINUTE_SHORT); - $this->assertSame('2009-02-14T04:03:30+05:00', $date->get(Zend_Date::W3C)); - $date->set( 65, Zend_Date::MINUTE_SHORT); - $this->assertSame('2009-02-14T05:05:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::MINUTE_SHORT); - $this->assertSame('2009-02-14T04:54:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::MINUTE_SHORT); - $this->assertSame('2009-02-13T23:30:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MINUTE_SHORT); - $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::MINUTE_SHORT, 'en_US'); - $this->assertSame('2009-02-14T04:09:30+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MINUTE_SHORT, 'en_US'); - $this->assertSame('2009-02-14T04:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-65, Zend_Date::MINUTE_SHORT, 'en_US'); - $this->assertSame('2009-02-13T21:55:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::MINUTE_SHORT, 'en_US'); - $this->assertSame('2009-02-14T02:36:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::SECOND); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::SECOND); - $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::SECOND); - $this->assertSame('2009-02-14T04:31:03+05:00', $date->get(Zend_Date::W3C)); - $date->set( 65, Zend_Date::SECOND); - $this->assertSame('2009-02-14T04:32:05+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::SECOND); - $this->assertSame('2009-02-14T04:31:54+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::SECOND); - $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SECOND); - $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::SECOND, 'en_US'); - $this->assertSame('2009-02-14T04:31:09+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SECOND, 'en_US'); - $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-65, Zend_Date::SECOND, 'en_US'); - $this->assertSame('2009-02-13T23:29:55+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SECOND, 'en_US'); - $this->assertSame('2009-02-14T04:29:50+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::SECOND_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::SECOND_SHORT); - $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C)); - $date->set( 3, Zend_Date::SECOND_SHORT); - $this->assertSame('2009-02-14T04:31:03+05:00', $date->get(Zend_Date::W3C)); - $date->set( 65, Zend_Date::SECOND_SHORT); - $this->assertSame('2009-02-14T04:32:05+05:00', $date->get(Zend_Date::W3C)); - $date->set(-6, Zend_Date::SECOND_SHORT); - $this->assertSame('2009-02-14T04:31:54+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set( 30, Zend_Date::SECOND_SHORT); - $this->assertSame('2009-02-13T23:31:30+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SECOND_SHORT); - $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set( 9, Zend_Date::SECOND_SHORT, 'en_US'); - $this->assertSame('2009-02-14T04:31:09+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SECOND_SHORT, 'en_US'); - $this->assertSame('2009-02-14T04:31:50+05:00', $date->get(Zend_Date::W3C)); - $date->setTimeZone('UTC'); - $date->set(-65, Zend_Date::SECOND_SHORT, 'en_US'); - $this->assertSame('2009-02-13T23:29:55+00:00', $date->get(Zend_Date::W3C)); - $date->set($d2, Zend_Date::SECOND_SHORT, 'en_US'); - $this->assertSame('2009-02-14T04:29:50+05:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::MILLISECOND); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::MILLISECOND); - $this->assertSame(0, $date->get(Zend_Date::MILLISECOND)); - $date->set( 3, Zend_Date::MILLISECOND); - $this->assertSame(3, $date->get(Zend_Date::MILLISECOND)); - $date->set( 1065, Zend_Date::MILLISECOND); - $this->assertSame(65, $date->get(Zend_Date::MILLISECOND)); - $date->set(-6, Zend_Date::MILLISECOND); - $this->assertSame(994, $date->get(Zend_Date::MILLISECOND)); - $date->set( 30, Zend_Date::MILLISECOND, true); - $this->assertSame(30, $date->get(Zend_Date::MILLISECOND)); - $date->set($d2, Zend_Date::MILLISECOND, true); - $this->assertSame(0, $date->get(Zend_Date::MILLISECOND)); - $date->set( 9, Zend_Date::MILLISECOND, false, 'en_US'); - $this->assertSame(9, $date->get(Zend_Date::MILLISECOND)); - $date->set($d2, Zend_Date::MILLISECOND, false, 'en_US'); - $this->assertSame(0, $date->get(Zend_Date::MILLISECOND)); - $date->set(-65, Zend_Date::MILLISECOND, true , 'en_US'); - $this->assertSame(935, $date->get(Zend_Date::MILLISECOND)); - $date->set($d2, Zend_Date::MILLISECOND, true , 'en_US'); - $this->assertSame(0, $date->get(Zend_Date::MILLISECOND)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIMEZONE_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DAYLIGHT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::GMT_DIFF); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::GMT_DIFF_SEP); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIMEZONE); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIMEZONE_SECS); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::ISO_8601); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::ISO_8601); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2007-10-20 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2007-10-20 201030', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('07-10-20 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('80-10-20 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-2007-10-20 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-07-10-20 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-7-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2007-10-20T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2007-10-20T201030', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('20-10-20T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2020-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('80-10-20T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-2007-10-20T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-07-10-20T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-7-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('20071020 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('201020 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2020-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('801020 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('1980-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-071020 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-7-10-20T20:10:30-07:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-00071020 20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-7-10-20T20:10:30+00:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(1234567890); - $date->set('20071020T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T20:10:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('-00071020T20:10:30', Zend_Date::ISO_8601); - $this->assertSame('-7-10-20T20:10:30+00:00', $date->get(Zend_Date::W3C)); - $date->setTimezone('Indian/Maldives'); - $date->set(1234567890); - $date->set('2007-10-20', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('20071020', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('20071020122030', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T12:20:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('071020', Zend_Date::ISO_8601); - $this->assertSame('2007-10-20T00:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('07:10:20', Zend_Date::ISO_8601); - $this->assertSame('1970-01-01T07:10:20+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RFC_2822); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RFC_2822); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Jan 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-01-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Feb 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-02-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Mar 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-03-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Apr 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-04-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 May 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-05-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Jun 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-06-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Jul 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-07-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Aug 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-08-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Sep 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-09-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Oct 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-10-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Nov 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-11-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Thu, 05 Dec 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->assertSame('2009-12-05T01:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - try { - $date->set('Thu, 05 Fxx 2009 01:31:30 +0500', Zend_Date::RFC_2822); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIMESTAMP); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::TIMESTAMP); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('1010101099', Zend_Date::TIMESTAMP); - $this->assertSame('2002-01-04T04:38:19+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::ERA); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::ERA_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DATES); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DATES); - $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('14.02.2009', Zend_Date::DATES); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DATE_FULL); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DATE_FULL); - $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Samstag, 14. Februar 2009', Zend_Date::DATE_FULL); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DATE_LONG); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DATE_LONG); - $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('14. Februar 2009', Zend_Date::DATE_LONG); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DATE_MEDIUM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DATE_MEDIUM); - $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('14.02.2009', Zend_Date::DATE_MEDIUM); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::DATE_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::DATE_SHORT); - $this->assertSame('2002-01-04T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('14.02.09', Zend_Date::DATE_SHORT); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIMES); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::TIMES); - $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('15:26:40', Zend_Date::TIMES); - $this->assertSame('2009-02-14T15:26:40+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIME_FULL); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::TIME_FULL); - $this->assertSame('2009-02-14T04:36:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('15:26 Uhr CET', Zend_Date::TIME_FULL); - $this->assertSame('2009-02-14T15:26:00+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIME_LONG); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::TIME_LONG); - $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('15:26:40 CET', Zend_Date::TIME_LONG); - $this->assertSame('2009-02-14T15:26:40+01:00', $date->get(Zend_Date::W3C)); - - $date->setTimezone('Indian/Maldives'); - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIME_MEDIUM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::TIME_MEDIUM); - $this->assertSame('2009-02-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('15:26:40', Zend_Date::TIME_MEDIUM); - $this->assertSame('2009-02-14T15:26:40+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::TIME_SHORT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::TIME_SHORT); - $this->assertSame('2009-02-14T04:36:00+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('15:26', Zend_Date::TIME_SHORT); - $this->assertSame('2009-02-14T15:26:00+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::ATOM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::ATOM); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2009-02-14T00:31:30+05:00', Zend_Date::ATOM); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::COOKIE); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::COOKIE); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Saturday, 14-Feb-09 00:31:30 Europe/Vienna', Zend_Date::COOKIE); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RFC_822); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RFC_822); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date::RFC_822); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RFC_850); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RFC_850); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Saturday, 14-Feb-09 00:31:30 Europe/Vienna', Zend_Date::RFC_850); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RFC_1036); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RFC_1036); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date::RFC_1036); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RFC_1123); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RFC_1123); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Sat, 14 Feb 2009 00:31:30 +0500', Zend_Date::RFC_1123); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RFC_3339); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RFC_3339); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2009-02-14T00:31:30+05:00', Zend_Date::RFC_3339); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::RSS); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::RSS); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('Sat, 14 Feb 2009 00:31:30 +0500', Zend_Date::RSS); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Sat, 14 Feb 2009 00:31:30 GMT', Zend_Date::RSS); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Sat, 14 Feb 09 00:31:30 GMT', Zend_Date::RSS); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('Sat, 14 Feb 09 00:31:30 +0500', Zend_Date::RSS); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date->set(1234567890); - try { - $date->set('noday', Zend_Date::W3C); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set($d2, Zend_Date::W3C); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->set(1234567890); - $date->set('2009-02-14T00:31:30+05:00', Zend_Date::W3C); - $this->assertSame('2009-02-14T00:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->set('2009-02-14T00:31:30-05:00', Zend_Date::W3C); - $this->assertSame('2009-02-14T00:31:30-05:00', $date->get(Zend_Date::W3C)); - - $date->setTimezone('Indian/Maldives'); - $date->set(1234567890); - try { - $date->set('noday', 'xx'); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - try { - $date->set($d2, 'xx'); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - $date->set(1234567890); - $date->set('1000', 'xx'); - $this->assertSame('1970-01-01T05:16:40+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for add - */ - public function testAdd() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $retour = $date->set(1234567890); - $this->assertSame((string)$retour,'1234567890'); - $this->assertSame((string)$date->add(10),'1234567900'); - $this->assertSame((string)$date->add(-10),'1234567890'); - $this->assertSame((string)$date->add(0),'1234567890'); - - $date->set($d2); - $date->add(10, Zend_Date::DAY); - $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::DAY); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Mon', Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::DAY_SHORT); - $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::DAY_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Montag', Zend_Date::WEEKDAY); - $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(1, Zend_Date::WEEKDAY_8601); - $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->add($d2, Zend_Date::DAY_SUFFIX); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - } - - - /** - * Test for add - */ - public function testAdd2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $date->set($d2); - $date->add(1, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('M', Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Mo', Zend_Date::WEEKDAY_NAME); - $this->assertSame('2002-01-05T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::WEEK); - $this->assertSame('2002-03-15T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::WEEK); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('April', Zend_Date::MONTH_NAME); - $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::MONTH); - $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::MONTH); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Apr', Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2002-08-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::MONTH_SHORT); - $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::MONTH_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->add($d2, Zend_Date::MONTH_DAYS); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->add('M', Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2002-06-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->add($d2, Zend_Date::LEAPYEAR); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->add(10, Zend_Date::YEAR_8601); - $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::YEAR_8601); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::YEAR); - $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::YEAR); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::YEAR_SHORT); - $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::YEAR_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->add('noday', Zend_Date::MERIDIEM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->add(10, Zend_Date::SWATCH); - $this->assertSame('2002-01-04T04:51:14+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::SWATCH); - $this->assertSame('2002-01-04T04:36:49+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::HOUR_SHORT); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::HOUR_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::HOUR_AM); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::HOUR_AM); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::HOUR); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::HOUR); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::MINUTE); - $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::MINUTE); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::MINUTE_SHORT); - $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::MINUTE_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::SECOND); - $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::SECOND); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::SECOND_SHORT); - $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C)); - $date->add(-10, Zend_Date::SECOND_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::MILLISECOND); - $this->assertSame(10, $date->get(Zend_Date::MILLISECOND)); - $date->add(-10, Zend_Date::MILLISECOND); - $this->assertSame( 0, $date->get(Zend_Date::MILLISECOND)); - - $date->set($d2); - try { - $date->add('noday', Zend_Date::TIMEZONE_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->add('noday', Zend_Date::DAYLIGHT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->add('noday', Zend_Date::GMT_DIFF); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->add('noday', Zend_Date::GMT_DIFF_SEP); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->add('noday', Zend_Date::TIMEZONE); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->add('noday', Zend_Date::TIMEZONE_SECS); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->add('1000-01-02 20:05:12', Zend_Date::ISO_8601); - $this->assertSame('3002-02-07T19:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Thu, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_2822); - $this->assertSame('3002-02-07T19:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add(10, Zend_Date::TIMESTAMP); - $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->add('noday', Zend_Date::ERA); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->add('noday', Zend_Date::ERA_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->add('10.02.0005', Zend_Date::DATES); - $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Samstag, 10. Februar 0005', Zend_Date::DATE_FULL); - $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10. Februar 0005', Zend_Date::DATE_LONG); - $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10.02.0005', Zend_Date::DATE_MEDIUM); - $this->assertSame('2007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10.02.05', Zend_Date::DATE_SHORT); - $this->assertSame('4007-03-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10:05:05', Zend_Date::TIMES); - $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10:05 Uhr CET', Zend_Date::TIME_FULL); - $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10:05:05 CET', Zend_Date::TIME_LONG); - $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10:05:05', Zend_Date::TIME_MEDIUM); - $this->assertSame('2002-01-04T14:41:55+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('10:05', Zend_Date::TIME_SHORT); - $this->assertSame('2002-01-04T14:41:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('1000-01-02T20:05:12+05:00', Zend_Date::ATOM); - $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::COOKIE); - $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_822); - $this->assertSame('4002-02-06T19:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::RFC_850); - $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_1036); - $this->assertSame('4002-02-07T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_1123); - $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('1000-01-02T20:05:12+05:00', Zend_Date::RFC_3339); - $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RSS); - $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('1000-01-02T20:05:12+05:00', Zend_Date::W3C); - $this->assertSame('3002-02-08T00:42:02+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->add('1000', 'xx'); - $this->assertSame('2002-01-04T04:53:30+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for sub - */ - public function testSub() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $retour = $date->set(1234567890); - $this->assertSame('1234567890', (string)$retour ); - $this->assertSame('1234567900', (string)$date->sub(-10)); - $this->assertSame('1234567890', (string)$date->sub( 10)); - $this->assertSame('1234567890', (string)$date->sub( 0)); - - $date->set($d2); - $date->sub(-10, Zend_Date::DAY); - $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::DAY); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for sub - */ - public function testSub2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $date->set($d2); - $date->sub('Mon', Zend_Date::WEEKDAY_SHORT); - $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::DAY_SHORT); - $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::DAY_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Montag', Zend_Date::WEEKDAY); - $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(1, Zend_Date::WEEKDAY_8601); - $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->sub($d2, Zend_Date::DAY_SUFFIX); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->sub(1, Zend_Date::WEEKDAY_DIGIT); - $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2002-01-14T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::DAY_OF_YEAR); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('M', Zend_Date::WEEKDAY_NARROW); - $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Mo', Zend_Date::WEEKDAY_NAME); - $this->assertSame('2002-01-03T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::WEEK); - $this->assertSame('2002-03-15T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::WEEK); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('April', Zend_Date::MONTH_NAME); - $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::MONTH); - $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::MONTH); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Apr', Zend_Date::MONTH_NAME_SHORT); - $this->assertSame('2001-09-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::MONTH_SHORT); - $this->assertSame('2002-11-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::MONTH_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->sub($d2, Zend_Date::MONTH_DAYS); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->sub('M', Zend_Date::MONTH_NAME_NARROW); - $this->assertSame('2001-10-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->sub($d2, Zend_Date::LEAPYEAR); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->sub(-10, Zend_Date::YEAR_8601); - $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::YEAR_8601); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::YEAR); - $this->assertSame('2012-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::YEAR); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(10, Zend_Date::YEAR_SHORT); - $this->assertSame('1992-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(-10, Zend_Date::YEAR_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(10, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('1992-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(-10, Zend_Date::YEAR_SHORT_8601); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::MERIDIEM); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->sub(-10, Zend_Date::SWATCH); - $this->assertSame('2002-01-04T04:51:15+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::SWATCH); - $this->assertSame('2002-01-04T04:36:51+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::HOUR_SHORT_AM); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::HOUR_SHORT); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::HOUR_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::HOUR_AM); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::HOUR_AM); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::HOUR); - $this->assertSame('2002-01-04T14:36:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::HOUR); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::MINUTE); - $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::MINUTE); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::MINUTE_SHORT); - $this->assertSame('2002-01-04T04:46:50+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::MINUTE_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::SECOND); - $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::SECOND); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::SECOND_SHORT); - $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C)); - $date->sub(10, Zend_Date::SECOND_SHORT); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::MILLISECOND); - $this->assertSame(10, $date->get(Zend_Date::MILLISECOND)); - $date->sub(10, Zend_Date::MILLISECOND); - $this->assertSame( 0, $date->get(Zend_Date::MILLISECOND)); - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::TIMEZONE_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::DAYLIGHT); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::GMT_DIFF); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::GMT_DIFF_SEP); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::TIMEZONE); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::TIMEZONE_SECS); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->sub('1000-01-02 20:05:12', Zend_Date::ISO_8601); - $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date::W3C)); - $date->set($d2); - $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::ISO_8601); - $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Thu, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_2822); - $this->assertSame('1001-11-25T13:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub(-10, Zend_Date::TIMESTAMP); - $this->assertSame('2002-01-04T04:37:00+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::ERA); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - try { - $date->sub('noday', Zend_Date::ERA_NAME); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set($d2); - $date->sub('10.02.0005', Zend_Date::DATES); - $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Samstag, 10. Februar 0005', Zend_Date::DATE_FULL); - $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10. Februar 0005', Zend_Date::DATE_LONG); - $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10.02.0005', Zend_Date::DATE_MEDIUM); - $this->assertSame('1996-10-27T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10.02.05', Zend_Date::DATE_SHORT); - $this->assertSame('-4-10-29T04:36:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10:05:05', Zend_Date::TIMES); - $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10:05 Uhr CET', Zend_Date::TIME_FULL); - $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10:05:05 CET', Zend_Date::TIME_LONG); - $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10:05:05', Zend_Date::TIME_MEDIUM); - $this->assertSame('2002-01-03T18:31:45+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('10:05', Zend_Date::TIME_SHORT); - $this->assertSame('2002-01-03T18:31:50+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::ATOM); - $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::COOKIE); - $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date::W3C) ); - - $date->set($d2); - $date->sub('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_822); - $this->assertSame('1-12-03T13:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Saturday, 02-Jan-00 20:05:12 Europe/Vienna', Zend_Date::RFC_850); - $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Sat, 02 Jan 00 20:05:12 +0500', Zend_Date::RFC_1036); - $this->assertSame('1-12-03T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RFC_1123); - $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::RFC_3339); - $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('Sat, 02 Jan 1000 20:05:12 +0500', Zend_Date::RSS); - $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('1000-01-02T20:05:12+05:00', Zend_Date::W3C); - $this->assertSame('1001-11-25T08:31:38+05:00', $date->get(Zend_Date::W3C)); - - $date->set($d2); - $date->sub('1000', 'xx'); - $this->assertSame('2002-01-04T04:20:10+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compare - */ - public function testCompare() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale);//03.01.2002 15:36:50 - - $retour = $date->set(1234567890); //13.02.2009 15:31:30 - $this->assertSame('1234567890', (string)$retour); - $this->assertSame( 0, $date->compare(1234567890)); - $this->assertSame( 1, $date->compare(1234567800)); - $this->assertSame(-1, $date->compare(1234567899)); - - $date->set($d2);//03.01.2002 15:36:50 - $this->assertSame( 1, $date->compare(3,Zend_Date::DAY)); - $this->assertSame( 0, $date->compare(4,Zend_Date::DAY)); - $this->assertSame(-1, $date->compare(5,Zend_Date::DAY)); - - $this->assertSame( 1, $date->compare('Mon',Zend_Date::WEEKDAY_SHORT)); - $this->assertSame(-1, $date->compare('Sam',Zend_Date::WEEKDAY_SHORT)); - - $date->set($d2);//03.01.2002 15:36:50 - $this->assertSame(0, $date->compare(0,Zend_Date::MILLISECOND)); - } - - /** - * Test for copy - */ - public function testCopy() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $date->set(1234567890); - $newdate = clone $date; - $this->assertSame($date->get(),$newdate->get()); - - $date->set($d2); - $newdate = $date->copyPart(Zend_Date::DAY); - $this->assertSame('2002-01-04T04:36:50+05:00', $date->get(Zend_Date::W3C )); - $this->assertSame('1970-01-04T05:00:00+05:00', $newdate->get(Zend_Date::W3C)); - } - - /** - * Test for equals - */ - public function testEquals() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $retour = $date->set(1234567890); - $this->assertSame('1234567890', (string)$retour); - $this->assertTrue( $date->equals(1234567890)); - $this->assertFalse($date->equals(1234567800)); - - $date->set($d2); - $this->assertFalse($date->equals(3,Zend_Date::DAY)); - $this->assertTrue( $date->equals(4,Zend_Date::DAY)); - } - - /** - * Test for isEarlier - */ - public function testIsEarlier() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $retour = $date->set(1234567890); - $this->assertSame('1234567890', (string)$retour); - $this->assertFalse($date->isEarlier(1234567890)); - $this->assertFalse($date->isEarlier(1234567800)); - $this->assertTrue( $date->isEarlier(1234567899)); - - $date->set($d2); - $this->assertFalse($date->isEarlier(3,Zend_Date::DAY)); - $this->assertFalse($date->isEarlier(4,Zend_Date::DAY)); - $this->assertTrue( $date->isEarlier(5,Zend_Date::DAY)); - } - - /** - * Test for isLater - */ - public function testIsLater() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(0,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $retour = $date->set(1234567890); - $this->assertSame('1234567890', (string)$retour); - $this->assertFalse($date->isLater(1234567890)); - $this->assertTrue( $date->isLater(1234567800)); - $this->assertFalse($date->isLater(1234567899)); - - $date->set($d2); - $this->assertTrue( $date->isLater(3,Zend_Date::DAY)); - $this->assertFalse($date->isLater(4,Zend_Date::DAY)); - $this->assertFalse($date->isLater(5,Zend_Date::DAY)); - } - - /** - * Test for getTime - */ - public function testGetTime() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $result = $date->getTime(); - $this->assertSame('1970-01-01T04:36:50+05:00', $result->get(Zend_Date::W3C)); - } - - /** - * Test for setTime - */ - public function testSetTime() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->setTime(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - $result = $date->setTime('10:20:30'); - $this->assertSame('2009-02-14T10:20:30+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2009-02-14T10:20:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTime('30-20-10','ss:mm:HH'); - $this->assertSame('2009-02-14T10:20:30+05:00', $date->get(Zend_Date::W3C)); - $date->setTime($d2); - $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(Zend_Date::now(), $locale); - $t1 = $date->get(Zend_Date::TIMESTAMP); - $date->setTime(Zend_Date::now()); - $t2 = $date->get(Zend_Date::TIMESTAMP); - $diff = abs($t2 - $t1); - $this->assertTrue($diff < 2, "Instance of Zend_Date has a significantly different time than returned by setTime(): $diff seconds"); - } - - /** - * Test for addTime - */ - public function testAddTime() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->addTime(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - - $date = new Zend_Date(1234567890,null,$locale); - $result = $date->addTime('10:20:30'); - $this->assertSame('2009-02-14T14:52:00+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2009-02-14T14:52:00+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->addTime('30:20:10','ss:mm:HH'); - $this->assertSame('2009-02-14T14:52:00+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->addTime($d2); - $this->assertSame('2009-02-14T09:03:09+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for subTime - */ - public function testSubTime() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->subTime(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - - $date = new Zend_Date(1234567890,null,$locale); - $result = $date->subTime('10:20:30'); - $this->assertSame('2009-02-13T18:11:00+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2009-02-13T18:11:00+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->subTime('30-20-10','ss:mm:HH'); - $this->assertSame('2009-02-13T18:11:00+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->subTime($d2); - $this->assertSame('2009-02-13T23:59:51+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compareTime - */ - public function testCompareTime() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $date = new Zend_Date(1234567890,null,$locale); - $this->assertSame(-1, $date->compareTime('10:20:30')); - $this->assertSame( 0, $date->compareTime('04:31:30')); - $this->assertSame( 1, $date->compareTime('04:00:30')); - $this->assertSame(-1, $date->compareTime($d2 )); - } - - /** - * Test for setTime - */ - public function testSetHour() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1234567890,null,$locale); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - for($i=23; $i >= 0; $i--) { - $date->setHour($i); - $hour = $i; - if ($i < 10) { - $hour = '0' . $hour; - } - $this->assertSame("2009-02-14T$hour:31:30+05:00", $date->get(Zend_Date::W3C)); - } - } - - /** - * Test for getDate - */ - public function testGetDate() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $result = $date->getDate(); - $this->assertSame('2002-01-04T05:00:00+05:00', $result->get(Zend_Date::W3C)); - } - - /** - * Test for setDate - */ - public function testSetDate() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->setDate(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - $result = $date->setDate('11.05.2008'); - // Hint: the hour changes from 0 to 1 because of DST... - // An hour is added by winter->summertime change - $this->assertSame('2008-05-11T04:31:30+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2008-05-11T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setDate('2008-05-11','YYYY-MM-dd'); - $this->assertSame('2008-05-11T04:31:30+05:00', $date->get(Zend_Date::W3C)); - $date->setDate($d2); - $this->assertSame('2009-02-14T04:31:30+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for addDate - */ - public function testAddDate() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->addDate(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - - $date = new Zend_Date(1234567890,null,$locale); - $result = $date->addDate('02-03-05'); - $this->assertSame('2014-05-17T04:31:30+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2014-05-17T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->addDate('05-03-02','YY-MM-dd'); - $this->assertSame('4014-05-17T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->addDate($d2); - $this->assertSame('4018-04-28T04:31:30+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for subDate - */ - public function testSubDate() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->subDate(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - - $date = new Zend_Date(1234567890,null,$locale); - $result = $date->subDate('03-05-1001'); - $this->assertSame('1007-09-08T04:31:30+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('1007-09-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->subDate('1001-05-03','YYYY-MM-dd'); - $this->assertSame('1007-09-08T04:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->subDate($d2); - $this->assertSame('-1-12-06T04:31:30+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compareDate - */ - public function testCompareDate() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $date = new Zend_Date(1234567890,$locale); - $this->assertSame( 1, $date->compareDate('10.01.2009')); - $this->assertSame( 0, $date->compareDate('14.02.2009')); - $this->assertSame(-1, $date->compareDate('15.02.2009')); - $this->assertSame( 0, $date->compareDate($d2 )); - } - - /** - * Test for getIso - */ - public function testGetIso() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,null,$locale); - $d2 = new Zend_Date(1010101010,null,$locale); - - $result = $date->getIso(); - $this->assertTrue(is_string($result)); - $this->assertSame('2002-01-04T04:36:50+05:00', $result); - } - - /** - * Test for setIso - */ - public function testSetIso() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->setIso(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - $result = $date->setIso('2002-01-04T00:00:00+0000'); - $this->assertSame('2002-01-04T00:00:00+00:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2002-01-04T00:00:00+00:00', $date->get(Zend_Date::W3C)); - $date->setIso($d2); - $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for addIso - */ - public function testAddIso() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $result = $date->addIso(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - } - - /** - * Test for addIso - */ - public function testAddIso2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $result = $date->setIso('2002-01-04T01:00:00+0500'); - $result = $date->addIso('0000-00-00T01:00:00+0500'); - $this->assertSame('2002-01-03T21:00:00+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2002-01-03T21:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->addIso('0001-01-01T01:01:01+0500'); - $this->assertSame('2003-02-04T17:01:01+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,$locale); - $date->addIso($d2); - $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for subIso - */ - public function testSubIso() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $result = $date->subIso(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - } - - /** - * Test for subIso - */ - public function testSubIso2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - $result = $date->subIso('0000-00-00T01:00:00+0500'); - $this->assertSame('2009-02-14T08:31:30+05:00', $result->get(Zend_Date::W3C)); - $this->assertSame('2009-02-14T08:31:30+05:00', $date->get(Zend_Date::W3C)); - - $result = $date->subIso('0001-01-01T01:01:01+0500'); - $this->assertSame('2008-01-14T12:30:29+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,null,$locale); - $date->subIso($d2); - $this->assertSame('-1-12-06T04:59:51+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compareIso - */ - public function testCompareIso() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,null,$locale); - $d2 = new Zend_Date(1234567899,null,$locale); - - $date = new Zend_Date(1234567890,null,$locale); - $this->assertSame( 1, $date->compareIso('2002-01-04T04:00:00+0500')); - $this->assertSame( 0, $date->compareIso('2009-02-14T04:31:30+0500')); - $this->assertSame(-1, $date->compareIso('2010-01-04T05:00:00+0500')); - $this->assertSame(-1, $date->compareIso($d2 )); - } - - /** - * Test for getArpa - */ - public function testGetArpa() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,null,$locale); - - $result = $date->getArpa(); - $this->assertTrue(is_string($result)); - $this->assertSame('Fri, 04 Jan 02 04:36:50 +0500', $result); - } - - /** - * Test for setArpa - */ - public function testSetArpa() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - $date->setTimezone('Indian/Maldives'); - - $result = $date->setArpa(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - $result = $date->setArpa('Sat, 03 May 01 00:00:00 +0500'); - $this->assertSame('Thu, 03 May 01 00:00:00 +0500', $result->get(Zend_Date::RFC_822)); - $this->assertSame('2001-05-03T00:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->setArpa($d2); - $this->assertSame('2009-02-14T04:31:39+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for addArpa - */ - public function testAddArpa() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $result = $date->addArpa(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - - $date = new Zend_Date(1234567890,$locale); - $result = $date->addArpa('Sat, 03 May 01 00:00:00 +0500'); - $this->assertSame('Sat, 17 Jul 10 23:31:30 +0500', $result->get(Zend_Date::RFC_822)); - $this->assertSame('4010-07-17T23:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,$locale); - $date->addArpa($d2); - $this->assertSame('4018-04-28T04:03:09+05:00', $date->get(Zend_Date::W3C)); - - $result = $date->setArpa('Fri, 05 Jan 07 03:35:53 +0500'); - $arpa = $result->getArpa(); - $this->assertSame('Fri, 05 Jan 07 03:35:53 +0500', $arpa); - } - - /** - * Test for subArpa - */ - public function testSubArpa() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $result = $date->subArpa(Zend_Date::now()); - $this->assertTrue($result instanceof Zend_Date); - - $date = new Zend_Date(1234567890,null,$locale); - $result = $date->subArpa('Sat, 03 May 01 00:00:00 +0500'); - $this->assertSame('Wed, 16 Sep 7 09:31:30 +0500', $result->get(Zend_Date::RFC_822)); - $this->assertSame('7-09-16T09:31:30+05:00', $date->get(Zend_Date::W3C)); - - $date = new Zend_Date(1234567890,$locale); - $date->subArpa($d2); - $this->assertSame('-1-12-06T04:59:51+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compareArpa - */ - public function testCompareArpa() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $date = new Zend_Date(1234567890,$locale); - $this->assertSame(-1, $date->compareArpa('Sat, 14 Feb 09 05:31:30 +0500')); - $this->assertSame( 0, $date->compareArpa('Sat, 14 Feb 09 04:31:30 +0500')); - $this->assertSame( 1, $date->compareArpa('Sat, 13 Feb 09 04:31:30 +0500')); - $this->assertSame(-1, $date->compareArpa($d2 )); - } - - /** - * Test for false locale setting - */ - public function testReducedParams() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,$locale); - - $date->setArpa('Sat, 03 May 01 00:00:00 +0500',$locale); - $this->assertSame('Thu, 03 May 01 00:00:00 +0500', $date->get(Zend_Date::RFC_822)); - } - - /** - * Test for SunFunc - */ - public function testSunFunc() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,$locale); - $date->setTimezone(date_default_timezone_get()); - - $result = Zend_Date_Cities::City('vienna'); - $this->assertTrue(is_array($result)); - $result = $date->getSunset($result); - $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date::W3C)); - - unset($result); - $result = Zend_Date_Cities::City('vienna', 'civil'); - $this->assertTrue(is_array($result)); - $result = $date->getSunset($result); - $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date::W3C)); - - unset($result); - $result = Zend_Date_Cities::City('vienna', 'nautic'); - $this->assertTrue(is_array($result)); - $result = $date->getSunset($result); - $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date::W3C)); - - unset($result); - $result = Zend_Date_Cities::City('vienna', 'astronomic'); - $this->assertTrue(is_array($result)); - $result = $date->getSunset($result); - $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date::W3C)); - - unset($result); - $result = Zend_Date_Cities::City('BERLIN'); - $this->assertTrue(is_array($result)); - $result = $date->getSunrise($result); - $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date::W3C)); - - unset($result); - $result = Zend_Date_Cities::City('London'); - $this->assertTrue(is_array($result)); - $result = $date->getSunInfo($result); - $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C )); - $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C )); - $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C )); - $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C)); - $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date::W3C )); - $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date::W3C )); - $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C )); - $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C )); - - unset($result); - $result = array('longitude' => 0); - try { - $result = $date->getSunrise($result); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - unset($result); - $result = array('latitude' => 0); - try { - $result = $date->getSunrise($result); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - unset($result); - $result = array('longitude' => 180.1, 'latitude' => 0); - try { - $result = $date->getSunrise($result); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - unset($result); - $result = array('longitude' => -180.1, 'latitude' => 0); - try { - $result = $date->getSunrise($result); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - unset($result); - $result = array('longitude' => 0, 'latitude' => 90.1); - try { - $result = $date->getSunrise($result); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - unset($result); - $result = array('longitude' => 0, 'latitude' => -90.1); - try { - $result = $date->getSunrise($result); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - unset($result); - $result = array('latitude' => 0, 'longitude' => 0); - $result = $date->getSunInfo($result); - $this->assertTrue(is_array($result)); - - unset($result); - $result = array('latitude' => 0, 'longitude' => 0); - $result = $date->getSunrise($result); - $this->assertTrue($result instanceof Zend_Date); - } - - /** - * Test for Timezone - */ - public function testTimezone() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1010101010,$locale); - $date->setTimezone(date_default_timezone_get()); - - $result = $date->getTimezone(); - $this->assertSame('Indian/Maldives', $result); - - try { - $result = $date->setTimezone('unknown'); - // if function timezone_identifiers_list is not available false should be returned - $this->assertFalse($result); - } catch (Zend_Date_Exception $e) { - // success - } - $result = $date->getTimezone(); - $this->assertSame('Indian/Maldives', $result); - - $result = $date->setTimezone('America/Chicago'); - $this->assertTrue($result); - $result = $date->getTimezone(); - $this->assertSame('America/Chicago', $result); - } - - /** - * Test for LeapYear - */ - public function testLeapYear() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date('01.01.2006', Zend_Date::DATES, $locale); - $this->assertFalse($date->isLeapYear()); - - unset($date); - $date = new Zend_Date('01.01.2004', Zend_Date::DATES, $locale); - $this->assertTrue($date->isLeapYear()); - - try { - $result = Zend_Date::checkLeapYear('noyear'); - $this->fail('exception expected'); - } catch (Zend_Date_Exception $e) { - // succeed - } - } - - /** - * Test for Today - */ - public function testToday() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(Zend_Date::now()); - $d2 = new Zend_Date(1010101010,$locale); - - $this->assertFalse($d2->isToday()); - $this->assertTrue($date->isToday()); - } - - /** - * Test for Yesterday - */ - public function testYesterday() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(Zend_Date::now()); - $d2 = new Zend_Date(1010101010,$locale); - $date->subDay(1); - $this->assertFalse($d2->isYesterday()); - $this->assertTrue($date->isYesterday()); - } - - /** - * Test for Tomorrow - */ - public function testTomorrow() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(Zend_Date::now()); - $d2 = new Zend_Date(1010101010,$locale); - - $date->addDay(1); - $this->assertFalse($d2->isTomorrow()); - $this->assertTrue($date->isTomorrow()); - } - - /** - * test isToday(), isTomorrow(), and isYesterday() for cases other than time() = "now" - */ - public function testIsDay() - { - date_default_timezone_set('Europe/Vienna'); // should have DST - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date_TestHelper('01.01.2006', Zend_Date::DATES, $locale); - - $date->_setTime($date->mktime(0, 0, 0, 1, 1, 2006)); - $this->assertTrue($date->isToday()); - $this->assertFalse($date->isTomorrow()); - $date->_setTime($date->mktime(0, 0, 0, 1, 1, 2006)); - $this->assertFalse($date->isYesterday()); - - $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2005)); - $this->assertTrue($date->isTomorrow()); - $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2005)); - $this->assertFalse($date->isYesterday()); - - $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2006)); - $this->assertFalse($date->isTomorrow()); - $date->_setTime($date->mktime(0, 0, 0, 12, 31, 2006)); - $this->assertFalse($date->isYesterday()); - - $date->_setTime($date->mktime(0, 0, 0, 1, 0, 2006)); - $this->assertTrue($date->isTomorrow()); - $date->_setTime($date->mktime(0, 0, 0, 1, 0, 2006)); - $this->assertFalse($date->isYesterday()); - - $date->_setTime($date->mktime(0, 0, 0, 1, 2, 2006)); - $this->assertFalse($date->isTomorrow()); - $date->_setTime($date->mktime(0, 0, 0, 1, 2, 2006)); - $this->assertTrue($date->isYesterday()); - } - - /** - * Test for Now - */ - public function testNow() - { - $locale = new Zend_Locale('de_AT'); - - $date = Zend_Date::now(); - - $reference = date('U'); - $this->assertTrue(($reference - $date->get(Zend_Date::TIMESTAMP)) < 2); - } - - /** - * Test for getYear - */ - public function testGetYear() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1610101010,$locale); - $date->setTimeZone(date_default_timezone_get()); - $d2->setTimeZone(date_default_timezone_get()); - - $result = $date->getYear(); - $this->assertTrue($result instanceof Zend_Date); - $this->assertSame('01.01.2009 05:00:00', $result->toString()); - $this->assertSame('01.01.2021 05:00:00', $d2->getYear()->toString()); - } - - /** - * Test for setYear - */ - public function testSetYear() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1577833200,$locale); - $date2 = new Zend_Date(2006, Zend_Date::YEAR); - $date->setTimeZone(date_default_timezone_get()); - - $date->setYear(2000); - $this->assertSame('2000-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(1800); - $this->assertSame('1800-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(2100); - $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear($date2); - $this->assertSame('2006-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - try { - $date->setYear('noyear'); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for addYear - */ - public function testAddYear() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1577833200,$locale); - $date->setTimeZone(date_default_timezone_get()); - - $date->addYear(1); - $this->assertSame('2021-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2022-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2023-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2024-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2025-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(1500); - $this->assertSame('1500-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(20); - $this->assertSame('1520-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(2100); - $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(20); - $this->assertSame('2120-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setDay(4); - $date->setMonth(4); - $date->setYear(2020); - $this->assertSame('2020-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2021-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2022-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2023-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2024-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(1); - $this->assertSame('2025-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(1500); - $this->assertSame('1500-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(20); - $this->assertSame('1520-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(2100); - $this->assertSame('2100-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->addYear(20); - $this->assertSame('2120-04-04T04:00:00+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for subYear - */ - public function testSubYear() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1577833200,$locale); - $date->setTimeZone(date_default_timezone_get()); - - $date->subYear(1); - $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subYear(1); - $this->assertSame('2018-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subYear(1); - $this->assertSame('2017-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subYear(1); - $this->assertSame('2016-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subYear(1); - $this->assertSame('2015-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(1500); - $this->assertSame('1500-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subYear(20); - $this->assertSame('1480-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setYear(2100); - $this->assertSame('2100-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subYear(20); - $this->assertSame('2080-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compareYear - */ - public function testCompareYear() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $date = new Zend_Date(1234567890,$locale); - $this->assertSame(-1, $date->compareYear(2010)); - $this->assertSame( 0, $date->compareYear(2009)); - $this->assertSame( 1, $date->compareYear(2008)); - $this->assertSame( 0, $date->compareYear($d2 )); - } - - /** - * Test for getMonth - */ - public function testGetMonth() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1610101010,$locale); - $date->setTimeZone(date_default_timezone_get()); - $d2->setTimeZone(date_default_timezone_get()); - - $result = $date->getMonth(); - $this->assertTrue($result instanceof Zend_Date); - $this->assertSame('01.02.1970 05:00:00', $result->toString( )); - $this->assertSame('01.02.1970 05:00:00', $date->getMonth()->toString()); - } - - /** - * Test for setMonth - */ - public function testSetMonth() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1577833200,$locale); - $date2 = new Zend_Date(2006, Zend_Date::YEAR); - $date->setTimeZone(date_default_timezone_get()); - - $date->setMonth(3); - $this->assertSame('2020-03-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setMonth(-3); - $this->assertSame('2019-09-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setMonth('March', 'en'); - $this->assertSame('2019-03-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - $date->setMonth($date2); - $this->assertSame('2019-01-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - - try { - $date->setMonth('nomonth'); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * Test for addMonth - */ - public function testAddMonth() - { - date_default_timezone_set('Europe/Vienna'); - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1577833200,$locale); - $date->setTimeZone(date_default_timezone_get()); - - $date->addMonth(1); - $this->assertSame('2020-02-01T00:00:00+01:00', $date->get(Zend_Date::W3C)); - $date->addMonth(1); - $this->assertSame('2020-03-01T00:00:00+01:00', $date->get(Zend_Date::W3C)); - $date->addMonth(1); - $this->assertSame('2020-04-01T00:00:00+02:00', $date->get(Zend_Date::W3C)); - $date->addMonth(1); - $this->assertSame('2020-05-01T00:00:00+02:00', $date->get(Zend_Date::W3C)); - $date->addMonth(1); - $this->assertSame('2020-06-01T00:00:00+02:00', $date->get(Zend_Date::W3C)); - $date->addMonth(5); - $this->assertSame('2020-11-01T00:00:00+01:00', $date->get(Zend_Date::W3C)); - - Zend_Date::setOptions(array('fix_dst' => true)); - $date = new Zend_Date('2007-10-01 00:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-10-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-11-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-10-01 23:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-10-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-11-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-03-01 00:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-03-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-04-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-03-01 23:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-03-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-04-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - Zend_Date::setOptions(array('fix_dst' => false)); - $date = new Zend_Date('2007-10-01 00:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-10-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-10-31 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-10-01 23:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-10-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-11-01 22:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-03-01 00:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-03-01 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-04-01 01:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-03-01 23:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-03-01 23:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-04-02 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-01-31 00:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-01-31 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - $date->addMonth(1); - $this->assertSame('2007-02-28 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - $date = new Zend_Date('2007-01-31 00:00:00', Zend_Date::ISO_8601); - $this->assertSame('2007-01-31 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - Zend_Date::setOptions(array('extend_month' => true)); - $date->addMonth(1); - $this->assertSame('2007-03-03 00:00:00', $date->toString('yyyy-MM-dd HH:mm:ss')); - - date_default_timezone_set('America/Chicago'); - $date = new Zend_Date(1577858400,$locale); - $date->setTimeZone(date_default_timezone_get()); - $this->assertSame('2020-01-01T00:00:00-06:00', $date->get(Zend_Date::ISO_8601)); - $date->addMonth(12); - $this->assertSame('2021-01-01T00:00:00-06:00', $date->get(Zend_Date::ISO_8601)); - - } - - /** - * Test for subMonth - */ - public function testSubMonth() - { - $locale = new Zend_Locale('de_AT'); - - $date = new Zend_Date(1577833200,$locale); - $date->setTimeZone(date_default_timezone_get()); - - $date->subMonth(1); - $this->assertSame('2019-12-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->subMonth(12); - $this->assertSame('2018-12-01T04:00:00+05:00', $date->get(Zend_Date::W3C)); - } - - /** - * Test for compareMonth - */ - public function testCompareMonth() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1234567890,$locale); - $d2 = new Zend_Date(1234567899,$locale); - - $date = new Zend_Date(1234567890,$locale); - $this->assertSame( 1, $date->compareMonth( 1)); - $this->assertSame( 0, $date->compareMonth( 2)); - $this->assertSame(-1, $date->compareMonth( 3)); - $this->assertSame( 0, $date->compareYear($d2)); - } - - /** - * Test accessors for _Locale member property of Zend_Date - */ - public function testLocale() - { - $date = new Zend_Date(Zend_Date::now()); - $locale = new Zend_Locale('en_Us'); - $set = $date->setLocale($locale); - $this->assertSame($set, $date->getLocale()); - } - - /** - * test for getWeek - */ - public function testGetWeek() - { - $locale = new Zend_Locale('de_AT'); - $date = new Zend_Date(1168293600, $locale); - - //Tuesday - $date->addDay(1); - $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString()); - - //Wednesday - $date->addDay(1); - $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString()); - - //Thursday - $date->addDay(1); - $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString()); - - //Friday - $date->addDay(1); - $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString()); - - //Friday 05:30 am - $date->addTime('05:30:00'); - $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString()); - - //Saturday - $date->addDay(1); - $this->assertSame('08.01.1970 05:00:00', $date->getWeek()->toString()); - - //Saturday [ar_EG] - // The right value for AM/PM has to be set in arabic letters - $this->assertSame('08â€/01â€/1970 5:00:00 ص', $date->getWeek('ar_EG')->toString()); - $date->setTimeZone('UTC'); - $this->assertSame('08â€/01â€/1970 12:00:00 ص', $date->getWeek('ar_EG')->toString()); - $date->setTimeZone('Indian/Maldives'); - $this->assertSame('08â€/01â€/1970 5:00:00 ص', $date->getWeek('ar_EG')->toString()); - - //Sunday [start of a new week as defined per ISO 8601] - $date->addDay(1); - $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString()); - - //Monday - $date->addDay(1); - $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString()); - - //Monday 03:45 pm - $date->addTime('15:45:00'); - $this->assertSame('15.01.1970 05:00:00', $date->getWeek()->toString()); - } - - /** - * test setting dates to specify weekdays - */ - public function testDay() - { - // all tests and calculations below are in GMT (that is intention for this test) - $date = new Zend_Date(0, 'de_AT'); - $date->setTimeZone('UTC'); - $dw = $date->getDay(); - $this->assertSame('01.01.1970 00:00:00', $dw->toString()); - for($day = 1; $day < 31; $day++) { - $date->setDay($day); - $dw = $date->getDay(); - $weekday = str_pad($day, 2, '0', STR_PAD_LEFT); - $this->assertSame("$weekday.01.1970 00:00:00", $dw->toString()); - } - } - - /** - * test setWeekday - */ - public function testSetWeekday() - { - $date = new Zend_Date('2006-01-01','YYYY-MM-dd', 'en'); - $date->setWeekday(1); - $this->assertSame('2005-12-26T00:00:00+05:00', $date->getIso()); - - $date->set('2006-01-02', 'YYYY-MM-dd'); - $date->setWeekday(1); - $this->assertSame('2006-01-02T00:00:00+05:00', $date->getIso()); - } - - /** - * test setLocale/getLocale - */ - public function testSetLocale() - { - $date = new Zend_Date(0, 'de'); - - $this->assertSame('de', $date->getLocale()); - $date->setLocale('en'); - $this->assertSame('en', $date->getLocale()); - $date->setLocale('en_XX'); - $this->assertSame('en', $date->getLocale()); - $date->setLocale('de_AT'); - $this->assertSame('de_AT', $date->getLocale()); - $locale = new Zend_Locale('ar'); - $date->setLocale($locale); - $this->assertSame('ar', $date->getLocale()); - - try { - $date->setLocale('xx_XX'); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - } - - /** - * test looseBehaviour - */ - public function testLoose() - { - $date = new Zend_Date(0, 'de'); - - try { - $date->set(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->set(10, 'de'); - $this->assertEquals(10, $date->getTimestamp()); - - try { - $date->add(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->add(10, 'de'); - $this->assertEquals(20, $date->getTimestamp()); - - try { - $date->sub(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - $date->sub(10, 'de'); - $this->assertEquals(10, $date->getTimestamp()); - - try { - $date->compare(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->equals(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->isEarlier(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->isLater(null, Zend_Date::YEAR); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setTime(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addTime(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subTime(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareTime(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setDate(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addDate(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subDate(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareDate(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setIso(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addIso(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subIso(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareIso(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setArpa(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addArpa(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subArpa(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareArpa(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setMonth(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addMonth(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subMonth(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareMonth(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setDay(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addDay(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subDay(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareDay(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setWeekday(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addWeekday(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subWeekday(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareWeekday(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setDayOfYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addDayOfYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subDayOfYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareDayOfYear(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setHour(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addHour(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subHour(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareHour(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setMinute(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addMinute(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subMinute(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareMinute(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setSecond(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addSecond(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subSecond(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareSecond(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->setWeek(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->addWeek(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->subWeek(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - $date->compareWeek(null); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - } - - public function testTimesync() - { - try { - $server = new Zend_TimeSync('ntp://pool.ntp.org', 'alias'); - $date1 = $server->getDate(); - // need to use the proxy class to simulate time() returning wrong value - $date2 = new Zend_Date_TestHelper(time()); - - $info = $server->getInfo(); - - if ($info['offset'] != 0) { - $this->assertFalse($date1->getTimestamp() == $date2->getTimestamp()); - } else { - $this->assertSame($date1->getTimestamp(), $date2->getTimestamp()); - } - } catch (Zend_TimeSync_Exception $e) { - $this->markTestIncomplete('NTP timeserver not available.'); - } - } - - public function testUsePhpDateFormat() - { - Zend_Date::setOptions(array('format_type' => 'iso')); - - // PHP date() format specifier tests - $date1 = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US'); - $date2 = new Zend_Date('2006-01-02 23:58:59', 'YYYY-MM-dd HH:mm:ss', 'en_US'); - $this->assertSame($date1->getTimestamp(), $date2->getTimestamp()); - - date_default_timezone_set('GMT'); - $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier) - $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'eee')); - $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'dd')); - $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString( 'EEE', 'en')); - $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'd')); - $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString( 'EEEE', 'en')); - $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'e')); - $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'SS')); - $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'D')); - $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'w')); - $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString( 'MMMM', 'en')); - $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'MM')); - $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString( 'MMM', 'en')); - $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'M')); - $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 'ddd')); - $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'l')); - $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'YYYY')); - $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'yyyy')); - $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'yy')); - $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString( 'a', 'en'))); - $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString( 'a', 'en'))); - $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B')); - $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'h')); - $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'H')); - $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'hh')); - $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'HH')); - $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'mm')); - $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 'ss')); - $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'zzzz')); - $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I')); - $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'Z')); - $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'ZZZZ')); - $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'z')); - $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'X')); - $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString('yyyy-MM-ddTHH:mm:ssZZZZ')); - $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r')); - $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U')); - - Zend_Date::setOptions(array('format_type' => 'php')); - - // PHP date() format specifier tests - $date1 = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US'); - $date2 = new Zend_Date('2006-01-02 23:58:59', 'Y-m-d H:i:s', 'en_US'); - $this->assertSame($date1->getTimestamp(), $date2->getTimestamp()); - - date_default_timezone_set('GMT'); - $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier) - $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w')); - $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd')); - $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en')); - $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j')); - $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en')); - $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N')); - $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S')); - $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z')); - $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W')); - $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en')); - $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm')); - $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en')); - $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n')); - $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't')); - $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L')); - $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o')); - $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y')); - $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y')); - $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en'))); - $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en'))); - $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B')); - $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g')); - $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G')); - $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h')); - $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H')); - $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i')); - $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's')); - $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e')); - $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I')); - $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O')); - $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P')); - $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T')); - $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z')); - $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c')); - $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r')); - $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U')); - - date_default_timezone_set('GMT'); - $date = new Zend_Date(mktime(20,10,0,10,10,2000)); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier) - $this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w')); - $this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd')); - $this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en')); - $this->assertSame(gmdate('j',$date->getTimestamp()), $date->toString( 'j')); - $this->assertSame(gmdate('l',$date->getTimestamp()), $date->toString('l', 'en')); - $this->assertSame(gmdate('N',$date->getTimestamp()), $date->toString( 'N')); - $this->assertSame(gmdate('S',$date->getTimestamp()), $date->toString( 'S')); - $this->assertSame(gmdate('z',$date->getTimestamp()), $date->toString( 'z')); - $this->assertSame(gmdate('W',$date->getTimestamp()), $date->toString( 'W')); - $this->assertSame(gmdate('F',$date->getTimestamp()), $date->toString('F', 'en')); - $this->assertSame(gmdate('m',$date->getTimestamp()), $date->toString( 'm')); - $this->assertSame(gmdate('M',$date->getTimestamp()), $date->toString('M', 'en')); - $this->assertSame(gmdate('n',$date->getTimestamp()), $date->toString( 'n')); - $this->assertSame(gmdate('t',$date->getTimestamp()), $date->toString( 't')); - $this->assertSame(gmdate('L',$date->getTimestamp()), $date->toString( 'L')); - $this->assertSame(gmdate('o',$date->getTimestamp()), $date->toString( 'o')); - $this->assertSame(gmdate('Y',$date->getTimestamp()), $date->toString( 'Y')); - $this->assertSame(gmdate('y',$date->getTimestamp()), $date->toString( 'y')); - $this->assertSame(gmdate('a',$date->getTimestamp()), strtolower($date->toString('a', 'en'))); - $this->assertSame(gmdate('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en'))); - $this->assertSame(gmdate('B',$date->getTimestamp()), $date->toString( 'B')); - $this->assertSame(gmdate('g',$date->getTimestamp()), $date->toString( 'g')); - $this->assertSame(gmdate('G',$date->getTimestamp()), $date->toString( 'G')); - $this->assertSame(gmdate('h',$date->getTimestamp()), $date->toString( 'h')); - $this->assertSame(gmdate('H',$date->getTimestamp()), $date->toString( 'H')); - $this->assertSame(gmdate('i',$date->getTimestamp()), $date->toString( 'i')); - $this->assertSame(gmdate('s',$date->getTimestamp()), $date->toString( 's')); - $this->assertSame( date('e',$date->getTimestamp()), $date->toString( 'e')); - $this->assertSame(gmdate('I',$date->getTimestamp()), $date->toString( 'I')); - $this->assertSame(gmdate('O',$date->getTimestamp()), $date->toString( 'O')); - $this->assertSame(gmdate('P',$date->getTimestamp()), $date->toString( 'P')); - $this->assertSame(gmdate('T',$date->getTimestamp()), $date->toString( 'T')); - $this->assertSame(gmdate('Z',$date->getTimestamp()), $date->toString( 'Z')); - $this->assertSame(gmdate('c',$date->getTimestamp()), $date->toString( 'c')); - $this->assertSame(gmdate('r',$date->getTimestamp()), $date->toString( 'r')); - $this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U')); - - date_default_timezone_set('Indian/Maldives'); - $date = new Zend_Date(0); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier) - $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w')); - $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd')); - $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en')); - $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j')); - $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en')); - $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N')); - $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S')); - $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z')); - $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W')); - $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en')); - $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm')); - $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en')); - $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n')); - $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't')); - $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L')); - $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o')); - $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y')); - $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y')); - $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en'))); - $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en'))); - $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B')); - $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g')); - $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G')); - $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h')); - $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H')); - $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i')); - $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's')); - $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e')); - $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I')); - $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O')); - $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P')); - $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T')); - $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z')); - $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c')); - $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r')); - $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U')); - - date_default_timezone_set('Indian/Maldives'); - $date = new Zend_Date(mktime(20,10,0,10,10,2000)); // 1970-01-01 is a Thursday (should be 4 for 'w' format specifier) - $this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w')); - $this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd')); - $this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en')); - $this->assertSame(date('j',$date->getTimestamp()), $date->toString( 'j')); - $this->assertSame(date('l',$date->getTimestamp()), $date->toString('l', 'en')); - $this->assertSame(date('N',$date->getTimestamp()), $date->toString( 'N')); - $this->assertSame(date('S',$date->getTimestamp()), $date->toString( 'S')); - $this->assertSame(date('z',$date->getTimestamp()), $date->toString( 'z')); - $this->assertSame(date('W',$date->getTimestamp()), $date->toString( 'W')); - $this->assertSame(date('F',$date->getTimestamp()), $date->toString('F', 'en')); - $this->assertSame(date('m',$date->getTimestamp()), $date->toString( 'm')); - $this->assertSame(date('M',$date->getTimestamp()), $date->toString('M', 'en')); - $this->assertSame(date('n',$date->getTimestamp()), $date->toString( 'n')); - $this->assertSame(date('t',$date->getTimestamp()), $date->toString( 't')); - $this->assertSame(date('L',$date->getTimestamp()), $date->toString( 'L')); - $this->assertSame(date('o',$date->getTimestamp()), $date->toString( 'o')); - $this->assertSame(date('Y',$date->getTimestamp()), $date->toString( 'Y')); - $this->assertSame(date('y',$date->getTimestamp()), $date->toString( 'y')); - $this->assertSame(date('a',$date->getTimestamp()), strtolower($date->toString('a', 'en'))); - $this->assertSame(date('A',$date->getTimestamp()), strtoupper($date->toString('A', 'en'))); - $this->assertSame(date('B',$date->getTimestamp()), $date->toString( 'B')); - $this->assertSame(date('g',$date->getTimestamp()), $date->toString( 'g')); - $this->assertSame(date('G',$date->getTimestamp()), $date->toString( 'G')); - $this->assertSame(date('h',$date->getTimestamp()), $date->toString( 'h')); - $this->assertSame(date('H',$date->getTimestamp()), $date->toString( 'H')); - $this->assertSame(date('i',$date->getTimestamp()), $date->toString( 'i')); - $this->assertSame(date('s',$date->getTimestamp()), $date->toString( 's')); - $this->assertSame(date('e',$date->getTimestamp()), $date->toString( 'e')); - $this->assertSame(date('I',$date->getTimestamp()), $date->toString( 'I')); - $this->assertSame(date('O',$date->getTimestamp()), $date->toString( 'O')); - $this->assertSame(date('P',$date->getTimestamp()), $date->toString( 'P')); - $this->assertSame(date('T',$date->getTimestamp()), $date->toString( 'T')); - $this->assertSame(date('Z',$date->getTimestamp()), $date->toString( 'Z')); - $this->assertSame(date('c',$date->getTimestamp()), $date->toString( 'c')); - $this->assertSame(date('r',$date->getTimestamp()), $date->toString( 'r')); - $this->assertSame(date('U',$date->getTimestamp()), $date->toString( 'U')); - Zend_Date::setOptions(array('format_type' => 'iso')); - } - - public function testDaylightsaving() - { - $date = new Zend_Date('2007.03.25', Zend_Date::DATES); - $date->set('16:00:00', Zend_Date::TIMES); - $this->assertEquals('2007-03-25T16:00:00+05:00', $date->get(Zend_Date::W3C)); - $date->set('01:00:00', Zend_Date::TIMES); - $this->assertEquals('2007-03-25T01:00:00+05:00', $date->get(Zend_Date::W3C)); - } - - public function testSetOptions() - { - $options = Zend_Date::setOptions(); - $this->assertTrue(is_array($options)); - $this->assertEquals('iso', $options['format_type']); - - Zend_Date::setOptions(array('format_type' => 'php')); - $options = Zend_Date::setOptions(); - $this->assertEquals('php', $options['format_type']); - - try { - Zend_Date::setOptions(array('format_type' => 'non')); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - Zend_Date::setOptions(array('unknown' => 'non')); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - try { - Zend_Date::setOptions(array('fix_dst' => 2)); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - try { - Zend_Date::setOptions(array('fix_dst' => 2)); - $this->fail(); - } catch (Zend_Date_Exception $e) { - // success - } - - require_once 'Zend/Cache.php'; - $cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 120, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/_files/')); - Zend_Date::setOptions(array('cache' => $cache)); - } - - public function testIsDate() - { - $this->assertTrue(Zend_Date::isDate('25.03.2007', 'de_AT')); - $this->assertTrue(Zend_Date::isDate('2007.03.25', 'YYYY.MM.dd')); - $this->assertTrue(Zend_Date::isDate('25.Mai.2007', 'dd.MMMM.YYYY', 'de_AT')); - $this->assertTrue(Zend_Date::isDate('25.Mai.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT')); - $this->assertFalse(Zend_Date::isDate('32.Mai.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT')); - $this->assertFalse(Zend_Date::isDate('30.Februar.2007 10:00:00', 'dd.MMMM.YYYY', 'de_AT')); - $this->assertFalse(Zend_Date::isDate('30.Februar.2007 30:00:00', 'dd.MMMM.YYYY HH:mm:ss', 'de_AT')); - } - - public function testToArray() - { - $date = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US'); - $return = $date->toArray(); - $orig = array('day' => 02, 'month' => 01, 'year' => 2006, 'hour' => 23, 'minute' => 58, - 'second' => 59, 'timezone' => 'MVT', 'timestamp' => 1136228339, 'weekday' => 1, - 'dayofyear' => 1, 'week' => '01', 'gmtsecs' => 18000); - $this->assertEquals($orig, $return); - } - - public function testFromArray() - { - $date = new Zend_Date(array('day' => 04, 'month' => 12, 'year' => 2006, 'hour' => 10, - 'minute' => 56, 'second' => 30), 'en_US'); - $this->assertSame('2006-12-04T10:56:30+05:00', $date->getIso()); - } - - public function testTimezoneArray() - { - date_default_timezone_set('UTC'); - - $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1, - 'hour' => 20, 'minute' => 45, 'second' => 37, 'en_US')); - $this->assertSame('2007-01-01T20:45:37+00:00', $date->getIso()); - - date_default_timezone_set('CET'); - $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1, - 'hour' => 1, 'minute' => 45, 'second' => 37, 'en_US')); - $this->assertSame('2007-01-01T01:45:37+01:00', $date->getIso()); - - $date = new Zend_Date(array('year' => 2006, 'month' => 4, 'day' => 18, - 'hour' => 12, 'minute' => 3, 'second' => 10, 'de_AT')); - $this->assertSame('2006-04-18T12:03:10+02:00', $date->getIso()); - } - - public function testExtendedDst() - { - Zend_Date::setOptions(array('format_type' => 'iso')); - $date = new Zend_Date(); - $date->setTimezone('UTC'); - $date->set('25-05-2050 12:00:00'); - $this->assertSame('2050-05-25 12:00:00', $date->get('YYYY-MM-dd HH:mm:ss')); - $date->setTimezone('Europe/Warsaw'); - $this->assertSame('2050-05-25 14:00:00', $date->get('YYYY-MM-dd HH:mm:ss')); - - $date->setTimezone('UTC'); - $date->set('25-05-2020 12:00:00'); - $this->assertSame('2020-05-25 12:00:00', $date->get('YYYY-MM-dd HH:mm:ss')); - $date->setTimezone('Europe/Warsaw'); - $this->assertSame('2020-05-25 14:00:00', $date->get('YYYY-MM-dd HH:mm:ss')); - } -} - -class Zend_Date_TestHelper extends Zend_Date -{ - public function _setTime($timestamp) - { - $this->_getTime($timestamp); - } - - protected function _getTime($timestamp = null) - { - static $_timestamp = null; - if ($timestamp !== null) { - $_timestamp = $timestamp; - } - if ($_timestamp !== null) { - return $_timestamp; - } - return time(); - } - - public function mktime($hour, $minute, $second, $month, $day, $year, $dst= -1, $gmt = false) - { - return parent::mktime($hour, $minute, $second, $month, $day, $year, $dst, $gmt); - } -} diff --git a/tests/Zend/Db/Adapter/Db2Test.php b/tests/Zend/Db/Adapter/Db2Test.php deleted file mode 100644 index 97a48f98a11072336096634479f86ef4320ee8ad..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Db2Test.php +++ /dev/null @@ -1,214 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Db_Adapter_TestCommon - */ -require_once 'Zend/Db/Adapter/TestCommon.php'; - -/** - * @see Zend_Db_Adapter_Db2 - */ -require_once 'Zend/Db/Adapter/Db2.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Adapter_Db2Test extends Zend_Db_Adapter_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'INTEGER' => Zend_Db::INT_TYPE, - 'SMALLINT' => Zend_Db::INT_TYPE, - 'BIGINT' => Zend_Db::BIGINT_TYPE, - 'DECIMAL' => Zend_Db::FLOAT_TYPE, - 'NUMERIC' => Zend_Db::FLOAT_TYPE - ); - - public function testAdapterDescribeTablePrimaryAuto() - { - $desc = $this->_db->describeTable('zfbugs'); - - $this->assertTrue($desc['bug_id']['PRIMARY']); - $this->assertEquals(1, $desc['bug_id']['PRIMARY_POSITION']); - $this->assertTrue($desc['bug_id']['IDENTITY']); - } - - public function testAdapterDescribeTableAttributeColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_name']['TABLE_NAME'], 'Expected table name to be zfproducts'); - $this->assertEquals('product_name', $desc['product_name']['COLUMN_NAME'], 'Expected column name to be product_name'); - $this->assertEquals(2, $desc['product_name']['COLUMN_POSITION'], 'Expected column position to be 2'); - $this->assertRegExp('/varchar/i', $desc['product_name']['DATA_TYPE'], 'Expected data type to be VARCHAR'); - $this->assertEquals('', $desc['product_name']['DEFAULT'], 'Expected default to be empty string'); - $this->assertTrue( $desc['product_name']['NULLABLE'], 'Expected product_name to be nullable'); - $this->assertEquals(0, $desc['product_name']['SCALE'], 'Expected scale to be 0'); - $this->assertEquals(0, $desc['product_name']['PRECISION'], 'Expected precision to be 0'); - $this->assertFalse( $desc['product_name']['PRIMARY'], 'Expected product_name not to be a primary key'); - $this->assertNull( $desc['product_name']['PRIMARY_POSITION'], 'Expected product_name to return null for PRIMARY_POSITION'); - $this->assertFalse( $desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY'); - } - - public function testAdapterDescribeTablePrimaryKeyColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME'], 'Expected table name to be zfproducts'); - $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME'], 'Expected column name to be product_id'); - $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION'], 'Expected column position to be 1'); - $this->assertEquals('', $desc['product_id']['DEFAULT'], 'Expected default to be empty string'); - $this->assertFalse( $desc['product_id']['NULLABLE'], 'Expected product_id not to be nullable'); - $this->assertEquals(0, $desc['product_id']['SCALE'], 'Expected scale to be 0'); - $this->assertEquals(0, $desc['product_id']['PRECISION'], 'Expected precision to be 0'); - $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key'); - $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']); - } - - /** - * Used by _testAdapterOptionCaseFoldingNatural() - * DB2 and Oracle return identifiers in uppercase naturally, - * so those test suites will override this method. - */ - protected function _testAdapterOptionCaseFoldingNaturalIdentifier() - { - return 'CASE_FOLDED_IDENTIFIER'; - } - - public function testAdapterTransactionCommit() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // use our default connection as the Connection1 - $dbConnection1 = $this->_db; - - // create a second connection to the same database - $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams()); - $dbConnection2->getConnection(); - $dbConnection2->query('SET ISOLATION LEVEL = UR'); - - // notice the number of rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)'); - - // start an explicit transaction in connection 1 - $dbConnection1->beginTransaction(); - - // delete a row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see one less row in connection 2 - // because it is doing an uncommitted read - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table (step 2) because conn2 is doing an uncommitted read'); - - // commit the DELETE - $dbConnection1->commit(); - - // now we should see one fewer rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 3)'); - - // delete another row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 2" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see results immediately, because - // the db connection returns to auto-commit mode - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(2, $count); - } - - public function testAdapterTransactionRollback() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // use our default connection as the Connection1 - $dbConnection1 = $this->_db; - - // create a second connection to the same database - $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams()); - $dbConnection2->getConnection(); - $dbConnection2->query('SET ISOLATION LEVEL = UR'); - - // notice the number of rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)'); - - // start an explicit transaction in connection 1 - $dbConnection1->beginTransaction(); - - // delete a row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see one less row in connection 2 - // because it is doing an uncommitted read - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table (step 2) because conn2 is doing an uncommitted read'); - - // rollback the DELETE - $dbConnection1->rollback(); - - // now we should see the same number of rows - // because the DELETE was rolled back - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table after DELETE is rolled back (step 3)'); - - // delete another row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 2" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see results immediately, because - // the db connection returns to auto-commit mode - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 4)'); - } - - public function testAdapterAlternateStatement() - { - $this->_testAdapterAlternateStatement('Test_Db2Statement'); - } - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Adapter/MysqliTest.php b/tests/Zend/Db/Adapter/MysqliTest.php deleted file mode 100644 index 401e05ea37be66fdeb44af93f122809c72f23311..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/MysqliTest.php +++ /dev/null @@ -1,272 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqliTest.php 6923 2007-11-25 02:00:06Z peptolab $ - */ - - -/** - * @see Zend_Db_Adapter_TestCommon - */ -require_once 'Zend/Db/Adapter/TestCommon.php'; - -/** - * @see Zend_Db_Adapter_Mysqli - */ -require_once 'Zend/Db/Adapter/Mysqli.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_MysqliTest extends Zend_Db_Adapter_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'INT' => Zend_Db::INT_TYPE, - 'INTEGER' => Zend_Db::INT_TYPE, - 'MEDIUMINT' => Zend_Db::INT_TYPE, - 'SMALLINT' => Zend_Db::INT_TYPE, - 'TINYINT' => Zend_Db::INT_TYPE, - 'BIGINT' => Zend_Db::BIGINT_TYPE, - 'SERIAL' => Zend_Db::BIGINT_TYPE, - 'DEC' => Zend_Db::FLOAT_TYPE, - 'DECIMAL' => Zend_Db::FLOAT_TYPE, - 'DOUBLE' => Zend_Db::FLOAT_TYPE, - 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE, - 'FIXED' => Zend_Db::FLOAT_TYPE, - 'FLOAT' => Zend_Db::FLOAT_TYPE - ); - - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - * - * MySQL actually allows delimited identifiers to remain - * case-insensitive, so this test overrides its parent. - */ - public function testAdapterAutoQuoteIdentifiersTrue() - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => true - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - $select = $this->_db->select(); - $select->from('zfproducts'); - $stmt = $this->_db->query($select); - $result1 = $stmt->fetchAll(); - $this->assertEquals(3, count($result1), 'Expected 3 rows in first query result'); - - $this->assertEquals(1, $result1[0]['product_id']); - - $select = $this->_db->select(); - $select->from('zfproducts'); - try { - $stmt = $this->_db->query($select); - $result2 = $stmt->fetchAll(); - $this->assertEquals(3, count($result2), 'Expected 3 rows in second query result'); - $this->assertEquals($result1, $result2); - } catch (Zend_Exception $e) { - $this->fail('exception caught where none was expected.'); - } - } - - public function testAdapterInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - /** - * test that quoteColumnAs() accepts a string - * and an alias, and returns each as delimited - * identifiers, with 'AS' in between. - */ - public function testAdapterQuoteColumnAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteColumnAs($string, $alias); - $this->assertEquals('`foo` AS `bar`', $value); - } - - /** - * test that quoteColumnAs() accepts a string - * and an alias, but ignores the alias if it is - * the same as the base identifier in the string. - */ - public function testAdapterQuoteColumnAsSameString() - { - $string = 'foo.bar'; - $alias = 'bar'; - $value = $this->_db->quoteColumnAs($string, $alias); - $this->assertEquals('`foo`.`bar`', $value); - } - - /** - * test that quoteIdentifier() accepts a string - * and returns a delimited identifier. - */ - public function testAdapterQuoteIdentifier() - { - $value = $this->_db->quoteIdentifier('table_name'); - $this->assertEquals('`table_name`', $value); - } - - /** - * test that quoteIdentifier() accepts an array - * and returns a qualified delimited identifier. - */ - public function testAdapterQuoteIdentifierArray() - { - $array = array('foo', 'bar'); - $value = $this->_db->quoteIdentifier($array); - $this->assertEquals('`foo`.`bar`', $value); - } - - /** - * test that quoteIdentifier() accepts an array - * containing a Zend_Db_Expr, and returns strings - * as delimited identifiers, and Exprs as unquoted. - */ - public function testAdapterQuoteIdentifierArrayDbExpr() - { - $expr = new Zend_Db_Expr('*'); - $array = array('foo', $expr); - $value = $this->_db->quoteIdentifier($array); - $this->assertEquals('`foo`.*', $value); - } - - /** - * test that quoteIdentifer() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIdentifierDoubleQuote() - { - $string = 'table_"_name'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('`table_"_name`', $value); - } - - /** - * test that quoteIdentifer() accepts an integer - * and returns a delimited identifier as with a string. - */ - public function testAdapterQuoteIdentifierInteger() - { - $int = 123; - $value = $this->_db->quoteIdentifier($int); - $this->assertEquals('`123`', $value); - } - - /** - * test that quoteIdentifier() accepts a string - * containing a dot (".") character, splits the - * string, quotes each segment individually as - * delimited identifers, and returns the imploded - * string. - */ - public function testAdapterQuoteIdentifierQualified() - { - $string = 'table.column'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('`table`.`column`', $value); - } - - /** - * test that quoteIdentifer() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIdentifierSingleQuote() - { - $string = "table_'_name"; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('`table_\'_name`', $value); - } - - /** - * test that quoteTableAs() accepts a string and an alias, - * and returns each as delimited identifiers. - * Most RDBMS want an 'AS' in between. - */ - public function testAdapterQuoteTableAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteTableAs($string, $alias); - $this->assertEquals('`foo` AS `bar`', $value); - } - - /** - * Ensures that the PDO Buffered Query does not throw the error - * 2014 General error - * - * @link http://framework.zend.com/issues/browse/ZF-2101 - * @return void - */ - public function testZF2101() - { - $params = $this->_util->getParams(); - $db = Zend_Db::factory($this->getDriver(), $params); - - // Set default bound value - $customerId = 1; - - // Stored procedure returns a single row - $stmt = $db->prepare('CALL zf_test_procedure(?)'); - $stmt->bindParam(1, $customerId); - $stmt->execute(); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - - // Reset statement - $stmt->closeCursor(); - - // Stored procedure returns a single row - $stmt = $db->prepare('CALL zf_test_procedure(?)'); - $stmt->bindParam(1, $customerId); - $stmt->execute(); - $this->assertEquals(1, $result[0]['product_id']); - } - - public function testAdapterAlternateStatement() - { - $this->_testAdapterAlternateStatement('Test_MysqliStatement'); - } - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Adapter/OracleTest.php b/tests/Zend/Db/Adapter/OracleTest.php deleted file mode 100644 index bcce7cbb6042f2574c69de11f70aa327a3457a13..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/OracleTest.php +++ /dev/null @@ -1,325 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Db_Adapter_TestCommon - */ -require_once 'Zend/Db/Adapter/TestCommon.php'; - -/** - * @see Zend_Db_Adapter_Oracle - */ -require_once 'Zend/Db/Adapter/Oracle.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Adapter_OracleTest extends Zend_Db_Adapter_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE, - 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE, - 'NUMBER' => Zend_Db::FLOAT_TYPE, - ); - - public function testAdapterDescribeTablePrimaryAuto() - { - $this->markTestSkipped('Oracle does not support auto-increment'); - } - - public function testAdapterDescribeTablePrimaryKeyColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']); - $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']); - $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']); - $this->assertEquals('', $desc['product_id']['DEFAULT']); - $this->assertFalse( $desc['product_id']['NULLABLE']); - $this->assertEquals(0, $desc['product_id']['SCALE']); - // Oracle reports precsion 11 for integers - $this->assertEquals(11, $desc['product_id']['PRECISION']); - $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key'); - $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']); - $this->assertFalse( $desc['product_id']['IDENTITY']); - } - - /** - * Test the Adapter's fetchAll() method. - */ - public function testAdapterFetchAll() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1)); - $this->assertEquals(2, count($result)); - $this->assertThat($result[0], $this->arrayHasKey('product_id')); - $this->assertEquals('2', $result[0]['product_id']); - } - - /** - * Test the Adapter's fetchAssoc() method. - */ - public function testAdapterFetchAssoc() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchAssoc("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id DESC", array(":id"=>1)); - foreach ($result as $idKey => $row) { - $this->assertThat($row, $this->arrayHasKey('product_id')); - $this->assertEquals($idKey, $row['product_id']); - } - } - - /** - * Test the Adapter's fetchCol() method. - */ - public function testAdapterFetchCol() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchCol("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1)); - $this->assertEquals(2, count($result)); // count rows - $this->assertEquals(2, $result[0]); - $this->assertEquals(3, $result[1]); - } - - /** - * Test the Adapter's fetchOne() method. - */ - public function testAdapterFetchOne() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $prod = 'Linux'; - $result = $this->_db->fetchOne("SELECT $product_name FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1)); - $this->assertEquals($prod, $result); - } - - /** - * Test the Adapter's fetchPairs() method. - */ - public function testAdapterFetchPairs() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $prod = 'Linux'; - $result = $this->_db->fetchPairs("SELECT $product_id, $product_name FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1)); - $this->assertEquals(2, count($result)); // count rows - $this->assertEquals($prod, $result[2]); - } - - /** - * Test the Adapter's fetchRow() method. - */ - public function testAdapterFetchRow() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1)); - $this->assertEquals(2, count($result)); // count columns - $this->assertEquals(2, $result['product_id']); - } - - public function testAdapterInsert() - { - $row = array ( - 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'), - 'product_name' => 'Solaris', - ); - $rowsAffected = $this->_db->insert('zfproducts', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId('zfproducts', null); // implies 'zfproducts_seq' - $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq'); - $this->assertEquals('4', (string) $lastInsertId, 'Expected new id to be 4'); - $this->assertEquals('4', (string) $lastSequenceId, 'Expected new id to be 4'); - } - - public function testAdapterInsertDbExpr() - { - $row = array ( - 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'), - 'product_name' => new Zend_Db_Expr('UPPER(\'Solaris\')') - ); - $rowsAffected = $this->_db->insert('zfproducts', $row); - $this->assertEquals(1, $rowsAffected); - $product_id = $this->_db->quoteIdentifier('product_id', true); - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 4"); - $result = $this->_db->fetchAll($select); - $this->assertType('array', $result); - $this->assertEquals('SOLARIS', $result[0]['product_name']); - } - - /** - * Test the Adapter's limit() method. - * Fetch 1 row. Then fetch 1 row offset by 1 row. - */ - public function testAdapterLimit() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - - $sql = $this->_db->limit("SELECT * FROM $products", 1); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result), - 'Expecting row count to be 1'); - $this->assertEquals(3, count($result[0]), - 'Expecting column count to be 3'); - $this->assertEquals(1, $result[0]['product_id'], - 'Expecting to get product_id 1'); - } - - public function testAdapterLimitOffset() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - - $sql = $this->_db->limit("SELECT * FROM $products", 1, 1); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result), - 'Expecting row count to be 1'); - $this->assertEquals(3, count($result[0]), - 'Expecting column count to be 3'); - $this->assertEquals(2, $result[0]['product_id'], - 'Expecting to get product_id 2'); - } - - /** - * Test that quote() takes an array and returns - * an imploded string of comma-separated, quoted elements. - */ - public function testAdapterQuoteArray() - { - $array = array("it's", 'all', 'right!'); - $value = $this->_db->quote($array); - $this->assertEquals("'it''s', 'all', 'right!'", $value); - } - - /** - * test that quote() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteDoubleQuote() - { - $value = $this->_db->quote('St John"s Wort'); - $this->assertEquals("'St John\"s Wort'", $value); - } - - /** - * test that quote() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteSingleQuote() - { - $string = "St John's Wort"; - $value = $this->_db->quote($string); - $this->assertEquals("'St John''s Wort'", $value); - } - - /** - * test that quoteInto() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIntoDoubleQuote() - { - $value = $this->_db->quoteInto('id=?', 'St John"s Wort'); - $this->assertEquals("id='St John\"s Wort'", $value); - } - - /** - * test that quoteInto() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIntoSingleQuote() - { - $value = $this->_db->quoteInto('id = ?', 'St John\'s Wort'); - $this->assertEquals("id = 'St John''s Wort'", $value); - } - - /** - * test that quoteTableAs() accepts a string and an alias, - * and returns each as delimited identifiers. - * Oracle does not want the 'AS' in between. - */ - public function testAdapterQuoteTableAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteTableAs($string, $alias); - $this->assertEquals('"foo" "bar"', $value); - } - - /** - * Used by _testAdapterOptionCaseFoldingNatural() - * DB2 and Oracle return identifiers in uppercase naturally, - * so those test suites will override this method. - */ - protected function _testAdapterOptionCaseFoldingNaturalIdentifier() - { - return 'CASE_FOLDED_IDENTIFIER'; - } - - public function testAdapterOptionCaseFoldingUpper() - { - $this->markTestIncomplete($this->getDriver() . ' does not support case-folding array keys yet.'); - } - - public function testAdapterOptionCaseFoldingLower() - { - $this->markTestIncomplete($this->getDriver() . ' does not support case-folding array keys yet.'); - } - - public function testAdapterTransactionCommit() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with transactions'); - } - - public function testAdapterTransactionRollback() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with transactions'); - } - - public function testAdapterAlternateStatement() - { - $this->_testAdapterAlternateStatement('Test_OracleStatement'); - } - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Adapter/Pdo/IbmTest.php b/tests/Zend/Db/Adapter/Pdo/IbmTest.php deleted file mode 100644 index 82f573b7bf9e7e125eb20006b76ffb50b4421200..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/IbmTest.php +++ /dev/null @@ -1,109 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Db_Adapter_Db2Test - */ -require_once 'Zend/Db/Adapter/Db2Test.php'; - - -/** - * @see Zend_Db_Adapter_Pdo_Ibm - */ -require_once 'Zend/Db/Adapter/Pdo/Ibm.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_Pdo_IbmTest extends Zend_Db_Adapter_Db2Test -{ - public function getDriver() - { - return 'Pdo_Ibm'; - } - - public function testAdapterTransactionCommit() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestIncomplete('IDS needs special consideration for transactions'); - } else { - parent::testAdapterTransactionCommit(); - } - } - - public function testAdapterTransactionRollback() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestIncomplete('IDS needs special consideration for transactions'); - } else { - parent::testAdapterTransactionCommit(); - } - } - - public function testAdapterLimitInvalidArgumentException() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $sql = $this->_db->limit("SELECT * FROM $products", 0); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - - $this->assertEquals(0, count($result), 'Expecting to see 0 rows returned'); - - try { - $sql = $this->_db->limit("SELECT * FROM $products", 1, -1); - $this->fail('Expected to catch Zend_Db_Adapter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expecting object of type Zend_Db_Adapter_Exception, got '.get_class($e)); - } - } - - /** - * Used by _testAdapterOptionCaseFoldingNatural() - * DB2 returns identifiers in uppercase naturally, - * while IDS does not - */ - protected function _testAdapterOptionCaseFoldingNaturalIdentifier() - { - $server = $this->_util->getServer(); - - if ($server == 'DB2') { - return 'CASE_FOLDED_IDENTIFIER'; - } - return 'case_folded_identifier'; - } -} diff --git a/tests/Zend/Db/Adapter/Pdo/MssqlTest.php b/tests/Zend/Db/Adapter/Pdo/MssqlTest.php deleted file mode 100644 index a169c572b61c798eba76b07157512830c4313ead..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/MssqlTest.php +++ /dev/null @@ -1,326 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MssqlTest.php 7530 2008-01-20 13:38:14Z peptolab $ - */ - -/** - * @see Zend_Db_Adapter_Pdo_TestCommon - */ -require_once 'Zend/Db/Adapter/Pdo/TestCommon.php'; - -/** - * @see Zend_Db_Adapter_Pdo_Mysql - */ -require_once 'Zend/Db/Adapter/Pdo/Mysql.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_Pdo_MssqlTest extends Zend_Db_Adapter_Pdo_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'INT' => Zend_Db::INT_TYPE, - 'SMALLINT' => Zend_Db::INT_TYPE, - 'TINYINT' => Zend_Db::INT_TYPE, - 'BIGINT' => Zend_Db::BIGINT_TYPE, - 'DECIMAL' => Zend_Db::FLOAT_TYPE, - 'FLOAT' => Zend_Db::FLOAT_TYPE, - 'MONEY' => Zend_Db::FLOAT_TYPE, - 'NUMERIC' => Zend_Db::FLOAT_TYPE, - 'REAL' => Zend_Db::FLOAT_TYPE, - 'SMALLMONEY' => Zend_Db::FLOAT_TYPE - ); - - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - */ - public function testAdapterAutoQuoteIdentifiersTrue() - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => true - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - $select = $this->_db->select(); - $select->from('zfproducts'); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), 'Expected 3 rows in first query result'); - - $this->assertEquals(1, $result[0]['product_id']); - } - - public function testAdapterDescribeTableAttributeColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_name']['TABLE_NAME']); - $this->assertEquals('product_name', $desc['product_name']['COLUMN_NAME']); - $this->assertEquals(2, $desc['product_name']['COLUMN_POSITION']); - $this->assertRegExp('/varchar/i', $desc['product_name']['DATA_TYPE']); - $this->assertEquals('', $desc['product_name']['DEFAULT']); - $this->assertFalse( $desc['product_name']['NULLABLE'], 'Expected product_name not to be nullable'); - $this->assertNull( $desc['product_name']['SCALE'], 'scale is not 0'); - // MS SQL Server reports varchar length in the PRECISION field. Whaaa?!? - $this->assertEquals(100, $desc['product_name']['PRECISION'], 'precision is not 100'); - $this->assertFalse( $desc['product_name']['PRIMARY'], 'Expected product_name not to be a primary key'); - $this->assertNull( $desc['product_name']['PRIMARY_POSITION'], 'Expected product_name to return null for PRIMARY_POSITION'); - $this->assertFalse( $desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY'); - } - - public function testAdapterDescribeTablePrimaryKeyColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']); - $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']); - $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']); - $this->assertEquals('', $desc['product_id']['DEFAULT']); - $this->assertFalse( $desc['product_id']['NULLABLE'], 'Expected product_id not to be nullable'); - $this->assertEquals(0, $desc['product_id']['SCALE'], 'scale is not 0'); - $this->assertEquals(10, $desc['product_id']['PRECISION'], 'precision is not 10'); - $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key'); - $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']); - } - - /** - * Test that quote() takes an array and returns - * an imploded string of comma-separated, quoted elements. - */ - public function testAdapterQuoteArray() - { - $array = array("it's", 'all', 'right!'); - $value = $this->_db->quote($array); - $this->assertEquals("'it''s', 'all', 'right!'", $value); - } - - /** - * test that quote() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteDoubleQuote() - { - $string = 'St John"s Wort'; - $value = $this->_db->quote($string); - $this->assertEquals("'St John\"s Wort'", $value); - } - - /** - * test that quote() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteSingleQuote() - { - $string = "St John's Wort"; - $value = $this->_db->quote($string); - $this->assertEquals("'St John''s Wort'", $value); - } - - /** - * test that quoteInto() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIntoDoubleQuote() - { - $string = 'id=?'; - $param = 'St John"s Wort'; - $value = $this->_db->quoteInto($string, $param); - $this->assertEquals("id='St John\"s Wort'", $value); - } - - /** - * test that quoteInto() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIntoSingleQuote() - { - $string = 'id = ?'; - $param = 'St John\'s Wort'; - $value = $this->_db->quoteInto($string, $param); - $this->assertEquals("id = 'St John''s Wort'", $value); - } - - public function testAdapterInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences.'); - } - - public function testAdapterInsertDbExpr() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - $expr = new Zend_Db_Expr('2+3'); - - $row = array ( - 'bug_id' => $expr, - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - - $this->_db->query("SET IDENTITY_INSERT $bugs ON"); - - $rowsAffected = $this->_db->insert('zfbugs', $row); - $this->assertEquals(1, $rowsAffected); - - $this->_db->query("SET IDENTITY_INSERT $bugs OFF"); - - $value = $this->_db->fetchOne("SELECT $bug_id FROM $bugs WHERE $bug_id = 5"); - $this->assertEquals(5, $value); - } - - public function testAdapterTransactionCommit() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // notice the number of rows in connection 2 - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)'); - - // start an explicit transaction in connection 1 - $this->_db->beginTransaction(); - - // delete a row in connection 1 - $rowsAffected = $this->_db->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should still see all rows in connection 2 - // because the DELETE has not been committed yet - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table (step 2); perhaps Adapter is still in autocommit mode?'); - - // commit the DELETE - $this->_db->commit(); - - // now we should see one fewer rows in connection 2 - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 3)'); - - // delete another row in connection 1 - $rowsAffected = $this->_db->delete( - 'zfbugs', - "$bug_id = 2" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see results immediately, because - // the db connection returns to auto-commit mode - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(2, $count); - } - - public function testAdapterTransactionRollback() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // notice the number of rows in connection 2 - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)'); - - // start an explicit transaction in connection 1 - $this->_db->beginTransaction(); - - // delete a row in connection 1 - $rowsAffected = $this->_db->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should still see all rows in connection 2 - // because the DELETE has not been committed yet - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table (step 2); perhaps Adapter is still in autocommit mode?'); - - // rollback the DELETE - $this->_db->rollback(); - - // now we should see the same number of rows - // because the DELETE was rolled back - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table after DELETE is rolled back (step 3)'); - - // delete another row in connection 1 - $rowsAffected = $this->_db->delete( - 'zfbugs', - "$bug_id = 2" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see results immediately, because - // the db connection returns to auto-commit mode - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 4)'); - } - - /** - * Test the Adapter's insert() method. - * This requires providing an associative array of column=>value pairs. - */ - public function testAdapterInsert() - { - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - $rowsAffected = $this->_db->insert('zfbugs', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId(); - $this->assertType('integer', $lastInsertId); - $this->assertEquals('5', (string) $lastInsertId, - 'Expected new id to be 5'); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Adapter/Pdo/MysqlTest.php b/tests/Zend/Db/Adapter/Pdo/MysqlTest.php deleted file mode 100644 index 6dccc14b17cdb640f7cbb3d3bedfd29ee833ae86..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/MysqlTest.php +++ /dev/null @@ -1,305 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqlTest.php 6923 2007-11-25 02:00:06Z peptolab $ - */ - - -/** - * @see Zend_Db_Adapter_Pdo_TestCommon - */ -require_once 'Zend/Db/Adapter/Pdo/TestCommon.php'; - - -/** - * @see Zend_Db_Adapter_Pdo_Mysql - */ -require_once 'Zend/Db/Adapter/Pdo/Mysql.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_Pdo_MysqlTest extends Zend_Db_Adapter_Pdo_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'INT' => Zend_Db::INT_TYPE, - 'INTEGER' => Zend_Db::INT_TYPE, - 'MEDIUMINT' => Zend_Db::INT_TYPE, - 'SMALLINT' => Zend_Db::INT_TYPE, - 'TINYINT' => Zend_Db::INT_TYPE, - 'BIGINT' => Zend_Db::BIGINT_TYPE, - 'SERIAL' => Zend_Db::BIGINT_TYPE, - 'DEC' => Zend_Db::FLOAT_TYPE, - 'DECIMAL' => Zend_Db::FLOAT_TYPE, - 'DOUBLE' => Zend_Db::FLOAT_TYPE, - 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE, - 'FIXED' => Zend_Db::FLOAT_TYPE, - 'FLOAT' => Zend_Db::FLOAT_TYPE - ); - - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - * - * MySQL actually allows delimited identifiers to remain - * case-insensitive, so this test overrides its parent. - */ - public function testAdapterAutoQuoteIdentifiersTrue() - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => true - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - $select = $this->_db->select(); - $select->from('zfproducts'); - $stmt = $this->_db->query($select); - $result1 = $stmt->fetchAll(); - - $this->assertEquals(1, $result1[0]['product_id']); - - $select = $this->_db->select(); - $select->from('zfproducts'); - try { - $stmt = $this->_db->query($select); - $result2 = $stmt->fetchAll(); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->fail('Unexpected exception '.get_class($e).' received: '.$e->getMessage()); - } - - $this->assertEquals($result1, $result2); - } - - /** - * Ensures that driver_options are properly passed along to PDO - * - * @see http://framework.zend.com/issues/browse/ZF-285 - * @return void - */ - public function testAdapterDriverOptions() - { - $params = $this->_util->getParams(); - - $params['driver_options'] = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true); - - $db = Zend_Db::factory($this->getDriver(), $params); - - $this->assertTrue((boolean) $db->getConnection()->getAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY)); - - $params['driver_options'] = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false); - - $db = Zend_Db::factory($this->getDriver(), $params); - - $this->assertFalse((boolean) $db->getConnection()->getAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY)); - } - - public function testAdapterInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - /** - * test that quoteColumnAs() accepts a string - * and an alias, and returns each as delimited - * identifiers, with 'AS' in between. - */ - public function testAdapterQuoteColumnAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteColumnAs($string, $alias); - $this->assertEquals('`foo` AS `bar`', $value); - } - - /** - * test that quoteColumnAs() accepts a string - * and an alias, but ignores the alias if it is - * the same as the base identifier in the string. - */ - public function testAdapterQuoteColumnAsSameString() - { - $string = 'foo.bar'; - $alias = 'bar'; - $value = $this->_db->quoteColumnAs($string, $alias); - $this->assertEquals('`foo`.`bar`', $value); - } - - /** - * test that quoteIdentifier() accepts a string - * and returns a delimited identifier. - */ - public function testAdapterQuoteIdentifier() - { - $value = $this->_db->quoteIdentifier('table_name'); - $this->assertEquals('`table_name`', $value); - } - - /** - * test that quoteIdentifier() accepts an array - * and returns a qualified delimited identifier. - */ - public function testAdapterQuoteIdentifierArray() - { - $array = array('foo', 'bar'); - $value = $this->_db->quoteIdentifier($array); - $this->assertEquals('`foo`.`bar`', $value); - } - - /** - * test that quoteIdentifier() accepts an array - * containing a Zend_Db_Expr, and returns strings - * as delimited identifiers, and Exprs as unquoted. - */ - public function testAdapterQuoteIdentifierArrayDbExpr() - { - $expr = new Zend_Db_Expr('*'); - $array = array('foo', $expr); - $value = $this->_db->quoteIdentifier($array); - $this->assertEquals('`foo`.*', $value); - } - - /** - * test that quoteIdentifer() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIdentifierDoubleQuote() - { - $string = 'table_"_name'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('`table_"_name`', $value); - } - - /** - * test that quoteIdentifer() accepts an integer - * and returns a delimited identifier as with a string. - */ - public function testAdapterQuoteIdentifierInteger() - { - $int = 123; - $value = $this->_db->quoteIdentifier($int); - $this->assertEquals('`123`', $value); - } - - /** - * test that quoteIdentifier() accepts a string - * containing a dot (".") character, splits the - * string, quotes each segment individually as - * delimited identifers, and returns the imploded - * string. - */ - public function testAdapterQuoteIdentifierQualified() - { - $string = 'table.column'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('`table`.`column`', $value); - } - - /** - * test that quoteIdentifer() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIdentifierSingleQuote() - { - $string = "table_'_name"; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('`table_\'_name`', $value); - } - - /** - * test that quoteTableAs() accepts a string and an alias, - * and returns each as delimited identifiers. - * Most RDBMS want an 'AS' in between. - */ - public function testAdapterQuoteTableAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteTableAs($string, $alias); - $this->assertEquals('`foo` AS `bar`', $value); - } - - /** - * Ensures that the character sequence ":0'" is handled properly - * - * @link http://framework.zend.com/issues/browse/ZF-2059 - * @return void - */ - public function testZF2059() - { - $this->markTestIncomplete('Inconsistent test results'); - } - - /** - * Ensures that the PDO Buffered Query does not throw the error - * 2014 General error - * - * @link http://framework.zend.com/issues/browse/ZF-2101 - * @return void - */ - public function testZF2101() - { - $params = $this->_util->getParams(); - $params['driver_options'] = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true); - $db = Zend_Db::factory($this->getDriver(), $params); - - // Set default bound value - $customerId = 1; - - // Stored procedure returns a single row - $stmt = $db->prepare('CALL zf_test_procedure(:customerId)'); - $stmt->bindParam('customerId', $customerId, PDO::PARAM_INT); - $stmt->execute(); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - - // Reset statement - $stmt->closeCursor(); - - // Stored procedure returns a single row - $stmt = $db->prepare('CALL zf_test_procedure(:customerId)'); - $stmt->bindParam('customerId', $customerId, PDO::PARAM_INT); - $stmt->execute(); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - } - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Adapter/Pdo/OciTest.php b/tests/Zend/Db/Adapter/Pdo/OciTest.php deleted file mode 100644 index 00d64822026cc86be3645fcf369bdb0fca6b6247..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/OciTest.php +++ /dev/null @@ -1,214 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Adapter/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Adapter_Pdo_OciTest extends Zend_Db_Adapter_Pdo_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE, - 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE, - 'NUMBER' => Zend_Db::FLOAT_TYPE - ); - - public function testAdapterDescribeTablePrimaryAuto() - { - $this->markTestSkipped('Oracle does not support auto-increment'); - } - - public function testAdapterDescribeTablePrimaryKeyColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']); - $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']); - $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']); - $this->assertEquals('', $desc['product_id']['DEFAULT']); - $this->assertFalse( $desc['product_id']['NULLABLE']); - $this->assertEquals(0, $desc['product_id']['SCALE']); - // Oracle reports precsion 11 for integers - $this->assertEquals(11, $desc['product_id']['PRECISION']); - $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key'); - $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']); - $this->assertFalse( $desc['product_id']['IDENTITY']); - } - - public function testAdapterInsert() - { - $row = array ( - 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'), - 'product_name' => 'Solaris', - ); - $rowsAffected = $this->_db->insert('zfproducts', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId('zfproducts', null); // implies 'products_seq' - $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq'); - $this->assertType('string', $lastInsertId); - $this->assertType('string', $lastSequenceId); - $this->assertEquals('4', (string) $lastInsertId, 'Expected new id to be 4'); - $this->assertEquals('4', (string) $lastSequenceId, 'Expected new id to be 4'); - } - - public function testAdapterInsertDbExpr() - { - $row = array ( - 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'), - 'product_name' => new Zend_Db_Expr('UPPER(\'Solaris\')') - ); - $rowsAffected = $this->_db->insert('zfproducts', $row); - $this->assertEquals(1, $rowsAffected); - $product_id = $this->_db->quoteIdentifier('product_id', true); - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 4"); - $result = $this->_db->fetchAll($select); - $this->assertType('array', $result); - $this->assertEquals('SOLARIS', $result[0]['product_name']); - } - - /** - * Test the Adapter's limit() method. - * Fetch 1 row. Then fetch 1 row offset by 1 row. - */ - public function testAdapterLimit() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - - $sql = $this->_db->limit("SELECT * FROM $products", 1); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result), - 'Expecting row count to be 1'); - $this->assertEquals(3, count($result[0]), - 'Expecting column count to be 3'); - $this->assertEquals(1, $result[0]['product_id'], - 'Expecting to get product_id 1'); - } - - public function testAdapterLimitOffset() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - - $sql = $this->_db->limit("SELECT * FROM $products", 1, 1); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result), - 'Expecting row count to be 1'); - $this->assertEquals(3, count($result[0]), - 'Expecting column count to be 3'); - $this->assertEquals(2, $result[0]['product_id'], - 'Expecting to get product_id 2'); - } - - /** - * Used by _testAdapterOptionCaseFoldingNatural() - * DB2 and Oracle return identifiers in uppercase naturally, - * so those test suites will override this method. - */ - protected function _testAdapterOptionCaseFoldingNaturalIdentifier() - { - return 'CASE_FOLDED_IDENTIFIER'; - } - - /** - * Test that quote() takes an array and returns - * an imploded string of comma-separated, quoted elements. - */ - public function testAdapterQuoteArray() - { - $array = array("it's", 'all', 'right!'); - $value = $this->_db->quote($array); - $this->assertEquals("'it''s', 'all', 'right!'", $value); - } - - /** - * test that quote() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteDoubleQuote() - { - $string = 'St John"s Wort'; - $value = $this->_db->quote($string); - $this->assertEquals("'St John\"s Wort'", $value); - } - - /** - * test that quote() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteSingleQuote() - { - $string = "St John's Wort"; - $value = $this->_db->quote($string); - $this->assertEquals("'St John''s Wort'", $value); - } - - /** - * test that quoteInto() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIntoDoubleQuote() - { - $string = 'id=?'; - $param = 'St John"s Wort'; - $value = $this->_db->quoteInto($string, $param); - $this->assertEquals("id='St John\"s Wort'", $value); - } - - /** - * test that quoteInto() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIntoSingleQuote() - { - $string = 'id = ?'; - $param = 'St John\'s Wort'; - $value = $this->_db->quoteInto($string, $param); - $this->assertEquals("id = 'St John''s Wort'", $value); - } - - /** - * test that quoteTableAs() accepts a string and an alias, - * and returns each as delimited identifiers. - * Oracle does not want the 'AS' in between. - */ - public function testAdapterQuoteTableAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteTableAs($string, $alias); - $this->assertEquals('"foo" "bar"', $value); - } - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php b/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php deleted file mode 100644 index 2ad8ea5fbc988bfeab56365d251f5e1df089d64e..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php +++ /dev/null @@ -1,175 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Adapter/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Adapter_Pdo_PgsqlTest extends Zend_Db_Adapter_Pdo_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'INTEGER' => Zend_Db::INT_TYPE, - 'SERIAL' => Zend_Db::INT_TYPE, - 'SMALLINT' => Zend_Db::INT_TYPE, - 'BIGINT' => Zend_Db::BIGINT_TYPE, - 'BIGSERIAL' => Zend_Db::BIGINT_TYPE, - 'DECIMAL' => Zend_Db::FLOAT_TYPE, - 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE, - 'NUMERIC' => Zend_Db::FLOAT_TYPE, - 'REAL' => Zend_Db::FLOAT_TYPE - ); - - public function testAdapterDescribeTablePrimaryAuto() - { - $desc = $this->_db->describeTable('zfbugs'); - - $this->assertTrue($desc['bug_id']['PRIMARY']); - $this->assertEquals(1, $desc['bug_id']['PRIMARY_POSITION']); - $this->assertTrue($desc['bug_id']['IDENTITY']); - } - - /** - * Test the Adapter's insert() method. - * This requires providing an associative array of column=>value pairs. - */ - public function testAdapterInsert() - { - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - $rowsAffected = $this->_db->insert('zfbugs', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id'); - $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq'); - $this->assertEquals((string) $lastInsertId, (string) $lastSequenceId, - 'Expected last insert id to be equal to last sequence id'); - $this->assertEquals('5', (string) $lastInsertId, - 'Expected new id to be 5'); - } - - public function testAdapterInsertSequence() - { - $row = array ( - 'product_id' => $this->_db->nextSequenceId('zfproducts_seq'), - 'product_name' => 'Solaris', - ); - $rowsAffected = $this->_db->insert('zfproducts', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId('zfproducts'); - $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq'); - $this->assertEquals((string) $lastInsertId, (string) $lastSequenceId, - 'Expected last insert id to be equal to last sequence id'); - $this->assertEquals('4', (string) $lastInsertId, - 'Expected new id to be 4'); - } - - public function testAdapterInsertDbExpr() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_description = $this->_db->quoteIdentifier('bug_description', true); - - $expr = new Zend_Db_Expr('2+3'); - - $row = array ( - 'bug_id' => $expr, - 'bug_description' => 'New bug 5', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - $rowsAffected = $this->_db->insert('zfbugs', $row); - $this->assertEquals(1, $rowsAffected); - - $value = $this->_db->fetchOne("SELECT $bug_description FROM $bugs WHERE $bug_id = 5"); - $this->assertEquals('New bug 5', $value); - } - - /** - * Test that quote() takes an array and returns - * an imploded string of comma-separated, quoted elements. - */ - public function testAdapterQuoteArray() - { - $array = array("it's", 'all', 'right!'); - $value = $this->_db->quote($array); - $this->assertEquals("'it''s', 'all', 'right!'", $value); - } - - /** - * test that quote() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteDoubleQuote() - { - $value = $this->_db->quote('St John"s Wort'); - $this->assertEquals("'St John\"s Wort'", $value); - } - - /** - * test that quote() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteSingleQuote() - { - $string = "St John's Wort"; - $value = $this->_db->quote($string); - $this->assertEquals("'St John''s Wort'", $value); - } - - /** - * test that quoteInto() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIntoDoubleQuote() - { - $value = $this->_db->quoteInto('id=?', 'St John"s Wort'); - $this->assertEquals("id='St John\"s Wort'", $value); - } - - /** - * test that quoteInto() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIntoSingleQuote() - { - $value = $this->_db->quoteInto('id = ?', 'St John\'s Wort'); - $this->assertEquals("id = 'St John''s Wort'", $value); - } - - function getDriver() - { - return 'Pdo_Pgsql'; - } - -} diff --git a/tests/Zend/Db/Adapter/Pdo/SqliteTest.php b/tests/Zend/Db/Adapter/Pdo/SqliteTest.php deleted file mode 100644 index bb7c19b74c3c448a49e381cffc6c4a4ec3eef095..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/SqliteTest.php +++ /dev/null @@ -1,206 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SqliteTest.php 5876 2007-07-27 07:29:38Z bkarwin $ - */ - - -/** - * @see Zend_Db_Adapter_Pdo_TestCommon - */ -require_once 'Zend/Db/Adapter/Pdo/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_Pdo_SqliteTest extends Zend_Db_Adapter_Pdo_TestCommon -{ - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, - 'INTEGER' => Zend_Db::BIGINT_TYPE, - 'REAL' => Zend_Db::FLOAT_TYPE - ); - - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - * - * SQLite actually allows delimited identifiers to remain - * case-insensitive, so this test overrides its parent. - */ - public function testAdapterAutoQuoteIdentifiersTrue() - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => true - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - $select = $this->_db->select(); - $select->from('zfproducts'); - $stmt = $this->_db->query($select); - $result1 = $stmt->fetchAll(); - - $this->assertEquals(1, $result1[0]['product_id']); - - $select = $this->_db->select(); - $select->from('ZFPRODUCTS'); - try { - $stmt = $this->_db->query($select); - $result2 = $stmt->fetchAll(); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->fail('Unexpected exception '.get_class($e).' received: '.$e->getMessage()); - } - - $this->assertEquals($result1, $result2); - } - - - public function testAdapterConstructInvalidParamDbnameException() - { - $this->markTestSkipped($this->getDriver() . ' does not throw exception on missing dbname'); - } - - public function testAdapterConstructInvalidParamUsernameException() - { - $this->markTestSkipped($this->getDriver() . ' does not support login credentials'); - } - - public function testAdapterConstructInvalidParamPasswordException() - { - $this->markTestSkipped($this->getDriver() . ' does not support login credentials'); - } - - public function testAdapterInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - /** - * Used by: - * - testAdapterOptionCaseFoldingNatural() - * - testAdapterOptionCaseFoldingUpper() - * - testAdapterOptionCaseFoldingLower() - */ - protected function _testAdapterOptionCaseFoldingSetup(Zend_Db_Adapter_Abstract $db) - { - $db->getConnection(); - $this->_util->setUp($db); - } - - /** - * Test that quote() takes an array and returns - * an imploded string of comma-separated, quoted elements. - */ - public function testAdapterQuoteArray() - { - $array = array("it's", 'all', 'right!'); - $value = $this->_db->quote($array); - $this->assertEquals("'it''s', 'all', 'right!'", $value); - } - - /** - * test that quote() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteDoubleQuote() - { - $value = $this->_db->quote('St John"s Wort'); - $this->assertEquals("'St John\"s Wort'", $value); - } - - /** - * test that quote() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteSingleQuote() - { - $string = "St John's Wort"; - $value = $this->_db->quote($string); - $this->assertEquals("'St John''s Wort'", $value); - } - - /** - * test that quoteInto() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIntoDoubleQuote() - { - $value = $this->_db->quoteInto('id=?', 'St John"s Wort'); - $this->assertEquals("id='St John\"s Wort'", $value); - } - - /** - * test that quoteInto() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIntoSingleQuote() - { - $value = $this->_db->quoteInto('id = ?', 'St John\'s Wort'); - $this->assertEquals("id = 'St John''s Wort'", $value); - } - - public function testAdapterTransactionAutoCommit() - { - $this->markTestSkipped($this->getDriver() . ' does not support transactions or concurrency'); - } - - public function testAdapterTransactionCommit() - { - $this->markTestSkipped($this->getDriver() . ' does not support transactions or concurrency'); - } - - public function testAdapterTransactionRollback() - { - $this->markTestSkipped($this->getDriver() . ' does not support transactions or concurrency'); - } - - /** - * @return void - * @see http://framework.zend.com/issues/browse/ZF-2293 - */ - public function testAdapterSupportsLengthInTableMetadataForVarcharFields() - { - $metadata = $this->_db->describeTable('zfbugs'); - $this->assertEquals(100, $metadata['bug_description']['LENGTH']); - $this->assertEquals(20, $metadata['bug_status']['LENGTH']); - } - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Adapter/Pdo/TestCommon.php b/tests/Zend/Db/Adapter/Pdo/TestCommon.php deleted file mode 100644 index 4bf6852694ef212e3a0c469050722bee61cc9db9..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Pdo/TestCommon.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 4608 2007-04-26 19:41:13Z darby $ - */ - - -/** - * @see Zend_Db_Adapter_TestCommon - */ -require_once 'Zend/Db/Adapter/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Adapter_Pdo_TestCommon extends Zend_Db_Adapter_TestCommon -{ - - public function testAdapterAlternateStatement() - { - $this->_testAdapterAlternateStatement('Test_PdoStatement'); - } - -} diff --git a/tests/Zend/Db/Adapter/SkipTests.php b/tests/Zend/Db/Adapter/SkipTests.php deleted file mode 100644 index 2c21208b519fc08fa468fb139da5ead57e23b0e5..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/SkipTests.php +++ /dev/null @@ -1,127 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Db - * @subpackage UnitTests - */ -abstract class Zend_Db_Adapter_Skip_CommonTest extends PHPUnit_Framework_TestCase -{ - abstract public function getDriver(); - - public function setUp() - { - $driver = $this->getDriver(); - $this->markTestSkipped("Testing Zend_Db_Adapter_$driver is not enabled in TestConfiguration.php"); - } - - public function testAdapter() - { - // this is here only so we have at least one test - } -} - -class Zend_Db_Adapter_Skip_Db2Test extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Db2'; - } -} - -class Zend_Db_Adapter_Skip_OracleTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Oracle'; - } -} - -class Zend_Db_Adapter_Skip_FirebirdTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Firebird'; - } -} - -class Zend_Db_Adapter_Skip_MysqliTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Mysqli'; - } -} - -class Zend_Db_Adapter_Skip_Pdo_MssqlTest extends Zend_Db_Adapter_Skip_CommonTest -{ - function getDriver() - { - return 'Pdo_Mssql'; - } -} - -class Zend_Db_Adapter_Skip_Pdo_MysqlTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Mysql'; - } -} - -class Zend_Db_Adapter_Skip_Pdo_OciTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Oci'; - } -} - -class Zend_Db_Adapter_Skip_Pdo_FirebirdTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Firebird'; - } -} - -class Zend_Db_Adapter_Skip_Pdo_PgsqlTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Pgsql'; - } -} - -class Zend_Db_Adapter_Skip_Pdo_SqliteTest extends Zend_Db_Adapter_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Sqlite'; - } -} - diff --git a/tests/Zend/Db/Adapter/Static.php b/tests/Zend/Db/Adapter/Static.php deleted file mode 100644 index 3f829ca88215070a553f2165390780d5f3c3662d..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/Static.php +++ /dev/null @@ -1,309 +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_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Static.php 5970 2007-08-03 01:56:49Z bkarwin $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Adapter_Abstract - */ -require_once 'Zend/Db/Adapter/Abstract.php'; - - -/** - * @see Zend_Db_Statement_Static - */ -require_once 'Zend/Db/Statement/Static.php'; - - -/** - * Class for connecting to SQL databases and performing common operations. - * - * @category Zend - * @package Zend_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_Static extends Zend_Db_Adapter_Abstract -{ - public $config = null; - - /** - * The number of seconds to sleep upon query execution - * - * @var integer - */ - protected $_onQuerySleep = 0; - - /** - * Sets the number of seconds to sleep upon query execution - * - * @param integer $seconds - * @return Zend_Db_Adapter_Static Provides a fluent interface - */ - public function setOnQuerySleep($seconds = 0) - { - $this->_onQuerySleep = (integer) $seconds; - - return $this; - } - - /** - * Returns the number of seconds to sleep upon query execution - * - * @return integer - */ - public function getOnQuerySleep() - { - return $this->_onQuerySleep; - } - - /** - * Check for config options that are mandatory. - * Throw exceptions if any are missing. - * - * @param array $config - * @throws Zend_Db_Adapter_Exception - */ - protected function _checkRequiredOptions(array $config) - { - // we need at least a dbname - if (! array_key_exists('dbname', $config)) { - require_once 'Zend/Db/Adapter/Exception.php'; - throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'dbname' that names the database instance"); - } - $this->config = $config; - } - - /** - * Prepares and executes a SQL statement with bound data. - * - * @param string|Zend_Db_Select $sql The SQL statement with placeholders. - * @param mixed $bind An array of data to bind to the placeholders. - * @return Zend_Db_Statement (may also be PDOStatement in the case of PDO) - */ - public function query($sql, $bind = array()) - { - // connect to the database if needed - $this->_connect(); - - // is the $sql a Zend_Db_Select object? - if ($sql instanceof Zend_Db_Select) { - $sql = $sql->__toString(); - } - - // make sure $bind to an array; - // don't use (array) typecasting because - // because $bind may be a Zend_Db_Expr object - if (!is_array($bind)) { - $bind = array($bind); - } - - // prepare and execute the statement with profiling - $stmt = $this->prepare($sql); - $q = $this->_profiler->queryStart($sql); - if ($this->_onQuerySleep > 0) { - sleep($this->_onQuerySleep); - } - $stmt->execute($bind); - $this->_profiler->queryEnd($q); - - // return the results embedded in the prepared statement object - $stmt->setFetchMode($this->_fetchMode); - return $stmt; - } - - /** - * Returns a list of the tables in the database. - * - * @return array - */ - public function listTables() - { - return array('dummy'); - } - - /** - * Returns the column descriptions for a table. - * - * The return value is an associative array keyed by the column name, - * as returned by the RDBMS. - * - * The value of each array element is an associative array - * with the following keys: - * - * SCHEMA_NAME => string; name of database or schema - * TABLE_NAME => string; - * COLUMN_NAME => string; column name - * COLUMN_POSITION => number; ordinal position of column in table - * DATA_TYPE => string; SQL datatype name of column - * DEFAULT => string; default expression of column, null if none - * NULLABLE => boolean; true if column can have nulls - * LENGTH => number; length of CHAR/VARCHAR - * SCALE => number; scale of NUMERIC/DECIMAL - * PRECISION => number; precision of NUMERIC/DECIMAL - * UNSIGNED => boolean; unsigned property of an integer type - * PRIMARY => boolean; true if column is part of the primary key - * PRIMARY_POSITION => integer; position of column in primary key - * - * @param string $tableName - * @param string $schemaName OPTIONAL - * @return array - */ - public function describeTable($tableName, $schemaName = null) - { - return array( - 'SCHEMA_NAME' => $schemaName, - 'TABLE_NAME' => $tableName, - 'COLUMN_NAME' => null, - 'COLUMN_POSITION' => null, - 'DATA_TYPE' => null, - 'DEFAULT' => null, - 'NULLABLE' => null, - 'LENGTH' => null, - 'SCALE' => null, - 'PRECISION' => null, - 'UNSIGNED' => null, - 'PRIMARY' => null, - 'PRIMARY_POSITION' => null, - ); - } - - /** - * Creates a connection to the database. - * - * @return void - */ - protected function _connect() - { - $this->_connection = $this; - return; - } - - /** - * Force the connection to close. - * - * @return void - */ - public function closeConnection() - { - $this->_connection = null; - } - - /** - * Prepare a statement and return a PDOStatement-like object. - * - * @param string|Zend_Db_Select $sql SQL query - * @return Zend_Db_Statment_Static - */ - public function prepare($sql) - { - return new Zend_Db_Statement_Static(); - } - - /** - * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column. - * - * As a convention, on RDBMS brands that support sequences - * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence - * from the arguments and returns the last id generated by that sequence. - * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method - * returns the last value generated for such a column, and the table name - * argument is disregarded. - * - * @param string $tableName OPTIONAL Name of table. - * @param string $primaryKey OPTIONAL Name of primary key column. - * @return integer - */ - public function lastInsertId($tableName = null, $primaryKey = 'id') - { - return null; - } - - /** - * Begin a transaction. - */ - protected function _beginTransaction() - { - return true; - } - - /** - * Commit a transaction. - */ - protected function _commit() - { - return true; - } - - /** - * Roll-back a transaction. - */ - protected function _rollBack() - { - return true; - } - - /** - * Set the fetch mode. - * - * @param integer $mode - */ - public function setFetchMode($mode) - { - return; - } - - /** - * Adds an adapter-specific LIMIT clause to the SELECT statement. - * - * @param mixed $sql - * @param integer $count - * @param integer $offset - * @return string - */ - public function limit($sql, $count, $offset = 0) - { - return $sql . " LIMIT $count OFFSET $offset"; - } - - /** - * Check if the adapter supports real SQL parameters. - * - * @param string $type - * @return bool - */ - public function supportsParameters($type) - { - return true; - } - -} diff --git a/tests/Zend/Db/Adapter/StaticTest.php b/tests/Zend/Db/Adapter/StaticTest.php deleted file mode 100644 index a25af7a25e26e0b2b08a8508a7157533864c62c4..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/StaticTest.php +++ /dev/null @@ -1,287 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 6923 2007-11-25 02:00:06Z peptolab $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Db - */ -require_once 'Zend/Db.php'; - -/** - * @see Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * @see Zend_Db_Adapter_Static - */ -require_once 'Zend/Db/Adapter/Static.php'; - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Adapter_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testDbConstructor() - { - $db = new Zend_Db_Adapter_Static( array('dbname' => 'dummy') ); - $this->assertType('Zend_Db_Adapter_Abstract', $db); - $this->assertEquals('dummy', $db->config['dbname']); - } - - public function testDbConstructorExceptionInvalidOptions() - { - list($major, $minor, $revision) = explode('.', PHP_VERSION); - if ($minor >= 2) { - try { - $db = new Zend_Db_Adapter_Static('scalar'); - $this->fail('Expected exception not thrown'); - } catch (Exception $e) { - $this->assertContains('Adapter parameters must be in an array or a Zend_Config object', $e->getMessage()); - } - } else { - $this->markTestIncomplete('Failure to meet type hint results in fatal error in PHP < 5.2.0'); - } - } - - public function testDbConstructorZendConfig() - { - $configData1 = array( - 'adapter' => 'Static', - 'params' => array( - 'dbname' => 'dummy' - ) - ); - $config1 = new Zend_Config($configData1); - $db = new Zend_Db_Adapter_Static($config1->params); - $this->assertType('Zend_Db_Adapter_Abstract', $db); - $this->assertEquals('dummy', $db->config['dbname']); - } - - public function testDbFactory() - { - $db = Zend_Db::factory('Static', array('dbname' => 'dummy') ); - $this->assertType('Zend_Db_Adapter_Abstract', $db); - $this->assertTrue(class_exists('Zend_Db_Adapter_Static')); - $this->assertType('Zend_Db_Adapter_Static', $db); - $this->assertEquals('dummy', $db->config['dbname']); - } - - public function testDbFactoryAlternateNamespace() - { - $ip = get_include_path(); - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $newIp = $dir . PATH_SEPARATOR . $ip; - set_include_path($newIp); - - try { - $db = Zend_Db::factory('Static', array('dbname' => 'dummy', 'adapterNamespace' => 'TestNamespace')); - } catch (Zend_Exception $e) { - set_include_path($ip); - $this->fail('Caught exception of type '.get_class($e).' where none was expected: '.$e->getMessage()); - } - - set_include_path($ip); - - $this->assertType('Zend_Db_Adapter_Abstract', $db); - $this->assertTrue(class_exists('Zend_Db_Adapter_Static')); - $this->assertType('Zend_Db_Adapter_Static', $db); - $this->assertTrue(class_exists('TestNamespace_Static')); - $this->assertType('TestNamespace_Static', $db); - } - - public function testDbFactoryAlternateNamespaceExceptionInvalidAdapter() - { - $ip = get_include_path(); - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $newIp = $dir . PATH_SEPARATOR . $ip; - set_include_path($newIp); - - try { - $db = Zend_Db::factory('Version', array('dbname' => 'dummy', 'adapterNamespace' => 'Zend')); - set_include_path($ip); - $this->fail('Expected to catch Zend_Db_Exception'); - } catch (Zend_Exception $e) { - set_include_path($ip); - $this->assertType('Zend_Db_Exception', $e, - 'Expected exception of type Zend_Db_Exception, got '.get_class($e)); - $this->assertEquals("Adapter class 'Zend_Version' does not extend Zend_Db_Adapter_Abstract", $e->getMessage()); - } - } - - public function testDbFactoryExceptionInvalidDriverName() - { - try { - $db = Zend_Db::factory(null); - $this->fail('Expected to catch Zend_Db_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Exception', $e, - 'Expected exception of type Zend_Db_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Adapter name must be specified in a string'); - } - } - - public function testDbFactoryExceptionInvalidOptions() - { - list($major, $minor, $revision) = explode('.', PHP_VERSION); - if ($minor >= 2) { - try { - $db = Zend_Db::factory('Static', 'scalar'); - $this->fail('Expected exception not thrown'); - } catch (Exception $e) { - $this->assertContains('Adapter parameters must be in an array or a Zend_Config object', $e->getMessage()); - } - } else { - $this->markTestIncomplete('Failure to meet type hint results in fatal error in PHP < 5.2.0'); - } - } - - public function testDbFactoryExceptionNoConfig() - { - list($major, $minor, $revision) = explode('.', PHP_VERSION); - if ($minor >= 2) { - try { - $db = Zend_Db::factory('Static'); - $this->fail('Expected exception not thrown'); - } catch (Exception $e) { - $this->assertContains('Configuration must have a key for \'dbname\' that names the database instance', $e->getMessage()); - } - } else { - $this->markTestIncomplete('Failure to meet type hint results in fatal error in PHP < 5.2.0'); - } - } - - public function testDbFactoryExceptionNoDatabaseName() - { - try { - $db = Zend_Db::factory('Static', array()); - $this->fail('Expected to catch Zend_Db_Adapter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expected exception of type Zend_Db_Adapter_Exception, got '.get_class($e)); - $this->assertEquals("Configuration must have a key for 'dbname' that names the database instance", $e->getMessage()); - } - } - - public function testDbFactoryZendConfig() - { - $configData1 = array( - 'adapter' => 'Static', - 'params' => array( - 'dbname' => 'dummy' - ) - ); - $config1 = new Zend_Config($configData1); - $db = Zend_Db::factory($config1); - $this->assertType('Zend_Db_Adapter_Static', $db); - $this->assertEquals('dummy', $db->config['dbname']); - } - - public function testDbFactoryZendConfigExceptionNoAdapter() - { - $configData1 = array( - 'params' => array( - 'dbname' => 'dummy' - ) - ); - $config1 = new Zend_Config($configData1); - try { - $db = Zend_Db::factory($config1); - $this->fail('Expected to catch Zend_Db_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Exception', $e, - 'Expected exception of type Zend_Db_Exception, got '.get_class($e)); - $this->assertEquals($e->getMessage(), 'Adapter name must be specified in a string'); - } - } - - public function testDbFactoryZendConfigOverrideArray() - { - $configData1 = array( - 'adapter' => 'Static', - 'params' => array( - 'dbname' => 'dummy' - ) - ); - $configData2 = array( - 'dbname' => 'vanilla' - ); - $config1 = new Zend_Config($configData1); - $db = Zend_Db::factory($config1, $configData2); - $this->assertType('Zend_Db_Adapter_Static', $db); - // second arg should be ignored - $this->assertEquals('dummy', $db->config['dbname']); - } - - public function testDbFactoryZendConfigOverrideZendConfig() - { - $configData1 = array( - 'adapter' => 'Static', - 'params' => array( - 'dbname' => 'dummy' - ) - ); - $configData2 = array( - 'dbname' => 'vanilla' - ); - $config1 = new Zend_Config($configData1); - $config2 = new Zend_Config($configData2); - $db = Zend_Db::factory($config1, $config2); - $this->assertType('Zend_Db_Adapter_Static', $db); - // second arg should be ignored - $this->assertEquals('dummy', $db->config['dbname']); - } - - public function testDbGetConnection() - { - $db = Zend_Db::factory('Static', array('dbname' => 'dummy')); - $conn = $db->getConnection(); - $this->assertType('Zend_Db_Adapter_Static', $conn); - } - - public function testDbGetFetchMode() - { - $db = Zend_Db::factory('Static', array('dbname' => 'dummy')); - $mode = $db->getFetchMode(); - $this->assertType('integer', $mode); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Adapter/TestCommon.php b/tests/Zend/Db/Adapter/TestCommon.php deleted file mode 100644 index 3ca2f0e43897b2999f6819d7b7333ad07f993fd9..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/TestCommon.php +++ /dev/null @@ -1,1763 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 6923 2007-11-25 02:00:06Z peptolab $ - */ - - -/** - * @see Zend_Db_TestSetup - */ -require_once 'Zend/Db/TestSetup.php'; - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Adapter_TestCommon extends Zend_Db_TestSetup -{ - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - */ - public function testAdapterZendConfig() - { - Zend_Loader::loadClass('Zend_Config'); - $params = new Zend_Config($this->_util->getParams()); - - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - } - - /** - * Test empty adapterNamespace issue - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - */ - public function testAdapterZendConfigEmptyNamespace() - { - Zend_Loader::loadClass('Zend_Config'); - $params = $this->_util->getParams(); - $params['adapterNamespace'] = ''; - $params = new Zend_Config($params); - - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - } - - /** - * Test empty driver_options issue - * Case: $config['driver_options'] == '' - */ - public function testAdapterZendConfigEmptyDriverOptions() - { - Zend_Loader::loadClass('Zend_Config'); - $params = $this->_util->getParams(); - $params['driver_options'] = ''; - $params = new Zend_Config($params); - - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - $config = $db->getConfig(); - $this->assertEquals(array(), $config['driver_options']); - } - - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true - */ - public function testAdapterAutoQuoteIdentifiersTrue() - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => true - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - $select = $this->_db->select(); - $select->from('zfproducts'); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), 'Expected 3 rows in first query result'); - - $this->assertEquals(1, $result[0]['product_id']); - - $select = $this->_db->select(); - $select->from('ZFPRODUCTS'); - try { - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->fail('Expected exception not thrown'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - } - - /** - * Test AUTO_QUOTE_IDENTIFIERS option - * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = false - */ - public function testAdapterAutoQuoteIdentifiersFalse() - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => false - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - - // create a new util object, with the new db adapter - $driver = $this->getDriver(); - $utilClass = "Zend_Db_TestUtil_{$driver}"; - $util = new $utilClass(); - $util->setAdapter($db); - - // create test table using no identifier quoting - $util->createTable('noquote', array( - 'id' => 'INT NOT NULL PRIMARY KEY', - 'stuff' => 'CHAR(10)' - )); - $tableName = $this->_util->getTableName('noquote'); - - // insert into the table - $numRows = $db->insert($tableName, array( - 'id' => 1, - 'stuff' => 'no quote 1' - )); - $this->assertEquals(1, $numRows, - 'number of rows in first insert not as expected'); - - // check if the row was inserted as expected - $sql = "SELECT id, stuff FROM $tableName ORDER BY id"; - $stmt = $db->query($sql); - $fetched = $stmt->fetchAll(Zend_Db::FETCH_NUM); - $a = array( - 0 => array(0 => 1, 1 => 'no quote 1') - ); - $this->assertEquals($a, $fetched, - 'result of first query not as expected'); - - // insert into the table using other case - $numRows = $db->insert($tableName, array( - 'ID' => 2, - 'STUFF' => 'no quote 2' - )); - $this->assertEquals(1, $numRows, - 'number of rows in second insert not as expected'); - - // check if the row was inserted as expected - $sql = 'SELECT ID, STUFF FROM ' . $tableName . ' ORDER BY ID'; - $stmt = $db->query($sql); - $fetched = $stmt->fetchAll(Zend_Db::FETCH_NUM); - - $a = array( - 0 => array(0 => 1, 1 => 'no quote 1'), - 1 => array(0 => 2, 1 => 'no quote 2'), - ); - $this->assertEquals($a, $fetched, - 'result of second query not as expected'); - - // clean up - $util->dropTable($tableName); - } - - - protected function _testAdapterConstructInvalidParam($param, $adapterClass = null) - { - $exceptionClass = 'Zend_Db_Adapter_Exception'; - if ($adapterClass === null) { - $adapterClass = 'Zend_Db_Adapter_' . $this->getDriver(); - } - - $params = $this->_util->getParams(); - unset($params[$param]); - - Zend_Loader::loadClass($adapterClass); - Zend_Loader::loadClass($exceptionClass); - - try { - $db = new $adapterClass($params); - $db->getConnection(); // force a connection - $this->fail("Expected to catch $exceptionClass"); - } catch (Zend_Exception $e) { - $this->assertType($exceptionClass, $e, "Expected to catch $exceptionClass, got ".get_class($e)); - $this->assertContains("Configuration array must have a key for '$param'", $e->getMessage()); - } - } - - public function testAdapterConstructInvalidParamDbnameException() - { - $this->_testAdapterConstructInvalidParam('dbname'); - } - - public function testAdapterConstructInvalidParamUsernameException() - { - $this->_testAdapterConstructInvalidParam('username'); - } - - public function testAdapterConstructInvalidParamPasswordException() - { - $this->_testAdapterConstructInvalidParam('password'); - } - - /** - * Test Adapter's delete() method. - * Delete one row from test table, and verify it was deleted. - * Then try to delete a row that doesn't exist, and verify it had no effect. - */ - public function testAdapterDelete() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select()->from('zfproducts')->order('product_id ASC'); - $result = $this->_db->fetchAll($select); - - $this->assertEquals(3, count($result), 'Expected count of result to be 2'); - $this->assertEquals(1, $result[0]['product_id'], 'Expecting product_id of 0th row to be 1'); - - $rowsAffected = $this->_db->delete('zfproducts', "$product_id = 2"); - $this->assertEquals(1, $rowsAffected, 'Expected rows affected to return 1', 'Expecting rows affected to be 1'); - - $select = $this->_db->select()->from('zfproducts')->order('product_id ASC'); - $result = $this->_db->fetchAll($select); - - $this->assertEquals(2, count($result), 'Expected count of result to be 2'); - $this->assertEquals(1, $result[0]['product_id'], 'Expecting product_id of 0th row to be 1'); - - $rowsAffected = $this->_db->delete('zfproducts', "$product_id = 327"); - $this->assertEquals(0, $rowsAffected, 'Expected rows affected to return 0'); - } - - public function testAdapterDeleteWhereArray() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $ids = $this->_db->fetchCol("SELECT $product_id FROM $products ORDER BY $product_id"); - $this->assertEquals(array(1, 2, 3), $ids); - - $rowsAffected = $this->_db->delete( - 'zfproducts', - array("$product_id = 1", "$product_name = 'Windows'") - ); - $this->assertEquals(1, $rowsAffected); - - $ids = $this->_db->fetchCol("SELECT $product_id FROM $products ORDER BY $product_id"); - $this->assertEquals(array(2, 3), $ids); - } - - public function testAdapterDeleteWhereDbExpr() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $expr = new Zend_Db_Expr("$product_id = 1"); - - $ids = $this->_db->fetchCol("SELECT $product_id FROM $products ORDER BY $product_id"); - $this->assertEquals(array(1, 2, 3), $ids); - - $rowsAffected = $this->_db->delete( - 'zfproducts', - $expr - ); - $this->assertEquals(1, $rowsAffected); - - $ids = $this->_db->fetchCol("SELECT $product_id FROM $products ORDER BY $product_id"); - $this->assertEquals(array(2, 3), $ids); - } - - public function testAdapterDeleteEmptyWhere() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count); - - $rowsAffected = $this->_db->delete( - 'zfbugs' - // intentionally no where clause - ); - - $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(0, $count); - } - - public function testAdapterDescribeTableAttributeColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_name']['TABLE_NAME'], 'Expected table name to be zfproducts'); - $this->assertEquals('product_name', $desc['product_name']['COLUMN_NAME'], 'Expected column name to be product_name'); - $this->assertEquals(2, $desc['product_name']['COLUMN_POSITION'], 'Expected column position to be 2'); - $this->assertRegExp('/varchar/i', $desc['product_name']['DATA_TYPE'], 'Expected data type to be VARCHAR'); - $this->assertEquals('', $desc['product_name']['DEFAULT'], 'Expected default to be empty string'); - $this->assertTrue( $desc['product_name']['NULLABLE'], 'Expected product_name to be nullable'); - $this->assertNull( $desc['product_name']['SCALE'], 'Expected scale to be null'); - $this->assertNull( $desc['product_name']['PRECISION'], 'Expected precision to be null'); - $this->assertFalse( $desc['product_name']['PRIMARY'], 'Expected product_name not to be a primary key'); - $this->assertNull( $desc['product_name']['PRIMARY_POSITION'], 'Expected product_name to return null for PRIMARY_POSITION'); - $this->assertFalse( $desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY'); - } - - /** - * Test Adapter's describeTable() method. - * Retrieve the adapter's description of the test table and examine it. - */ - public function testAdapterDescribeTableHasColumns() - { - $desc = $this->_db->describeTable('zfproducts'); - - $cols = array( - 'product_id', - 'product_name' - ); - $this->assertEquals($cols, array_keys($desc)); - } - - public function testAdapterDescribeTableMetadataFields() - { - $desc = $this->_db->describeTable('zfproducts'); - - $keys = array( - 'SCHEMA_NAME', - 'TABLE_NAME', - 'COLUMN_NAME', - 'COLUMN_POSITION', - 'DATA_TYPE', - 'DEFAULT', - 'NULLABLE', - 'LENGTH', - 'SCALE', - 'PRECISION', - 'UNSIGNED', - 'PRIMARY', - 'PRIMARY_POSITION', - 'IDENTITY' - ); - $this->assertEquals($keys, array_keys($desc['product_name'])); - } - - /** - * Test that an auto-increment key reports itself. - * This is not supported in all RDBMS brands, so we test - * it separately from the full describe tests above. - */ - public function testAdapterDescribeTablePrimaryAuto() - { - $desc = $this->_db->describeTable('zfproducts'); - - $auto = $desc['product_id']['IDENTITY']; - if ($auto === null) { - $this->markTestIncomplete($this->getDriver() . ' needs to learn how to discover auto-increment keys'); - } - $this->assertTrue($desc['product_id']['IDENTITY']); - } - - public function testAdapterDescribeTablePrimaryKeyColumn() - { - $desc = $this->_db->describeTable('zfproducts'); - - $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME'], 'Expected table name to be zfproducts'); - $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME'], 'Expected column name to be product_id'); - $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION'], 'Expected column position to be 1'); - $this->assertEquals('', $desc['product_id']['DEFAULT'], 'Expected default to be empty string'); - $this->assertFalse( $desc['product_id']['NULLABLE'], 'Expected product_id not to be nullable'); - $this->assertNull( $desc['product_id']['SCALE'], 'Expected scale to be null'); - $this->assertNull( $desc['product_id']['PRECISION'], 'Expected precision to be null'); - $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key'); - $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']); - } - - /** - * Test the Adapter's fetchAll() method. - */ - public function testAdapterFetchAll() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1); - $this->assertEquals(2, count($result)); - $this->assertEquals('2', $result[0]['product_id']); - } - - /** - * Test that fetchAssoc() still fetched an associative array - * after the adapter's default fetch mode is set to something else. - */ - public function testAdapterFetchAllOverrideFetchMode() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $col_name = $this->_db->foldCase('product_id'); - - $this->_db->setFetchMode(Zend_Db::FETCH_OBJ); - - // Test associative array - $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1, Zend_Db::FETCH_ASSOC); - $this->assertEquals(2, count($result)); - $this->assertType('array', $result[0]); - $this->assertEquals(2, count($result[0])); // count columns - $this->assertEquals(2, $result[0][$col_name]); - - // Test numeric and associative array - $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1, Zend_Db::FETCH_BOTH); - $this->assertEquals(2, count($result)); - $this->assertType('array', $result[0]); - $this->assertEquals(4, count($result[0])); // count columns - $this->assertEquals(2, $result[0][$col_name]); - $this->assertEquals(2, $result[0][0]); - - // Ensure original fetch mode has been retained - $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id", 1); - $this->assertEquals(2, count($result)); - $this->assertType('object', $result[0]); - $this->assertEquals(2, $result[0]->$col_name); - } - - /** - * Test the Adapter's fetchAssoc() method. - */ - public function testAdapterFetchAssoc() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchAssoc("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id DESC", 1); - foreach ($result as $idKey => $row) { - $this->assertEquals($idKey, $row['product_id']); - } - } - - /** - * Test that fetchAssoc() still fetched an associative array - * after the adapter's default fetch mode is set to something else. - */ - public function testAdapterFetchAssocAfterSetFetchMode() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $this->_db->setFetchMode(Zend_Db::FETCH_OBJ); - $result = $this->_db->fetchAssoc("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id DESC", 1); - $this->assertType('array', $result); - $this->assertEquals(array('product_id', 'product_name'), array_keys(current($result))); - } - - /** - * Test the Adapter's fetchCol() method. - */ - public function testAdapterFetchCol() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchCol("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1); - $this->assertType('array', $result); - $this->assertEquals(2, count($result)); // count rows - $this->assertEquals(2, $result[0]); - $this->assertEquals(3, $result[1]); - } - - /** - * Test that fetchCol() still fetched an associative array - * after the adapter's default fetch mode is set to something else. - */ - public function testAdapterFetchColAfterSetFetchMode() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $this->_db->setFetchMode(Zend_Db::FETCH_OBJ); - $result = $this->_db->fetchCol("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1); - $this->assertType('array', $result); - $this->assertEquals(2, count($result)); // count rows - $this->assertEquals(2, $result[0]); - $this->assertEquals(3, $result[1]); - } - - /** - * Test the Adapter's fetchOne() method. - */ - public function testAdapterFetchOne() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $prod = 'Linux'; - $result = $this->_db->fetchOne("SELECT $product_name FROM $products WHERE $product_id > ? ORDER BY $product_id", 1); - $this->assertEquals($prod, $result); - } - - /** - * Test that fetchCol() still fetched an associative array - * after the adapter's default fetch mode is set to something else. - */ - public function testAdapterFetchOneAfterSetFetchMode() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $this->_db->setFetchMode(Zend_Db::FETCH_OBJ); - $prod = 'Linux'; - $result = $this->_db->fetchOne("SELECT $product_name FROM $products WHERE $product_id > ? ORDER BY $product_id", 1); - $this->assertType('string', $result); - $this->assertEquals($prod, $result); - } - - /** - * Test the Adapter's fetchPairs() method. - */ - public function testAdapterFetchPairs() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $prod = 'Linux'; - $result = $this->_db->fetchPairs("SELECT $product_id, $product_name FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1); - $this->assertEquals(2, count($result)); // count rows - $this->assertEquals($prod, $result[2]); - } - - /** - * Test the Adapter's fetchPairs() method. - */ - public function testAdapterFetchPairsAfterSetFetchMode() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $this->_db->setFetchMode(Zend_Db::FETCH_OBJ); - $prod = 'Linux'; - $result = $this->_db->fetchPairs("SELECT $product_id, $product_name FROM $products WHERE $product_id > ? ORDER BY $product_id ASC", 1); - $this->assertType('array', $result); - $this->assertEquals(2, count($result)); // count rows - $this->assertEquals($prod, $result[2]); - } - - /** - * Test the Adapter's fetchRow() method. - */ - public function testAdapterFetchRow() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id", 1); - $this->assertEquals(2, count($result)); // count columns - $this->assertEquals(2, $result['product_id']); - } - - /** - * Test that fetchAssoc() still fetched an associative array - * after the adapter's default fetch mode is set to something else. - */ - public function testAdapterFetchRowOverrideFetchMode() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $col_name = $this->_db->foldCase('product_id'); - - $this->_db->setFetchMode(Zend_Db::FETCH_OBJ); - - // Test associative array - $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id", 1, Zend_Db::FETCH_ASSOC); - $this->assertType('array', $result); - $this->assertEquals(2, count($result)); // count columns - $this->assertEquals(2, $result['product_id']); - - // Test numeric and associative array - $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id", 1, Zend_Db::FETCH_BOTH); - $this->assertType('array', $result); - $this->assertEquals(4, count($result)); // count columns - $this->assertEquals(2, $result['product_id']); - $this->assertEquals(2, $result[0]); - - // Ensure original fetch mode has been retained - $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > ? ORDER BY $product_id", 1); - $this->assertType('object', $result); - $this->assertEquals(2, $result->$col_name); - } - - /** - * Test the Adapter's insert() method. - * This requires providing an associative array of column=>value pairs. - */ - public function testAdapterInsert() - { - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - $rowsAffected = $this->_db->insert('zfbugs', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId(); - $this->assertType('string', $lastInsertId); - $this->assertEquals('5', (string) $lastInsertId, - 'Expected new id to be 5'); - } - - public function testAdapterInsertSequence() - { - $row = array ( - 'product_id' => $this->_db->nextSequenceId('zfproducts_seq'), - 'product_name' => 'Solaris', - ); - $rowsAffected = $this->_db->insert('zfproducts', $row); - $this->assertEquals(1, $rowsAffected); - $lastInsertId = $this->_db->lastInsertId('zfproducts'); - $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq'); - $this->assertType('string', $lastInsertId); - $this->assertType('string', $lastSequenceId); - $this->assertEquals('4', (string) $lastInsertId, 'Expected new id to be 4'); - } - - public function testAdapterInsertDbExpr() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - $expr = new Zend_Db_Expr('2+3'); - - $row = array ( - 'bug_id' => $expr, - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - $rowsAffected = $this->_db->insert('zfbugs', $row); - $this->assertEquals(1, $rowsAffected); - - $value = $this->_db->fetchOne("SELECT $bug_id FROM $bugs WHERE $bug_id = 5"); - $this->assertEquals(5, $value); - } - - /** - * Test the Adapter's limit() method. - * Fetch 1 row. Then fetch 1 row offset by 1 row. - */ - public function testAdapterLimit() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $product_id", 1); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result), - 'Expecting row count to be 1'); - $this->assertEquals(2, count($result[0]), - 'Expecting column count to be 2'); - $this->assertEquals(1, $result[0]['product_id'], - 'Expecting to get product_id 1'); - } - - public function testAdapterLimitOffset() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $product_id", 1, 1); - - $stmt = $this->_db->query($sql); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result), - 'Expecting row count to be 1'); - $this->assertEquals(2, count($result[0]), - 'Expecting column count to be 2'); - $this->assertEquals(2, $result[0]['product_id'], - 'Expecting to get product_id 2'); - } - - public function testAdapterLimitInvalidArgumentException() - { - try { - $sql = $this->_db->limit('SELECT * FROM zfproducts', 0); - $this->fail('Expected to catch Zend_Db_Adapter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expecting object of type Zend_Db_Adapter_Exception, got '.get_class($e)); - } - - try { - $sql = $this->_db->limit('SELECT * FROM zfproducts', 1, -1); - $this->fail('Expected to catch Zend_Db_Adapter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expecting object of type Zend_Db_Adapter_Exception, got '.get_class($e)); - } - } - - - /** - * Test the Adapter's listTables() method. - * Fetch the list of tables and verify that the test table exists in - * the list. - */ - public function testAdapterListTables() - { - $tables = $this->_db->listTables(); - $this->assertContains('zfproducts', $tables); - } - - /** - * Used by _testAdapterOptionCaseFoldingNatural() - * DB2 and Oracle return identifiers in uppercase naturally, - * so those test suites will override this method. - */ - protected function _testAdapterOptionCaseFoldingNaturalIdentifier() - { - return 'case_folded_identifier'; - } - - /** - * Used by _testAdapterOptionCaseFoldingNatural() - * SQLite needs to do metadata setup, - * because it uses the in-memory database, - * so that test suite will override this method. - */ - protected function _testAdapterOptionCaseFoldingSetup(Zend_Db_Adapter_Abstract $db) - { - $db->getConnection(); - } - - /** - * Used by: - * - testAdapterOptionCaseFoldingNatural() - * - testAdapterOptionCaseFoldingUpper() - * - testAdapterOptionCaseFoldingLower() - * - * @param int $case - * @return string - */ - public function _testAdapterOptionCaseFoldingCommon($case) - { - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::CASE_FOLDING => $case - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $this->_testAdapterOptionCaseFoldingSetup($db); - $products = $db->quoteIdentifier('zfproducts'); - $product_name = $db->quoteIdentifier('product_name'); - /* - * it is important not to delimit the pname identifier - * in the following query - */ - $sql = "SELECT $product_name AS case_folded_identifier FROM $products"; - $stmt = $db->query($sql); - $result = $stmt->fetchAll(Zend_Db::FETCH_ASSOC); - $keys = array_keys($result[0]); - return $keys[0]; - } - - /** - * Test the connection's CASE_FOLDING option. - * Case: Zend_Db::CASE_NATURAL - */ - public function testAdapterOptionCaseFoldingNatural() - { - $natural = $this->_testAdapterOptionCaseFoldingCommon(Zend_Db::CASE_NATURAL); - $expected = $this->_testAdapterOptionCaseFoldingNaturalIdentifier(); - $this->assertEquals($natural, $expected, 'Natural case does not match'); - } - - /** - * Test the connection's CASE_FOLDING option. - * Case: Zend_Db::CASE_UPPER - */ - public function testAdapterOptionCaseFoldingUpper() - { - $upper = $this->_testAdapterOptionCaseFoldingCommon(Zend_Db::CASE_UPPER); - $expected = strtoupper($this->_testAdapterOptionCaseFoldingNaturalIdentifier()); - $this->assertEquals($upper, $expected, 'Upper case does not match'); - } - - /** - * Test the connection's CASE_FOLDING option. - * Case: Zend_Db::CASE_LOWER - */ - public function testAdapterOptionCaseFoldingLower() - { - $lower = $this->_testAdapterOptionCaseFoldingCommon(Zend_Db::CASE_LOWER); - $expected = strtolower($this->_testAdapterOptionCaseFoldingNaturalIdentifier()); - $this->assertEquals($lower, $expected, 'Lower case does not match'); - } - - /** - * Test the connection's CASE_FOLDING option. - * Case: invalid value throws exception - */ - public function testAdapterOptionCaseFoldingInvalidException() - { - try { - $lower = $this->_testAdapterOptionCaseFoldingCommon(-999); - $this->fail('Expected exception not thrown'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expecting object of type Zend_Db_Adapter_Exception, got '.get_class($e)); - $this->assertEquals("Case must be one of the following constants: Zend_Db::CASE_NATURAL, Zend_Db::CASE_LOWER, Zend_Db::CASE_UPPER", $e->getMessage()); - } - } - - /** - * Test that we can query twice in a row. - * That is, a query doesn't leave the adapter in an unworking state. - * See bug ZF-1778. - */ - public function testAdapterQueryAfterUnclosedQuery() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id'); - - $stmt1 = $this->_db->query($select); - $result1 = $stmt1->fetchAll(Zend_Db::FETCH_NUM); - - $stmt1 = $this->_db->query($select); - $result2 = $stmt1->fetchAll(Zend_Db::FETCH_NUM); - - $this->assertEquals($result1, $result2); - } - - /** - * Ensures that query() throws an exception when given a bogus query - * - * @return void - */ - public function testAdapterQueryBogus() - { - try { - $this->_db->query('Bogus query'); - $this->fail('Expected exception not thrown'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - } - - /** - * Ensures that query() throws an exception when given a bogus table - * - * @return void - */ - public function testAdapterQueryBogusTable() - { - try { - $this->_db->query('SELECT * FROM BogusTable'); - $this->fail('Expected exception not thrown'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - } - - /** - * Ensures that query() provides expected behavior when returning no results - * - * @return void - */ - public function testAdapterQueryResultsNone() - { - $stmt = $this->_db->query('SELECT * FROM ' . $this->_db->quoteIdentifier('zfbugs') . ' WHERE ' - . $this->_db->quoteIdentifier('bug_id') . ' = -1'); - - $this->assertTrue(is_object($stmt), - 'Expected query() to return object; got ' . gettype($stmt)); - - $this->assertType('Zend_Db_Statement_Interface', $stmt, - 'Expected query() to return Zend_Db_Statement or PDOStatement; got ' . get_class($stmt)); - - $this->assertEquals(0, $count = count($stmt->fetchAll()), - "Expected fetchAll() to return zero rows; got $count"); - } - - /** - * Test that quote() accepts a string and returns - * a quoted string. - */ - public function testAdapterQuote() - { - $string = 'String without quotes'; - $value = $this->_db->quote($string); - $this->assertEquals("'String without quotes'", $value); - } - - /** - * Test that quote() takes an array and returns - * an imploded string of comma-separated, quoted elements. - */ - public function testAdapterQuoteArray() - { - $array = array("it's", 'all', 'right!'); - $value = $this->_db->quote($array); - $this->assertEquals("'it\\'s', 'all', 'right!'", $value); - } - - /** - * test that quote() accepts a Zend_Db_Expr - * and returns the string representation, - * with no quoting applied. - */ - public function testAdapterQuoteDbExpr() - { - $string = 'String with "`\' quotes'; - $expr = new Zend_Db_Expr($string); - $value = $this->_db->quote($expr); - $this->assertEquals($string, $value); - } - - /** - * test that quote() accepts a string containing - * digits and returns an unquoted string. - */ - public function testAdapterQuoteDigitString() - { - $string = '123'; - $value = $this->_db->quote($string); - $this->assertEquals("'123'", $value); - } - - /** - * test that quote() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteDoubleQuote() - { - $string = 'St John"s Wort'; - $value = $this->_db->quote($string); - $this->assertEquals("'St John\\\"s Wort'", $value); - } - - /** - * test that quote() accepts an integer and - * returns an unquoted integer. - */ - public function testAdapterQuoteInteger() - { - $int = 123; - $value = $this->_db->quote($int); - $this->assertEquals(123, $value); - } - - /** - * test that quote() accepts an array and returns - * an imploded string of unquoted elements - */ - public function testAdapterQuoteIntegerArray() - { - $array = array(1,'2',3); - $value = $this->_db->quote($array); - $this->assertEquals("1, '2', 3", $value); - } - - /** - * test that quote() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteSingleQuote() - { - $string = "St John's Wort"; - $value = $this->_db->quote($string); - $this->assertEquals("'St John\'s Wort'", $value); - } - - /** - * test that quoteColumnAs() accepts a string - * and an alias, and returns each as delimited - * identifiers, with 'AS' in between. - */ - public function testAdapterQuoteColumnAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteColumnAs($string, $alias); - $this->assertEquals('"foo" AS "bar"', $value); - } - - /** - * test that quoteColumnAs() accepts a string - * and an alias, but ignores the alias if it is - * the same as the base identifier in the string. - */ - public function testAdapterQuoteColumnAsSameString() - { - $string = 'foo.bar'; - $alias = 'bar'; - $value = $this->_db->quoteColumnAs($string, $alias); - $this->assertEquals('"foo"."bar"', $value); - } - - /** - * test that quoteIdentifier() accepts a string - * and returns a delimited identifier. - */ - public function testAdapterQuoteIdentifier() - { - $string = 'table_name'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('"table_name"', $value); - } - - /** - * test that quoteIdentifier() accepts an array - * and returns a qualified delimited identifier. - */ - public function testAdapterQuoteIdentifierArray() - { - $array = array('foo', 'bar'); - $value = $this->_db->quoteIdentifier($array); - $this->assertEquals('"foo"."bar"', $value); - } - - /** - * test that quoteIdentifier() accepts an array - * containing a Zend_Db_Expr, and returns strings - * as delimited identifiers, and Exprs as unquoted. - */ - public function testAdapterQuoteIdentifierArrayDbExpr() - { - $expr = new Zend_Db_Expr('*'); - $array = array('foo', $expr); - $value = $this->_db->quoteIdentifier($array); - $this->assertEquals('"foo".*', $value); - } - - /** - * test that quoteIdentifier() accepts a Zend_Db_Expr - * and returns the string representation, - * with no quoting applied. - */ - public function testAdapterQuoteIdentifierDbExpr() - { - $string = 'String with "`\' quotes'; - $expr = new Zend_Db_Expr($string); - $value = $this->_db->quoteIdentifier($expr); - $this->assertEquals($string, $value); - } - - /** - * test that quoteIdentifer() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIdentifierDoubleQuote() - { - $string = 'table_"_name'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('"table_""_name"', $value); - } - - /** - * test that quoteIdentifer() accepts an integer - * and returns a delimited identifier as with a string. - */ - public function testAdapterQuoteIdentifierInteger() - { - $int = 123; - $value = $this->_db->quoteIdentifier($int); - $this->assertEquals('"123"', $value); - } - - /** - * test that quoteIdentifier() accepts a string - * containing a dot (".") character, splits the - * string, quotes each segment individually as - * delimited identifers, and returns the imploded - * string. - */ - public function testAdapterQuoteIdentifierQualified() - { - $string = 'table.column'; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('"table"."column"', $value); - } - - /** - * test that quoteIdentifer() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIdentifierSingleQuote() - { - $string = "table_'_name"; - $value = $this->_db->quoteIdentifier($string); - $this->assertEquals('"table_\'_name"', $value); - } - - /** - * test that quoteTableAs() accepts a string and an alias, - * and returns each as delimited identifiers. - * Most RDBMS want an 'AS' in between. - */ - public function testAdapterQuoteTableAs() - { - $string = "foo"; - $alias = "bar"; - $value = $this->_db->quoteTableAs($string, $alias); - $this->assertEquals('"foo" AS "bar"', $value); - } - - /** - * test that quoteInto() accepts a Zend_Db_Expr - * and returns the string representation, - * with no quoting applied. - */ - public function testAdapterQuoteIntoDbExpr() - { - $string = 'id=?'; - $expr = new Zend_Db_Expr('CURDATE()'); - $value = $this->_db->quoteInto($string, $expr); - $this->assertEquals("id=CURDATE()", $value); - } - - /** - * test that quoteInto() escapes a double-quote - * character in a string. - */ - public function testAdapterQuoteIntoDoubleQuote() - { - $string = 'id=?'; - $param = 'St John"s Wort'; - $value = $this->_db->quoteInto($string, $param); - $this->assertEquals("id='St John\\\"s Wort'", $value); - } - - /** - * test that quoteInto() escapes a single-quote - * character in a string. - */ - public function testAdapterQuoteIntoSingleQuote() - { - $string = 'id = ?'; - $param = 'St John\'s Wort'; - $value = $this->_db->quoteInto($string, $param); - $this->assertEquals("id = 'St John\\'s Wort'", $value); - } - - protected $_numericDataTypes = array( - Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, - Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, - Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE - ); - - public function testAdapterQuoteIntoType() - { - $value = $this->_db->quoteInto('foo = ?', 1234, Zend_Db::INT_TYPE); - $this->assertType('string', $value); - $this->assertEquals('foo = 1234', $value, - 'Incorrect quoteInto() result for INT_TYPE'); - - $value = $this->_db->quoteInto('foo = ?', 1234, Zend_Db::BIGINT_TYPE); - $this->assertType('string', $value); - $this->assertEquals('foo = 1234', $value, - 'Incorrect quoteInto() result for BIGINT_TYPE'); - - $value = $this->_db->quoteInto('foo = ?', 12.34, Zend_Db::FLOAT_TYPE); - $this->assertType('string', $value); - $this->assertEquals('foo = 12.340000', $value, - 'Incorrect quoteInto() result for FLOAT_TYPE'); - - $value = $this->_db->quoteInto('foo = ?', 1234, 'CHAR'); - $this->assertType('string', $value); - $this->assertEquals("foo = 1234", $value, - 'Incorrect quoteInto() result for CHAR'); - - $value = $this->_db->quoteInto('foo = ?', '1234', 'CHAR'); - $this->assertType('string', $value); - $this->assertEquals("foo = '1234'", $value, - 'Incorrect quoteInto() result for CHAR'); - } - - public function testAdapterQuoteIntoCount() - { - $value = $this->_db->quoteInto('foo = ? and bar = ?', 1234, null, 1); - $this->assertType('string', $value); - $this->assertEquals('foo = 1234 and bar = ?', $value, - 'Incorrect quoteInto() result for count'); - } - - public function testAdapterQuoteTypeInt() - { - foreach ($this->_numericDataTypes as $typeName => $type) { - if ($type != 0) { - continue; - } - - // test int value - $value = $this->_db->quote(1234, $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234', $value, - "Incorrect quote() INT_TYPE result for int"); - - // test int string - $value = $this->_db->quote('1234', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234', $value, - "Incorrect quote() INT_TYPE result for int string"); - - // test int string with + sign - $value = $this->_db->quote('+1234', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234', $value, - "Incorrect quote() INT_TYPE result for int string with + sign"); - - // test int string with - sign - $value = $this->_db->quote('-1234', $typeName); - $this->assertType('string', $value); - $this->assertEquals('-1234', $value, - "Incorrect quote() INT_TYPE result for int string with - sign"); - - // test int string with non-digit text - $value = $this->_db->quote('1234abcd', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234', $value, - "Incorrect quote() INT_TYPE result for int string with non-digit text"); - - // test non-digit test; it should return 0 - $value = $this->_db->quote('abcd', $typeName); - $this->assertType('string', $value); - $this->assertEquals('0', $value, - "Incorrect quote() INT_TYPE result for non-digit string"); - - // test Zend_Db_Expr is passed through literally - $value = $this->_db->quote(new Zend_Db_Expr('1+2+3'), $typeName); - $this->assertType('string', $value); - $this->assertEquals("1+2+3", $value, - "Incorrect quote() INT_TYPE result for Zend_Db_Expr"); - } - } - - public function testAdapterQuoteTypeBigInt() - { - foreach ($this->_numericDataTypes as $typeName => $type) { - if ($type != 1) { - continue; - } - - // test int value - $value = $this->_db->quote(1234, $typeName); - $this->assertType('string', $value); - $this->assertEquals(1234, $value, - "Incorrect quote() BIGINT_TYPE result for int"); - - // test int string - $value = $this->_db->quote('1234', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234', $value, - "Incorrect quote() BIGINT_TYPE result for int string"); - - // test int string with + sign - $value = $this->_db->quote('+1234', $typeName); - $this->assertType('string', $value); - $this->assertEquals('+1234', $value, - "Incorrect quote() BIGINT_TYPE result for int string"); - - // test int string with - sign - $value = $this->_db->quote('-1234', $typeName); - $this->assertType('string', $value); - $this->assertEquals('-1234', $value, - "Incorrect quote() BIGINT_TYPE result for int string"); - - // test int string with positive exponent - $value = $this->_db->quote('1234e15', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234e15', $value, - "Incorrect quote() BIGINT_TYPE result for int string"); - - $value = $this->_db->quote('1234e+15', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234e+15', $value, - "Incorrect quote() BIGINT_TYPE result for int string"); - - // test int value with negative exponent - $value = $this->_db->quote('1234e-15', $typeName); - $this->assertType('string', $value); - $this->assertEquals('1234e-15', $value, - "Incorrect quote() BIGINT_TYPE result for int string"); - - // test bigint value - $value = $this->_db->quote('2200000000', $typeName); - $this->assertType('string', $value); - $this->assertEquals('2200000000', $value, - "Incorrect quote() BIGINT_TYPE result for big int string"); - - // test octal value with leading zeroes - $value = $this->_db->quote('020310253000', $typeName); - $this->assertType('string', $value); - $this->assertEquals('020310253000', $value, - "Incorrect quote() BIGINT_TYPE result for big octal int string with leading zeroes"); - - // test decimal value with leading zeroes - $value = $this->_db->quote('09091', $typeName); - $this->assertType('string', $value); - $this->assertEquals('09091', $value, - "Incorrect quote() BIGINT_TYPE result for decimal int string with leading zeroes"); - - // test hex value with ODBC-style notation - $value = $this->_db->quote('0x83215600', $typeName); - $this->assertType('string', $value); - $this->assertEquals('0x83215600', $value, - "Incorrect quote() BIGINT_TYPE result for big hex int string"); - - // test non-numeric value; it should be zero - $value = $this->_db->quote('abcd', $typeName); - $this->assertType('string', $value); - $this->assertEquals('0', $value, - "Incorrect quote() BIGINT_TYPE result for non-digt string"); - - // test Zend_Db_Expr is passed through literally - $value = $this->_db->quote(new Zend_Db_Expr('1+2+3'), $typeName); - $this->assertType('string', $value); - $this->assertEquals("1+2+3", $value, - "Incorrect quote() BIGINT_TYPE result for Zend_Db_Expr"); - } - } - - public function testAdapterQuoteTypeFloat() - { - foreach ($this->_numericDataTypes as $typeName => $type) { - if ($type != 2) { - continue; - } - - $value = $this->_db->quote(12.34, $typeName); - $this->assertType('string', $value); - $this->assertEquals('12.34', $value, - "Incorrect quote() FLOAT_TYPE result"); - - $value = $this->_db->quote('12.34', $typeName); - $this->assertType('string', $value); - $this->assertEquals('12.34', $value, - "Incorrect quote() FLOAT_TYPE result"); - - $value = $this->_db->quote('+12.34', $typeName); - $this->assertType('string', $value); - $this->assertEquals('12.34', $value, - "Incorrect quote() FLOAT_TYPE result"); - - $value = $this->_db->quote('-12.34', $typeName); - $this->assertType('string', $value); - $this->assertEquals('-12.34', $value, - "Incorrect quote() FLOAT_TYPE result"); - - $value = $this->_db->quote('12.34abcd', $typeName); - $this->assertType('string', $value); - $this->assertEquals('12.34', $value, - "Incorrect quote() FLOAT_TYPE result"); - - $value = $this->_db->quote('abcd', $typeName); - $this->assertType('string', $value); - $this->assertEquals('0', $value, - "Incorrect quote() FLOAT_TYPE result"); - - $value = $this->_db->quote(new Zend_Db_Expr('1+2+3'), $typeName); - $this->assertType('string', $value); - $this->assertEquals("1+2+3", $value, - "Incorrect quote() FLOAT_TYPE result"); - } - } - - public function testAdapterQuoteTypeNonNumeric() - { - $value = $this->_db->quote(1234, 'CHAR'); - $this->assertType('integer', $value); - $this->assertEquals(1234, $value, - "Incorrect quote() CHAR type result"); - - $value = $this->_db->quote('1234', 'CHAR'); - $this->assertType('string', $value); - $this->assertEquals("'1234'", $value, - "Incorrect quote() CHAR type result"); - - $value = $this->_db->quote('1234abcd', 'CHAR'); - $this->assertType('string', $value); - $this->assertEquals("'1234abcd'", $value, - "Incorrect quote() CHAR type result"); - - $value = $this->_db->quote('1234abcd56', 'CHAR'); - $this->assertType('string', $value); - $this->assertEquals("'1234abcd56'", $value, - "Incorrect quote() CHAR type result"); - - // test Zend_Db_Expr is passed through literally - $value = $this->_db->quote(new Zend_Db_Expr('1+2+3'), 'CHAR'); - $this->assertType('string', $value); - $this->assertEquals("1+2+3", $value, - "Incorrect quote() CHAR type result for Zend_Db_Expr"); - } - - /** - * Ensures that the character sequence ":0'" is handled properly - * - * @link http://framework.zend.com/issues/browse/ZF-2059 - * @return void - */ - public function testZF2059() - { - $value = ':0\''; - $valueQuoted = $this->_db->quote($value); - $sql = 'SELECT bug_id FROM zfbugs WHERE bug_status != ' . $valueQuoted; - $results = $this->_db->fetchAll($sql); - $this->assertEquals(4, count($results)); - } - - public function testAdapterSetFetchMode() - { - $modes = array( - Zend_Db::FETCH_ASSOC, - Zend_Db::FETCH_BOTH, - Zend_Db::FETCH_NUM, - Zend_Db::FETCH_OBJ - ); - foreach ($modes as $mode) { - $this->_db->setFetchMode($mode); - $this->assertEquals($mode, $this->_db->getFetchMode()); - } - } - - public function testAdapterSetFetchModeInvalidException() - { - try { - $this->_db->setFetchMode(-999); - $this->fail('Expected exception not thrown'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expecting object of type Zend_Db_Adapter_Exception, got '.get_class($e)); - $this->assertEquals("Invalid fetch mode '-999' specified", $e->getMessage()); - } - } - - public function testAdapterTransactionAutoCommit() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // use our default connection as the Connection1 - $dbConnection1 = $this->_db; - - // create a second connection to the same database - $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams()); - $dbConnection2->getConnection(); - - // notice the number of rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count); - - // delete a row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see the results in connection 2 immediately - // after the DELETE executes, because it's autocommit - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count); - } - - public function testAdapterTransactionCommit() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // use our default connection as the Connection1 - $dbConnection1 = $this->_db; - - // create a second connection to the same database - $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams()); - $dbConnection2->getConnection(); - - // notice the number of rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)'); - - // start an explicit transaction in connection 1 - $dbConnection1->beginTransaction(); - - // delete a row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should still see all rows in connection 2 - // because the DELETE has not been committed yet - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table (step 2); perhaps Adapter is still in autocommit mode?'); - - // commit the DELETE - $dbConnection1->commit(); - - // now we should see one fewer rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 3)'); - - // delete another row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 2" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see results immediately, because - // the db connection returns to auto-commit mode - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(2, $count); - } - - public function testAdapterTransactionRollback() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - // use our default connection as the Connection1 - $dbConnection1 = $this->_db; - - // create a second connection to the same database - $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams()); - $dbConnection2->getConnection(); - - // notice the number of rows in connection 2 - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)'); - - // start an explicit transaction in connection 1 - $dbConnection1->beginTransaction(); - - // delete a row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // we should still see all rows in connection 2 - // because the DELETE has not been committed yet - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table (step 2); perhaps Adapter is still in autocommit mode?'); - - // rollback the DELETE - $dbConnection1->rollback(); - - // now we should see the same number of rows - // because the DELETE was rolled back - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table after DELETE is rolled back (step 3)'); - - // delete another row in connection 1 - $rowsAffected = $dbConnection1->delete( - 'zfbugs', - "$bug_id = 2" - ); - $this->assertEquals(1, $rowsAffected); - - // we should see results immediately, because - // the db connection returns to auto-commit mode - $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs"); - $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 4)'); - } - - /** - * Test the Adapter's update() method. - * Update a single row and verify that the change was made. - * Attempt to update a row that does not exist, and verify - * that no change was made. - */ - public function testAdapterUpdate() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - // Test that we can change the values in - // an existing row. - $rowsAffected = $this->_db->update( - 'zfproducts', - array('product_name' => 'Vista'), - "$product_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - // Query the row to see if we have the new values. - $select = $this->_db->select(); - $select->from('zfproducts'); - $select->where("$product_id = 1"); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - - $this->assertEquals(1, $result[0]['product_id']); - $this->assertEquals('Vista', $result[0]['product_name']); - - // Test that update affects no rows if the WHERE - // clause matches none. - $rowsAffected = $this->_db->update( - 'zfproducts', - array('product_name' => 'Vista'), - "$product_id = 327" - ); - $this->assertEquals(0, $rowsAffected); - } - - public function testAdapterUpdateSetDbExpr() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $bug_status = $this->_db->quoteIdentifier('bug_status'); - - $expr = new Zend_Db_Expr("UPPER('setExpr')"); - $rowsAffected = $this->_db->update( - 'zfbugs', - array('bug_status' => $expr), - "$bug_id = 1" - ); - $this->assertEquals(1, $rowsAffected); - - $value = $this->_db->fetchOne("SELECT $bug_status FROM $bugs WHERE $bug_id = 1"); - $this->assertEquals('SETEXPR', $value); - } - - public function testAdapterUpdateWhereArray() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $bug_status = $this->_db->quoteIdentifier('bug_status'); - - $rowsAffected = $this->_db->update( - 'zfbugs', - array('bug_status' => 'ARRAY'), - array("$bug_id = 1", "$bug_status = 'NEW'") - ); - $this->assertEquals(1, $rowsAffected); - - $value = $this->_db->fetchOne("SELECT $bug_status FROM $bugs WHERE $bug_id = 1"); - $this->assertEquals('ARRAY', $value); - } - - public function testAdapterUpdateWhereDbExpr() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $bug_status = $this->_db->quoteIdentifier('bug_status'); - - $whereExpr = new Zend_Db_Expr("$bug_id = 1"); - - $rowsAffected = $this->_db->update( - 'zfbugs', - array('bug_status' => 'DBEXPR'), - $whereExpr - ); - $this->assertEquals(1, $rowsAffected); - - $value = $this->_db->fetchOne("SELECT $bug_status FROM $bugs WHERE $bug_id = 1"); - $this->assertEquals('DBEXPR', $value); - } - - public function testAdapterUpdateEmptyWhere() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_status = $this->_db->quoteIdentifier('bug_status'); - - $rowsAffected = $this->_db->update( - 'zfbugs', - array('bug_status' => 'EMPTY') - // intentionally no where clause - ); - $this->assertEquals(4, $rowsAffected); - - $value = $this->_db->fetchCol("SELECT $bug_status FROM $bugs"); - $this->assertEquals(array_fill(0, 4, 'EMPTY'), $value); - } - - protected function _testAdapterAlternateStatement($stmtClass) - { - $ip = get_include_path(); - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $newIp = $dir . PATH_SEPARATOR . $ip; - set_include_path($newIp); - - $params = $this->_util->getParams(); - - $params['options'] = array( - Zend_Db::AUTO_QUOTE_IDENTIFIERS => false - ); - $db = Zend_Db::factory($this->getDriver(), $params); - $db->getConnection(); - $db->setStatementClass($stmtClass); - - $currentStmtClass = $db->getStatementClass(); - $this->assertEquals($stmtClass, $currentStmtClass); - - $bugs = $this->_db->quoteIdentifier('zfbugs'); - - $stmt = $db->prepare("SELECT COUNT(*) FROM $bugs"); - - $this->assertType($stmtClass, $stmt, - 'Expecting object of type ' . $stmtClass . ', got ' . get_class($stmt)); - } - - public function testAdapterSetCustomProfiler() - { - $profilerOptions = array( - 'enabled' => true, - 'class' => 'stdClass', - 'instance' => new stdClass() - ); - - try { - $this->_db->setProfiler($profilerOptions); - $this->fail('Expected to catch Zend_Db_Profiler_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Profiler_Exception', $e); - $this->assertEquals('Class stdClass does not extend Zend_Db_Profiler', $e->getMessage()); - } - } - -} \ No newline at end of file diff --git a/tests/Zend/Db/Adapter/_files/Test/Db2Statement.php b/tests/Zend/Db/Adapter/_files/Test/Db2Statement.php deleted file mode 100644 index 00abec5fb00b86531daf9b20baeb8a49e1e7ea7a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/_files/Test/Db2Statement.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db2Statement.php 9577 2008-05-31 01:50:27Z peptolab $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Statement_Db2 - */ -require_once 'Zend/Db/Statement/Db2.php'; - -/** - * Test Class for extending base Zend_Db_Statements - * - * @category Zend - * @package Zend_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Test_Db2Statement extends Zend_Db_Statement_Db2 -{ -} diff --git a/tests/Zend/Db/Adapter/_files/Test/MysqliStatement.php b/tests/Zend/Db/Adapter/_files/Test/MysqliStatement.php deleted file mode 100644 index 8860ff10f87c28dab738451834eec6045a834c9e..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/_files/Test/MysqliStatement.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqliStatement.php 9577 2008-05-31 01:50:27Z peptolab $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Statement_Mysqli - */ -require_once 'Zend/Db/Statement/Mysqli.php'; - -/** - * Test Class for extending base Zend_Db_Statements - * - * @category Zend - * @package Zend_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Test_MysqliStatement extends Zend_Db_Statement_Mysqli -{ -} diff --git a/tests/Zend/Db/Adapter/_files/Test/OracleStatement.php b/tests/Zend/Db/Adapter/_files/Test/OracleStatement.php deleted file mode 100644 index 8c10d485374af6bf56f88b46526363f2d8c775af..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/_files/Test/OracleStatement.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OracleStatement.php 9577 2008-05-31 01:50:27Z peptolab $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Statement_Oracle - */ -require_once 'Zend/Db/Statement/Oracle.php'; - -/** - * Test Class for extending base Zend_Db_Statements - * - * @category Zend - * @package Zend_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Test_OracleStatement extends Zend_Db_Statement_Oracle -{ -} diff --git a/tests/Zend/Db/Adapter/_files/Test/PdoStatement.php b/tests/Zend/Db/Adapter/_files/Test/PdoStatement.php deleted file mode 100644 index 2bca3526b434bd82b3cd91e2ded901a496179295..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/_files/Test/PdoStatement.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PdoStatement.php 9577 2008-05-31 01:50:27Z peptolab $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Statement_Pdo - */ -require_once 'Zend/Db/Statement/Pdo.php'; - -/** - * Test Class for extending base Zend_Db_Statements - * - * @category Zend - * @package Zend_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Test_PdoStatement extends Zend_Db_Statement_Pdo -{ -} diff --git a/tests/Zend/Db/Adapter/_files/Testnamespace/Static.php b/tests/Zend/Db/Adapter/_files/Testnamespace/Static.php deleted file mode 100644 index e5473168e3f02ac43c9c3c74c3cf0f6b9ace242b..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Adapter/_files/Testnamespace/Static.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Static.php 5065 2007-05-31 05:04:21Z bkarwin $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Adapter_Static - */ -require_once 'Zend/Db/Adapter/Static.php'; - -/** - * Class for connecting to SQL databases and performing common operations. - * - * @category Zend - * @package Zend_Db - * @subpackage Adapter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Testnamespace_Static extends Zend_Db_Adapter_Static -{ -} diff --git a/tests/Zend/Db/AllTests.php b/tests/Zend/Db/AllTests.php deleted file mode 100644 index ab5b0bb44057d9bc59b3b2aae42bda82e45130d3..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/AllTests.php +++ /dev/null @@ -1,201 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 7538 2008-01-21 12:25:15Z kgbfernando $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Db_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * PHPUnit_Framework_TestSuite - */ -// require_once 'PHPUnit/Framework/TestSuite.php'; - -/** - * PHPUnit_TextUI_TestRunner - */ -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - -/** - * @see Zend_Db_SkipTests - */ -require_once 'Zend/Db/SkipTests.php'; - -/** - * @see Zend_Db_Profiler_AllTests - */ -require_once 'Zend/Db/Profiler/AllTests.php'; - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_AllTests -{ - - protected static $_skipTestSuite = null; - - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Db'); - - /** - * Static tests should always be enabled, - * but if they're not, don't throw an error. - */ - if (!defined('TESTS_ZEND_DB_ADAPTER_STATIC_ENABLED')) { - define('TESTS_ZEND_DB_ADAPTER_STATIC_ENABLED', true); - } - - self::_addDbTestSuites($suite, 'Static'); - self::_addDbTestSuites($suite, 'Db2'); - self::_addDbTestSuites($suite, 'Mysqli'); - self::_addDbTestSuites($suite, 'Oracle'); - self::_addDbTestSuites($suite, 'Firebird'); - - /** - * @todo self::_addDbTestSuites($suite, 'Odbc'); - */ - self::_addDbTestSuites($suite, 'Pdo_Ibm'); - self::_addDbTestSuites($suite, 'Pdo_Mssql'); - self::_addDbTestSuites($suite, 'Pdo_Mysql'); - self::_addDbTestSuites($suite, 'Pdo_Oci'); - self::_addDbTestSuites($suite, 'Pdo_Pgsql'); - self::_addDbTestSuites($suite, 'Pdo_Sqlite'); - self::_addDbTestSuites($suite, 'Pdo_Firebird'); - - if (self::$_skipTestSuite !== null) { - $suite->addTest(self::$_skipTestSuite); - } - - $suite->addTest(Zend_Db_Profiler_AllTests::suite()); - - return $suite; - } - - protected static function _addDbTestSuites($suite, $driver) - { - $DRIVER = strtoupper($driver); - $enabledConst = "TESTS_ZEND_DB_ADAPTER_{$DRIVER}_ENABLED"; - if (!defined($enabledConst) || constant($enabledConst) != true) { - self::_skipTestSuite($driver, "this Adapter is not enabled in TestConfiguration.php"); - return; - } - - $ext = array( - 'Oracle' => 'oci8', - 'Db2' => 'ibm_db2', - 'Mysqli' => 'mysqli', - 'Firebird' => 'interbase', - /** - * @todo 'Odbc' - */ - ); - - if (isset($ext[$driver]) && !extension_loaded($ext[$driver])) { - self::_skipTestSuite($driver, "extension '{$ext[$driver]}' is not loaded"); - return; - } - - if (preg_match('/^pdo_(.*)/i', $driver, $matches)) { - // check for PDO extension - if (!extension_loaded('pdo')) { - self::_skipTestSuite($driver, "extension 'PDO' is not loaded"); - return; - } - - // check the PDO driver is available - $pdo_driver = strtolower($matches[1]); - if (!in_array($pdo_driver, PDO::getAvailableDrivers())) { - self::_skipTestSuite($driver, "PDO driver '{$pdo_driver}' is not available"); - return; - } - } - - try { - - Zend_Loader::loadClass("Zend_Db_Adapter_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Profiler_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Statement_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Select_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Table_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Table_Select_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Table_Rowset_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Table_Row_{$driver}Test"); - Zend_Loader::loadClass("Zend_Db_Table_Relationships_{$driver}Test"); - - // if we get this far, there have been no exceptions loading classes - // so we can add them as test suites - - $suite->addTestSuite("Zend_Db_Adapter_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Profiler_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Statement_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Select_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Table_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Table_Select_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Table_Rowset_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Table_Row_{$driver}Test"); - $suite->addTestSuite("Zend_Db_Table_Relationships_{$driver}Test"); - - } catch (Zend_Exception $e) { - self::_skipTestSuite($driver, "cannot load test classes: " . $e->getMessage()); - } - } - - protected static function _skipTestSuite($driver, $message = '') - { - $skipTestClass = "Zend_Db_Skip_{$driver}Test"; - $skipTest = new $skipTestClass(); - $skipTest->message = $message; - - if (self::$_skipTestSuite === null) { - self::$_skipTestSuite = new PHPUnit_Framework_TestSuite('Zend_Db skipped test suites'); - } - - self::$_skipTestSuite->addTest($skipTest); - } - -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Db_AllTests::main') { - Zend_Db_AllTests::main(); -} diff --git a/tests/Zend/Db/Profiler/AllTests.php b/tests/Zend/Db/Profiler/AllTests.php deleted file mode 100644 index a8642581dd77f87b0d3f6cfb22e7a3d605fde802..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/AllTests.php +++ /dev/null @@ -1,61 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Db_Profiler_AllTests::main'); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Db/Profiler/FirebugTest.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Db_Profiler_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Db_Profiler'); - - $suite->addTestSuite('Zend_Db_Profiler_FirebugTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Db_Profiler_AllTests::main') { - Zend_Db_Profiler_AllTests::main(); -} diff --git a/tests/Zend/Db/Profiler/Db2Test.php b/tests/Zend/Db/Profiler/Db2Test.php deleted file mode 100644 index c711e9ce7cfa0e2a2b5512abae8d06259e63bbf8..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Db2Test.php +++ /dev/null @@ -1,53 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Db2Test extends Zend_Db_Profiler_TestCommon -{ - - public function testProfilerPreparedStatementWithBoundParams() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params'); - } - - public function getDriver() - { - return 'Db2'; - } -} diff --git a/tests/Zend/Db/Profiler/FirebugTest.php b/tests/Zend/Db/Profiler/FirebugTest.php deleted file mode 100644 index da17b5a4764a9720f03ffbbff389316422450ef8..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/FirebugTest.php +++ /dev/null @@ -1,201 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 3980 2007-03-15 21:38:38Z mike $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Db */ -require_once 'Zend/Db.php'; - -/** Zend_Db_Profiler_Firebug */ -require_once 'Zend/Db/Profiler/Firebug.php'; - -/** Zend_Wildfire_Plugin_FirePhp */ -require_once 'Zend/Wildfire/Plugin/FirePhp.php'; - -/** Zend_Wildfire_Channel_HttpHeaders */ -require_once 'Zend/Wildfire/Channel/HttpHeaders.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** Zend_Controller_Response_Http */ -require_once 'Zend/Controller/Response/Http.php'; - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 3980 2007-03-15 21:38:38Z mike $ - */ -class Zend_Db_Profiler_FirebugTest extends PHPUnit_Framework_TestCase -{ - - protected $_controller = null; - protected $_request = null; - protected $_response = null; - protected $_profiler = null; - protected $_db = null; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Db_Profiler_FirebugTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - if (!extension_loaded('pdo_sqlite')) { - $this->markTestSkipped('Requires PDO_Sqlite extension'); - } - - date_default_timezone_set('America/Los_Angeles'); - - $this->_request = new Zend_Db_Profiler_FirebugTest_Request(); - $this->_response = new Zend_Db_Profiler_FirebugTest_Response(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $channel->setRequest($this->_request); - $channel->setResponse($this->_response); - - $this->_profiler = new Zend_Db_Profiler_Firebug(); - $this->_db = Zend_Db::factory('PDO_SQLITE', - array('dbname' => ':memory:', - 'profiler' => $this->_profiler)); - $this->_db->getConnection()->exec('CREATE TABLE foo ( - id INTEGNER NOT NULL, - col1 VARCHAR(10) NOT NULL - )'); - } - - public function tearDown() - { - $this->_db->getConnection()->exec('DROP TABLE foo'); - - Zend_Wildfire_Channel_HttpHeaders::destroyInstance(); - Zend_Wildfire_Plugin_FirePhp::destroyInstance(); - } - - public function testEnable() - { - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $this->_db->insert('foo', array('id'=>1,'col1'=>'original')); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $this->assertFalse($protocol->getMessages()); - - $this->_profiler->setEnabled(true); - - $this->_db->insert('foo', array('id'=>1,'col1'=>'original')); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $messages = $protocol->getMessages(); - - $this->assertEquals(substr($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] - [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0],0,55), - '[{"Type":"TABLE","Label":"Zend_Db_Profiler_Firebug (1 @'); - } - - public function testDisable() - { - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $this->_profiler->setEnabled(true); - - $this->_db->insert('foo', array('id'=>1,'col1'=>'original')); - - $this->_profiler->setEnabled(false); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $this->assertFalse($protocol->getMessages()); - } - - public function testCustomLabel() - { - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $this->_profiler = new Zend_Db_Profiler_Firebug('Label 1'); - $this->_profiler->setEnabled(true); - $this->_db->setProfiler($this->_profiler); - $this->_db->insert('foo', array('id'=>1,'col1'=>'original')); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $messages = $protocol->getMessages(); - - $this->assertEquals(substr($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] - [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0],0,38), - '[{"Type":"TABLE","Label":"Label 1 (1 @'); - } - - public function testNoQueries() - { - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $this->_profiler->setEnabled(true); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $messages = $protocol->getMessages(); - - $this->assertFalse($messages); - } - -} - - -class Zend_Db_Profiler_FirebugTest_Request extends Zend_Controller_Request_Http -{ - public function getHeader($header) - { - if ($header == 'User-Agent') { - return 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 FirePHP/0.1.0'; - } - } -} - -class Zend_Db_Profiler_FirebugTest_Response extends Zend_Controller_Response_Http -{ - public function canSendHeaders($throw = false) - { - return true; - } -} diff --git a/tests/Zend/Db/Profiler/MysqliTest.php b/tests/Zend/Db/Profiler/MysqliTest.php deleted file mode 100644 index 242844dcda9425995f6917d387bdbfcd0e84d8e1..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/MysqliTest.php +++ /dev/null @@ -1,48 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_MysqliTest extends Zend_Db_Profiler_TestCommon -{ - - public function getDriver() - { - return 'Mysqli'; - } -} diff --git a/tests/Zend/Db/Profiler/OracleTest.php b/tests/Zend/Db/Profiler/OracleTest.php deleted file mode 100644 index 9e3c8f36dc496e6bb80c44d6bd9476bb60d9e033..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/OracleTest.php +++ /dev/null @@ -1,155 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_OracleTest extends Zend_Db_Profiler_TestCommon -{ - - public function testProfilerPreparedStatementWithParams() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - // prepare a query - $select = $this->_db->select() - ->from('zfbugs') - ->where("$bug_id = :bug_id"); - $stmt = $this->_db->prepare($select->__toString()); - - // execute query a first time - $stmt->execute(array(':bug_id' => 2)); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(2, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true); - $this->assertType('array', $profiles, 'Expected array, got '.gettype($profiles)); - $this->assertEquals(1, count($profiles), 'Expected to find 1 profile'); - $qp = $profiles[0]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = :bug_id", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(':bug_id' => 2), $params); - - // execute query a second time - $stmt->execute(array(':bug_id' => 3)); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(3, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true); - $this->assertType('array', $profiles, 'Expected array, got '.gettype($profiles)); - $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles'); - $qp = $profiles[1]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = :bug_id", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(':bug_id' => 3), $params); - } - - public function testProfilerPreparedStatementWithBoundParams() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - // prepare a query - $select = $this->_db->select() - ->from('zfbugs') - ->where("$bug_id = :bug_id"); - $stmt = $this->_db->prepare($select->__toString()); - - // execute query a first time - $id = 1; - $this->assertTrue($stmt->bindParam(':bug_id', $id)); - $id = 2; - $stmt->execute(); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(2, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true); - $this->assertType('array', $profiles); - $this->assertEquals(1, count($profiles), 'Expected to find 1 profile'); - $qp = $profiles[0]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = :bug_id", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(':bug_id' => 2), $params); - - // execute query a first time - $id = 3; - $stmt->execute(); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(3, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true); - $this->assertType('array', $profiles); - $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles'); - $qp = $profiles[1]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = :bug_id", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(':bug_id' => 3), $params); - } - - - public function getDriver() - { - return 'Oracle'; - } -} diff --git a/tests/Zend/Db/Profiler/Pdo/IbmTest.php b/tests/Zend/Db/Profiler/Pdo/IbmTest.php deleted file mode 100644 index f748d8ee538bb947113705bb4818e35dbb86543a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Pdo/IbmTest.php +++ /dev/null @@ -1,47 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Pdo_IbmTest extends Zend_Db_Profiler_TestCommon -{ - public function getDriver() - { - return 'Pdo_Ibm'; - } - -} diff --git a/tests/Zend/Db/Profiler/Pdo/MssqlTest.php b/tests/Zend/Db/Profiler/Pdo/MssqlTest.php deleted file mode 100644 index 27c8dcaf2fbaedd718ab3c0fdb4b9db43ccf2537..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Pdo/MssqlTest.php +++ /dev/null @@ -1,46 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Pdo_MssqlTest extends Zend_Db_Profiler_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mssql'; - } -} diff --git a/tests/Zend/Db/Profiler/Pdo/MysqlTest.php b/tests/Zend/Db/Profiler/Pdo/MysqlTest.php deleted file mode 100644 index f6fd906113bdd1d449fc2eff98794aa16c95d82f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Pdo/MysqlTest.php +++ /dev/null @@ -1,48 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Pdo_MysqlTest extends Zend_Db_Profiler_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mysql'; - } -} diff --git a/tests/Zend/Db/Profiler/Pdo/OciTest.php b/tests/Zend/Db/Profiler/Pdo/OciTest.php deleted file mode 100644 index 3ce43f3e3462fdd797b47684ad66ebb718073ccd..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Pdo/OciTest.php +++ /dev/null @@ -1,48 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Pdo_OciTest extends Zend_Db_Profiler_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Oci'; - } -} diff --git a/tests/Zend/Db/Profiler/Pdo/PgsqlTest.php b/tests/Zend/Db/Profiler/Pdo/PgsqlTest.php deleted file mode 100644 index f7fc3a952656f4b8242e2a122d2171d1b8f40756..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Pdo/PgsqlTest.php +++ /dev/null @@ -1,48 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Pdo_PgsqlTest extends Zend_Db_Profiler_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Pgsql'; - } -} diff --git a/tests/Zend/Db/Profiler/Pdo/SqliteTest.php b/tests/Zend/Db/Profiler/Pdo/SqliteTest.php deleted file mode 100644 index f2388b76acd8558b87fc0c0eabc34d442d523786..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/Pdo/SqliteTest.php +++ /dev/null @@ -1,53 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler_TestCommon - */ -require_once 'Zend/Db/Profiler/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_Pdo_SqliteTest extends Zend_Db_Profiler_TestCommon -{ - - public function testProfilerPreparedStatementWithBoundParams() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params'); - } - - public function getDriver() - { - return 'Pdo_Sqlite'; - } -} diff --git a/tests/Zend/Db/Profiler/ProfilerCustom.php b/tests/Zend/Db/Profiler/ProfilerCustom.php deleted file mode 100644 index 7ae0c3ff80ac93e534015ee42d763ed3df773a16..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/ProfilerCustom.php +++ /dev/null @@ -1,41 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 6170 2007-08-21 21:59:18Z bkarwin $ - */ - - -/** - * @see Zend_Db_Profiler - */ -require_once 'Zend/Db/Profiler.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_ProfilerCustom extends Zend_Db_Profiler -{ -} diff --git a/tests/Zend/Db/Profiler/StaticTest.php b/tests/Zend/Db/Profiler/StaticTest.php deleted file mode 100644 index 14c0aac8a93da7cfb43b5b4d2e89b24aeef4015a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/StaticTest.php +++ /dev/null @@ -1,812 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 6556 2007-10-01 20:37:03Z darby $ - */ - - -/** - * @see Zend_Db_TestSetup - */ -require_once 'Zend/Db/TestSetup.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Profiler_StaticTest extends Zend_Db_TestSetup -{ - - /** - * @return void - */ - public function testProfilerFactoryFalse() - { - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => false - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got '.get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got '.get_class($prof)); - $this->assertFalse($prof->getEnabled()); - } - - /** - * @return void - */ - public function testProfilerFactoryTrue() - { - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => true - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got '.get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got '.get_class($prof)); - $this->assertTrue($prof->getEnabled()); - } - - /** - * Ensures that passing the 'profiler' option as a string continues to work as prior to SVN r6172. - * - * E.g., 'profiler' => 'true', 'profiler' => '1' results in default profiler enabled. - * - * @return void - */ - public function testProfilerFactoryString() - { - $profilerStrings = array( - 'true', - '1', - 'Zend_Db_Profiler_ProfilerCustom' - ); - foreach ($profilerStrings as $profilerString) { - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => $profilerString - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got ' . get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got ' . get_class($prof)); - $this->assertTrue($prof->getEnabled()); - } - } - - /** - * @return void - */ - public function testProfilerFactoryInstance() - { - require_once 'Zend/Db/Profiler/ProfilerCustom.php'; - $profiler = new Zend_Db_Profiler_ProfilerCustom(); - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => $profiler - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got ' . get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got ' . get_class($prof)); - $this->assertType('Zend_Db_Profiler_ProfilerCustom', $prof, - 'Expected object of type Zend_Db_Profiler_ProfilerCustom, got ' . get_class($prof)); - $this->assertFalse($prof->getEnabled()); - } - - /** - * @return void - */ - public function testProfilerFactoryArrayEnabled() - { - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => array( - 'enabled' => true - ) - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got '.get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got '.get_class($prof)); - $this->assertTrue($prof->getEnabled()); - } - - /** - * @return void - */ - public function testProfilerFactoryArrayClass() - { - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => array( - 'class' => 'Zend_Db_Profiler_ProfilerCustom' - ) - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got '.get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got '.get_class($prof)); - $this->assertType('Zend_Db_Profiler_ProfilerCustom', $prof, - 'Expected object of type Zend_Db_Profiler_ProfilerCustom, got '.get_class($prof)); - $this->assertFalse($prof->getEnabled()); - } - - /** - * @return void - */ - public function testProfilerFactoryArrayInstance() - { - require_once 'Zend/Db/Profiler/ProfilerCustom.php'; - $profiler = new Zend_Db_Profiler_ProfilerCustom(); - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => array( - 'instance' => $profiler - ) - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got '.get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got '.get_class($prof)); - $this->assertType('Zend_Db_Profiler_ProfilerCustom', $prof, - 'Expected object of type Zend_Db_Profiler_ProfilerCustom, got '.get_class($prof)); - $this->assertFalse($prof->getEnabled()); - } - - /** - * @return void - */ - public function testProfilerFactoryConfig() - { - require_once 'Zend/Config.php'; - $config = new Zend_Config(array( - 'class' => 'Zend_Db_Profiler_ProfilerCustom' - )); - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => $config - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got '.get_class($db)); - $prof = $db->getProfiler(); - $this->assertType('Zend_Db_Profiler', $prof, - 'Expected object of type Zend_Db_Profiler, got '.get_class($prof)); - $this->assertType('Zend_Db_Profiler_ProfilerCustom', $prof, - 'Expected object of type Zend_Db_Profiler_ProfilerCustom, got '.get_class($prof)); - $this->assertFalse($prof->getEnabled()); - } - - /** - * Ensures that setting the profiler does not affect whether the profiler is enabled. - * - * @return void - */ - public function testProfilerFactoryEnabledUnaffected() - { - require_once 'Zend/Db/Profiler/ProfilerCustom.php'; - $profiler = new Zend_Db_Profiler_ProfilerCustom(); - $profiler->setEnabled(true); - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => $profiler - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got ' . get_class($db)); - $profiler2 = $db->getProfiler(); - $this->assertSame($profiler, $profiler2); - $this->assertTrue($profiler->getEnabled()); - } - - /** - * Ensures that an instance of an invalid profiler class results in an exception - * - * @return void - */ - public function testProfilerFactoryInvalidClass() - { - $profilerInvalid = new stdClass(); - try { - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => $profilerInvalid - ) - ); - $this->fail('Expected Zend_Db_Profiler_Exception not thrown'); - } catch (Zend_Db_Profiler_Exception $e) { - $this->assertContains('Profiler argument must be an instance of', $e->getMessage()); - } - } - - /** - * Ensures that the factory can handle an instance of Zend_Config having a profiler instance - * - * @return void - */ - public function testProfilerFactoryConfigInstance() - { - require_once 'Zend/Db/Profiler/ProfilerCustom.php'; - $profiler = new Zend_Db_Profiler_ProfilerCustom(); - - require_once 'Zend/Config.php'; - $config = new Zend_Config(array('instance' => $profiler)); - - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => $config - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got ' . get_class($db)); - $profiler2 = $db->getProfiler(); - $this->assertSame($profiler, $profiler2); - $this->assertFalse($profiler->getEnabled()); - } - - /** - * Ensures that a provided instance overrides a class definition - * - * @return void - */ - public function testProfilerFactoryInstanceOverridesClass() - { - require_once 'Zend/Db/Profiler/ProfilerCustom.php'; - $profiler = new Zend_Db_Profiler_ProfilerCustom(); - $db = Zend_Db::factory('Static', - array( - 'dbname' => 'dummy', - 'profiler' => array( - 'instance' => $profiler, - 'class' => 'stdClass' - ) - ) - ); - $this->assertType('Zend_Db_Adapter_Abstract', $db, - 'Expected object of type Zend_Db_Adapter_Abstract, got ' . get_class($db)); - $profiler2 = $db->getProfiler(); - $this->assertSame($profiler, $profiler2); - $this->assertFalse($profiler->getEnabled()); - } - - /** - * Ensures that setEnabled() behaves as expected. - * - * @return void - */ - public function testProfilerSetEnabled() - { - $prof = $this->_db->getProfiler(); - - $this->assertSame($prof->setEnabled(true), $prof); - $this->assertTrue($prof->getEnabled()); - - $this->assertSame($prof->setEnabled(false), $prof); - $this->assertFalse($prof->getEnabled()); - } - - /** - * Ensures that setFilterElapsedSecs() behaves as expected. - * - * @return void - */ - public function testProfilerSetFilterElapsedSecs() - { - $prof = $this->_db->getProfiler(); - - $this->assertSame($prof->setFilterElapsedSecs(), $prof); - $this->assertNull($prof->getFilterElapsedSecs()); - - $this->assertSame($prof->setFilterElapsedSecs(null), $prof); - $this->assertNull($prof->getFilterElapsedSecs()); - - $this->assertSame($prof->setFilterElapsedSecs(3), $prof); - $this->assertEquals(3, $prof->getFilterElapsedSecs()); - } - - /** - * Ensures that setFilterQueryType() remembers the setting. - * - * @return void - */ - public function testProfilerSetFilterQueryType() - { - $prof = $this->_db->getProfiler(); - - $this->assertSame($prof->setFilterQueryType(), $prof); - $this->assertNull($prof->getFilterQueryType()); - - $this->assertSame($prof->setFilterQueryType(null), $prof); - $this->assertNull($prof->getFilterQueryType()); - - $queryTypes = Zend_Db_Profiler::DELETE; - $this->assertSame($prof->setFilterQueryType($queryTypes), $prof); - $this->assertEquals($queryTypes, $prof->getFilterQueryType()); - } - - /** - * Ensures that clear() behaves as expected - * - * @return void - */ - public function testProfilerClear() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $this->assertSame($prof->clear(), $prof); - - $this->assertFalse($prof->getQueryProfiles()); - } - - /** - * Ensures that queryStart() behaves as expected. - * - * @return void - */ - public function testProfilerQueryStart() - { - $prof = $this->_db->getProfiler(); - - $this->assertNull($prof->queryStart('sqlDisabled1')); - - $prof->setEnabled(true); - - $queries = array( - array( - 'sql' => '', - 'typeGiven' => null, - 'typeExpected' => Zend_Db_Profiler::QUERY - ), - array( - 'sql' => '', - 'typeGiven' => Zend_Db_Profiler::QUERY, - 'typeExpected' => Zend_Db_Profiler::QUERY - ), - array( - 'sql' => 'something', - 'typeGiven' => null, - 'typeExpected' => Zend_Db_Profiler::QUERY - ), - array( - 'sql' => 'INSERT', - 'typeGiven' => null, - 'typeExpected' => Zend_Db_Profiler::INSERT - ), - array( - 'sql' => 'sqlInsert', - 'typeGiven' => Zend_Db_Profiler::INSERT, - 'typeExpected' => Zend_Db_Profiler::INSERT - ), - array( - 'sql' => 'INSERT', - 'typeGiven' => Zend_Db_Profiler::UPDATE, - 'typeExpected' => Zend_Db_Profiler::UPDATE - ), - array( - 'sql' => 'UPDATE', - 'typeGiven' => null, - 'typeExpected' => Zend_Db_Profiler::UPDATE - ), - array( - 'sql' => 'sqlUpdate', - 'typeGiven' => Zend_Db_Profiler::UPDATE, - 'typeExpected' => Zend_Db_Profiler::UPDATE - ), - array( - 'sql' => 'UPDATE', - 'typeGiven' => Zend_Db_Profiler::DELETE, - 'typeExpected' => Zend_Db_Profiler::DELETE - ), - array( - 'sql' => 'DELETE', - 'typeGiven' => null, - 'typeExpected' => Zend_Db_Profiler::DELETE - ), - array( - 'sql' => 'sqlDelete', - 'typeGiven' => Zend_Db_Profiler::DELETE, - 'typeExpected' => Zend_Db_Profiler::DELETE - ), - array( - 'sql' => 'DELETE', - 'typeGiven' => Zend_Db_Profiler::SELECT, - 'typeExpected' => Zend_Db_Profiler::SELECT - ), - array( - 'sql' => 'SELECT', - 'typeGiven' => null, - 'typeExpected' => Zend_Db_Profiler::SELECT - ), - array( - 'sql' => 'sqlSelect', - 'typeGiven' => Zend_Db_Profiler::SELECT, - 'typeExpected' => Zend_Db_Profiler::SELECT - ), - array( - 'sql' => 'SELECT', - 'typeGiven' => Zend_Db_Profiler::INSERT, - 'typeExpected' => Zend_Db_Profiler::INSERT - ) - ); - - foreach ($queries as $key => $query) { - $this->assertEquals($key, $prof->queryStart($query['sql'], $query['typeGiven'])); - } - - $prof->setEnabled(false); - - $this->assertNull($prof->queryStart('sqlDisabled2')); - - $queryProfiles = $prof->getQueryProfiles(null, true); - - $this->assertEquals(count($queries), count($queryProfiles)); - - foreach ($queryProfiles as $queryId => $queryProfile) { - $this->assertTrue(isset($queries[$queryId])); - $this->assertEquals($queries[$queryId]['sql'], $queryProfile->getQuery()); - $this->assertEquals($queries[$queryId]['typeExpected'], $queryProfile->getQueryType()); - } - } - - /** - * Ensures that queryEnd() behaves as expected when given invalid query handle. - * - * @return void - */ - public function testProfilerQueryEndHandleInvalid() - { - $prof = $this->_db->getProfiler(); - - $prof->queryEnd('invalid'); - - $prof->setEnabled(true); - - try { - $prof->queryEnd('invalid'); - $this->fail('Expected Zend_Db_Profiler_Exception not thrown'); - } catch (Zend_Db_Profiler_Exception $e) { - $this->assertContains('no query with handle', $e->getMessage()); - } - } - - /** - * Ensures that queryEnd() throws an exception when the query has already ended. - * - * @return void - */ - public function testProfilerQueryEndAlreadyEnded() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $queryId = $prof->queryStart('sql'); - - $prof->queryEnd($queryId); - - try { - $prof->queryEnd($queryId); - $this->fail('Expected Zend_Db_Profiler_Exception not thrown'); - } catch (Zend_Db_Profiler_Exception $e) { - $this->assertContains('has already ended', $e->getMessage()); - } - } - - /** - * Ensures that queryEnd() does not keep the query profile if the elapsed time is less than - * the minimum time allowed by the elapsed seconds filter. - * - * @return void - */ - public function testProfilerQueryEndFilterElapsedSecs() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true) - ->setFilterElapsedSecs(1); - - $prof->queryEnd($prof->queryStart('sqlTimeShort1')); - - $this->_db->query('sqlTimeShort2'); - - $this->_db->setOnQuerySleep(2); - - $this->_db->query('sqlTimeLong'); - - $this->_db->setOnQuerySleep(0); - - $this->_db->query('sqlTimeShort3'); - - $this->assertEquals(1, count($queryProfiles = $prof->getQueryProfiles())); - - $this->assertTrue(isset($queryProfiles[2])); - - $this->assertEquals('sqlTimeLong', $queryProfiles[2]->getQuery()); - } - - /** - * Ensures that queryEnd() does not keep the query profile if the query type is not allowed - * by the query type filter. - * - * @return void - */ - public function testProfilerQueryEndFilterQueryType() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true) - ->setFilterQueryType(Zend_Db_Profiler::UPDATE); - - $this->_db->query('INSERT'); - $this->_db->query('UPDATE'); - $this->_db->query('DELETE'); - $this->_db->query('SELECT'); - $this->_db->query('UPDATE'); - $this->_db->query('DELETE'); - - $this->assertEquals(2, count($prof->getQueryProfiles())); - } - - /** - * Ensures that getQueryProfile() throws an exception when given an invalid query handle. - * - * @return void - */ - public function testProfilerGetQueryProfileHandleInvalid() - { - try { - $this->_db->getProfiler()->getQueryProfile('invalid'); - $this->fail('Expected Zend_Db_Profiler_Exception not thrown'); - } catch (Zend_Db_Profiler_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Ensures that getQueryProfile() behaves as expected when provided a valid handle. - * - * @return void - */ - public function testProfilerGetQueryProfileHandleValid() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $queryId = $prof->queryStart('sql'); - - $this->assertType('Zend_Db_Profiler_Query', - $prof->getQueryProfile($queryId)); - } - - /** - * Ensures that getQueryProfiles() returns only those queries of the specified type(s). - * - * @return void - */ - public function testProfilerGetQueryProfilesFilterQueryType() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $queries = array( - 'INSERT', - 'UPDATE', - 'DELETE', - 'SELECT' - ); - - foreach ($queries as $query) { - $this->_db->query($query); - } - - foreach ($queries as $queryId => $query) { - $queryProfiles = $prof->getQueryProfiles(constant("Zend_Db_Profiler::$query")); - $this->assertEquals(1, count($queryProfiles)); - $this->assertTrue(isset($queryProfiles[$queryId])); - $this->assertEquals($query, $queryProfiles[$queryId]->getQuery()); - } - } - - /** - * Ensures that getTotalElapsedSecs() behaves as expected for basic usage. - * - * @return void - */ - public function testProfilerGetTotalElapsedSecsBasic() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $this->_db->setOnQuerySleep(1); - - $numQueries = 3; - - for ($queryCount = 0; $queryCount < $numQueries; ++$queryCount) { - $this->_db->query("sql $queryCount"); - } - - $this->assertThat( - $prof->getTotalElapsedSecs(), - $this->greaterThan($numQueries - 0.1) - ); - } - - /** - * Ensures that getTotalElapsedSecs() only counts queries of the specified type(s). - * - * @return void - */ - public function testProfilerGetTotalElapsedSecsFilterQueryType() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $this->_db->query('SELECT'); - - $this->_db->query('SELECT'); - - $this->_db->setOnQuerySleep(1); - - $this->_db->query('UPDATE'); - - $this->_db->setOnQuerySleep(0); - - $this->_db->query('SELECT'); - - $this->_db->setOnQuerySleep(1); - - $this->_db->query('UPDATE'); - - $this->_db->setOnQuerySleep(0); - - $this->_db->query('SELECT'); - - $this->assertThat( - $prof->getTotalElapsedSecs(Zend_Db_Profiler::SELECT), - $this->lessThan(1) - ); - - $this->assertThat( - $prof->getTotalElapsedSecs(Zend_Db_Profiler::UPDATE), - $this->greaterThan(1.9) - ); - } - - /** - * Ensures that getTotalNumQueries() behaves as expected for basic usage. - * - * @return void - */ - public function testProfilerGetTotalNumQueries() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $numQueries = 3; - - for ($queryCount = 0; $queryCount < $numQueries; ++$queryCount) { - $this->_db->query("sql $queryCount"); - } - - $this->assertEquals($numQueries, $prof->getTotalNumQueries()); - } - - /** - * Ensures that getTotalNumQueries() only counts queries of the specified type(s). - * - * @return void - */ - public function testProfilerGetTotalNumQueriesFilterQueryType() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $queries = array( - 'INSERT' => 2, - 'UPDATE' => 5, - 'DELETE' => 1, - 'SELECT' => 3 - ); - - foreach ($queries as $querySql => $queryCount) { - for ($i = 0; $i < $queryCount; ++$i) { - $this->_db->query("$querySql $i"); - } - } - - foreach ($queries as $querySql => $queryCount) { - $this->assertEquals($queryCount, $prof->getTotalNumQueries(constant("Zend_Db_Profiler::$querySql"))); - } - } - - /** - * Ensures that getLastQueryProfile() returns false when no queries have been profiled. - * - * @return void - */ - public function testProfilerGetLastQueryProfileFalse() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $this->assertFalse($prof->getLastQueryProfile()); - } - - /** - * Ensures that getLastQueryProfile() returns the last query profiled, regardless whether it has ended. - * - * @return void - */ - public function testProfilerGetLastQueryProfile() - { - $prof = $this->_db->getProfiler() - ->setEnabled(true); - - $this->_db->query('sql 1'); - - $prof->queryStart('sql 2'); - - $this->assertType('Zend_Db_Profiler_Query', - $queryProfile = $prof->getLastQueryProfile()); - - $this->assertEquals('sql 2', $queryProfile->getQuery()); - - $this->assertFalse($queryProfile->getElapsedSecs()); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Profiler/TestCommon.php b/tests/Zend/Db/Profiler/TestCommon.php deleted file mode 100644 index 6bd9044caede980cae060809cfbba7d3e5d26b7f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Profiler/TestCommon.php +++ /dev/null @@ -1,266 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_TestSetup - */ -require_once 'Zend/Db/TestSetup.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Profiler_TestCommon extends Zend_Db_TestSetup -{ - - public function setUp() - { - parent::setUp(); - $this->_db->getProfiler()->setEnabled(true); - } - - public function tearDown() - { - $this->_db->getProfiler()->setEnabled(false); - parent::tearDown(); - } - - public function testProfilerPreparedStatement() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - // prepare a query - $select = $this->_db->select() - ->from('zfbugs') - ->where("$bug_id = 2"); - $stmt = $this->_db->prepare($select->__toString()); - - // execute query a first time - $stmt->execute(); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(2, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(); - $this->assertType('array', $profiles); - $this->assertEquals(1, count($profiles), 'Expected to find 1 profile'); - $qp = $profiles[0]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // execute query a second time - $stmt->execute(); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(2, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(); - $this->assertType('array', $profiles); - $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles'); - $qp = $profiles[1]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - $this->assertNotSame($profiles[0], $profiles[1]); - $this->assertEquals($profiles[0]->getQuery(), $profiles[1]->getQuery()); - } - - public function testProfilerPreparedStatementWithParams() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_status = $this->_db->quoteIdentifier('bug_status', true); - - // prepare a query - $select = $this->_db->select() - ->from('zfbugs') - ->where("$bug_id = ? AND $bug_status = ?"); - $stmt = $this->_db->prepare($select->__toString()); - - // execute query a first time - $stmt->execute(array(2, 'VERIFIED')); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(2, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(); - $this->assertType('array', $profiles); - $this->assertEquals(1, count($profiles), 'Expected to find 1 profile'); - $qp = $profiles[0]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = ?", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(1 => 2, 2 => 'VERIFIED'), $params); - - // execute query a second time - $stmt->execute(array(3, 'FIXED')); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(3, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(); - $this->assertType('array', $profiles); - $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles'); - $qp = $profiles[1]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - $this->assertNotSame($profiles[0], $profiles[1]); - $this->assertEquals($profiles[0]->getQuery(), $profiles[1]->getQuery()); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = ?", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(1 => 3, 2 => 'FIXED'), $params); - - $this->assertNotSame($profiles[0], $profiles[1]); - $this->assertEquals($profiles[0]->getQuery(), $profiles[1]->getQuery()); - } - - public function testProfilerPreparedStatementWithBoundParams() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_status = $this->_db->quoteIdentifier('bug_status', true); - - // prepare a query - $select = $this->_db->select() - ->from('zfbugs') - ->where("$bug_id = ? AND $bug_status = ?"); - $stmt = $this->_db->prepare($select->__toString()); - - // execute query a first time - $id = 1; - $status = 'NEW'; - $this->assertTrue($stmt->bindParam(1, $id)); - $this->assertTrue($stmt->bindParam(2, $status)); - $id = 2; - $status = 'VERIFIED'; - $stmt->execute(); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(2, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(); - $this->assertType('array', $profiles, 'Expected array, got '.gettype($profiles)); - $this->assertEquals(1, count($profiles), 'Expected to find 1 profile'); - $qp = $profiles[0]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = ?", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(1 => 2, 2 => 'VERIFIED'), $params); - - // execute query a second time - $id = 3; - $status = 'FIXED'; - $stmt->execute(); - $results = $stmt->fetchAll(); - $this->assertType('array', $results); - $this->assertEquals(3, $results[0]['bug_id']); - - // analyze query profiles - $profiles = $this->_db->getProfiler()->getQueryProfiles(); - $this->assertType('array', $profiles, 'Expected array, got '.gettype($profiles)); - $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles'); - $qp = $profiles[1]; - $this->assertType('Zend_Db_Profiler_Query', $qp); - - // analyze query in the profile - $sql = $qp->getQuery(); - $this->assertContains(" = ?", $sql); - $params = $qp->getQueryParams(); - $this->assertType('array', $params); - $this->assertEquals(array(1 => 3, 2 => 'FIXED'), $params); - } - - /** - * Ensures that setFilterQueryType() actually filters - * - * @return void - */ - protected function _testProfilerSetFilterQueryTypeCommon($queryType) - { - $bugs = $this->_db->quoteIdentifier('zfbugs', true); - $bug_status = $this->_db->quoteIdentifier('bug_status', true); - - $prof = $this->_db->getProfiler(); - $prof->setEnabled(true); - - $this->assertSame($prof->setFilterQueryType($queryType), $prof); - $this->assertEquals($queryType, $prof->getFilterQueryType()); - - $this->_db->query("SELECT * FROM $bugs"); - $this->_db->query("INSERT INTO $bugs ($bug_status) VALUES (?)", array('NEW')); - $this->_db->query("DELETE FROM $bugs"); - $this->_db->query("UPDATE $bugs SET $bug_status = ?", array('FIXED')); - - $qps = $prof->getQueryProfiles(); - $this->assertType('array', $qps, 'Expecting some query profiles, got none'); - foreach ($qps as $qp) { - $qtype = $qp->getQueryType(); - $this->assertEquals($queryType, $qtype, - "Found query type $qtype, which should have been filtered out"); - } - - $prof->setEnabled(false); - } - - public function testProfilerSetFilterQueryTypeInsert() - { - $this->_testProfilerSetFilterQueryTypeCommon(Zend_Db_Profiler::INSERT); - } - - public function testProfilerSetFilterQueryTypeUpdate() - { - $this->_testProfilerSetFilterQueryTypeCommon(Zend_Db_Profiler::UPDATE); - } - - public function testProfilerSetFilterQueryTypeDelete() - { - $this->_testProfilerSetFilterQueryTypeCommon(Zend_Db_Profiler::DELETE); - } - - public function testProfilerSetFilterQueryTypeSelect() - { - $this->_testProfilerSetFilterQueryTypeCommon(Zend_Db_Profiler::SELECT); - } - - -} diff --git a/tests/Zend/Db/Select/Db2Test.php b/tests/Zend/Db/Select/Db2Test.php deleted file mode 100644 index 682f1cce1f33a8ac514885b99f1b88444df516a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Db2Test.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_Db2Test extends Zend_Db_Select_TestCommon -{ - - public function testSelectJoinCross() - { - $this->markTestSkipped($this->getDriver() . ' does not support CROSS JOIN'); - } - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Select/MysqliTest.php b/tests/Zend/Db/Select/MysqliTest.php deleted file mode 100644 index fe8e35166b82c531833ab91d5d78cefda877f5de..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/MysqliTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_MysqliTest extends Zend_Db_Select_TestCommon -{ - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Select/OdbcTest.php b/tests/Zend/Db/Select/OdbcTest.php deleted file mode 100644 index 34af76b46fbda2266eada8fde606b56bacf9f5fb..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_OdbcTest extends Zend_Db_Select_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Select/OracleTest.php b/tests/Zend/Db/Select/OracleTest.php deleted file mode 100644 index f617298ac223aa3f182774dc3096b5f014f5c3bb..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/OracleTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_OracleTest extends Zend_Db_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function testSelectJoinQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Select/Pdo/IbmTest.php b/tests/Zend/Db/Select/Pdo/IbmTest.php deleted file mode 100644 index 533daf29ec01f3fed9e564725de365fbdc7e4fb7..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Pdo/IbmTest.php +++ /dev/null @@ -1,75 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Db_Select_TestCommon - */ -require_once 'Zend/Db/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Select_Pdo_IbmTest extends Zend_Db_Select_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Ibm'; - } - - public function testSelectGroupByExpr() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestIncomplete('IDS does not support this SQL syntax'); - } else { - parent::testSelectGroupByExpr(); - } - } - - public function testSelectGroupByAutoExpr() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestIncomplete('IDS does not support this SQL syntax'); - } else { - parent::testSelectGroupByAutoExpr(); - } - } - - public function testSelectJoinCross() - { - $this->markTestSkipped($this->getDriver() . ' adapter support for CROSS JOIN not yet available'); - } -} diff --git a/tests/Zend/Db/Select/Pdo/MssqlTest.php b/tests/Zend/Db/Select/Pdo/MssqlTest.php deleted file mode 100644 index 1781ebf6284abaaae2d6526a266e5fc1e368536e..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Pdo/MssqlTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_Pdo_MssqlTest extends Zend_Db_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.'); - } - - public function testSelectJoinQualified() - { - $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.'); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Select/Pdo/MysqlTest.php b/tests/Zend/Db/Select/Pdo/MysqlTest.php deleted file mode 100644 index 7098f82d26cb6077bc2552757ffe3a0efd11f487..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Pdo/MysqlTest.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqlTest.php 5097 2007-06-04 16:06:43Z darby $ - */ - - -/** - * @see Zend_Db_Select_TestCommon - */ -require_once 'Zend/Db/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Select_Pdo_MysqlTest extends Zend_Db_Select_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Select/Pdo/OciTest.php b/tests/Zend/Db/Select/Pdo/OciTest.php deleted file mode 100644 index 6c749e3b39a3c74e49b850ba0729f3cce51c1ea0..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Pdo/OciTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_Pdo_OciTest extends Zend_Db_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function testSelectJoinQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Select/Pdo/PgsqlTest.php b/tests/Zend/Db/Select/Pdo/PgsqlTest.php deleted file mode 100644 index 5e4e81f91f81c483dc03d69bb0ec258fcb930a44..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Pdo/PgsqlTest.php +++ /dev/null @@ -1,118 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PgsqlTest.php 4969 2007-05-25 19:16:50Z darby $ - */ - - -/** - * @see Zend_Db_Select_TestCommon - */ -require_once 'Zend/Db/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Select_Pdo_PgsqlTest extends Zend_Db_Select_TestCommon -{ - public function getDriver() - { - return 'Pdo_Pgsql'; - } - - public function testSelectGroupByExpr() - { - $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY'); - } - - public function testSelectGroupByAutoExpr() - { - $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY'); - } - - /** - * Ensures that from() provides expected behavior using schema specification - * - * @return void - */ - public function testSelectFromSchemaSpecified() - { - $schema = 'public'; - $table = 'zfbugs'; - - $sql = $this->_db->select()->from($table, '*', $schema); - - $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString()); - - $rowset = $this->_db->fetchAll($sql); - - $this->assertEquals(4, count($rowset)); - } - - /** - * Ensures that from() provides expected behavior using schema in the table name - * - * @return void - */ - public function testSelectFromSchemaInName() - { - $schema = 'public'; - $table = 'zfbugs'; - - $name = "$schema.$table"; - - $sql = $this->_db->select()->from($name); - - $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString()); - - $rowset = $this->_db->fetchAll($sql); - - $this->assertEquals(4, count($rowset)); - } - - /** - * Ensures that from() overrides schema specification with schema in the table name - * - * @return void - */ - public function testSelectFromSchemaInNameOverridesSchemaArgument() - { - $schema = 'public'; - $table = 'zfbugs'; - - $name = "$schema.$table"; - - $sql = $this->_db->select()->from($name, '*', 'ignored'); - - $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString()); - - $rowset = $this->_db->fetchAll($sql); - - $this->assertEquals(4, count($rowset)); - } -} diff --git a/tests/Zend/Db/Select/Pdo/SqliteTest.php b/tests/Zend/Db/Select/Pdo/SqliteTest.php deleted file mode 100644 index 9af31caf2d7038a9d61d3e2143e79df644b1c58d..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/Pdo/SqliteTest.php +++ /dev/null @@ -1,144 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Select_Pdo_SqliteTest extends Zend_Db_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestSkipped($this->getDriver() . ' does not support qualified table names'); - } - - public function testSelectJoinQualified() - { - $this->markTestSkipped($this->getDriver() . ' does not support qualified table names'); - } - - public function testSelectFromForUpdate() - { - $this->markTestSkipped($this->getDriver() . ' does not support FOR UPDATE'); - } - - public function testSelectJoinRight() - { - $this->markTestSkipped($this->getDriver() . ' does not support RIGHT OUTER JOIN'); - } - - public function testSelectGroupBy() - { - $select = $this->_selectGroupBy(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function testSelectGroupByQualified() - { - $select = $this->_selectGroupByQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function testSelectHaving() - { - $select = $this->_selectHaving(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - } - - public function testSelectHavingWithParameter() - { - $select = $this->_selectHavingWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - } - - public function testSelectHavingOr() - { - $select = $this->_selectHavingOr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function testSelectHavingOrWithParameter() - { - $select = $this->_selectHavingOrWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Select/StaticTest.php b/tests/Zend/Db/Select/StaticTest.php deleted file mode 100644 index 9d1a7be046941ff2b57f6adde58910d890553996..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/StaticTest.php +++ /dev/null @@ -1,639 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Select_TestCommon - */ -require_once 'Zend/Db/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Select_StaticTest extends Zend_Db_Select_TestCommon -{ - /** - * Test basic use of the Zend_Db_Select class. - * - * @return void - */ - public function testSelect() - { - $select = $this->_select(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts"', $sql); - } - - /** - * Test basic use of the Zend_Db_Select class. - * - * @return void - */ - public function testSelectQuery() - { - $select = $this->_select(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts"', $sql); - $stmt = $select->query(); - Zend_Loader::loadClass('Zend_Db_Statement_Static'); - $this->assertType('Zend_Db_Statement_Static', $stmt); - } - - /** - * Test Zend_Db_Select specifying columns - * - * @return void - */ - public function testSelectColumnsScalar() - { - $select = $this->_selectColumnsScalar(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test Zend_Db_Select specifying columns - * - * @return void - */ - public function testSelectColumnsArray() - { - $select = $this->_selectColumnsArray(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_id", "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test support for column aliases. - * e.g. from('table', array('alias' => 'col1')). - * - * @return void - */ - public function testSelectColumnsAliases() - { - $select = $this->_selectColumnsAliases(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" AS "alias" FROM "zfproducts"', $sql); - } - - /** - * Test syntax to support qualified column names, - * e.g. from('table', array('table.col1', 'table.col2')). - * - * @return void - */ - public function testSelectColumnsQualified() - { - $select = $this->_selectColumnsQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test support for columns defined by Zend_Db_Expr. - * - * @return void - */ - public function testSelectColumnsExpr() - { - $select = $this->_selectColumnsExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test support for automatic conversion of SQL functions to - * Zend_Db_Expr, e.g. from('table', array('COUNT(*)')) - * should generate the same result as - * from('table', array(new Zend_Db_Expr('COUNT(*)'))) - */ - - public function testSelectColumnsAutoExpr() - { - $select = $this->_selectColumnsAutoExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT COUNT(*) AS "count" FROM "zfproducts"', $sql); - } - - /** - * Test adding the DISTINCT query modifier to a Zend_Db_Select object. - */ - - public function testSelectDistinctModifier() - { - $select = $this->_selectDistinctModifier(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT DISTINCT 327 FROM "zfproducts"', $sql); - } - - /** - * Test support for schema-qualified table names in from() - * e.g. from('schema.table'). - */ - - public function testSelectFromQualified() - { - $select = $this->_selectFromQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "dummy"."zfproducts"', $sql); - } - - public function testSelectColumnsReset() - { - $select = $this->_selectColumnsReset() - ->reset(Zend_Db_Select::COLUMNS) - ->columns('product_name'); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "p"."product_name" FROM "zfproducts" AS "p"', $sql); - } - - public function testSelectFromForUpdate() - { - $select = $this->_db->select() - ->from("zfproducts") - ->forUpdate(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" FOR UPDATE', $sql); - } - - /** - * Test adding a JOIN to a Zend_Db_Select object. - */ - - public function testSelectJoin() - { - $select = $this->_selectJoin(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id"', $sql); - } - - /** - * Test adding an INNER JOIN to a Zend_Db_Select object. - * This should be exactly the same as the plain JOIN clause. - */ - - public function testSelectJoinWithCorrelationName() - { - $select = $this->_selectJoinWithCorrelationName(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "xyz1".*, "xyz2".* FROM "zfproducts" AS "xyz1" INNER JOIN "zfbugs_products" AS "xyz2" ON "xyz1"."product_id" = "xyz2"."product_id" WHERE ("xyz1"."product_id" = 1)', $sql); - } - - /** - * Test adding an INNER JOIN to a Zend_Db_Select object. - * This should be exactly the same as the plain JOIN clause. - */ - - public function testSelectJoinInner() - { - $select = $this->_selectJoinInner(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id"', $sql); - } - - /** - * Test adding an outer join to a Zend_Db_Select object. - */ - - public function testSelectJoinLeft() - { - $select = $this->_selectJoinLeft(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs".*, "zfbugs_products".* FROM "zfbugs" LEFT JOIN "zfbugs_products" ON "zfbugs"."bug_id" = "zfbugs_products"."bug_id"', $sql); - } - - /** - * Test adding an outer join to a Zend_Db_Select object. - */ - - public function testSelectJoinRight() - { - $select = $this->_selectJoinRight(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products".*, "zfbugs".* FROM "zfbugs_products" RIGHT JOIN "zfbugs" ON "zfbugs_products"."bug_id" = "zfbugs"."bug_id"', $sql); - } - - /** - * Test adding a cross join to a Zend_Db_Select object. - */ - - public function testSelectJoinCross() - { - $select = $this->_selectJoinCross(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" CROSS JOIN "zfbugs_products"', $sql); - } - - /** - * Test support for schema-qualified table names in join(), - * e.g. join('schema.table', 'condition') - */ - - public function testSelectJoinQualified() - { - $select = $this->_selectJoinQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "dummy"."zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id"', $sql); - } - - /** - * Test adding a JOIN USING to a Zend_Db_Select object. - */ - - public function testSelectJoinUsing() - { - $select = $this->_selectJoinUsing(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfbugs_products"."product_id" = "zfproducts"."product_id" WHERE ("zfbugs_products"."product_id" < 3)', $sql); - } - - /** - * Test adding a JOIN INNER USING to a Zend_Db_Select object. - */ - - public function testSelectJoinInnerUsing() - { - $select = $this->_selectJoinInnerUsing(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfbugs_products"."product_id" = "zfproducts"."product_id" WHERE ("zfbugs_products"."product_id" < 3)', $sql); - } - - public function testSelectJoinWithNocolumns() - { - $select = $this->_selectJoinWithNocolumns(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" INNER JOIN "zfbugs" ON "zfbugs"."bug_id" = 1 INNER JOIN "zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id" AND "zfbugs_products"."bug_id" = "zfbugs"."bug_id"', $sql); - } - - /** - * Test adding a WHERE clause to a Zend_Db_Select object. - */ - - public function testSelectWhere() - { - $select = $this->_selectWhere(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2)', $sql); - } - - /** - * Test adding an array in the WHERE clause to a Zend_Db_Select object. - */ - - public function testSelectWhereArray() - { - $select = $this->_selectWhereArray(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" IN (1, 2, 3))', $sql); - } - - /** - * test adding more WHERE conditions, - * which should be combined with AND by default. - */ - - public function testSelectWhereAnd() - { - $select = $this->_selectWhereAnd(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2) AND ("product_id" = 1)', $sql); - } - - /** - * Test support for where() with a parameter, - * e.g. where('id = ?', 1). - */ - - public function testSelectWhereWithParameter() - { - $select = $this->_selectWhereWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2)', $sql); - } - - /** - * Test support for where() with a parameter, - * e.g. where('id = ?', 1). - */ - - public function testSelectWhereWithType() - { - $select = $this->_selectWhereWithType(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2)', $sql); - } - - /** - * Test support for where() with a float parameter, - * e.g. where('id = ?', 1). - */ - - public function testSelectWhereWithTypeFloat() - { - $select = $this->_selectWhereWithTypeFloat(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfprice".* FROM "zfprice" WHERE ("price_total" = 200.450000)', $sql); - } - - /** - * * Test adding an OR WHERE clause to a Zend_Db_Select object. - */ - - public function testSelectWhereOr() - { - $select = $this->_selectWhereOr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 1) OR ("product_id" = 2)', $sql); - } - - /** - * Test support for where() with a parameter, - * e.g. orWhere('id = ?', 2). - */ - - public function testSelectWhereOrWithParameter() - { - $select = $this->_selectWhereOrWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 1) OR ("product_id" = 2)', $sql); - } - - /** - * Test adding a GROUP BY clause to a Zend_Db_Select object. - */ - - public function testSelectGroupBy() - { - $select = $this->_selectGroupBy(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for qualified table in group(), - * e.g. group('schema.table'). - */ - - public function testSelectGroupByQualified() - { - $select = $this->_selectGroupByQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "zfbugs_products"."bug_id" ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for Zend_Db_Expr in group(), - * e.g. group(new Zend_Db_Expr('id+1')) - */ - - public function testSelectGroupByExpr() - { - $select = $this->_selectGroupByExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "bug_id"+1 AS "bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id"+1 ORDER BY "bug_id"+1', $sql); - } - - /** - * Test support for automatic conversion of a SQL - * function to a Zend_Db_Expr in group(), - * e.g. group('LOWER(title)') should give the same - * result as group(new Zend_Db_Expr('LOWER(title)')). - */ - - - public function testSelectGroupByAutoExpr() - { - $select = $this->_selectGroupByAutoExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT ABS("zfbugs_products"."bug_id") AS "bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY ABS("zfbugs_products"."bug_id") ORDER BY ABS("zfbugs_products"."bug_id") ASC', $sql); - } - - /** - * Test adding a HAVING clause to a Zend_Db_Select object. - */ - - public function testSelectHaving() - { - $select = $this->_selectHaving(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) ORDER BY "bug_id" ASC', $sql); - } - - - public function testSelectHavingAnd() - { - $select = $this->_selectHavingAnd(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) AND (COUNT(*) = 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for parameter in having(), - * e.g. having('count(*) > ?', 1). - */ - - - public function testSelectHavingWithParameter() - { - $select = $this->_selectHavingWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test adding a HAVING clause to a Zend_Db_Select object. - */ - - - public function testSelectHavingOr() - { - $select = $this->_selectHavingOr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) OR (COUNT(*) = 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for parameter in orHaving(), - * e.g. orHaving('count(*) > ?', 1). - */ - - public function testSelectHavingOrWithParameter() - { - $select = $this->_selectHavingOrWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) OR (COUNT(*) = 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test adding an ORDER BY clause to a Zend_Db_Select object. - */ - - public function testSelectOrderBy() - { - $select = $this->_selectOrderBy(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC', $sql); - } - - - public function testSelectOrderByArray() - { - $select = $this->_selectOrderByArray(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_name" ASC, "product_id" ASC', $sql); - } - - - public function testSelectOrderByAsc() - { - $select = $this->_selectOrderByAsc(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC', $sql); - } - - - public function testSelectOrderByDesc() - { - $select = $this->_selectOrderByDesc(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" DESC', $sql); - } - - /** - * Test support for qualified table in order(), - * e.g. order('schema.table'). - */ - - public function testSelectOrderByQualified() - { - $select = $this->_selectOrderByQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "zfproducts"."product_id" ASC', $sql); - } - - /** - * Test support for Zend_Db_Expr in order(), - * e.g. order(new Zend_Db_Expr('id+1')). - */ - - public function testSelectOrderByExpr() - { - $select = $this->_selectOrderByExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY 1', $sql); - } - - /** - * Test automatic conversion of SQL functions to - * Zend_Db_Expr, e.g. order('LOWER(title)') - * should give the same result as - * order(new Zend_Db_Expr('LOWER(title)')). - */ - - public function testSelectOrderByAutoExpr() - { - $select = $this->_selectOrderByAutoExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY ABS("zfproducts"."product_id") ASC', $sql); - } - - /** - * Test ORDER BY clause that contains multiple lines. - * See ZF-1822, which says that the regexp matching - * ASC|DESC fails when string is multi-line. - */ - - public function testSelectOrderByMultiLine() - { - $select = $this->_selectOrderByMultiLine(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" DESC', $sql); - } - - /** - * Test adding a LIMIT clause to a Zend_Db_Select object. - */ - - public function testSelectLimit() - { - $select = $this->_selectLimit(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 0', $sql); - } - - - public function testSelectLimitNone() - { - $select = $this->_selectLimitNone(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC', $sql); - } - - - public function testSelectLimitOffset() - { - $select = $this->_selectLimitOffset(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 1', $sql); - } - - /** - * Test the limitPage() method of a Zend_Db_Select object. - */ - - public function testSelectLimitPageOne() - { - $select = $this->_selectLimitPageOne(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 0', $sql); - } - - - public function testSelectLimitPageTwo() - { - $select = $this->_selectLimitPageTwo(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 1', $sql); - } - - public function testSelectUnionString() - { - $select = $this->_selectUnionString(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "bug_id" AS "id", "bug_status" AS "name" FROM "zfbugs" UNION SELECT "product_id" AS "id", "product_name" AS "name" FROM "zfproducts" ORDER BY "id" ASC', $sql); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Select/TestCommon.php b/tests/Zend/Db/Select/TestCommon.php deleted file mode 100644 index d66a1910f5adb9e6add1942d706076fb262cce5f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Select/TestCommon.php +++ /dev/null @@ -1,1461 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_TestSetup - */ -require_once 'Zend/Db/TestSetup.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Select_TestCommon extends Zend_Db_TestSetup -{ - /** - * Test basic use of the Zend_Db_Select class. - */ - protected function _select() - { - $select = $this->_db->select(); - $select->from('zfproducts'); - return $select; - } - - public function testSelect() - { - $select = $this->_select(); - $this->assertType('Zend_Db_Select', $select, - 'Expecting object of type Zend_Db_Select, got '.get_class($select)); - $stmt = $this->_db->query($select); - $row = $stmt->fetch(); - $stmt->closeCursor(); - $this->assertEquals(2, count($row)); // correct number of fields - $this->assertEquals(1, $row['product_id']); // correct data - } - - public function testSelectToString() - { - $select = $this->_select(); - $this->assertEquals($select->__toString(), $select->assemble()); // correct data - } - - /** - * Test basic use of the Zend_Db_Select class. - */ - public function testSelectQuery() - { - $select = $this->_select(); - $this->assertType('Zend_Db_Select', $select, - 'Expecting object of type Zend_Db_Select, got '.get_class($select)); - $stmt = $select->query(); - $row = $stmt->fetch(); - $stmt->closeCursor(); - $this->assertEquals(2, count($row)); // correct number of fields - $this->assertEquals(1, $row['product_id']); // correct data - } - - /** - * Test Zend_Db_Select specifying columns - */ - protected function _selectColumnsScalar() - { - $select = $this->_db->select() - ->from('zfproducts', 'product_name'); // scalar - return $select; - } - - public function testSelectColumnsScalar() - { - $select = $this->_selectColumnsScalar(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), 'Expected count of result set to be 2'); - $this->assertEquals(1, count($result[0]), 'Expected column count of result set to be 1'); - $this->assertThat($result[0], $this->arrayHasKey('product_name')); - } - - protected function _selectColumnsArray() - { - $select = $this->_db->select() - ->from('zfproducts', array('product_id', 'product_name')); // array - return $select; - } - - public function testSelectColumnsArray() - { - $select = $this->_selectColumnsArray(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), 'Expected count of result set to be 2'); - $this->assertEquals(2, count($result[0]), 'Expected column count of result set to be 2'); - $this->assertThat($result[0], $this->arrayHasKey('product_id')); - $this->assertThat($result[0], $this->arrayHasKey('product_name')); - } - - /** - * Test support for column aliases. - * e.g. from('table', array('alias' => 'col1')). - */ - protected function _selectColumnsAliases() - { - $select = $this->_db->select() - ->from('zfproducts', array('alias' => 'product_name')); - return $select; - } - - public function testSelectColumnsAliases() - { - $select = $this->_selectColumnsAliases(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), 'Expected count of result set to be 2'); - $this->assertThat($result[0], $this->arrayHasKey('alias')); - $this->assertThat($result[0], $this->logicalNot($this->arrayHasKey('product_name'))); - } - - /** - * Test syntax to support qualified column names, - * e.g. from('table', array('table.col1', 'table.col2')). - */ - protected function _selectColumnsQualified() - { - $select = $this->_db->select() - ->from('zfproducts', "zfproducts.product_name"); - return $select; - } - - public function testSelectColumnsQualified() - { - $select = $this->_selectColumnsQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertThat($result[0], $this->arrayHasKey('product_name')); - } - - /** - * Test support for columns defined by Zend_Db_Expr. - */ - protected function _selectColumnsExpr() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $select = $this->_db->select() - ->from('zfproducts', new Zend_Db_Expr($products.'.'.$product_name)); - return $select; - } - - public function testSelectColumnsExpr() - { - $select = $this->_selectColumnsExpr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertThat($result[0], $this->arrayHasKey('product_name')); - } - - /** - * Test support for automatic conversion of SQL functions to - * Zend_Db_Expr, e.g. from('table', array('COUNT(*)')) - * should generate the same result as - * from('table', array(new Zend_Db_Expr('COUNT(*)'))) - */ - protected function _selectColumnsAutoExpr() - { - $select = $this->_db->select() - ->from('zfproducts', array('count' => 'COUNT(*)')); - return $select; - } - - public function testSelectColumnsAutoExpr() - { - $select = $this->_selectColumnsAutoExpr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertThat($result[0], $this->arrayHasKey('count')); - $this->assertEquals(3, $result[0]['count']); - } - - /** - * Test adding the DISTINCT query modifier to a Zend_Db_Select object. - */ - protected function _selectDistinctModifier() - { - $select = $this->_db->select() - ->distinct() - ->from('zfproducts', new Zend_Db_Expr(327)); - return $select; - } - - public function testSelectDistinctModifier() - { - $select = $this->_selectDistinctModifier(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - } - - /** - * Test adding the FOR UPDATE query modifier to a Zend_Db_Select object. - * - public function testSelectForUpdateModifier() - { - } - */ - - /** - * Test support for schema-qualified table names in from() - * e.g. from('schema.table'). - */ - protected function _selectFromQualified() - { - $schema = $this->_util->getSchema(); - $select = $this->_db->select() - ->from("$schema.zfproducts"); - return $select; - } - - public function testSelectFromQualified() - { - $select = $this->_selectFromQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - } - - /** - * Test support for nested select in from() - */ - protected function _selectFromSelectObject() - { - $subquery = $this->_db->select() - ->from('subqueryTable'); - - $select = $this->_db->select() - ->from($subquery); - return $select; - } - - public function testSelectFromSelectObject() - { - $select = $this->_selectFromSelectObject(); - $query = $select->assemble(); - $cmp = 'SELECT ' . $this->_db->quoteIdentifier('t') . '.* FROM (SELECT ' - . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM ' - . $this->_db->quoteIdentifier('subqueryTable') . ') AS ' - . $this->_db->quoteIdentifier('t'); - $this->assertEquals($query, $cmp); - } - - /** - * Test support for nested select in from() - */ - protected function _selectColumnsReset() - { - $select = $this->_db->select() - ->from(array('p' => 'zfproducts'), array('product_id', 'product_name')); - return $select; - } - - public function testSelectColumnsReset() - { - $select = $this->_selectColumnsReset() - ->reset(Zend_Db_Select::COLUMNS) - ->columns('product_name'); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertContains('product_name', array_keys($result[0])); - $this->assertNotContains('product_id', array_keys($result[0])); - - $select = $this->_selectColumnsReset() - ->reset(Zend_Db_Select::COLUMNS) - ->columns('p.product_name'); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertContains('product_name', array_keys($result[0])); - $this->assertNotContains('product_id', array_keys($result[0])); - - $select = $this->_selectColumnsReset() - ->reset(Zend_Db_Select::COLUMNS) - ->columns('product_name', 'p'); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertContains('product_name', array_keys($result[0])); - $this->assertNotContains('product_id', array_keys($result[0])); - } - - public function testSelectColumnsResetBeforeFrom() - { - $select = $this->_selectColumnsReset(); - try { - $select->reset(Zend_Db_Select::COLUMNS) - ->reset(Zend_Db_Select::FROM) - ->columns('product_id'); - $this->fail('Expected exception of type "Zend_Db_Select_Exception"'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Select_Exception', $e, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e)); - $this->assertEquals("No table has been specified for the FROM clause", $e->getMessage()); - } - } - - protected function _selectColumnWithColonQuotedParameter() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where($product_id . ' = ?', "as'as:x"); - return $select; - } - - public function testSelectColumnWithColonQuotedParameter() - { - $stmt = $select = $this->_selectColumnWithColonQuotedParameter() - ->query(); - $result = $stmt->fetchAll(); - $this->assertEquals(0, count($result)); - } - - /** - * Test support for FOR UPDATE - * e.g. from('schema.table'). - */ - public function testSelectFromForUpdate() - { - $select = $this->_db->select() - ->from("zfproducts") - ->forUpdate(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - } - - /** - * Test adding a JOIN to a Zend_Db_Select object. - */ - protected function _selectJoin() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - - $select = $this->_db->select() - ->from('zfproducts') - ->join('zfbugs_products', "$products.$product_id = $bugs_products.$product_id"); - return $select; - } - - public function testSelectJoin() - { - $select = $this->_selectJoin(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(6, count($result)); - $this->assertEquals(3, count($result[0])); - } - - /** - * Test adding an INNER JOIN to a Zend_Db_Select object. - * This should be exactly the same as the plain JOIN clause. - */ - protected function _selectJoinWithCorrelationName() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - $xyz1 = $this->_db->quoteIdentifier('xyz1'); - $xyz2 = $this->_db->quoteIdentifier('xyz2'); - - $select = $this->_db->select() - ->from( array('xyz1' => 'zfproducts') ) - ->join( array('xyz2' => 'zfbugs_products'), "$xyz1.$product_id = $xyz2.$product_id") - ->where("$xyz1.$product_id = 1"); - return $select; - } - - public function testSelectJoinWithCorrelationName() - { - $select = $this->_selectJoinWithCorrelationName(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(3, count($result[0])); - } - - /** - * Test adding an INNER JOIN to a Zend_Db_Select object. - * This should be exactly the same as the plain JOIN clause. - */ - protected function _selectJoinInner() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - - $select = $this->_db->select() - ->from('zfproducts') - ->joinInner('zfbugs_products', "$products.$product_id = $bugs_products.$product_id"); - return $select; - } - - public function testSelectJoinInner() - { - $select = $this->_selectJoinInner(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(6, count($result)); - $this->assertEquals(3, count($result[0])); - } - - /** - * Test adding a JOIN to a Zend_Db_Select object. - */ - protected function _selectJoinWithNocolumns() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bugs = $this->_db->quoteIdentifier('zfbugs'); - - $select = $this->_db->select() - ->from('zfproducts') - ->join('zfbugs', "$bugs.$bug_id = 1", array()) - ->join('zfbugs_products', "$products.$product_id = $bugs_products.$product_id AND $bugs_products.$bug_id = $bugs.$bug_id", null); - return $select; - } - - public function testSelectJoinWithNocolumns() - { - $select = $this->_selectJoinWithNocolumns(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - $this->assertEquals(2, count($result[0])); - } - - /** - * Test adding an outer join to a Zend_Db_Select object. - */ - protected function _selectJoinLeft() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - $select = $this->_db->select() - ->from('zfbugs') - ->joinLeft('zfbugs_products', "$bugs.$bug_id = $bugs_products.$bug_id"); - return $select; - } - - public function testSelectJoinLeft() - { - $select = $this->_selectJoinLeft(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(7, count($result)); - $this->assertEquals(9, count($result[0])); - $this->assertEquals(3, $result[3]['product_id']); - $this->assertNull($result[6]['product_id']); - } - - /** - * Returns a select object that uses table aliases and specifies a mixed ordering of columns, - * for testing whether the user-specified ordering is preserved. - * - * @return Zend_Db_Select - */ - protected function _selectJoinLeftTableAliasesColumnOrderPreserve() - { - $bugsBugId = $this->_db->quoteIdentifier('b.bug_id'); - $bugsProductBugId = $this->_db->quoteIdentifier('bp.bug_id'); - - $select = $this->_db->select() - ->from(array('b' => 'zfbugs'), array('b.bug_id', 'bp.product_id', 'b.bug_description')) - ->joinLeft(array('bp' => 'zfbugs_products'), "$bugsBugId = $bugsProductBugId", array()); - - return $select; - } - - /** - * Ensures that when table aliases are used with a mixed ordering of columns, the user-specified - * column ordering is preserved. - * - * @return void - */ - public function testJoinLeftTableAliasesColumnOrderPreserve() - { - $select = $this->_selectJoinLeftTableAliasesColumnOrderPreserve(); - $this->assertRegExp('/^.*b.*bug_id.*,.*bp.*product_id.*,.*b.*bug_description.*$/s', $select->assemble()); - } - - /** - * Test adding an outer join to a Zend_Db_Select object. - */ - protected function _selectJoinRight() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - $select = $this->_db->select() - ->from('zfbugs_products') - ->joinRight('zfbugs', "$bugs_products.$bug_id = $bugs.$bug_id"); - return $select; - } - - public function testSelectJoinRight() - { - $select = $this->_selectJoinRight(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(7, count($result)); - $this->assertEquals(9, count($result[0])); - $this->assertEquals(3, $result[3]['product_id']); - $this->assertNull($result[6]['product_id']); - } - - /** - * Test adding a cross join to a Zend_Db_Select object. - */ - protected function _selectJoinCross() - { - $select = $this->_db->select() - ->from('zfproducts') - ->joinCross('zfbugs_products'); - return $select; - } - - public function testSelectJoinCross() - { - $select = $this->_selectJoinCross(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(18, count($result)); - $this->assertEquals(3, count($result[0])); - } - - /** - * Test support for schema-qualified table names in join(), - * e.g. join('schema.table', 'condition') - */ - protected function _selectJoinQualified() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $schema = $this->_util->getSchema(); - $select = $this->_db->select() - ->from('zfproducts') - ->join("$schema.zfbugs_products", "$products.$product_id = $bugs_products.$product_id"); - return $select; - } - - public function testSelectJoinQualified() - { - $select = $this->_selectJoinQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(6, count($result)); - $this->assertEquals(3, count($result[0])); - } - - protected function _selectJoinUsing() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->joinUsing("zfbugs_products", "$product_id") - ->where("$bugs_products.$product_id < ?", 3); - return $select; - } - - public function testSelectMagicMethod() - { - $select = $this->_selectJoinUsing(); - try { - $select->foo(); - $this->fail('Expected exception of type "Zend_Db_Select_Exception"'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Select_Exception', $e, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e)); - $this->assertEquals("Unrecognized method 'foo()'", $e->getMessage()); - } - } - - public function testSelectJoinUsing() - { - $select = $this->_selectJoinUsing(); - $sql = preg_replace('/\\s+/', ' ', $select->assemble()); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0]['product_id']); - } - - protected function _selectJoinInnerUsing() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->joinInnerUsing("zfbugs_products", "$product_id") - ->where("$bugs_products.$product_id < ?", 3); - return $select; - } - - public function testSelectJoinInnerUsing() - { - $select = $this->_selectJoinInnerUsing(); - $sql = preg_replace('/\\s+/', ' ', $select->assemble()); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0]['product_id']); - } - - public function testSelectJoinInnerUsingException() - { - $select = $this->_selectJoinInnerUsing(); - try { - $select->joinFooUsing(); - $this->fail('Expected exception of type "Zend_Db_Select_Exception"'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Select_Exception', $e, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e)); - $this->assertEquals("Unrecognized method 'joinFooUsing()'", $e->getMessage()); - } - } - - protected function _selectJoinCrossUsing() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$bugs_products.$product_id < ?", 3); - return $select; - } - - public function testSelectJoinCrossUsing() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - $select = $this->_selectJoinCrossUsing(); - try { - $select->joinCrossUsing("zfbugs_products", "$product_id"); - $this->fail('Expected exception of type "Zend_Db_Select_Exception"'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Select_Exception', $e, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e)); - $this->assertEquals("Cannot perform a joinUsing with method 'joinCrossUsing()'", $e->getMessage()); - } - } - - /** - * Test adding a WHERE clause to a Zend_Db_Select object. - */ - protected function _selectWhere() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 2"); - return $select; - } - - public function testSelectWhere() - { - $select = $this->_selectWhere(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(2, $result[0]['product_id']); - } - - /** - * Test support for nested select in from() - */ - protected function _selectWhereSelectObject() - { - $subquery = $this->_db->select() - ->from('subqueryTable'); - - $select = $this->_db->select() - ->from('table') - ->where('foo IN ?', $subquery); - return $select; - } - - public function testSelectWhereSelectObject() - { - $select = $this->_selectWhereSelectObject(); - $query = $select->assemble(); - $cmp = 'SELECT ' . $this->_db->quoteIdentifier('table') . '.* FROM ' - . $this->_db->quoteIdentifier('table') . ' WHERE (foo IN (SELECT ' - . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM ' - . $this->_db->quoteIdentifier('subqueryTable') . '))'; - $this->assertEquals($query, $cmp); - } - - protected function _selectWhereArray() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id IN (?)", array(1, 2, 3)); - return $select; - } - - public function testSelectWhereArray() - { - $select = $this->_selectWhereArray(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - } - - /** - * test adding more WHERE conditions, - * which should be combined with AND by default. - */ - protected function _selectWhereAnd() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 2") - ->where("$product_id = 1"); - return $select; - } - - public function testSelectWhereAnd() - { - $select = $this->_selectWhereAnd(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(0, count($result)); - } - - /** - * Test support for where() with a parameter, - * e.g. where('id = ?', 1). - */ - protected function _selectWhereWithParameter() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = ?", 2); - return $select; - } - - public function testSelectWhereWithParameter() - { - $select = $this->_selectWhereWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(2, $result[0]['product_id']); - } - - /** - * Test support for where() with a specified type, - * e.g. where('id = ?', 1, 'int'). - */ - protected function _selectWhereWithType() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = ?", 2, 'int'); - return $select; - } - - public function testSelectWhereWithType() - { - $select = $this->_selectWhereWithType(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(2, $result[0]['product_id']); - } - - /** - * Test support for where() with a specified type, - * e.g. where('id = ?', 1, 'int'). - */ - protected function _selectWhereWithTypeFloat() - { - $price_total = $this->_db->quoteIdentifier('price_total'); - - $select = $this->_db->select() - ->from('zfprice') - ->where("$price_total = ?", 200.45, Zend_Db::FLOAT_TYPE); - return $select; - } - - public function testSelectWhereWithTypeFloat() - { - $locale = setlocale(LC_ALL, null); - - $select = $this->_selectWhereWithTypeFloat(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(200.45, $result[0]['price_total']); - - try { - setlocale(LC_ALL, 'fr_BE.UTF-8'); - $select = $this->_selectWhereWithTypeFloat(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(200.45, $result[0]['price_total']); - } catch (Zend_Exception $e) { - setlocale(LC_ALL, $locale); - throw $e; - } - - setlocale(LC_ALL, $locale); - } - - /** - * Test adding an OR WHERE clause to a Zend_Db_Select object. - */ - protected function _selectWhereOr() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->orWhere("$product_id = 1") - ->orWhere("$product_id = 2"); - return $select; - } - - public function testSelectWhereOr() - { - $select = $this->_selectWhereOr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0]['product_id']); - $this->assertEquals(2, $result[1]['product_id']); - } - - /** - * Test support for where() with a parameter, - * e.g. orWhere('id = ?', 2). - */ - protected function _selectWhereOrWithParameter() - { - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->orWhere("$product_id = ?", 1) - ->orWhere("$product_id = ?", 2); - return $select; - } - - public function testSelectWhereOrWithParameter() - { - $select = $this->_selectWhereOrWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0]['product_id']); - $this->assertEquals(2, $result[1]['product_id']); - } - - /** - * Test adding a GROUP BY clause to a Zend_Db_Select object. - */ - protected function _selectGroupBy() - { - $thecount = $this->_db->quoteIdentifier('thecount'); - - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', new Zend_Db_Expr("COUNT(*) AS $thecount"))) - ->group('bug_id') - ->order('bug_id'); - return $select; - } - - public function testSelectGroupBy() - { - $select = $this->_selectGroupBy(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1]['bug_id']); - $this->assertEquals(1, $result[1]['thecount']); - } - - /** - * Test support for qualified table in group(), - * e.g. group('schema.table'). - */ - protected function _selectGroupByQualified() - { - $thecount = $this->_db->quoteIdentifier('thecount'); - - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', new Zend_Db_Expr("COUNT(*) AS $thecount"))) - ->group("zfbugs_products.bug_id") - ->order('bug_id'); - return $select; - } - - public function testSelectGroupByQualified() - { - $select = $this->_selectGroupByQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1]['bug_id']); - $this->assertEquals(1, $result[1]['thecount']); - } - - /** - * Test support for Zend_Db_Expr in group(), - * e.g. group(new Zend_Db_Expr('id+1')) - */ - protected function _selectGroupByExpr() - { - $thecount = $this->_db->quoteIdentifier('thecount'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id'=>new Zend_Db_Expr("$bug_id+1"), new Zend_Db_Expr("COUNT(*) AS $thecount"))) - ->group(new Zend_Db_Expr("$bug_id+1")) - ->order(new Zend_Db_Expr("$bug_id+1")); - return $select; - } - - public function testSelectGroupByExpr() - { - $select = $this->_selectGroupByExpr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(2, $result[0]['bug_id'], - 'Expected first bug_id to be 2'); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first group to be 2'); - $this->assertEquals(3, $result[1]['bug_id'], - 'Expected second bug_id to be 3'); - $this->assertEquals(1, $result[1]['thecount'], - 'Expected count(*) of second group to be 1'); - } - - /** - * Test support for automatic conversion of a SQL - * function to a Zend_Db_Expr in group(), - * e.g. group('LOWER(title)') should give the same - * result as group(new Zend_Db_Expr('LOWER(title)')). - */ - - protected function _selectGroupByAutoExpr() - { - $thecount = $this->_db->quoteIdentifier('thecount'); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id'=>"ABS($bugs_products.$bug_id)", new Zend_Db_Expr("COUNT(*) AS $thecount"))) - ->group("ABS($bugs_products.$bug_id)") - ->order("ABS($bugs_products.$bug_id)"); - return $select; - } - - public function testSelectGroupByAutoExpr() - { - $select = $this->_selectGroupByAutoExpr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount'], 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1]['bug_id']); - $this->assertEquals(1, $result[1]['thecount']); - } - - /** - * Test adding a HAVING clause to a Zend_Db_Select object. - */ - protected function _selectHaving() - { - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', 'COUNT(*) AS thecount')) - ->group('bug_id') - ->having('COUNT(*) > 1') - ->order('bug_id'); - return $select; - } - - public function testSelectHaving() - { - $select = $this->_selectHaving(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount']); - } - - protected function _selectHavingAnd() - { - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', 'COUNT(*) AS thecount')) - ->group('bug_id') - ->having('COUNT(*) > 1') - ->having('COUNT(*) = 1') - ->order('bug_id'); - return $select; - } - - public function testSelectHavingAnd() - { - $select = $this->_selectHavingAnd(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(0, count($result)); - } - - /** - * Test support for parameter in having(), - * e.g. having('count(*) > ?', 1). - */ - - protected function _selectHavingWithParameter() - { - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', 'COUNT(*) AS thecount')) - ->group('bug_id') - ->having('COUNT(*) > ?', 1) - ->order('bug_id'); - return $select; - } - - public function testSelectHavingWithParameter() - { - $select = $this->_selectHavingWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount']); - } - - /** - * Test adding a HAVING clause to a Zend_Db_Select object. - */ - - protected function _selectHavingOr() - { - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', 'COUNT(*) AS thecount')) - ->group('bug_id') - ->orHaving('COUNT(*) > 1') - ->orHaving('COUNT(*) = 1') - ->order('bug_id'); - return $select; - } - - public function testSelectHavingOr() - { - $select = $this->_selectHavingOr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount']); - $this->assertEquals(2, $result[1]['bug_id']); - $this->assertEquals(1, $result[1]['thecount']); - } - - /** - * Test support for parameter in orHaving(), - * e.g. orHaving('count(*) > ?', 1). - */ - protected function _selectHavingOrWithParameter() - { - $select = $this->_db->select() - ->from('zfbugs_products', array('bug_id', 'COUNT(*) AS thecount')) - ->group('bug_id') - ->orHaving('COUNT(*) > ?', 1) - ->orHaving('COUNT(*) = ?', 1) - ->order('bug_id'); - return $select; - } - - public function testSelectHavingOrWithParameter() - { - $select = $this->_selectHavingOrWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0]['bug_id']); - $this->assertEquals(3, $result[0]['thecount']); - $this->assertEquals(2, $result[1]['bug_id']); - $this->assertEquals(1, $result[1]['thecount']); - } - - /** - * Test adding an ORDER BY clause to a Zend_Db_Select object. - */ - protected function _selectOrderBy() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id'); - return $select; - } - - public function testSelectOrderBy() - { - $select = $this->_selectOrderBy(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - } - - protected function _selectOrderByArray() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order(array('product_name', 'product_id')); - return $select; - } - - public function testSelectOrderByArray() - { - $select = $this->_selectOrderByArray(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), - 'Expected count of result set to be 3'); - $this->assertEquals('Linux', $result[0]['product_name']); - $this->assertEquals(2, $result[0]['product_id']); - } - - protected function _selectOrderByAsc() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order("product_id ASC"); - return $select; - } - - public function testSelectOrderByAsc() - { - $select = $this->_selectOrderByAsc(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), - 'Expected count of result set to be 2'); - $this->assertEquals(1, $result[0]['product_id']); - } - - protected function _selectOrderByDesc() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order("product_id DESC"); - return $select; - } - - public function testSelectOrderByDesc() - { - $select = $this->_selectOrderByDesc(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result), - 'Expected count of result set to be 2'); - $this->assertEquals(3, $result[0]['product_id']); - } - - /** - * Test support for qualified table in order(), - * e.g. order('schema.table'). - */ - protected function _selectOrderByQualified() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order("zfproducts.product_id"); - return $select; - } - - public function testSelectOrderByQualified() - { - $select = $this->_selectOrderByQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - } - - /** - * Test support for Zend_Db_Expr in order(), - * e.g. order(new Zend_Db_Expr('id+1')). - */ - protected function _selectOrderByExpr() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order(new Zend_Db_Expr("1")); - return $select; - } - - public function testSelectOrderByExpr() - { - $select = $this->_selectOrderByExpr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - } - - /** - * Test automatic conversion of SQL functions to - * Zend_Db_Expr, e.g. order('LOWER(title)') - * should give the same result as - * order(new Zend_Db_Expr('LOWER(title)')). - */ - protected function _selectOrderByAutoExpr() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $select = $this->_db->select() - ->from('zfproducts') - ->order("ABS($products.$product_id)"); - return $select; - } - - public function testSelectOrderByAutoExpr() - { - $select = $this->_selectOrderByAutoExpr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, $result[0]['product_id']); - } - - /** - * Test ORDER BY clause that contains multiple lines. - * See ZF-1822, which says that the regexp matching - * ASC|DESC fails when string is multi-line. - */ - protected function _selectOrderByMultiLine() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order("product_id\nDESC"); - return $select; - } - - public function testSelectOrderByMultiLine() - { - $select = $this->_selectOrderByMultiLine(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, $result[0]['product_id']); - } - - /** - * Test adding a LIMIT clause to a Zend_Db_Select object. - */ - protected function _selectLimit() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id') - ->limit(1); - return $select; - } - - public function testSelectLimit() - { - $select = $this->_selectLimit(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(1, $result[0]['product_id']); - } - - protected function _selectLimitNone() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id') - ->limit(); // no limit - return $select; - } - - public function testSelectLimitNone() - { - $select = $this->_selectLimitNone(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(3, count($result)); - } - - protected function _selectLimitOffset() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id') - ->limit(1, 1); - return $select; - } - - public function testSelectLimitOffset() - { - $select = $this->_selectLimitOffset(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(2, $result[0]['product_id']); - } - - /** - * Test the limitPage() method of a Zend_Db_Select object. - */ - protected function _selectLimitPageOne() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id') - ->limitPage(1, 1); // first page, length 1 - return $select; - } - - public function testSelectLimitPageOne() - { - $select = $this->_selectLimitPageOne(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(1, $result[0]['product_id']); - } - - protected function _selectLimitPageTwo() - { - $select = $this->_db->select() - ->from('zfproducts') - ->order('product_id') - ->limitPage(2, 1); // second page, length 1 - return $select; - } - - public function testSelectLimitPageTwo() - { - $select = $this->_selectLimitPageTwo(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(1, count($result)); - $this->assertEquals(2, $result[0]['product_id']); - } - - /** - * Test the getPart() and reset() methods of a Zend_Db_Select object. - */ - public function testSelectGetPartAndReset() - { - $select = $this->_db->select() - ->from('zfproducts') - ->limit(1); - $count = $select->getPart(Zend_Db_Select::LIMIT_COUNT); - $this->assertEquals(1, $count); - - $select->reset(Zend_Db_Select::LIMIT_COUNT); - $count = $select->getPart(Zend_Db_Select::LIMIT_COUNT); - $this->assertNull($count); - - $select->reset(); // reset the whole object - $from = $select->getPart(Zend_Db_Select::FROM); - $this->assertTrue(empty($from)); - } - - /** - * Test the UNION statement for a Zend_Db_Select object. - */ - protected function _selectUnionString() - { - $bugs = $this->_db->quoteIdentifier('zfbugs'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $bug_status = $this->_db->quoteIdentifier('bug_status'); - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - $id = $this->_db->quoteIdentifier('id'); - $name = $this->_db->quoteIdentifier('name'); - $sql1 = "SELECT $bug_id AS $id, $bug_status AS $name FROM $bugs"; - $sql2 = "SELECT $product_id AS $id, $product_name AS $name FROM $products"; - - $select = $this->_db->select() - ->union(array($sql1, $sql2)) - ->order('id'); - return $select; - } - - public function testSelectUnionString() - { - $select = $this->_selectUnionString(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $this->assertEquals(7, count($result)); - $this->assertEquals(1, $result[0]['id']); - } - -} diff --git a/tests/Zend/Db/SkipTests.php b/tests/Zend/Db/SkipTests.php deleted file mode 100644 index c8867ee02fcac5ef885fbf0b9c329a9620b0f400..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/SkipTests.php +++ /dev/null @@ -1,161 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SkipTests.php 7538 2008-01-21 12:25:15Z kgbfernando $ - */ - -// require_once 'PHPUnit/Framework/TestCase.php'; - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Skip_CommonTest extends PHPUnit_Framework_TestCase -{ - public $message = null; - - abstract public function getDriver(); - - public function setUp() - { - $driver = $this->getDriver(); - $message = 'Skipping ' . $this->getDriver(); - if ($this->message) { - $message .= ': ' . $this->message; - } - $this->markTestSkipped($message); - } - - public function testDb() - { - // this is here only so we have at least one test - } -} - -class Zend_Db_Skip_StaticTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Static'; - } -} - -class Zend_Db_Skip_Db2Test extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Db2'; - } -} - -class Zend_Db_Skip_MysqliTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Mysqli'; - } -} - -class Zend_Db_Skip_OdbcTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Odbc'; - } -} - -class Zend_Db_Skip_OracleTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Oracle'; - } -} - -class Zend_Db_Skip_FirebirdTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Firebird'; - } -} - -class Zend_Db_Skip_Pdo_IbmTest extends Zend_Db_Skip_CommonTest -{ - function getDriver() - { - return 'Pdo_Ibm'; - } -} - -class Zend_Db_Skip_Pdo_MssqlTest extends Zend_Db_Skip_CommonTest -{ - function getDriver() - { - return 'Pdo_Mssql'; - } -} - -class Zend_Db_Skip_Pdo_MysqlTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Mysql'; - } -} - -class Zend_Db_Skip_Pdo_OciTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Oci'; - } -} - -class Zend_Db_Skip_Pdo_FirebirdTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Firebird'; - } -} - -class Zend_Db_Skip_Pdo_PgsqlTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Pgsql'; - } -} - -class Zend_Db_Skip_Pdo_SqliteTest extends Zend_Db_Skip_CommonTest -{ - public function getDriver() - { - return 'Pdo_Sqlite'; - } -} diff --git a/tests/Zend/Db/Statement/Db2Test.php b/tests/Zend/Db/Statement/Db2Test.php deleted file mode 100644 index 983da1065131a217e47e80df8a90c52729c2a1cd..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Db2Test.php +++ /dev/null @@ -1,126 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Db2Test extends Zend_Db_Statement_TestCommon -{ - - public function testStatementErrorCodeKeyViolation() - { - $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.'); - } - - public function testStatementErrorInfoKeyViolation() - { - $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.'); - } - - public function testStatementColumnCountForSelect() - { - $select = $this->_db->select() - ->from('zfproducts'); - - $stmt = $this->_db->prepare($select->__toString()); - - $n = $stmt->columnCount(); - // DB2 returns the column count once the query has been prepared - // while PDO returns it only after it has been executed - $this->assertEquals(2, $n); - - $stmt->execute(); - - $n = $stmt->columnCount(); - $stmt->closeCursor(); - - $this->assertType('integer', $n); - $this->assertEquals(2, $n); - } - - public function testStatementBindParamByPosition() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params'); - } - - public function testStatementBindParamByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - try { - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)"); - // test with colon prefix - $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true'); - // test with no colon prefix - $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true'); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals("Invalid bind-variable position ':id'", $e->getMessage()); - } - } - - public function testStatementBindValueByPosition() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params'); - } - - public function testStatementBindValueByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - try { - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)"); - // test with colon prefix - $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true'); - // test with no colon prefix - $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true'); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals("Invalid bind-variable position ':id'", $e->getMessage()); - } - } - - public function testStatementGetColumnMeta() - { - $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]'); - } - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Statement/MysqliTest.php b/tests/Zend/Db/Statement/MysqliTest.php deleted file mode 100644 index 860504b03862a7dba2b1514992c5c75dd51bd11b..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/MysqliTest.php +++ /dev/null @@ -1,105 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_MysqliTest extends Zend_Db_Statement_TestCommon -{ - - public function testStatementRowCount() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->prepare("DELETE FROM $products WHERE $product_id = 1"); - - $n = $stmt->rowCount(); - $this->assertType('integer', $n); - $this->assertEquals(-1, $n, 'Expecting row count to be -1 before executing query'); - - $stmt->execute(); - - $n = $stmt->rowCount(); - $stmt->closeCursor(); - - $this->assertType('integer', $n); - $this->assertEquals(1, $n, 'Expected row count to be one after executing query'); - } - - public function testStatementBindParamByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - try { - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)"); - // test with colon prefix - $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true'); - // test with no colon prefix - $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true'); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals("Invalid bind-variable position ':id'", $e->getMessage()); - } - } - - public function testStatementBindValueByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - try { - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)"); - // test with colon prefix - $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true'); - // test with no colon prefix - $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true'); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals("Invalid bind-variable position ':id'", $e->getMessage()); - } - } - - public function testStatementGetColumnMeta() - { - $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]'); - } - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Statement/OdbcTest.php b/tests/Zend/Db/Statement/OdbcTest.php deleted file mode 100644 index e1f9bdb09c08ef72181bfabfaffccefaa013b054..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_OdbcTest extends Zend_Db_Statement_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Statement/OracleTest.php b/tests/Zend/Db/Statement/OracleTest.php deleted file mode 100644 index 781c0dd18c5584923715d12a172cbe92863bf225..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/OracleTest.php +++ /dev/null @@ -1,103 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_OracleTest extends Zend_Db_Statement_TestCommon -{ - - public function testStatementBindParamByPosition() - { - $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position'); - } - - public function testStatementBindValueByPosition() - { - $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position'); - } - - public function testStatementErrorCodeKeyViolation() - { - $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.'); - } - - public function testStatementErrorInfoKeyViolation() - { - $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.'); - } - - public function testStatementExecuteWithParams() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)"); - $stmt->execute(array('product_id' => 4, 'product_name' => 'Solaris')); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 4"); - $result = $this->_db->fetchAll($select); - $stmt->closeCursor(); - - $this->assertEquals(array(array('product_id'=>4, 'product_name'=>'Solaris')), $result); - } - - public function testStatementFetchAllStyleBoth() - { - $this->markTestIncomplete($this->getDriver() . ' driver does not support fetchAll(FETCH_BOTH)'); - } - - public function testStatementGetColumnMeta() - { - $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]'); - } - - public function testStatementNextRowset() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - try { - $stmt->nextRowset(); - $this->fail('Expected to catch Zend_Db_Statement_Oracle_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Oracle_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Oracle_Exception, got '.get_class($e)); - $this->assertEquals('HYC00 Optional feature not implemented', $e->getMessage()); - } - $stmt->closeCursor(); - } - - public function testStatementSetFetchModeBoth() - { - $this->markTestIncomplete($this->getDriver() . ' does not implement FETCH_BOTH correctly.'); - } - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Statement/Pdo/IbmTest.php b/tests/Zend/Db/Statement/Pdo/IbmTest.php deleted file mode 100644 index 59eccf8298f79d40f64feb1932d46a7c5a667c61..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/IbmTest.php +++ /dev/null @@ -1,105 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Pdo_IbmTest extends Zend_Db_Statement_Pdo_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Ibm'; - } - - /** - * used by testStatementGetColumnMeta() - * - */ - protected $_getColumnMetaKeys = array( - 'scale', 'table', 'native_type', 'flags', 'name', 'len', 'precision', 'pdo_type' - ); - - public function testStatementNextRowset() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - - $result = $stmt->nextRowset(); - - // there is no next rowset so $result should be false - $this->assertFalse($result); - $stmt->closeCursor(); - } - - public function testStatementColumnCountForSelect() - { - $select = $this->_db->select() - ->from('zfproducts'); - - $stmt = $this->_db->prepare($select->__toString()); - - $n = $stmt->columnCount(); - $this->assertEquals(2, $n); - - $stmt->execute(); - - $n = $stmt->columnCount(); - $stmt->closeCursor(); - - $this->assertType('integer', $n); - $this->assertEquals(2, $n); - } - - public function testStatementGetSetAttribute() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - - $value = 'value'; - try { - $stmt->setAttribute(1234, $value); - } catch (Zend_Exception $e) { - $this->assertContains('This driver doesn\'t support setting attributes', $e->getMessage()); - } - - try { - $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #1"); - } catch (Zend_Exception $e) { - $this->assertContains('Driver does not support this function: 1 Unknown attribute', $e->getMessage()); - return; - } - - $valueArray = array('value1', 'value2'); - $stmt->setAttribute(1235, $valueArray); - $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #1"); - $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2"); - - $valueObject = new stdClass(); - $stmt->setAttribute(1236, $valueObject); - $this->assertSame($valueObject, $stmt->getAttribute(1236), "Expected object"); - $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #2"); - $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2"); - } -} diff --git a/tests/Zend/Db/Statement/Pdo/MssqlTest.php b/tests/Zend/Db/Statement/Pdo/MssqlTest.php deleted file mode 100644 index d41bc3af92e219d0c239f32524a5743537b3c049..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/MssqlTest.php +++ /dev/null @@ -1,89 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Pdo_MssqlTest extends Zend_Db_Statement_Pdo_TestCommon -{ - - public function testStatementGetColumnMeta() - { - $this->markTestSkipped($this->getDriver() . ' does not support meta data.'); - } - - public function testStatementExecuteWithParams() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - // Make IDENTITY column accept explicit value. - // This can be done in only one table in a given session. - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON"); - parent::testStatementExecuteWithParams(); - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF"); - } - - public function testStatementBindParamByPosition() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - // Make IDENTITY column accept explicit value. - // This can be done in only one table in a given session. - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON"); - parent::testStatementBindParamByPosition(); - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF"); - } - - public function testStatementBindParamByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - // Make IDENTITY column accept explicit value. - // This can be done in only one table in a given session. - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON"); - parent::testStatementBindParamByName(); - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF"); - } - - public function testStatementBindValueByPosition() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - // Make IDENTITY column accept explicit value. - // This can be done in only one table in a given session. - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON"); - parent::testStatementBindValueByPosition(); - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF"); - } - - public function testStatementBindValueByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - // Make IDENTITY column accept explicit value. - // This can be done in only one table in a given session. - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON"); - parent::testStatementBindValueByName(); - $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF"); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Statement/Pdo/MysqlTest.php b/tests/Zend/Db/Statement/Pdo/MysqlTest.php deleted file mode 100644 index 738a94bb040319ac315468c9914174de53d4bde5..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/MysqlTest.php +++ /dev/null @@ -1,67 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Pdo_MysqlTest extends Zend_Db_Statement_Pdo_TestCommon -{ - - public function testStatementNextRowset() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - try { - $stmt->nextRowset(); - } catch (Zend_Db_Statement_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals('SQLSTATE[HYC00]: Optional feature not implemented', $e->getMessage()); - } - $stmt->closeCursor(); - } - - /** - * Ensures that the character sequence ":0'" is handled properly - * - * @link http://framework.zend.com/issues/browse/ZF-2059 - * @return void - */ - public function testZF2059() - { - $sql = "SELECT bug_id FROM zfbugs WHERE bug_status != ':0'"; - $results = $this->_db->fetchAll($sql); - $this->assertEquals(4, count($results)); - - $select = $this->_db->select()->from('zfbugs', 'bug_id') - ->where('bug_status != ?', ':0'); - $results = $this->_db->fetchAll($select); - $this->assertEquals(4, count($results)); - } - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Statement/Pdo/OciTest.php b/tests/Zend/Db/Statement/Pdo/OciTest.php deleted file mode 100644 index f6636efec6fe497bfeb41a2b11eb04f730598393..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/OciTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Pdo_OciTest extends Zend_Db_Statement_Pdo_TestCommon -{ - - public function testStatementGetColumnMeta() - { - $this->markTestSkipped($this->getDriver() . ' does not support statement metadata'); - } - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Statement/Pdo/PgsqlTest.php b/tests/Zend/Db/Statement/Pdo/PgsqlTest.php deleted file mode 100644 index e6386750e4caa36b6e118d2884d59821922a470a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/PgsqlTest.php +++ /dev/null @@ -1,38 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Pdo_PgsqlTest extends Zend_Db_Statement_Pdo_TestCommon -{ - - protected $_getColumnMetaKeys = array( - 'pgsql:oid', 'native_type', 'name', 'len', 'precision', 'pdo_type' - ); - - public function getDriver() - { - return 'Pdo_Pgsql'; - } - -} diff --git a/tests/Zend/Db/Statement/Pdo/SqliteTest.php b/tests/Zend/Db/Statement/Pdo/SqliteTest.php deleted file mode 100644 index 40eb5f502183710ec2e5a95e2d62f6a2385020f2..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/SqliteTest.php +++ /dev/null @@ -1,48 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/Pdo/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_Pdo_SqliteTest extends Zend_Db_Statement_Pdo_TestCommon -{ - - public function testStatementBindParamByName() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding parameters'); - } - - public function testStatementBindParamByPosition() - { - $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding parameters'); - } - - protected $_getColumnMetaKeys = array( - 'native_type', 'sqlite:decl_type', 'flags', 'name', 'len', 'precision', 'pdo_type' - ); - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Statement/Pdo/TestCommon.php b/tests/Zend/Db/Statement/Pdo/TestCommon.php deleted file mode 100644 index 0f45f347e9f92facd6ff4cba85f10ded429da414..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Pdo/TestCommon.php +++ /dev/null @@ -1,64 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Statement/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -abstract class Zend_Db_Statement_Pdo_TestCommon extends Zend_Db_Statement_TestCommon -{ - - public function testStatementConstruct() - { - $select = $this->_db->select() - ->from('zfproducts'); - $sql = $select->__toString(); - $stmt = new Zend_Db_Statement_Pdo($this->_db, $sql); - $this->assertType('Zend_Db_Statement_Pdo', $stmt); - $stmt->closeCursor(); - } - - public function testStatementConstructWithSelectObject() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = new Zend_Db_Statement_Pdo($this->_db, $select); - $this->assertType('Zend_Db_Statement_Interface', $stmt); - $stmt->closeCursor(); - } - - public function testStatementNextRowset() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - try { - $stmt->nextRowset(); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals('SQLSTATE[IM001]: Driver does not support this function: driver does not support multiple rowsets', $e->getMessage()); - } - $stmt->closeCursor(); - } - -} diff --git a/tests/Zend/Db/Statement/Static.php b/tests/Zend/Db/Statement/Static.php deleted file mode 100644 index f7dd37a296c319ef71924b57f91c924a05889a22..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/Static.php +++ /dev/null @@ -1,169 +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_Db - * @subpackage Statement - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Static.php 4679 2007-05-02 22:17:39Z darby $ - */ - - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @see Zend_Db_Statement_Interface - */ -require_once 'Zend/Db/Statement/Interface.php'; - - -/** - * Emulates a PDOStatement for native database adapters. - * - * @category Zend - * @package Zend_Db - * @subpackage Statement - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Statement_Static implements Zend_Db_Statement_Interface -{ - /** - * binds a PHP variable to an output column in a result set - */ - public function bindColumn($column, &$param, $type = null) - { - } - - /** - * binds a PHP variable to a parameter in the prepared statement - */ - public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null) - { - } - - /** - * binds a value to a parameter in the prepared statement - */ - public function bindValue($parameter, $value, $type = null) - { - } - - /** - * closes the cursor, allowing the statement to be executed again - */ - public function closeCursor() - { - } - - /** - * returns the number of columns in the result set - */ - public function columnCount() - { - } - - /** - * retrieves an error code, if any, from the statement - */ - public function errorCode() - { - } - - /** - * retrieves an array of error information, if any, from the statement - */ - public function errorInfo() - { - } - - /** - * executes a prepared statement - */ - public function execute(array $params = array()) - { - } - - /** - * fetches a row from a result set - */ - public function fetch($style = null, $cursor = null, $offset = null) - { - } - - /** - * fetches an array containing all of the rows from a result set - */ - public function fetchAll($style = null, $col = null) - { - } - - /** - * returns the data from a single column in a result set - */ - public function fetchColumn($col = 0) - { - } - - /** - * fetches the next row and returns it as an object - */ - public function fetchObject($class = 'stdClass', array $config = array()) - { - } - - /** - * retrieves a Zend_Db_Statement attribute - */ - public function getAttribute($key) - { - } - - /** - * retrieves the next rowset (result set) - */ - public function nextRowset() - { - } - - /** - * returns the number of rows that were affected by the execution of an SQL statement - */ - public function rowCount() - { - } - - /** - * sets a Zend_Db_Statement attribute - */ - public function setAttribute($key, $val) - { - } - - /** - * sets the fetch mode for a Zend_Db_Statement - */ - public function setFetchMode($mode) - { - } -} diff --git a/tests/Zend/Db/Statement/StaticTest.php b/tests/Zend/Db/Statement/StaticTest.php deleted file mode 100644 index f68bc23e6930eed026f6c9abf5a142afd0bb08d2..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/StaticTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Statement_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testStatic() - { - $this->assertTrue(true); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Statement/TestCommon.php b/tests/Zend/Db/Statement/TestCommon.php deleted file mode 100644 index f7689c7b0fbe8ed564dbc906e9ff2aad2bbc3d03..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Statement/TestCommon.php +++ /dev/null @@ -1,852 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/TestSetup.php'; - -require_once 'Zend/Db/Statement/Exception.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -abstract class Zend_Db_Statement_TestCommon extends Zend_Db_TestSetup -{ - - public function testStatementConstruct() - { - $statementClass = 'Zend_Db_Statement_' . $this->getDriver(); - - $select = $this->_db->select() - ->from('zfproducts'); - $sql = $select->__toString(); - $stmt = new $statementClass($this->_db, $sql); - $this->assertType('Zend_Db_Statement_Interface', $stmt); - $stmt->closeCursor(); - } - - public function testStatementConstructWithSelectObject() - { - $statementClass = 'Zend_Db_Statement_' . $this->getDriver(); - - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = new $statementClass($this->_db, $select); - $this->assertType('Zend_Db_Statement_Interface', $stmt); - $stmt->closeCursor(); - } - - public function testStatementConstructFromPrepare() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - $this->assertType('Zend_Db_Statement_Interface', $stmt); - $stmt->closeCursor(); - } - - public function testStatementConstructFromQuery() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->query($select); - $this->assertType('Zend_Db_Statement_Interface', $stmt); - $stmt->closeCursor(); - } - - public function testStatementConstructFromSelect() - { - $stmt = $this->_db->select() - ->from('zfproducts') - ->query(); - $this->assertType('Zend_Db_Statement_Interface', $stmt); - $stmt->closeCursor(); - } - - public function testStatementConstructExceptionBadSql() - { - $sql = "SELECT * FROM *"; - try { - $stmt = $this->_db->query($sql); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - } - - public function testStatementRowCount() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->prepare("DELETE FROM $products WHERE $product_id = 1"); - - $n = $stmt->rowCount(); - $this->assertType('integer', $n); - $this->assertEquals(0, $n, 'Expecting row count to be 0 before executing query'); - - $stmt->execute(); - - $n = $stmt->rowCount(); - $stmt->closeCursor(); - - $this->assertType('integer', $n); - $this->assertEquals(1, $n, 'Expected row count to be one after executing query'); - } - - public function testStatementColumnCountForSelect() - { - $select = $this->_db->select() - ->from('zfproducts'); - - $stmt = $this->_db->prepare($select->__toString()); - - $n = $stmt->columnCount(); - $this->assertEquals(0, $n, 'Expecting column count to be 0 before executing query'); - - $stmt->execute(); - - $n = $stmt->columnCount(); - $stmt->closeCursor(); - - $this->assertType('integer', $n); - $this->assertEquals(2, $n); - } - - public function testStatementColumnCountForDelete() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->prepare("DELETE FROM $products WHERE $product_id = 1"); - - $n = $stmt->columnCount(); - $this->assertEquals(0, $n, 'Expecting column count to be 0 before executing query'); - - $stmt->execute(); - - $n = $stmt->columnCount(); - $this->assertEquals(0, $n, 'Expecting column count to be null after executing query'); - } - - public function testStatementExecuteWithParams() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (?, ?)"); - $stmt->execute(array(4, 'Solaris')); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 4"); - $result = $this->_db->fetchAll($select); - $stmt->closeCursor(); - - $this->assertEquals(array(array('product_id'=>4, 'product_name'=>'Solaris')), $result); - } - - public function testStatementErrorCodeKeyViolation() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (?, ?)"); - try { - // INSERT a value that results in a key violation - $retval = $stmt->execute(array(1, 'Solaris')); - if ($retval === false) { - throw new Zend_Db_Statement_Exception('dummy'); - } - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - $code = $stmt->errorCode(); - // @todo what to assert here? - } - - public function testStatementErrorInfoKeyViolation() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (?, ?)"); - try { - // INSERT a value that results in a key violation - $retval = $stmt->execute(array(1, 'Solaris')); - if ($retval === false) { - throw new Zend_Db_Statement_Exception('dummy'); - } - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - $code = $stmt->errorCode(); - $info = $stmt->errorInfo(); - $this->assertEquals($code, $info[0]); - // @todo what to assert here? - } - - public function testStatementSetFetchModeAssoc() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - // set the adapter fetch mode to something different - $this->_db->setFetchMode(Zend_Db::FETCH_BOTH); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $stmt->setFetchMode(Zend_Db::FETCH_ASSOC); - $result = $stmt->fetchAll(); - - $this->assertEquals(2, count($result)); - $this->assertEquals(2, count($result[0])); - - // check for FETCH_ASSOC entries - $this->assertEquals(2, $result[0]['product_id']); - $this->assertEquals('Linux', $result[0]['product_name']); - - // check FETCH_NUM entries - $this->assertFalse(isset($result[0][0])); - $this->assertFalse(isset($result[0][1])); - } - - public function testStatementSetFetchModeNum() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - // set the adapter fetch mode to something different - $this->_db->setFetchMode(Zend_Db::FETCH_BOTH); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $stmt->setFetchMode(Zend_Db::FETCH_NUM); - $result = $stmt->fetchAll(); - - $this->assertEquals(2, count($result)); - $this->assertEquals(2, count($result[0])); - - // check for FETCH_ASSOC entries - $this->assertFalse(isset($result[0]['product_id'])); - $this->assertFalse(isset($result[0]['product_name'])); - - // check FETCH_NUM entries - $this->assertEquals(2, $result[0][0]); - $this->assertEquals('Linux', $result[0][1]); - } - - public function testStatementSetFetchModeBoth() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - // set the adapter fetch mode to something different - $this->_db->setFetchMode(Zend_Db::FETCH_ASSOC); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $stmt->setFetchMode(Zend_Db::FETCH_BOTH); - $result = $stmt->fetchAll(); - - $this->assertEquals(2, count($result)); - $this->assertEquals(4, count($result[0])); - - // check for FETCH_ASSOC entries - $this->assertEquals(2, $result[0]['product_id']); - $this->assertEquals('Linux', $result[0]['product_name']); - - // check FETCH_NUM entries - $this->assertEquals(2, $result[0][0]); - $this->assertEquals('Linux', $result[0][1]); - } - - public function testStatementSetFetchModeObj() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - // set the adapter fetch mode to something different - $this->_db->setFetchMode(Zend_Db::FETCH_BOTH); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $stmt->setFetchMode(Zend_Db::FETCH_OBJ); - $result = $stmt->fetchAll(); - - $this->assertEquals(2, count($result)); - $this->assertType('stdClass', $result[0]); - - // check for FETCH_OBJ entries - $this->assertEquals(2, $result[0]->product_id); - $this->assertEquals('Linux', $result[0]->product_name); - } - - public function testStatementSetFetchModeInvalidException() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - try { - // invalid value - $stmt->setFetchMode(-999); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertContains('invalid fetch mode', $e->getMessage()); - } - } - - public function testStatementFetchAll() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(); - - $this->assertEquals(2, count($result)); - $this->assertEquals(2, count($result[0])); - $this->assertEquals(2, $result[0]['product_id']); - $this->assertFalse(isset($result[0][0])); - } - - public function testStatementFetchAllStyleNum() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(Zend_Db::FETCH_NUM); - - $this->assertEquals(2, count($result)); - $this->assertEquals(2, count($result[0])); - $this->assertEquals(2, $result[0][0]); - $this->assertEquals('Linux', $result[0][1]); - $this->assertFalse(isset($result[0]['product_id'])); - } - - public function testStatementFetchAllStyleAssoc() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(Zend_Db::FETCH_ASSOC); - - $this->assertEquals(2, count($result)); - $this->assertEquals(2, count($result[0])); - $this->assertEquals(2, $result[0]['product_id']); - $this->assertFalse(isset($result[0][0])); - } - - public function testStatementFetchAllStyleBoth() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(Zend_Db::FETCH_BOTH); - - $this->assertEquals(2, count($result)); - $this->assertEquals(4, count($result[0])); - $this->assertEquals(2, $result[0][0]); - $this->assertEquals('Linux', $result[0][1]); - $this->assertEquals(2, $result[0]['product_id']); - $this->assertEquals('Linux', $result[0]['product_name']); - } - - public function testStatementFetchAllStyleObj() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(Zend_Db::FETCH_OBJ); - - $this->assertEquals(2, count($result)); - $this->assertType('stdClass', $result[0]); - $this->assertEquals(2, $result[0]->product_id); - } - - public function testStatementFetchAllStyleColumn() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(Zend_Db::FETCH_COLUMN); - - $this->assertEquals(2, count($result)); - $this->assertEquals(2, $result[0]); - $this->assertEquals(3, $result[1]); - } - - public function testStatementFetchAllStyleColumnWithArg() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchAll(Zend_Db::FETCH_COLUMN, 1); - - $this->assertEquals(2, count($result)); - $this->assertType('string', $result[0]); - $this->assertEquals('Linux', $result[0]); - $this->assertEquals('OS X', $result[1]); - } - - public function testStatementFetchAllStyleException() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - try { - $result = $stmt->fetchAll(-99); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - $stmt->closeCursor(); - } - - public function testStatementFetchColumn() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - - $result = $stmt->fetchColumn(); - $this->assertEquals(2, $result); - $result = $stmt->fetchColumn(); - $this->assertEquals(3, $result); - - $stmt->closeCursor(); - } - - public function testStatementFetchColumnEmptyResult() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - // query that is known to return zero rows - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id < 1 ORDER BY $product_id ASC"); - - $result = $stmt->fetchColumn(); - $stmt->closeCursor(); - - $this->assertFalse($result); - } - - public function testStatementFetchColumnWithArg() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - - $result = $stmt->fetchColumn(1); - $this->assertEquals('Linux', $result); - $result = $stmt->fetchColumn(1); - $this->assertEquals('OS X', $result); - - $stmt->closeCursor(); - } - - public function testStatementFetchObject() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchObject(); - $stmt->closeCursor(); - - $this->assertType('stdClass', $result, - 'Expecting object of type stdClass, got '.get_class($result)); - $this->assertEquals('Linux', $result->product_name); - } - - public function testStatementFetchObjectEmptyResult() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - // query that is known to return zero rows - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id < 1 ORDER BY $product_id ASC"); - $result = $stmt->fetchObject(); - $stmt->closeCursor(); - - $this->assertFalse($result); - } - - public function testStatementFetchStyleNum() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetch(Zend_Db::FETCH_NUM); - $stmt->closeCursor(); - - $this->assertType('array', $result); - $this->assertEquals('Linux', $result[1]); - $this->assertFalse(isset($result['product_name'])); - } - - public function testStatementFetchStyleAssoc() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetch(Zend_Db::FETCH_ASSOC); - $stmt->closeCursor(); - - $this->assertType('array', $result); - $this->assertEquals('Linux', $result['product_name']); - $this->assertFalse(isset($result[1])); - } - - public function testStatementFetchStyleBoth() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetch(Zend_Db::FETCH_BOTH); - $stmt->closeCursor(); - - $this->assertType('array', $result); - $this->assertEquals('Linux', $result[1]); - $this->assertEquals('Linux', $result['product_name']); - } - - public function testStatementFetchStyleObj() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - $result = $stmt->fetch(Zend_Db::FETCH_OBJ); - $stmt->closeCursor(); - - $this->assertType('stdClass', $result, - 'Expecting object of type stdClass, got '.get_class($result)); - $this->assertEquals('Linux', $result->product_name); - } - - public function testStatementFetchStyleException() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - try { - $result = $stmt->fetch(-99); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - } - $stmt->closeCursor(); - } - - public function testStatementBindParamByPosition() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (?, ?)"); - $this->assertTrue($stmt->bindParam(1, $productIdValue), 'Expected bindParam(1) to return true'); - $this->assertTrue($stmt->bindParam(2, $productNameValue), 'Expected bindParam(2) to return true'); - - // we should be able to set the values after binding them - $productIdValue = 4; - $productNameValue = 'Solaris'; - - // no params as args to execute() - $this->assertTrue($stmt->execute(), 'Expected execute() to return true'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 4"); - $result = $this->_db->fetchAll($select); - - $this->assertEquals(array(array('product_id' => $productIdValue, 'product_name' => $productNameValue)), $result); - } - - public function testStatementBindParamByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)"); - // test with colon prefix - $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true'); - // test with no colon prefix - $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true'); - - // we should be able to set the values after binding them - $productIdValue = 4; - $productNameValue = 'Solaris'; - - // no params as args to execute() - $this->assertTrue($stmt->execute(), 'Expected execute() to return true'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id = 4"); - $result = $this->_db->fetchAll($select); - $stmt->closeCursor(); - - $this->assertEquals(array(array('product_id' => $productIdValue, 'product_name' => $productNameValue)), $result); - } - - public function testStatementBindValueByPosition() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (?, ?)"); - $this->assertTrue($stmt->bindValue(1, $productIdValue), 'Expected bindValue(1) to return true'); - $this->assertTrue($stmt->bindValue(2, $productNameValue), 'Expected bindValue(2) to return true'); - - // we should be able to change the values without changing what gets inserted - $productIdValue = 5; - $productNameValue = 'Solaris'; - - // no params as args to execute() - $this->assertTrue($stmt->execute(), 'Expected execute() to return true'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id >= 4"); - $result = $this->_db->fetchAll($select); - $stmt->closeCursor(); - - $this->assertEquals(array(array('product_id' => '4', 'product_name' => 'AmigaOS')), $result); - } - - public function testStatementBindValueByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - $product_name = $this->_db->quoteIdentifier('product_name'); - - $productIdValue = 4; - $productNameValue = 'AmigaOS'; - - $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)"); - // test with colon prefix - $this->assertTrue($stmt->bindValue(':id', $productIdValue), 'Expected bindValue(\':id\') to return true'); - // test with no colon prefix - $this->assertTrue($stmt->bindValue('name', $productNameValue), 'Expected bindValue(\'name\') to return true'); - - // we should be able to change the values without changing what gets inserted - $productIdValue = 5; - $productNameValue = 'Solaris'; - - // no params as args to execute() - $this->assertTrue($stmt->execute(), 'Expected execute() to return true'); - - $select = $this->_db->select() - ->from('zfproducts') - ->where("$product_id >= 4"); - $result = $this->_db->fetchAll($select); - $stmt->closeCursor(); - - $this->assertEquals(array(array('product_id' => '4', 'product_name' => 'AmigaOS')), $result); - } - - public function testStatementBindColumnByPosition() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $prodIdValue = -99; - $prodNameValue = 'AmigaOS'; - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - - $this->assertTrue($stmt->bindColumn(1, $prodIdValue), - 'Expected bindColumn(product_id) to return true'); - $this->assertTrue($stmt->bindColumn(2, $prodNameValue), - 'Expected bindColumn(product_name) to return true'); - - $this->assertTrue($stmt->fetch(Zend_Db::FETCH_BOUND), - 'Expected fetch() call 1 to return true'); - $this->assertEquals(2, $prodIdValue); - $this->assertEquals('Linux', $prodNameValue); - - $this->assertTrue($stmt->fetch(Zend_Db::FETCH_BOUND), - 'Expected fetch() call 2 to return true'); - $this->assertEquals(3, $prodIdValue); - $this->assertEquals('OS X', $prodNameValue); - - $stmt->closeCursor(); - } - - public function testStatementBindColumnByName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $prodIdValue = -99; - $prodNameValue = 'AmigaOS'; - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - - $this->assertTrue($stmt->bindColumn('product_id', $prodIdValue), - 'Expected bindColumn(product_id) to return true'); - $this->assertTrue($stmt->bindColumn('product_name', $prodNameValue), - 'Expected bindColumn(product_name) to return true'); - - $this->assertTrue($stmt->fetch(Zend_Db::FETCH_BOUND), - 'Expected fetch() call 1 to return true'); - $this->assertEquals(2, $prodIdValue); - $this->assertEquals('Linux', $prodNameValue); - - $this->assertTrue($stmt->fetch(Zend_Db::FETCH_BOUND), - 'Expected fetch() call 2 to return true'); - $this->assertEquals(3, $prodIdValue); - $this->assertEquals('OS X', $prodNameValue); - - $stmt->closeCursor(); - } - - public function testStatementBindColumnByPositionAndName() - { - $products = $this->_db->quoteIdentifier('zfproducts'); - $product_id = $this->_db->quoteIdentifier('product_id'); - - $prodIdValue = -99; - $prodNameValue = 'AmigaOS'; - - $stmt = $this->_db->query("SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC"); - - $this->assertTrue($stmt->bindColumn(1, $prodIdValue), - 'Expected bindColumn(1) to return true'); - $this->assertTrue($stmt->bindColumn('product_name', $prodNameValue), - 'Expected bindColumn(product_name) to return true'); - - $this->assertTrue($stmt->fetch(Zend_Db::FETCH_BOUND), - 'Expected fetch() call 1 to return true'); - $this->assertEquals(2, $prodIdValue); - $this->assertEquals('Linux', $prodNameValue); - - $this->assertTrue($stmt->fetch(Zend_Db::FETCH_BOUND), - 'Expected fetch() call 2 to return true'); - $this->assertEquals(3, $prodIdValue); - $this->assertEquals('OS X', $prodNameValue); - - $stmt->closeCursor(); - } - - protected $_getColumnMetaKeys = array( - 'native_type', 'flags', 'table', 'name', 'len', 'precision', 'pdo_type' - ); - - public function testStatementGetColumnMeta() - { - $select = $this->_db->select() - ->from('zfbugs'); - $stmt = $this->_db->prepare($select->__toString()); - $stmt->execute(); - for ($i = 0; $i < $stmt->columnCount(); ++$i) { - $meta = $stmt->getColumnMeta($i); - $this->assertType('array', $meta); - foreach ($this->_getColumnMetaKeys as $key) { - if ($key == 'table' && version_compare(PHP_VERSION, '5.2.0', '<')) { - continue; - } - $this->assertContains($key, array_keys($meta)); - } - } - } - - public function testStatementNextRowset() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - try { - $stmt->nextRowset(); - $this->fail('Expected to catch Zend_Db_Statement_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Statement_Exception', $e, - 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e)); - $this->assertEquals('nextRowset() is not implemented', $e->getMessage()); - } - $stmt->closeCursor(); - } - - public function testStatementGetSetAttribute() - { - $select = $this->_db->select() - ->from('zfproducts'); - $stmt = $this->_db->prepare($select->__toString()); - - $value = 'value'; - try { - $stmt->setAttribute(1234, $value); - } catch (Zend_Exception $e) { - $this->assertContains('This driver doesn\'t support setting attributes', $e->getMessage()); - } - - try { - $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #1"); - } catch (Zend_Exception $e) { - $this->assertContains('This driver doesn\'t support getting attributes', $e->getMessage()); - return; - } - - $valueArray = array('value1', 'value2'); - $stmt->setAttribute(1235, $valueArray); - $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #1"); - $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2"); - - $valueObject = new stdClass(); - $stmt->setAttribute(1236, $valueObject); - $this->assertSame($valueObject, $stmt->getAttribute(1236), "Expected object"); - $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #2"); - $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2"); - } - -} diff --git a/tests/Zend/Db/Table/Db2Test.php b/tests/Zend/Db/Table/Db2Test.php deleted file mode 100644 index c676f3f3df7c666a0879d25aefe289e63cedab21..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Db2Test.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Db2Test extends Zend_Db_Table_TestCommon -{ - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Table/MysqliTest.php b/tests/Zend/Db/Table/MysqliTest.php deleted file mode 100644 index c7bbaca63fbb12733925d960b336e5d4c3fbff79..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/MysqliTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_MysqliTest extends Zend_Db_Table_TestCommon -{ - - public function testTableInsertSequence() - { - $this->markTestSkipped($this->getDriver().' does not support sequences.'); - } - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Table/OdbcTest.php b/tests/Zend/Db/Table/OdbcTest.php deleted file mode 100644 index 6bd2506379eaafff1829603206990701ae14d941..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_OdbcTest extends Zend_Db_Table_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Table/OracleTest.php b/tests/Zend/Db/Table/OracleTest.php deleted file mode 100644 index 6e22df9998ce8b1d04d857d0a875c43908ccf12b..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/OracleTest.php +++ /dev/null @@ -1,61 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_OracleTest extends Zend_Db_Table_TestCommon -{ - - public function testTableInsert() - { - $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.'); - } - - public function testTableInsertSequence() - { - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq')); - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => new Zend_Db_Expr( - $this->_db->quoteInto('DATE ?', '2007-04-02')), - 'updated_on' => new Zend_Db_Expr( - $this->_db->quoteInto('DATE ?', '2007-04-02')), - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId('zfbugs'); - $lastSequenceId = $this->_db->lastSequenceId('zfbugs_seq'); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals($insertResult, $lastSequenceId); - $this->assertEquals(5, $insertResult); - } - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Table/Pdo/IbmTest.php b/tests/Zend/Db/Table/Pdo/IbmTest.php deleted file mode 100644 index 2d3e4e4bd8e639006e9fe7db0141f79b45d62881..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Pdo/IbmTest.php +++ /dev/null @@ -1,47 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Db_Table_TestCommon - */ -require_once 'Zend/Db/Table/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Pdo_IbmTest extends Zend_Db_Table_TestCommon -{ - public function getDriver() - { - return 'Pdo_Ibm'; - } -} \ No newline at end of file diff --git a/tests/Zend/Db/Table/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Pdo/MssqlTest.php deleted file mode 100644 index dbcd7feb0efe06fe31d72e8a1bc865ad9e2e2bad..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Pdo/MssqlTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Pdo_MssqlTest extends Zend_Db_Table_TestCommon -{ - - public function testTableInsertSequence() - { - $this->markTestSkipped($this->getDriver().' does not support sequences.'); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Table/Pdo/MysqlTest.php b/tests/Zend/Db/Table/Pdo/MysqlTest.php deleted file mode 100644 index 344bb6e351f826cfe1498d585993beb3dbeaf477..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Pdo/MysqlTest.php +++ /dev/null @@ -1,54 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqlTest.php 4681 2007-05-03 01:31:22Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_TestCommon - */ -require_once 'Zend/Db/Table/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Pdo_MysqlTest extends Zend_Db_Table_TestCommon -{ - - public function testTableInsertSequence() - { - $this->markTestSkipped($this->getDriver().' does not support sequences.'); - } - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Table/Pdo/OciTest.php b/tests/Zend/Db/Table/Pdo/OciTest.php deleted file mode 100644 index 6feaea2f268b5ef51ee11bdd22a79542d0286d78..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Pdo/OciTest.php +++ /dev/null @@ -1,61 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Pdo_OciTest extends Zend_Db_Table_TestCommon -{ - - public function testTableInsert() - { - $this->markTestSkipped($this->getDriver().' does not support auto-increment keys.'); - } - - public function testTableInsertSequence() - { - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq')); - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => new Zend_Db_Expr( - $this->_db->quoteInto('DATE ?', '2007-04-02')), - 'updated_on' => new Zend_Db_Expr( - $this->_db->quoteInto('DATE ?', '2007-04-02')), - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId('zfbugs'); - $lastSequenceId = $this->_db->lastSequenceId('zfbugs_seq'); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals($insertResult, $lastSequenceId); - $this->assertEquals(5, $insertResult); - } - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Table/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Pdo/PgsqlTest.php deleted file mode 100644 index f7241c372cc199a12321f479c274bdaffa94f6b3..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Pdo/PgsqlTest.php +++ /dev/null @@ -1,211 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PgsqlTest.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_TestCommon - */ -require_once 'Zend/Db/Table/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Pdo_PgsqlTest extends Zend_Db_Table_TestCommon -{ - public function getDriver() - { - return 'Pdo_Pgsql'; - } - - public function testTableInsert() - { - $table = $this->_table['bugs']; - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id'); - $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq'); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals($insertResult, $lastSequenceId); - $this->assertEquals(5, $lastInsertId); - } - - public function testTableInsertPkNull() - { - $table = $this->_table['bugs']; - $row = array ( - 'bug_id' => null, - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id'); - $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq'); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals($insertResult, $lastSequenceId); - $this->assertEquals(5, $lastInsertId); - } - - public function testTableInsertSequence() - { - $table = $this->_getTable('Zend_Db_Table_TableProducts', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfproducts_seq')); - $row = array ( - 'product_name' => 'Solaris' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId('zfproducts'); - $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq'); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals($insertResult, $lastSequenceId); - $this->assertEquals(4, $insertResult); - } - - /** - * Ensures that the schema is null if not specified - * - * @return void - */ - public function testTableSchemaNotSetIsNull() - { - $tableInfo = $this->_table['bugs']->info(); - - $this->assertNull($tableInfo['schema']); - } - - /** - * Ensures that the schema is set by the 'schema' constructor configuration directive - * - * @return void - */ - public function testTableSchemaSetByConstructorConfigSchema() - { - $schema = 'public'; - - $config = array( - 'db' => $this->_db, - 'schema' => $schema - ); - - $table = new Zend_Db_Table_TableBugs($config); - - $tableInfo = $table->info(); - - $this->assertEquals($schema, $tableInfo['schema']); - } - - /** - * Ensures that the schema is set by the 'name' constructor configuration directive - * - * @return void - */ - public function testTableSchemaSetByConstructorConfigName() - { - $schema = 'public'; - - $tableName = "$schema.zfbugs"; - - $config = array( - 'db' => $this->_db, - 'name' => $tableName - ); - - $table = new Zend_Db_Table_TableBugs($config); - - $tableInfo = $table->info(); - - $this->assertEquals($schema, $tableInfo['schema']); - } - - /** - * Ensures that a schema given in the 'name' constructor configuration directive overrides any schema specified - * by the 'schema' constructor configuration directive. - * - * @return void - */ - public function testTableSchemaConstructorConfigNameOverridesSchema() - { - $schema = 'public'; - - $tableName = "$schema.zfbugs"; - - $config = array( - 'db' => $this->_db, - 'schema' => 'foo', - 'name' => $tableName - ); - - $table = new Zend_Db_Table_TableBugs($config); - - $tableInfo = $table->info(); - - $this->assertEquals($schema, $tableInfo['schema']); - } - - /** - * Ensures that fetchAll() provides expected behavior when the schema is specified - * - * @return void - */ - public function testTableFetchAllSchemaSet() - { - $schema = 'public'; - - $config = array( - 'db' => $this->_db, - 'schema' => $schema, - ); - - $table = new Zend_Db_Table_TableBugs($config); - - $rowset = $table->fetchAll(); - - $this->assertThat( - $rowset, - $this->isInstanceOf('Zend_Db_Table_Rowset') - ); - - $this->assertEquals( - 4, - count($rowset) - ); - } -} diff --git a/tests/Zend/Db/Table/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Pdo/SqliteTest.php deleted file mode 100644 index 6973444cc544349c3e5fac84982fddb6dfc15fdb..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Pdo/SqliteTest.php +++ /dev/null @@ -1,59 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SqliteTest.php 5097 2007-06-04 16:06:43Z darby $ - */ - - -/** - * @see Zend_Db_Table_TestCommon - */ -require_once 'Zend/Db/Table/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Pdo_SqliteTest extends Zend_Db_Table_TestCommon -{ - - public function testTableInsertSequence() - { - $this->markTestSkipped($this->getDriver().' does not support sequences.'); - } - - public function testDbTableSchemaSpecified() - { - $this->markTestSkipped($this->getDriver() . ' does not support qualified table names'); - } - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/Db2Test.php b/tests/Zend/Db/Table/Relationships/Db2Test.php deleted file mode 100644 index 4587408ee2308bcefed9a425fcf9a3e3c39f7487..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Db2Test.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Relationships_Db2Test extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/MysqliTest.php b/tests/Zend/Db/Table/Relationships/MysqliTest.php deleted file mode 100644 index 42c626debfc115339fb50e756de84882b614a883..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/MysqliTest.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqliTest.php 4527 2007-04-17 22:49:14Z darby $ - */ - - -/** - * @see Zend_Db_Table_Relationships_TestCommon - */ -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Relationships_MysqliTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/OdbcTest.php b/tests/Zend/Db/Table/Relationships/OdbcTest.php deleted file mode 100644 index 4eb5a04f4dcc358b54f169e7f057144910ebb8be..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Relationships_OdbcTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/OracleTest.php b/tests/Zend/Db/Table/Relationships/OracleTest.php deleted file mode 100644 index 6e02fb512475c863658fa34538f47678924eb5cd..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/OracleTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Relationships_OracleTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/Pdo/IbmTest.php b/tests/Zend/Db/Table/Relationships/Pdo/IbmTest.php deleted file mode 100644 index dda4780b1c7716b77bdcaf9a4785007e1a4c9aa1..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Pdo/IbmTest.php +++ /dev/null @@ -1,59 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Db_Table_Relationships_TestCommon - */ -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Relationships_Pdo_IbmTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Ibm'; - } - - public function testTableRelationshipCascadingUpdateUsageBasicString() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestSkipped('IDS serial columns cannot be updated'); - } else { - parent::testTableRelationshipCascadingUpdateUsageBasicString(); - } - } -} diff --git a/tests/Zend/Db/Table/Relationships/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Relationships/Pdo/MssqlTest.php deleted file mode 100644 index 6490aab4c7c80ea0ba21b7f6c354a08d432e9b91..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Pdo/MssqlTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Relationships_Pdo_MssqlTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function testTableRelationshipCascadingUpdateUsageBasicString() - { - $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.'); - } - - public function testTableRelationshipCascadingUpdateUsageInvalidNoop() - { - $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.'); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/Pdo/MysqlTest.php b/tests/Zend/Db/Table/Relationships/Pdo/MysqlTest.php deleted file mode 100644 index 6d15f53882d2bab382fdfeed5a53b5cb77d14e5e..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Pdo/MysqlTest.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqlTest.php 4778 2007-05-11 18:25:32Z darby $ - */ - - -/** - * @see Zend_Db_Table_Relationships_TestCommon - */ -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Relationships_Pdo_MysqlTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/Pdo/OciTest.php b/tests/Zend/Db/Table/Relationships/Pdo/OciTest.php deleted file mode 100644 index 43cb1b3f85202c62a1de46f0298d9ea7b435363d..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Pdo/OciTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Relationships_Pdo_OciTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Relationships/Pdo/PgsqlTest.php deleted file mode 100644 index 8da52d8897622171f25c097c8cfdd56228b6164f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Pdo/PgsqlTest.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PgsqlTest.php 4969 2007-05-25 19:16:50Z darby $ - */ - - -/** - * @see Zend_Db_Table_Relationships_TestCommon - */ -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Relationships_Pdo_PgsqlTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Pgsql'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Relationships/Pdo/SqliteTest.php deleted file mode 100644 index 83c57a6eaf6ba3af2a4667d979a7ad8af95b792f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/Pdo/SqliteTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Relationships/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Relationships_Pdo_SqliteTest extends Zend_Db_Table_Relationships_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/StaticTest.php b/tests/Zend/Db/Table/Relationships/StaticTest.php deleted file mode 100644 index 283533f9b3a8a953d2d813c4c24ab3a4ddc9c770..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/StaticTest.php +++ /dev/null @@ -1,117 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 5484 2007-06-28 21:38:50Z bkarwin $ - */ - - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Db_Table_Row_TestMockRow - */ -require_once 'Zend/Db/Table/Row/TestMockRow.php'; - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Relationships_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testTableRelationshipsFindDependentMagic() - { - $row = new Zend_Db_Table_Row_TestMockRow(); - - $this->assertNull($row->dependentTable); - $this->assertNull($row->ruleKey); - - $row->findTable1(); - $this->assertEquals('Table1', $row->dependentTable); - $this->assertNull($row->ruleKey); - - $row->findTable2ByRule1(); - $this->assertEquals('Table2', $row->dependentTable); - $this->assertEquals('Rule1', $row->ruleKey); - } - - public function testTableRelationshipsFindParentMagic() - { - $row = new Zend_Db_Table_Row_TestMockRow(); - - $this->assertNull($row->parentTable); - $this->assertNull($row->ruleKey); - - $row->findParentTable1(); - $this->assertEquals('Table1', $row->parentTable); - $this->assertNull($row->ruleKey); - - $row->findParentTable2ByRule1(); - $this->assertEquals('Table2', $row->parentTable); - $this->assertEquals('Rule1', $row->ruleKey); - } - - public function testTableRelationshipsFindManyToManyMagic() - { - $row = new Zend_Db_Table_Row_TestMockRow(); - - $this->assertNull($row->matchTable); - $this->assertNull($row->intersectionTable); - $this->assertNull($row->callerRefRuleKey); - $this->assertNull($row->matchRefRuleKey); - - $row->findTable1ViaTable2(); - $this->assertEquals('Table1', $row->matchTable); - $this->assertEquals('Table2', $row->intersectionTable); - $this->assertNull($row->callerRefRuleKey); - $this->assertNull($row->matchRefRuleKey); - - $row->findTable3ViaTable4ByRule1(); - $this->assertEquals('Table3', $row->matchTable); - $this->assertEquals('Table4', $row->intersectionTable); - $this->assertEquals('Rule1', $row->callerRefRuleKey); - $this->assertNull($row->matchRefRuleKey); - - $row->findTable5ViaTable6ByRule2AndRule3(); - $this->assertEquals('Table5', $row->matchTable); - $this->assertEquals('Table6', $row->intersectionTable); - $this->assertEquals('Rule2', $row->callerRefRuleKey); - $this->assertEquals('Rule3', $row->matchRefRuleKey); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Table/Relationships/TestCommon.php b/tests/Zend/Db/Table/Relationships/TestCommon.php deleted file mode 100644 index 9cd4cbbcbfefd2f232a02cbce9c899f71d8f606a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Relationships/TestCommon.php +++ /dev/null @@ -1,1121 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 7530 2008-01-20 13:38:14Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_TestSetup - */ -require_once 'Zend/Db/Table/TestSetup.php'; - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Table_Relationships_TestCommon extends Zend_Db_Table_TestSetup -{ - - public function testTableRelationshipFindParentRow() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $account_name = $this->_db->foldCase('account_name'); - - $table = $this->_table['bugs']; - - $childRows = $table->fetchAll("$bug_id = 1"); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $parentRow = $childRow1->findParentRow('Zend_Db_Table_TableAccounts'); - $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow)); - - $this->assertEquals('goofy', $parentRow->$account_name); - } - - public function testTableRelationshipFindParentRowSelect() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $account_name = $this->_db->foldCase('account_name'); - - $table = $this->_table['bugs']; - $select = $table->select()->where('account_name = ?', 'goofy'); - - $childRows = $table->fetchAll("$bug_id = 1"); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $parentRow = $childRow1->findParentRow('Zend_Db_Table_TableAccounts', null, $select); - $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow)); - - $this->assertEquals('goofy', $parentRow->$account_name); - } - - public function testTableRelationshipMagicFindParentRow() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $account_name = $this->_db->foldCase('account_name'); - - $table = $this->_table['bugs']; - - $childRows = $table->fetchAll("$bug_id = 1"); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $parentRow = $childRow1->findParentZend_Db_Table_TableAccounts(); - $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow)); - - $this->assertEquals('goofy', $parentRow->$account_name); - } - - public function testTableRelationshipMagicFindParentRowSelect() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $account_name = $this->_db->foldCase('account_name'); - - $table = $this->_table['bugs']; - $select = $table->select()->where('account_name = ?', 'goofy'); - - $childRows = $table->fetchAll("$bug_id = 1"); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $parentRow = $childRow1->findParentZend_Db_Table_TableAccounts($select); - $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow)); - - $this->assertEquals('goofy', $parentRow->$account_name); - } - - public function testTableRelationshipMagicException() - { - $table = $this->_table['bugs']; - - $parentRows = $table->find(1); - $parentRow1 = $parentRows->current(); - - // Completely bogus method - try { - $result = $parentRow1->nonExistantMethod(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals("Unrecognized method 'nonExistantMethod()'", $e->getMessage()); - } - } - - public function testTableRelationshipFindParentRowException() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $childRows = $table->fetchAll("$bug_id = 1"); - $childRow1 = $childRows->current(); - - try { - $parentRow = $childRow1->findParentRow('nonexistant_class'); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for nonexistent table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('File "nonexistant' . DIRECTORY_SEPARATOR . 'class.php" does not exist or class "nonexistant_class" was not found in the file', $e->getMessage()); - } - - try { - $parentRow = $childRow1->findParentRow(new stdClass()); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for wrong table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('Parent table must be a Zend_Db_Table_Abstract, but it is stdClass', $e->getMessage()); - } - } - - public function testTableRelationshipFindManyToManyRowset() - { - $table = $this->_table['bugs']; - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableProducts', 'Zend_Db_Table_TableBugsProducts'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows)); - - $this->assertEquals(3, $destRows->count()); - } - - public function testTableRelationshipFindManyToManyRowsetSelect() - { - $product_name = $this->_db->foldCase('product_name'); - $bug_id = $this->_db->foldCase('bug_id'); - - $table = $this->_table['bugs']; - $select = $table->select()->where($bug_id . ' = ?', 1) - ->limit(2) - ->order($product_name . ' ASC'); - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableProducts', 'Zend_Db_Table_TableBugsProducts', - null, null, $select); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows)); - - $this->assertEquals(2, $destRows->count()); - - $childRow = $destRows->current(); - $this->assertEquals('Linux', $childRow->$product_name); - } - - public function testTableRelationshipMagicFindManyToManyRowset() - { - $table = $this->_table['bugs']; - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - $destRows = $originRow1->findZend_Db_Table_TableProductsViaZend_Db_Table_TableBugsProducts(); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows)); - - $this->assertEquals(3, $destRows->count()); - } - - public function testTableRelationshipMagicFindManyToManyRowsetSelect() - { - $product_name = $this->_db->foldCase('product_name'); - $bug_id = $this->_db->foldCase('bug_id'); - - $table = $this->_table['bugs']; - $select = $table->select()->where($bug_id . ' = ?', 1) - ->limit(2) - ->order($product_name . ' ASC'); - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - $destRows = $originRow1->findZend_Db_Table_TableProductsViaZend_Db_Table_TableBugsProducts($select); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows)); - - $this->assertEquals(2, $destRows->count()); - - $childRow = $destRows->current(); - $this->assertEquals('Linux', $childRow->$product_name); - } - - public function testTableRelationshipFindManyToManyRowsetException() - { - $table = $this->_table['bugs']; - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - // Use nonexistant class for destination table - try { - $destRows = $originRow1->findManyToManyRowset('nonexistant_class', 'Zend_Db_Table_TableBugsProducts'); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for nonexistent table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('File "nonexistant' . DIRECTORY_SEPARATOR . 'class.php" does not exist or class "nonexistant_class" was not found in the file', $e->getMessage()); - } - - // Use stdClass instead of table class for destination table - try { - $destRows = $originRow1->findManyToManyRowset(new stdClass(), 'Zend_Db_Table_TableBugsProducts'); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for nonexistent table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('Match table must be a Zend_Db_Table_Abstract, but it is stdClass', $e->getMessage()); - } - - // Use nonexistant class for intersection table - try { - $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableProducts', 'nonexistant_class'); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for nonexistent table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('File "nonexistant' . DIRECTORY_SEPARATOR . 'class.php" does not exist or class "nonexistant_class" was not found in the file', $e->getMessage()); - } - - // Use stdClass instead of table class for intersection table - try { - $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableProducts', new stdClass()); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for nonexistent table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('Intersection table must be a Zend_Db_Table_Abstract, but it is stdClass', $e->getMessage()); - } - - } - - public function testTableRelationshipFindDependentRowset() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - $product_id = $this->_db->foldCase('product_id'); - - $parentRows = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $parentRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($parentRows)); - $parentRow1 = $parentRows->current(); - - $childRows = $parentRow1->findDependentRowset('Zend_Db_Table_TableBugsProducts'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $this->assertEquals(3, $childRows->count()); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $this->assertEquals(1, $childRow1->$bug_id); - $this->assertEquals(1, $childRow1->$product_id); - } - - public function testTableRelationshipFindDependentRowsetSelect() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - $product_id = $this->_db->foldCase('product_id'); - - $select = $table->select()->limit(2) - ->order($product_id . ' DESC'); - - $parentRows = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $parentRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($parentRows)); - $parentRow1 = $parentRows->current(); - - $childRows = $parentRow1->findDependentRowset('Zend_Db_Table_TableBugsProducts', null, $select); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $this->assertEquals(1, $childRow1->$bug_id); - $this->assertEquals(3, $childRow1->$product_id); - } - - public function testTableRelationshipMagicFindDependentRowset() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - $product_id = $this->_db->foldCase('product_id'); - - $parentRows = $table->find(1); - $parentRow1 = $parentRows->current(); - - $childRows = $parentRow1->findZend_Db_Table_TableBugsProducts(); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $this->assertEquals(3, $childRows->count()); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $this->assertEquals(1, $childRow1->$bug_id); - $this->assertEquals(1, $childRow1->$product_id); - } - - public function testTableRelationshipMagicFindDependentRowsetSelect() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - $product_id = $this->_db->foldCase('product_id'); - $select = $table->select()->limit(2) - ->order($product_id . ' DESC'); - - $parentRows = $table->find(1); - $parentRow1 = $parentRows->current(); - - $childRows = $parentRow1->findZend_Db_Table_TableBugsProducts($select); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $this->assertEquals(2, $childRows->count()); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $this->assertEquals(1, $childRow1->$bug_id); - $this->assertEquals(3, $childRow1->$product_id); - } - - public function testTableRelationshipFindDependentRowsetException() - { - $table = $this->_table['bugs']; - - $parentRows = $table->find(1); - $parentRow1 = $parentRows->current(); - - try { - $childRows = $parentRow1->findDependentRowset('nonexistant_class'); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for nonexistent table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('File "nonexistant' . DIRECTORY_SEPARATOR . 'class.php" does not exist or class "nonexistant_class" was not found in the file', $e->getMessage()); - } - - try { - $childRows = $parentRow1->findDependentRowset(new stdClass()); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for wrong table class'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('Dependent table must be a Zend_Db_Table_Abstract, but it is stdClass', $e->getMessage()); - } - } - - /** - * Ensures that basic cascading update functionality succeeds using strings for single columns - * - * @return void - */ - public function testTableRelationshipCascadingUpdateUsageBasicString() - { - $bug = $this->_getTable('Zend_Db_Table_TableBugsCustom') - ->find(1) - ->current(); - $bug_id = $this->_db->foldCase('bug_id'); - - $this->assertEquals( - 3, - count($bugProducts = $bug->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find three dependent rows' - ); - - $bug->$bug_id = 333; - - $bug->save(); - - $this->assertEquals( - 3, - count($bugProducts = $bug->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find three dependent rows' - ); - - foreach ($bugProducts as $bugProduct) { - $this->assertEquals(333, $bugProduct->$bug_id); - } - - $bug->$bug_id = 1; - - $bug->save(); - - $this->assertEquals( - 3, - count($bugProducts = $bug->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find three dependent rows' - ); - - foreach ($bugProducts as $bugProduct) { - $this->assertEquals(1, $bugProduct->$bug_id); - } - } - - /** - * Ensures that basic cascading update functionality succeeds using arrays for single columns - * - * @return void - */ - public function testTableRelationshipCascadingUpdateUsageBasicArray() - { - $account1 = $this->_getTable('Zend_Db_Table_TableAccountsCustom') - ->find('mmouse') - ->current(); - $account_name = $this->_db->foldCase('account_name'); - $reported_by = $this->_db->foldCase('reported_by'); - - $this->assertEquals( - 1, - count($account1->findDependentRowset('Zend_Db_Table_TableBugsCustom')), - 'Expecting to find one dependent row' - ); - - $account1->$account_name = 'daisy'; - - $account1->save(); - - $this->assertEquals( - 1, - count($account1Bugs = $account1->findDependentRowset('Zend_Db_Table_TableBugsCustom')), - 'Expecting to find one dependent row' - ); - - foreach ($account1Bugs as $account1Bug) { - $this->assertEquals('daisy', $account1Bug->$reported_by); - } - - $account1->$account_name = 'mmouse'; - - $account1->save(); - - $this->assertEquals( - 1, - count($account1Bugs = $account1->findDependentRowset('Zend_Db_Table_TableBugsCustom')), - 'Expecting to find one dependent row' - ); - - foreach ($account1Bugs as $account1Bug) { - $this->assertEquals('mmouse', $account1Bug->$reported_by); - } - } - - /** - * Ensures that cascading update functionality is not run when onUpdate != self::CASCADE - * - * @return void - */ - public function testTableRelationshipCascadingUpdateUsageInvalidNoop() - { - $product1 = $this->_getTable('Zend_Db_Table_TableProductsCustom') - ->find(1) - ->current(); - - $this->assertEquals( - 1, - count($product1->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find one dependent row' - ); - - $product_id = $this->_db->foldCase('product_id'); - $product1->$product_id = 333; - - $product1->save(); - - $this->assertEquals( - 0, - count($product1BugsProducts = $product1->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find one dependent row' - ); - - $product1->$product_id = 1; - - $product1->save(); - - $this->assertEquals( - 1, - count($product1BugsProducts = $product1->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find one dependent row' - ); - - foreach ($product1BugsProducts as $product1BugsProduct) { - $this->assertEquals(1, $product1BugsProduct->$product_id); - } - } - - /** - * Ensures that basic cascading delete functionality succeeds using strings for single columns - * - * @return void - */ - public function testTableRelationshipCascadingDeleteUsageBasicString() - { - $bug1 = $this->_getTable('Zend_Db_Table_TableBugsCustom') - ->find(1) - ->current(); - - $this->assertEquals( - 3, - count($bug1->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find three dependent rows' - ); - - $bug1->delete(); - - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $this->assertEquals( - 0, - count($this->_getTable('Zend_Db_Table_TableBugsProductsCustom')->fetchAll("$bug_id = 1")), - 'Expecting cascading delete to have reduced dependent rows to zero' - ); - } - - /** - * Ensures that basic cascading delete functionality succeeds using arrays for single columns - * - * @return void - */ - public function testTableRelationshipCascadingDeleteUsageBasicArray() - { - $reported_by = $this->_db->quoteIdentifier('reported_by', true); - - $account1 = $this->_getTable('Zend_Db_Table_TableAccountsCustom') - ->find('mmouse') - ->current(); - - $this->assertEquals( - 1, - count($account1->findDependentRowset('Zend_Db_Table_TableBugsCustom')), - 'Expecting to find one dependent row' - ); - - $account1->delete(); - - $tableBugsCustom = $this->_getTable('Zend_Db_Table_TableBugsCustom'); - - $this->assertEquals( - 0, - count( - $tableBugsCustom->fetchAll( - $tableBugsCustom->getAdapter() - ->quoteInto("$reported_by = ?", 'mmouse') - ) - ), - 'Expecting cascading delete to have reduced dependent rows to zero' - ); - } - - /** - * Ensures that cascading delete functionality is not run when onDelete != self::CASCADE - * - * @return void - */ - public function testTableRelationshipCascadingDeleteUsageInvalidNoop() - { - $product1 = $this->_getTable('Zend_Db_Table_TableProductsCustom') - ->find(1) - ->current(); - - $this->assertEquals( - 1, - count($product1->findDependentRowset('Zend_Db_Table_TableBugsProductsCustom')), - 'Expecting to find one dependent row' - ); - - $product1->delete(); - - $product_id = $this->_db->quoteIdentifier('product_id', true); - - $this->assertEquals( - 1, - count($this->_getTable('Zend_Db_Table_TableBugsProductsCustom')->fetchAll("$product_id = 1")), - 'Expecting to find one dependent row' - ); - } - - public function testTableRelationshipGetReference() - { - $table = $this->_table['bugs']; - - $map = $table->getReference('Zend_Db_Table_TableAccounts', 'Reporter'); - - $this->assertThat($map, $this->arrayHasKey('columns')); - $this->assertThat($map, $this->arrayHasKey('refTableClass')); - $this->assertThat($map, $this->arrayHasKey('refColumns')); - } - - public function testTableRelationshipGetReferenceException() - { - $table = $this->_table['bugs']; - - try { - $table->getReference('Zend_Db_Table_TableAccounts', 'Nonexistent'); - $this->fail('Expected to catch Zend_Db_Table_Exception for nonexistent reference rule'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - } - - try { - $table->getReference('Nonexistent', 'Reporter'); - $this->fail('Expected to catch Zend_Db_Table_Exception for nonexistent rule tableClass'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - } - - try { - $table->getReference('Nonexistent'); - $this->fail('Expected to catch Zend_Db_Table_Exception for nonexistent rule tableClass'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - } - } - - /** - * Ensures that findParentRow() returns an instance of a custom row class when passed an instance - * of the table class having $_rowClass overridden. - * - * @return void - */ - public function testTableRelationshipFindParentRowCustomInstance() - { - $myRowClass = 'Zend_Db_Table_Row_TestMyRow'; - - Zend_Loader::loadClass($myRowClass); - - $bug1Reporter = $this->_table['bugs'] - ->find(1) - ->current() - ->findParentRow($this->_table['accounts']->setRowClass($myRowClass)); - - $this->assertType($myRowClass, $bug1Reporter, - "Expecting object of type $myRowClass, got ".get_class($bug1Reporter)); - } - - /** - * Ensures that findParentRow() returns an instance of a custom row class when passed a string class - * name, where the class has $_rowClass overridden. - * - * @return void - */ - public function testTableRelationshipFindParentRowCustomClass() - { - $myRowClass = 'Zend_Db_Table_Row_TestMyRow'; - - Zend_Loader::loadClass($myRowClass); - - Zend_Loader::loadClass('Zend_Db_Table_TableAccountsCustom'); - - $bug1Reporter = $this->_getTable('Zend_Db_Table_TableBugsCustom') - ->find(1) - ->current() - ->findParentRow(new Zend_Db_Table_TableAccountsCustom(array('db' => $this->_db))); - - $this->assertType($myRowClass, $bug1Reporter, - "Expecting object of type $myRowClass, got ".get_class($bug1Reporter)); - } - - /** - * Ensures that findDependentRowset() returns instances of custom row and rowset classes when - * passed an instance of the table class. - * - * @return void - */ - public function testTableRelationshipFindDependentRowsetCustomInstance() - { - $myRowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - $myRowClass = 'Zend_Db_Table_Row_TestMyRow'; - - Zend_Loader::loadClass($myRowsetClass); - - $account_name = $this->_db->quoteIdentifier('account_name', true); - - $bugs = $this->_table['accounts'] - ->fetchRow($this->_db->quoteInto("$account_name = ?", 'mmouse')) - ->findDependentRowset( - $this->_table['bugs'] - ->setRowsetClass($myRowsetClass) - ->setRowClass($myRowClass), - 'Engineer' - ); - - $this->assertType($myRowsetClass, $bugs, - "Expecting object of type $myRowsetClass, got ".get_class($bugs)); - - $this->assertEquals(3, count($bugs)); - - foreach ($bugs as $bug) { - $this->assertType($myRowClass, $bug, - "Expecting object of type $myRowClass, got ".get_class($bug)); - } - } - - /** - * Ensures that findDependentRowset() returns instances of custom row and rowset classes when - * passed the named class. - * - * @return void - */ - public function testTableRelationshipFindDependentRowsetCustomClass() - { - $myRowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - $myRowClass = 'Zend_Db_Table_Row_TestMyRow'; - - Zend_Loader::loadClass($myRowsetClass); - - $account_name = $this->_db->quoteIdentifier('account_name', true); - - $bugs = $this->_getTable('Zend_Db_Table_TableAccountsCustom') - ->fetchRow($this->_db->quoteInto("$account_name = ?", 'mmouse')) - ->findDependentRowset('Zend_Db_Table_TableBugsCustom', 'Engineer'); - - $this->assertType($myRowsetClass, $bugs, - "Expecting object of type $myRowsetClass, got ".get_class($bugs)); - - $this->assertEquals(3, count($bugs)); - - foreach ($bugs as $bug) { - $this->assertType($myRowClass, $bug, - "Expecting object of type $myRowClass, got ".get_class($bug)); - } - } - - /** - * Ensures that findManyToManyRowset() returns instances of custom row and rowset class when - * passed an instance of the table class. - * - * @return void - */ - public function testTableRelationshipFindManyToManyRowsetCustomInstance() - { - $myRowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - $myRowClass = 'Zend_Db_Table_Row_TestMyRow'; - - Zend_Loader::loadClass($myRowsetClass); - - $bug1Products = $this->_table['bugs'] - ->find(1) - ->current() - ->findManyToManyRowset( - $this->_table['products'] - ->setRowsetClass($myRowsetClass) - ->setRowClass($myRowClass), - 'Zend_Db_Table_TableBugsProducts' - ); - - $this->assertType($myRowsetClass, $bug1Products, - "Expecting object of type $myRowsetClass, got ".get_class($bug1Products)); - - $this->assertEquals(3, count($bug1Products)); - - foreach ($bug1Products as $bug1Product) { - $this->assertType($myRowClass, $bug1Product, - "Expecting object of type $myRowClass, got ".get_class($bug1Product)); - } - } - - /** - * Ensures that findManyToManyRowset() returns instances of custom row and rowset classes when - * passed the named class. - * - * @return void - */ - public function testTableRelationshipFindManyToManyRowsetCustomClass() - { - $myRowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - $myRowClass = 'Zend_Db_Table_Row_TestMyRow'; - - Zend_Loader::loadClass($myRowsetClass); - - $bug1Products = $this->_getTable('Zend_Db_Table_TableBugsCustom') - ->find(1) - ->current() - ->findManyToManyRowset( - 'Zend_Db_Table_TableProductsCustom', - 'Zend_Db_Table_TableBugsProductsCustom' - ); - - $this->assertType($myRowsetClass, $bug1Products, - "Expecting object of type $myRowsetClass, got ".get_class($bug1Products)); - - $this->assertEquals(3, count($bug1Products)); - - foreach ($bug1Products as $bug1Product) { - $this->assertType($myRowClass, $bug1Product, - "Expecting object of type $myRowClass, got ".get_class($bug1Product)); - } - } - - /** - * Ensures that rows returned by findParentRow() are updatable. - * - * @return void - */ - public function testTableRelationshipFindParentRowIsUpdateable() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $account_name = $this->_db->foldCase('account_name'); - - $table = $this->_table['bugs']; - - $childRows = $table->fetchAll("$bug_id = 1"); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $parentRow = $childRow1->findParentRow('Zend_Db_Table_TableAccounts'); - $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow)); - - $this->assertEquals('goofy', $parentRow->$account_name); - - $parentRow->$account_name = 'clarabell'; - try { - $parentRow->save(); - } catch (Zend_Exception $e) { - $this->fail('Failed with unexpected '.get_class($e).': '.$e->getMessage()); - } - - $accounts = $this->_db->quoteIdentifier('zfaccounts', true); - $account_name = $this->_db->quoteIdentifier('account_name', true); - $accounts_list = $this->_db->fetchCol("SELECT $account_name from $accounts ORDER BY $account_name"); - // if the save() did an UPDATE instead of an INSERT, then goofy should - // be missing, and clarabell should be present - $this->assertEquals(array('clarabell', 'dduck', 'mmouse'), $accounts_list); - } - - /** - * Ensures that rows returned by findDependentRowset() are updatable. - * - * @return void - */ - public function testTableRelationshipFindDependentRowsetIsUpdateable() - { - $table = $this->_table['accounts']; - $bug_id_column = $this->_db->foldCase('bug_id'); - $bug_description = $this->_db->foldCase('bug_description'); - - $parentRows = $table->find('mmouse'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $parentRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($parentRows)); - $parentRow1 = $parentRows->current(); - - $childRows = $parentRow1->findDependentRowset('Zend_Db_Table_TableBugs'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows)); - - $this->assertEquals(1, $childRows->count()); - - $childRow1 = $childRows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1)); - - $childRow1->$bug_description = 'Updated description'; - $bug_id = $childRow1->$bug_id_column; - try { - $childRow1->save(); - } catch (Zend_Exception $e) { - $this->fail('Failed with unexpected '.get_class($e).': '.$e->getMessage()); - } - - // find the row we just updated and make sure it has the new value. - $bugs_table = $this->_table['bugs']; - $bugs_rows = $bugs_table->find($bug_id); - $this->assertEquals(1, $bugs_rows->count()); - $bug1 = $bugs_rows->current(); - $this->assertEquals($bug_id, $bug1->$bug_id_column); - $this->assertEquals('Updated description', $bug1->$bug_description); - } - - /** - * Ensures that rows returned by findManyToManyRowset() are updatable. - * - * @return void - */ - public function testTableRelationshipFindManyToManyRowsetIsUpdateable() - { - $table = $this->_table['bugs']; - $product_id_column = $this->_db->foldCase('product_id'); - $product_name = $this->_db->foldCase('product_name'); - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableProducts', 'Zend_Db_Table_TableBugsProducts'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows)); - - $this->assertEquals(3, $destRows->count()); - - $row1 = $destRows->current(); - $product_id = $row1->$product_id_column; - $row1->$product_name = 'AmigaOS'; - try { - $row1->save(); - } catch (Zend_Exception $e) { - $this->fail('Failed with unexpected '.get_class($e).': '.$e->getMessage()); - } - - // find the row we just updated and make sure it has the new value. - $products_table = $this->_table['products']; - $product_rows = $products_table->find($product_id); - $this->assertEquals(1, $product_rows->count()); - $product_row = $product_rows->current(); - $this->assertEquals($product_id, $product_row->$product_id_column); - $this->assertEquals('AmigaOS', $product_row->$product_name); - } - - public function testTableRelationshipOmitRefColumns() - { - $refMap = array( - 'Reporter' => array( - 'columns' => array('reported_by'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts' - ) - ); - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array( - 'name' => 'zfbugs', - 'referenceMap' => $refMap - ) - ); - - $bug1 = $table->find(1)->current(); - $reporter = $bug1->findParentRow('Zend_Db_Table_TableAccounts'); - $this->assertEquals(array('account_name' => 'goofy'), $reporter->toArray()); - } - - /** - * Create database table based on BUGS_PRODUCTS bug with alternative - * spellings of column names. Then create a Table class for this - * physical table and return it. - */ - protected function _getBugsProductsWithDissimilarColumns() - { - $altCols = array( - 'boog_id' => 'INTEGER NOT NULL', - 'produck_id' => 'INTEGER NOT NULL', - 'PRIMARY KEY' => 'boog_id,produck_id' - ); - $this->_util->createTable('AltBugsProducts', $altCols); - $altBugsProducts = $this->_db->quoteIdentifier($this->_db->foldCase('zfalt_bugs_products'), true); - $bugsProducts = $this->_db->quoteIdentifier($this->_db->foldCase('zfbugs_products'), true); - $this->_db->query("INSERT INTO $altBugsProducts SELECT * FROM $bugsProducts"); - - $refMap = array( - 'Boog' => array( - 'columns' => array('boog_id'), - 'refTableClass' => 'Zend_Db_Table_TableBugs', - 'refColumns' => array('bug_id') - ), - 'Produck' => array( - 'columns' => array('produck_id'), - 'refTableClass' => 'Zend_Db_Table_TableProducts', - 'refColumns' => array('product_id') - ) - ); - $options = array('name' => 'zfalt_bugs_products', 'referenceMap' => $refMap); - $table = $this->_getTable('Zend_Db_Table_TableSpecial', $options); - return $table; - } - - /** - * Test that findParentRow() works even if the column names are - * not the same. - */ - public function testTableRelationshipFindParentRowWithDissimilarColumns() - { - $bug_id = $this->_db->foldCase('bug_id'); - $product_id = $this->_db->foldCase('product_id'); - - $intersectionTable = $this->_getBugsProductsWithDissimilarColumns(); - $intRow = $intersectionTable->find(2, 3)->current(); - - $bugRow = $intRow->findParentRow('Zend_Db_Table_TableBugs'); - $this->assertEquals(2, $bugRow->$bug_id); - - $productRow = $intRow->findParentRow('Zend_Db_Table_TableProducts'); - $this->assertEquals(3, $productRow->$product_id); - } - - /** - * Test that findDependentRowset() works even if the column names are - * not the same. - */ - public function testTableRelationshipFindDependentRowsetWithDissimilarColumns() - { - $intersectionTable = $this->_getBugsProductsWithDissimilarColumns(); - $bugsTable = $this->_getTable('Zend_Db_Table_TableBugs'); - $bugRow = $bugsTable->find(2)->current(); - - $intRows = $bugRow->findDependentRowset($intersectionTable); - $this->assertEquals(array(2, 3), array_values($intRows->current()->toArray())); - } - - /** - * Test that findManyToManyRowset() works even if the column names are - * not the same. - */ - public function testTableRelationshipFindManyToManyRowsetWithDissimilarColumns() - { - $product_id = $this->_db->foldCase('product_id'); - - $intersectionTable = $this->_getBugsProductsWithDissimilarColumns(); - $bugsTable = $this->_getTable('Zend_Db_Table_TableBugs'); - $bugRow = $bugsTable->find(2)->current(); - - $productRows = $bugRow->findManyToManyRowset('Zend_Db_Table_TableProducts', $intersectionTable); - $this->assertEquals(3, $productRows->current()->$product_id); - } - - /** - * Test that findManyToManyRowset() works even if the column types are - * not the same. - */ - public function testTableRelationshipFindManyToManyRowsetWithDissimilarTypes() - { - $table = $this->_table['products']; - - $originRows = $table->find(1); - $originRow1 = $originRows->current(); - - $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableBugs', 'Zend_Db_Table_TableBugsProducts'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows)); - - $this->assertEquals(1, $destRows->count()); - } - -} diff --git a/tests/Zend/Db/Table/Row/Db2Test.php b/tests/Zend/Db/Table/Row/Db2Test.php deleted file mode 100644 index 057692b9753f361df4a18b32c69cd753ec1f8eca..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Db2Test.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Db2Test extends Zend_Db_Table_Row_TestCommon -{ - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Table/Row/MysqliTest.php b/tests/Zend/Db/Table/Row/MysqliTest.php deleted file mode 100644 index 0a259a78d9c90a1af5d73f4a0051003d12064ffe..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/MysqliTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_MysqliTest extends Zend_Db_Table_Row_TestCommon -{ - - public function testTableRowSaveInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Table/Row/OdbcTest.php b/tests/Zend/Db/Table/Row/OdbcTest.php deleted file mode 100644 index ab58a705076a335c37d556c93b8d8c7b6d342478..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_OdbcTest extends Zend_Db_Table_Row_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Table/Row/OracleTest.php b/tests/Zend/Db/Table/Row/OracleTest.php deleted file mode 100644 index 9b28f516b5e51100bc2af5fe5069a6f63f98f9ed..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/OracleTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_OracleTest extends Zend_Db_Table_Row_TestCommon -{ - - public function testTableRowSaveInsert() - { - $this->markTestSkipped($this->getDriver() . ' does not support auto-increment keys.'); - } - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Table/Row/Pdo/IbmTest.php b/tests/Zend/Db/Table/Row/Pdo/IbmTest.php deleted file mode 100644 index b783b4e2e99b3d03c36a50f78831e095a40047fd..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Pdo/IbmTest.php +++ /dev/null @@ -1,43 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Pdo_IbmTest extends Zend_Db_Table_Row_TestCommon -{ - public function getDriver() - { - return 'Pdo_Ibm'; - } - - public function testTableRowSetPrimaryKey() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestSkipped('IDS Serial columns cannot be updated'); - } else { - parent::testTableRowSetPrimaryKey(); - } - } -} diff --git a/tests/Zend/Db/Table/Row/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Row/Pdo/MssqlTest.php deleted file mode 100644 index e228858b46c37d42c0ca02dc1df1cfba807e25d8..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Pdo/MssqlTest.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Pdo_MssqlTest extends Zend_Db_Table_Row_TestCommon -{ - - public function testTableRowSaveInsert() - { - $this->markTestIncomplete($this->getDriver() . ': DEFAULT or NULL are not allowed as explicit identity values.'); - } - - public function testTableRowSetPrimaryKey() - { - $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.'); - } - - public function testTableRowSaveInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Table/Row/Pdo/MysqlTest.php b/tests/Zend/Db/Table/Row/Pdo/MysqlTest.php deleted file mode 100644 index 69627500c20d0382fee08ef8b1bbe24a5da3f34c..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Pdo/MysqlTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Pdo_MysqlTest extends Zend_Db_Table_Row_TestCommon -{ - - public function testTableRowSaveInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Table/Row/Pdo/OciTest.php b/tests/Zend/Db/Table/Row/Pdo/OciTest.php deleted file mode 100644 index 2afb8d390182a466beebc6b323a872d165f299b1..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Pdo/OciTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Pdo_OciTest extends Zend_Db_Table_Row_TestCommon -{ - - public function testTableRowSaveInsert() - { - $this->markTestSkipped($this->getDriver() . ' does not support auto-increment keys.'); - } - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Table/Row/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Row/Pdo/PgsqlTest.php deleted file mode 100644 index bd6bb9c3c97dddcf59e5106135f40760b21b0b92..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Pdo/PgsqlTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Pdo_PgsqlTest extends Zend_Db_Table_Row_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Pgsql'; - } - -} diff --git a/tests/Zend/Db/Table/Row/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Row/Pdo/SqliteTest.php deleted file mode 100644 index 42ec6a37226c176bf54e538a276e89eb7a8affaa..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/Pdo/SqliteTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Row/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Row_Pdo_SqliteTest extends Zend_Db_Table_Row_TestCommon -{ - - public function testTableRowSaveInsertSequence() - { - $this->markTestSkipped($this->getDriver() . ' does not support sequences'); - } - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Table/Row/StaticTest.php b/tests/Zend/Db/Table/Row/StaticTest.php deleted file mode 100644 index f8de39d7485abcbb17b771be55fd095ab8c7845c..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/StaticTest.php +++ /dev/null @@ -1,92 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Db_Table_Row_TestMockRow - */ -require_once 'Zend/Db/Table/Row/TestMockRow.php'; - -class Zend_Db_Table_Row_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testTableRowTransformColumnNotUsedInConstructor() - { - $data = array( - 'column' => 'value1', - 'column_foo' => 'value2', - 'column_bar_baz' => 'value3' - ); - $row = new Zend_Db_Table_Row_TestMockRow(array('data' => $data)); - - $array = $row->toArray(); - $this->assertEquals($data, $array); - } - - public function testTableRowTransformColumnMagicGet() - { - $data = array( - 'column' => 'value1', - 'column_foo' => 'value2', - 'column_bar_baz' => 'value3' - ); - $row = new Zend_Db_Table_Row_TestMockRow(array('data' => $data)); - - $this->assertEquals('value1', $row->column); - $this->assertEquals('value2', $row->columnFoo); - $this->assertEquals('value3', $row->columnBarBaz); - } - - public function testTableRowTransformColumnMagicSet() - { - $data = array( - 'column' => 'value1', - 'column_foo' => 'value2', - 'column_bar_baz' => 'value3' - ); - $row = new Zend_Db_Table_Row_TestMockRow(array('data' => $data)); - - $this->assertEquals('value1', $row->column); - $this->assertEquals('value2', $row->columnFoo); - $this->assertEquals('value3', $row->columnBarBaz); - - $row->column = 'another value 1'; - $row->columnFoo = 'another value 2'; - $row->columnBarBaz = 'another value 3'; - - $array = $row->toArray(); - $this->assertEquals( - array( - 'column' => 'another value 1', - 'column_foo' => 'another value 2', - 'column_bar_baz' => 'another value 3' - ), $array); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Table/Row/TestCommon.php b/tests/Zend/Db/Table/Row/TestCommon.php deleted file mode 100644 index 36f2592710a03c0ecb89590cb3a48170a07da4a7..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/TestCommon.php +++ /dev/null @@ -1,734 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_TestSetup - */ -require_once 'Zend/Db/Table/TestSetup.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Db/Table/Row.php'; - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Table_Row_TestCommon extends Zend_Db_Table_TestSetup -{ - - protected function _testTableRow() - { - $table = $this->_table['bugs']; - - $bug_id = $this->_db->foldCase('bug_id'); - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - $created_on = $this->_db->foldCase('created_on'); - $updated_on = $this->_db->foldCase('updated_on'); - $reported_by = $this->_db->foldCase('reported_by'); - $assigned_to = $this->_db->foldCase('assigned_to'); - $verified_by = $this->_db->foldCase('verified_by'); - - $data = array( - $bug_id => '1', - $bug_description => 'System needs electricity to run', - $bug_status => 'NEW', - $created_on => '2007-04-01', - $updated_on => '2007-04-01', - $reported_by => 'goofy', - $assigned_to => 'mmouse', - $verified_by => 'dduck' - ); - - $config = array( - 'table' => $table, - 'stored' => true, - 'readOnly' => false, - 'data' => $data, - ); - - Zend_Loader::loadClass('Zend_Db_Table_Row_TestTableRow'); - return new Zend_Db_Table_Row_TestTableRow($config); - } - - public function testTableFindRow() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(1, count($rowset)); - } - - public function testTableRowConstructor() - { - $table = $this->_table['bugs']; - - $config = array( - 'db' => $this->_db, - 'table' => $table, - 'data' => array(), - 'readOnly' => true - ); - - $row1 = new Zend_Db_Table_Row($config); - - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - try { - $bug_description = $row1->bug_description; - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals("Specified column \"bug_description\" is not in the row", $e->getMessage()); - } - - $config['data'] = 'Invalid'; - - try { - $row1 = new Zend_Db_Table_Row($config); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals("Data must be an array", $e->getMessage()); - } - } - - public function testTableRowReadOnly() - { - $table = $this->_table['bugs']; - - $row1 = new Zend_Db_Table_Row( - array( - 'db' => $this->_db, - 'table' => $table, - 'readOnly' => true - ) - ); - - $this->assertTrue($row1->isReadOnly()); - } - - public function testTableRowToArray() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $a = $row1->toArray(); - - $this->assertTrue(is_array($a)); - - // fix for #ZF-1898 - $arrayObject = new ArrayObject($row1->toArray(),ArrayObject::ARRAY_AS_PROPS); - $arrayObject->bug_status = 'foobar'; - $this->assertNotEquals('foobar',$row1->bug_status); - - $cols = array( - 'bug_id', - 'bug_description', - 'bug_status', - 'created_on', - 'updated_on', - 'reported_by', - 'assigned_to', - 'verified_by', - ); - $this->assertEquals($cols, array_keys($a)); - } - - public function testTableRowSelect() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $select = $row1->select(); - $this->assertType('Zend_Db_Table_Select', $select, - 'Expecting object of type Zend_Db_Table_Select, got '.get_class($select)); - } - - public function testTableRowMagicGet() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - try { - $this->assertEquals(1, $row1->$bug_id); - $this->assertEquals('System needs electricity to run', $row1->$bug_description); - $this->assertEquals('NEW', $row1->$bug_status); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - - if (!isset($row1->$bug_id)) { - $this->fail('Column "id" is set but isset() returns false'); - } - } - - public function testTableRowMagicSet() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - try { - $row1->$bug_description = 'foo'; - $this->assertEquals('foo', $row1->$bug_description); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - } - - public function testTableRowSetFromArray() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - - $data = array( - $bug_description => 'New Description', - $bug_status => 'INVALID' - ); - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $result = $row1->setFromArray($data); - - $this->assertSame($result, $row1); - - try { - $this->assertEquals($data[$bug_description], $row1->$bug_description); - $this->assertEquals($data[$bug_status], $row1->$bug_status); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - } - - public function testTableRowSaveInsert() - { - $table = $this->_table['bugs']; - $data = array( - 'bug_description' => 'New Description', - 'bug_status' => 'INVALID' - ); - try { - $row3 = $table->createRow($data); - $this->assertNull($row3->bug_id); - $row3->save(); - $this->assertEquals(5, $row3->bug_id); - $this->assertEquals($data['bug_description'], $row3->bug_description); - $this->assertEquals($data['bug_status'], $row3->bug_status); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - } - - public function testTableRowSaveInsertSequence() - { - $table = $this->_getTable('Zend_Db_Table_TableProducts', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfproducts_seq')); - $product_id = $this->_db->foldCase('product_id'); - $product_name = $this->_db->foldCase('product_name'); - - $data = array ( - $product_name => 'Solaris' - ); - $row3 = $table->createRow($data); - $row3->save(); - try { - $this->assertEquals(4, $row3->$product_id); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - } - - public function testTableRowSaveUpdate() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - - $data = array( - $bug_description => 'New Description', - $bug_status => 'INVALID' - ); - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $row1->setFromArray($data); - $row1->save(); - - try { - $this->assertEquals(1, $row1->$bug_id); - $this->assertEquals($data[$bug_description], $row1->$bug_description); - $this->assertEquals($data[$bug_status], $row1->$bug_status); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - } - - public function testTableRowSaveInvalidTable() - { - $table = $this->_table['bugs']; - - $row = $this->_testTableRow(); - - try { - $row->setTableColsToFail($table); - $row->setTable($table); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for incorrect parent table'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('The specified Table does not have the same columns as the Row', $e->getMessage()); - } - - $row = $this->_testTableRow(); - - try { - $row->setPrimaryKeyToFail1($table); - $row->setTable($table); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for incorrect parent table'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('The specified Table \'Zend_Db_Table_TableBugs\' does not have the same primary key as the Row', $e->getMessage()); - } - } - - public function testTableRowSaveUpdateInvalidInfo() - { - $table = $this->_table['bugs']; - - $row = $this->_testTableRow(); - - $bug_status = $this->_db->foldCase('bug_status'); - $row->$bug_status = 'VALID'; - - try { - $row->setTable($table); - $row->setPrimaryKeyToFail1(); - $row->save(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for incorrect parent table'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('The primary key must be set as an array', $e->getMessage()); - } - - try { - $row->setTable($table); - $row->setPrimaryKeyToFail2(); - $row->save(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for incorrect parent table'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('The specified Table \'Zend_Db_Table_TableBugs\' does not have the same primary key as the Row', $e->getMessage()); - } - } - - public function testTableRowSaveUpdateRefresh() - { - $table = $this->_table['bugs']; - - $bug_status = $this->_db->foldCase('bug_status'); - - $row = $this->_testTableRow(); - $row->$bug_status = 'VALID'; - - try { - $row->save(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for missing parent'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('Cannot refresh row as parent is missing', $e->getMessage()); - } - } - - public function testTableRowSetTable() - { - $table = $this->_table['bugs']; - $table2 = $this->_table['products']; - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $row1->setTable(null); - $this->assertFalse($row1->isConnected()); - - try { - $row1->setTable($table2); - $this->fail('Expected to catch Zend_Db_Table_Exception for incorrect parent table'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception got '.get_class($e)); - $this->assertEquals('The specified Table is of class Zend_Db_Table_TableProducts, expecting class to be instance of Zend_Db_Table_TableBugs', $e->getMessage()); - } - } - - public function testTableRowSetInvalidTable() - { - $table = $this->_table['bugs']; - - $row = $this->_testTableRow(); - - try { - $row->setTableToFail(); - $row->setTable($table); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for incorrect parent table'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('The specified Table is of class Zend_Db_Table_TableBugs, expecting class to be instance of foo', $e->getMessage()); - } - } - - public function testTableRowExceptionGetColumnNotInRow() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $column = 'doesNotExist'; - - try { - $dummy = $row1->$column; - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals("Specified column \"$column\" is not in the row", $e->getMessage()); - } - } - - public function testTableRowExceptionSetColumnNotInRow() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - $column = 'doesNotExist'; - - try { - $row1->$column = 'dummy value'; - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals("Specified column \"$column\" is not in the row", $e->getMessage()); - } - } - - public function testTableRowExceptionBogusPrimaryKey() - { - $table = $this->_table['bugs_products']; - $bogusData = array( - 'bug_id' => 3, - 'foo' => 'bar' - ); - $row = new Zend_Db_Table_Row(array('table' => $table, 'data' => $bogusData)); - try { - $rowsAffected = $row->delete(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals("The specified Table 'Zend_Db_Table_TableBugsProducts' does not have the same primary key as the Row", $e->getMessage()); - } - } - - public function testTableRowSetPrimaryKey() - { - $table = $this->_table['bugs']; - $bug_id = $this->_db->foldCase('bug_id'); - - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - - try { - $row1->$bug_id = 6; - $row1->save(); - $this->assertEquals(6, $row1->$bug_id); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - } - - public function testTableRowSerialize() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $row1 = $rowset->current(); - - $serRow1 = serialize($row1); - - $row1New = unserialize($serRow1); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1New, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1New)); - $this->assertEquals($row1->toArray(), $row1New->toArray()); - } - - public function testTableRowSerializeExceptionNotConnected() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $row1 = $rowset->current(); - - $serRow1 = serialize($row1); - - $row1New = unserialize($serRow1); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1New, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1New)); - $bug_description = $this->_db->foldCase('bug_description'); - $row1New->$bug_description = 'New description'; - - try { - $row1New->save(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals("Cannot save a Row unless it is connected", $e->getMessage()); - } - } - - public function testTableRowSerializeReconnectedUpdate() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $row1 = $rowset->current(); - - $serRow1 = serialize($row1); - - $row1New = unserialize($serRow1); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1New, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1New)); - - try { - $connected = $row1New->setTable($table); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - $this->assertTrue($connected); - - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - $data = array( - $bug_description => 'New Description', - $bug_status => 'INVALID' - ); - $row1New->setFromArray($data); - - try { - $rowsAffected = $row1New->save(); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - $this->assertEquals(1, $rowsAffected); - } - - public function testTableRowSerializeReconnectedDelete() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $row1 = $rowset->current(); - - $serRow1 = serialize($row1); - - $row1New = unserialize($serRow1); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1New, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1New)); - - try { - $connected = $row1New->setTable($table); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - $this->assertTrue($connected); - - try { - $rowsAffected = $row1New->delete(); - } catch (Zend_Exception $e) { - $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n"); - } - $this->assertEquals(1, $rowsAffected); - } - - public function testTableRowSerializeExceptionWrongTable() - { - $table = $this->_table['bugs']; - - $rowset = $table->find(1); - $row1 = $rowset->current(); - - $serRow1 = serialize($row1); - - $row1New = unserialize($serRow1); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1New, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1New)); - - $table2 = $this->_table['products']; - $connected = false; - try { - $connected = $row1New->setTable($table2); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals('The specified Table is of class Zend_Db_Table_TableProducts, expecting class to be instance of Zend_Db_Table_TableBugs', $e->getMessage()); - } - $this->assertFalse($connected); - } - - public function testTableRowSetReadOnly() - { - $table = $this->_table['bugs']; - $bug_status = $this->_db->foldCase('bug_status'); - - $rowset = $table->find(1); - $row1 = $rowset->current(); - - $row1->setReadOnly(true); - $this->assertTrue($row1->isReadOnly()); - - $data = array( - 'bug_description' => 'New Description', - 'bug_status' => 'INVALID' - ); - - $row2 = $table->createRow($data); - $row2->setReadOnly(true); - try { - $row2->save(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals('This row has been marked read-only', $e->getMessage()); - } - - $row2->setReadOnly(false); - $row2->save(); - - $row2->$bug_status = 'VALID'; - $row2->setReadOnly(true); - - try { - $row2->save(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals('This row has been marked read-only', $e->getMessage()); - } - - $row2->setReadOnly(false); - $row2->save(); - } - - public function testTableRowInvalidTransformColumn() - { - $row = $this->_testTableRow(); - - try { - $row->setInvalidColumn(); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception for invalid column type'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception got '.get_class($e)); - $this->assertEquals('Specified column is not a string', $e->getMessage()); - } - } - -} diff --git a/tests/Zend/Db/Table/Row/TestMockRow.php b/tests/Zend/Db/Table/Row/TestMockRow.php deleted file mode 100644 index 7ac2264d76dc68756e1b899bd441828b7c6d4b7f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/TestMockRow.php +++ /dev/null @@ -1,79 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestMyRow.php 5117 2007-06-05 00:38:13Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_Row_Abstract - */ -require_once 'Zend/Db/Table/Row/Abstract.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Row_TestMockRow extends Zend_Db_Table_Row_Abstract -{ - - public $parentTable = null; - public $dependentTable = null; - public $ruleKey = null; - - public $matchTable = null; - public $intersectionTable = null; - public $callerRefRuleKey = null; - public $matchRefRuleKey = null; - - public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Table_Select $select = null) - { - $this->dependentTable = $dependentTable; - $this->ruleKey = $ruleKey; - } - - public function findParentRow($parentTable, $ruleKey = null, Zend_Db_Table_Select $select = null) - { - $this->parentTable = $parentTable; - $this->ruleKey = $ruleKey; - } - - public function findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule = null, - $matchRefRule = null, Zend_Db_Table_Select $select = null) - { - $this->matchTable = $matchTable; - $this->intersectionTable = $intersectionTable; - $this->callerRefRuleKey = $callerRefRule; - $this->matchRefRuleKey = $matchRefRule; - } - - protected function _transformColumn($columnName) - { - // convert 'columnFoo' to 'column_foo' - $columnName = strtolower(preg_replace('/([A-Z])/', '_$1', $columnName)); - return $columnName; - } - -} diff --git a/tests/Zend/Db/Table/Row/TestMyRow.php b/tests/Zend/Db/Table/Row/TestMyRow.php deleted file mode 100644 index 3c04443637afa72c8def37758cede5647d5edb9a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/TestMyRow.php +++ /dev/null @@ -1,40 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestMyRow.php 5117 2007-06-05 00:38:13Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_Row_Abstract - */ -require_once 'Zend/Db/Table/Row/Abstract.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Row_TestMyRow extends Zend_Db_Table_Row_Abstract -{} diff --git a/tests/Zend/Db/Table/Row/TestTableRow.php b/tests/Zend/Db/Table/Row/TestTableRow.php deleted file mode 100644 index 77fb6bd62e9a4933747d9e11a80f437c925782a3..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Row/TestTableRow.php +++ /dev/null @@ -1,72 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestTableRow.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_Row_Abstract - */ -require_once 'Zend/Db/Table/Row/Abstract.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Row_TestTableRow extends Zend_Db_Table_Row_Abstract -{ - protected $_tableClass = 'Zend_Db_Table_TableBugs'; - - public function setInvalidColumn() - { - $this->_transformColumn(array('bug_id')); - } - - public function setTableToFail() - { - $this->_tableClass = 'foo'; - } - - public function setTableColsToFail() - { - $this->_data = array(); - } - - public function setPrimaryKeyToFail1() - { - $this->_primary = 'foo'; - } - - public function setPrimaryKeyToFail2() - { - $this->_primary = array(); - } - - protected function _postUpdate() - { - $this->bug_id = 0; - } -} diff --git a/tests/Zend/Db/Table/Rowset/Db2Test.php b/tests/Zend/Db/Table/Rowset/Db2Test.php deleted file mode 100644 index 414c0fc49b1b96b2cb90e19753d563aa8ac21221..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Db2Test.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Db2Test extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/MysqliTest.php b/tests/Zend/Db/Table/Rowset/MysqliTest.php deleted file mode 100644 index f776ed69713f7c00291db19ced48262f6d9cb965..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/MysqliTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_MysqliTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/OdbcTest.php b/tests/Zend/Db/Table/Rowset/OdbcTest.php deleted file mode 100644 index 6d26ecef12fa89b6fbf91606984c8250bdf0b160..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_OdbcTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/OracleTest.php b/tests/Zend/Db/Table/Rowset/OracleTest.php deleted file mode 100644 index d238e1c7338a6d2c2f87a1220e7c1b5189e1db0c..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/OracleTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_OracleTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/Pdo/IbmTest.php b/tests/Zend/Db/Table/Rowset/Pdo/IbmTest.php deleted file mode 100644 index f7d0da0e235d5bc36a5a9cc7955dcccb5ace6bc5..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Pdo/IbmTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Pdo_IbmTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Ibm'; - } - -} \ No newline at end of file diff --git a/tests/Zend/Db/Table/Rowset/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Rowset/Pdo/MssqlTest.php deleted file mode 100644 index c90bc1aad95e83fa7036adece371f0f1aa8b9f95..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Pdo/MssqlTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Pdo_MssqlTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/Pdo/MysqlTest.php b/tests/Zend/Db/Table/Rowset/Pdo/MysqlTest.php deleted file mode 100644 index 9564d341573b2bfebd919631c82113cc5e8e80dc..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Pdo/MysqlTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Pdo_MysqlTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/Pdo/OciTest.php b/tests/Zend/Db/Table/Rowset/Pdo/OciTest.php deleted file mode 100644 index d3f7ef98bb0709cbed6b3c1f1d0c82441683e49a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Pdo/OciTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Pdo_OciTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Rowset/Pdo/PgsqlTest.php deleted file mode 100644 index cbfd4aa0ba51e6f28e498a7ac360a70bf96d7d0c..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Pdo/PgsqlTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Pdo_PgsqlTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Pgsql'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Rowset/Pdo/SqliteTest.php deleted file mode 100644 index e2e01bf135f6d2427bbfc249f0949a8298bcf7eb..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/Pdo/SqliteTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Rowset/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_Pdo_SqliteTest extends Zend_Db_Table_Rowset_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/StaticTest.php b/tests/Zend/Db/Table/Rowset/StaticTest.php deleted file mode 100644 index 341d8be866618a44a5658fe617ac13ac7d5273c1..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/StaticTest.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Rowset_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testStatic() - { - $this->markTestIncomplete('Static table tests are not implemented yet'); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Table/Rowset/TestCommon.php b/tests/Zend/Db/Table/Rowset/TestCommon.php deleted file mode 100644 index e3b7aed85bae3d43fd3ffbe9294d427087b9a330..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/TestCommon.php +++ /dev/null @@ -1,257 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 7427 2008-01-14 13:14:14Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_TestSetup - */ -require_once 'Zend/Db/Table/TestSetup.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Table_Rowset_TestCommon extends Zend_Db_Table_TestSetup -{ - - public function testTableRowsetIterator() - { - $table = $this->_table['bugs']; - - $rows = $table->find(array(1, 2)); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rows, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rows)); - - // see if we're at the beginning - $this->assertEquals(0, $rows->key()); - $this->assertTrue($rows->valid()); - - // get first row and see if it's the right one - $row1 = $rows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(1, $row1->$bug_id); - - // advance to next row - $rows->next(); - $this->assertEquals(1, $rows->key()); - $this->assertTrue($rows->valid()); - - // get second row and see if it's the right one - $row2 = $rows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row2, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row2)); - $this->assertEquals(2, $row2->$bug_id); - - // advance beyond last row - $rows->next(); - $this->assertEquals(2, $rows->key()); - $this->assertFalse($rows->valid()); - - // current() returns null if beyond last row - $row3 = $rows->current(); - $this->assertNull($row3); - - // rewind to beginning - $result = $rows->rewind(); - $this->assertEquals($result, $rows); - $this->assertEquals(0, $rows->key()); - $this->assertTrue($rows->valid()); - - // get row at beginning and compare it to - // the one we got earlier - $row1Copy = $rows->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - $this->assertEquals(1, $row1->$bug_id); - $this->assertSame($row1, $row1Copy); - - // test seeking to infinite fails - $rows->rewind(); - try{ - $rows->seek(99999); // this index should not exist - $this->fail('An exception should have been thrown here'); - }catch(Zend_Db_Table_Rowset_Exception $e){ } - try{ - $rows->seek(-20); - $this->fail('An exception should have been thrown here'); - }catch(Zend_Db_Table_Rowset_Exception $e){ } - - - $rows->seek(1); - $row = $rows->current(); - $this->assertEquals(1, $rows->key()); - $this->assertTrue($rows->valid()); - $this->assertEquals(2, $row2->$bug_id); - - $rows->rewind(); - $row = $rows->getRow(1); - $this->assertEquals(0, $rows->key()); // pointer should not have moved - $this->assertEquals(1, $row1->$bug_id); - - $rows->rewind(); - $row = $rows->getRow(1, true); - $this->assertEquals(1, $rows->key()); // pointer should have moved - $this->assertEquals(1, $row1->$bug_id); - - $rows->rewind(); - $rowcopy = $rows->seek(1)->current(); - $rows->rewind(); - $row1 = $rows->getRow(1); - $this->assertSame($rowcopy, $row1); - - try{ - $rows->getRow(99999); // this index should not exist - $this->fail('An exception should have been thrown here'); - }catch(Zend_Db_Table_Rowset_Exception $e){ - // has the exception correctly been overwritten by getRow() ? - $this->assertRegExp('#No row could be found at position \d+#',$e->getMessage()); - } - - } - - public function testTableRowsetEmpty() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $rows = $table->fetchAll("$bug_id = -1"); - $this->assertEquals(0, count($rows)); - $this->assertNull($rows->current()); - } - - public function testTableRowsetToArray() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - - $rows = $table->find(array(1, 2)); - $this->assertEquals(2, count($rows)); - - // iterate through the rowset, because that's the only way - // to force it to instantiate the individual Rows - foreach ($rows as $row) { - $row->$bug_description = 'foo'; - } - - $a = $rows->toArray(); - - $this->assertTrue(is_array($a)); - $this->assertEquals(count($a), count($rows)); - $this->assertTrue(is_array($a[0])); - $this->assertEquals(8, count($a[0])); - $this->assertEquals('foo', $a[0][$bug_description]); - } - - public function testTableRowsetGetConnected() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - - $rows = $table->find(1); - - $this->assertTrue($rows->isConnected()); - } - - public function testTableRowsetGetTable() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - - $rows = $table->find(1); - $rows->setTable($table); - - $this->assertEquals($table, $rows->getTable()); - } - - public function testTableRowsetGetTableClass() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - - $rows = $table->find(1); - $this->assertEquals(get_class($table), $rows->getTableClass()); - } - - public function testTableSerializeRowset() - { - $table = $this->_table['bugs']; - - $rows = $table->find(1); - - $serRows = serialize($rows); - - $rowsNew = unserialize($serRows); - - $this->assertFalse($rowsNew->isConnected()); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowsNew, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowsNew)); - - $row1New = $rowsNew->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1New, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1New)); - } - - public function testTableSerializeRowsetExceptionWrongTable() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - - $rows = $table->find(1); - - // iterate through the rowset, because that's the only way - // to force it to instantiate the individual Rows - foreach ($rows as $row) - { - $row->$bug_description = $row->$bug_description; - } - - $serRows = serialize($rows); - - $rowsNew = unserialize($serRows); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowsNew, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowsNew)); - - $table2 = $this->_table['products']; - $connected = false; - try { - $connected = $rowsNew->setTable($table2); - $this->fail('Expected to catch Zend_Db_Table_Row_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Row_Exception', $e, - 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e)); - $this->assertEquals('The specified Table is of class Zend_Db_Table_TableProducts, expecting class to be instance of Zend_Db_Table_TableBugs', $e->getMessage()); - } - $this->assertFalse($connected); - } - -} diff --git a/tests/Zend/Db/Table/Rowset/TestMyRowset.php b/tests/Zend/Db/Table/Rowset/TestMyRowset.php deleted file mode 100644 index ffe1f18ce4f669c8ff229c3e35c61675f0f802c1..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Rowset/TestMyRowset.php +++ /dev/null @@ -1,40 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestMyRowset.php 5117 2007-06-05 00:38:13Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_Rowset_Abstract - */ -require_once 'Zend/Db/Table/Rowset/Abstract.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Rowset_TestMyRowset extends Zend_Db_Table_Rowset_Abstract -{} diff --git a/tests/Zend/Db/Table/Select/Db2Test.php b/tests/Zend/Db/Table/Select/Db2Test.php deleted file mode 100644 index 1871d2da6dabe3e60abf7930bed0c059a5eed1ac..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Db2Test.php +++ /dev/null @@ -1,39 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_Db2Test extends Zend_Db_Table_Select_TestCommon -{ - - public function testSelectJoinCross() - { - $this->markTestSkipped($this->getDriver() . ' does not support CROSS JOIN'); - } - - public function getDriver() - { - return 'Db2'; - } - -} diff --git a/tests/Zend/Db/Table/Select/MysqliTest.php b/tests/Zend/Db/Table/Select/MysqliTest.php deleted file mode 100644 index eaf270e610cffda3305da7c451ebe718c554aa8a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/MysqliTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_MysqliTest extends Zend_Db_Table_Select_TestCommon -{ - - public function getDriver() - { - return 'Mysqli'; - } - -} diff --git a/tests/Zend/Db/Table/Select/OdbcTest.php b/tests/Zend/Db/Table/Select/OdbcTest.php deleted file mode 100644 index 3d9535c51de67679b2471647e152ddbcd1f5daf5..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/OdbcTest.php +++ /dev/null @@ -1,34 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_OdbcTest extends Zend_Db_Table_Select_TestCommon -{ - - public function getDriver() - { - return 'Odbc'; - } - -} diff --git a/tests/Zend/Db/Table/Select/OracleTest.php b/tests/Zend/Db/Table/Select/OracleTest.php deleted file mode 100644 index ee12ed886d127e17430d320bfe55128d68a0e3fd..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/OracleTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_OracleTest extends Zend_Db_Table_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function testSelectJoinQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function getDriver() - { - return 'Oracle'; - } - -} diff --git a/tests/Zend/Db/Table/Select/Pdo/IbmTest.php b/tests/Zend/Db/Table/Select/Pdo/IbmTest.php deleted file mode 100644 index 8a375cab5d4f74cca8bd800f3dcf4f7a29f64098..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Pdo/IbmTest.php +++ /dev/null @@ -1,75 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Db_Table_Select_TestCommon - */ -require_once 'Zend/Db/Table/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Select_Pdo_IbmTest extends Zend_Db_Table_Select_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Ibm'; - } - - public function testSelectGroupByExpr() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestIncomplete('IDS does not support this SQL syntax'); - } else { - parent::testSelectGroupByExpr(); - } - } - - public function testSelectGroupByAutoExpr() - { - $server = $this->_util->getServer(); - - if ($server == 'IDS') { - $this->markTestIncomplete('IDS does not support this SQL syntax'); - } else { - parent::testSelectGroupByAutoExpr(); - } - } - - public function testSelectJoinCross() - { - $this->markTestSkipped($this->getDriver() . ' adapter support for CROSS JOIN not yet available'); - } -} diff --git a/tests/Zend/Db/Table/Select/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Select/Pdo/MssqlTest.php deleted file mode 100644 index 080dc68c3acbf90d1b62a2ce950327935d7c5588..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Pdo/MssqlTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_Pdo_MssqlTest extends Zend_Db_Table_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.'); - } - - public function testSelectJoinQualified() - { - $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.'); - } - - public function getDriver() - { - return 'Pdo_Mssql'; - } - -} diff --git a/tests/Zend/Db/Table/Select/Pdo/MysqlTest.php b/tests/Zend/Db/Table/Select/Pdo/MysqlTest.php deleted file mode 100644 index dba985ce1cb0ee6938994be1d5f5d5cb1b6a45b9..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Pdo/MysqlTest.php +++ /dev/null @@ -1,49 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MysqlTest.php 5097 2007-06-04 16:06:43Z darby $ - */ - - -/** - * @see Zend_Db_Table_Select_TestCommon - */ -require_once 'Zend/Db/Table/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Select_Pdo_MysqlTest extends Zend_Db_Table_Select_TestCommon -{ - - public function getDriver() - { - return 'Pdo_Mysql'; - } - -} diff --git a/tests/Zend/Db/Table/Select/Pdo/OciTest.php b/tests/Zend/Db/Table/Select/Pdo/OciTest.php deleted file mode 100644 index 353354a64312a9bae08019e90d52b75cbdf293ac..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Pdo/OciTest.php +++ /dev/null @@ -1,44 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_Pdo_OciTest extends Zend_Db_Table_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function testSelectJoinQualified() - { - $this->markTestIncomplete($this->getDriver() . ' does not report its schema as we expect.'); - } - - public function getDriver() - { - return 'Pdo_Oci'; - } - -} diff --git a/tests/Zend/Db/Table/Select/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Select/Pdo/PgsqlTest.php deleted file mode 100644 index 21eef5527e89bf9f3361006fc5f3ebe758db913a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Pdo/PgsqlTest.php +++ /dev/null @@ -1,118 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PgsqlTest.php 4969 2007-05-25 19:16:50Z darby $ - */ - - -/** - * @see Zend_Db_Table_Select_TestCommon - */ -require_once 'Zend/Db/Table/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Select_Pdo_PgsqlTest extends Zend_Db_Table_Select_TestCommon -{ - public function getDriver() - { - return 'Pdo_Pgsql'; - } - - public function testSelectGroupByExpr() - { - $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY'); - } - - public function testSelectGroupByAutoExpr() - { - $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY'); - } - - /** - * Ensures that from() provides expected behavior using schema specification - * - * @return void - */ - public function testSelectFromSchemaSpecified() - { - $schema = 'public'; - $table = 'zfbugs'; - - $sql = $this->_db->select()->from($table, '*', $schema); - - $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString()); - - $rowset = $this->_db->fetchAll($sql); - - $this->assertEquals(4, count($rowset)); - } - - /** - * Ensures that from() provides expected behavior using schema in the table name - * - * @return void - */ - public function testSelectFromSchemaInName() - { - $schema = 'public'; - $table = 'zfbugs'; - - $name = "$schema.$table"; - - $sql = $this->_db->select()->from($name); - - $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString()); - - $rowset = $this->_db->fetchAll($sql); - - $this->assertEquals(4, count($rowset)); - } - - /** - * Ensures that from() overrides schema specification with schema in the table name - * - * @return void - */ - public function testSelectFromSchemaInNameOverridesSchemaArgument() - { - $schema = 'public'; - $table = 'zfbugs'; - - $name = "$schema.$table"; - - $sql = $this->_db->select()->from($name, '*', 'ignored'); - - $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString()); - - $rowset = $this->_db->fetchAll($sql); - - $this->assertEquals(4, count($rowset)); - } -} diff --git a/tests/Zend/Db/Table/Select/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Select/Pdo/SqliteTest.php deleted file mode 100644 index 8d0bb118a0775bd9214feef23631fd8afc8de3b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/Pdo/SqliteTest.php +++ /dev/null @@ -1,144 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/Select/TestCommon.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_Select_Pdo_SqliteTest extends Zend_Db_Table_Select_TestCommon -{ - - public function testSelectFromQualified() - { - $this->markTestSkipped($this->getDriver() . ' does not support qualified table names'); - } - - public function testSelectJoinQualified() - { - $this->markTestSkipped($this->getDriver() . ' does not support qualified table names'); - } - - public function testSelectFromForUpdate() - { - $this->markTestSkipped($this->getDriver() . ' does not support FOR UPDATE'); - } - - public function testSelectJoinRight() - { - $this->markTestSkipped($this->getDriver() . ' does not support RIGHT OUTER JOIN'); - } - - public function testSelectGroupBy() - { - $select = $this->_selectGroupBy(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function testSelectGroupByQualified() - { - $select = $this->_selectGroupByQualified(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result), - 'Expected count of first result set to be 2'); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount'], - 'Expected count(*) of first result set to be 2'); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function testSelectHaving() - { - $select = $this->_selectHaving(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - } - - public function testSelectHavingWithParameter() - { - $select = $this->_selectHavingWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(2, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - } - - public function testSelectHavingOr() - { - $select = $this->_selectHavingOr(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function testSelectHavingOrWithParameter() - { - $select = $this->_selectHavingOrWithParameter(); - $stmt = $this->_db->query($select); - $result = $stmt->fetchAll(); - $bugs_products = $this->_db->quoteIdentifier('zfbugs_products'); - $bug_id = $this->_db->quoteIdentifier('bug_id'); - $key = "$bugs_products.$bug_id"; - $this->assertEquals(3, count($result)); - $this->assertEquals(1, $result[0][$key]); - $this->assertEquals(3, $result[0]['thecount']); - $this->assertEquals(2, $result[1][$key]); - $this->assertEquals(1, $result[1]['thecount']); - } - - public function getDriver() - { - return 'Pdo_Sqlite'; - } - -} diff --git a/tests/Zend/Db/Table/Select/StaticTest.php b/tests/Zend/Db/Table/Select/StaticTest.php deleted file mode 100644 index 5c9fd4aca9ffb465bba1756554144c288b5a5f3f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/StaticTest.php +++ /dev/null @@ -1,647 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StaticTest.php 6923 2007-11-25 02:00:06Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_Select_TestCommon - */ -require_once 'Zend/Db/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_Select_StaticTest extends Zend_Db_Select_TestCommon -{ - /** - * Test basic use of the Zend_Db_Select class. - * - * @return void - */ - public function testSelect() - { - $select = $this->_select(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts"', $sql); - } - - /** - * Test basic use of the Zend_Db_Select class. - * - * @return void - */ - public function testSelectQuery() - { - $select = $this->_select(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts"', $sql); - $stmt = $select->query(); - Zend_Loader::loadClass('Zend_Db_Statement_Static'); - $this->assertType('Zend_Db_Statement_Static', $stmt); - } - - /** - * Test Zend_Db_Select specifying columns - * - * @return void - */ - public function testSelectColumnsScalar() - { - $select = $this->_selectColumnsScalar(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test Zend_Db_Select specifying columns - * - * @return void - */ - public function testSelectColumnsArray() - { - $select = $this->_selectColumnsArray(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_id", "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test support for column aliases. - * e.g. from('table', array('alias' => 'col1')). - * - * @return void - */ - public function testSelectColumnsAliases() - { - $select = $this->_selectColumnsAliases(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" AS "alias" FROM "zfproducts"', $sql); - } - - /** - * Test syntax to support qualified column names, - * e.g. from('table', array('table.col1', 'table.col2')). - * - * @return void - */ - public function testSelectColumnsQualified() - { - $select = $this->_selectColumnsQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test support for columns defined by Zend_Db_Expr. - * - * @return void - */ - public function testSelectColumnsExpr() - { - $select = $this->_selectColumnsExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts"."product_name" FROM "zfproducts"', $sql); - } - - /** - * Test support for automatic conversion of SQL functions to - * Zend_Db_Expr, e.g. from('table', array('COUNT(*)')) - * should generate the same result as - * from('table', array(new Zend_Db_Expr('COUNT(*)'))) - */ - - public function testSelectColumnsAutoExpr() - { - $select = $this->_selectColumnsAutoExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT COUNT(*) AS "count" FROM "zfproducts"', $sql); - } - - /** - * Test adding the DISTINCT query modifier to a Zend_Db_Select object. - */ - - public function testSelectDistinctModifier() - { - $select = $this->_selectDistinctModifier(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT DISTINCT 327 FROM "zfproducts"', $sql); - } - - /** - * Test adding the FOR UPDATE query modifier to a Zend_Db_Select object. - * - public function testSelectForUpdateModifier() - { - } - */ - - public function testSelectColumnsReset() - { - $select = $this->_selectColumnsReset() - ->reset(Zend_Db_Select::COLUMNS) - ->columns('product_name'); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "p"."product_name" FROM "zfproducts" AS "p"', $sql); - } - - /** - * Test support for schema-qualified table names in from() - * e.g. from('schema.table'). - */ - - public function testSelectFromQualified() - { - $select = $this->_selectFromQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "dummy"."zfproducts"', $sql); - } - - public function testSelectFromForUpdate() - { - $select = $this->_db->select() - ->from("zfproducts") - ->forUpdate(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" FOR UPDATE', $sql); - } - - /** - * Test adding a JOIN to a Zend_Db_Select object. - */ - - public function testSelectJoin() - { - $select = $this->_selectJoin(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id"', $sql); - } - - /** - * Test adding an INNER JOIN to a Zend_Db_Select object. - * This should be exactly the same as the plain JOIN clause. - */ - - public function testSelectJoinWithCorrelationName() - { - $select = $this->_selectJoinWithCorrelationName(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "xyz1".*, "xyz2".* FROM "zfproducts" AS "xyz1" INNER JOIN "zfbugs_products" AS "xyz2" ON "xyz1"."product_id" = "xyz2"."product_id" WHERE ("xyz1"."product_id" = 1)', $sql); - } - - /** - * Test adding an INNER JOIN to a Zend_Db_Select object. - * This should be exactly the same as the plain JOIN clause. - */ - - public function testSelectJoinInner() - { - $select = $this->_selectJoinInner(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id"', $sql); - } - - /** - * Test adding an outer join to a Zend_Db_Select object. - */ - - public function testSelectJoinLeft() - { - $select = $this->_selectJoinLeft(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs".*, "zfbugs_products".* FROM "zfbugs" LEFT JOIN "zfbugs_products" ON "zfbugs"."bug_id" = "zfbugs_products"."bug_id"', $sql); - } - - /** - * Test adding an outer join to a Zend_Db_Select object. - */ - - public function testSelectJoinRight() - { - $select = $this->_selectJoinRight(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products".*, "zfbugs".* FROM "zfbugs_products" RIGHT JOIN "zfbugs" ON "zfbugs_products"."bug_id" = "zfbugs"."bug_id"', $sql); - } - - /** - * Test adding a cross join to a Zend_Db_Select object. - */ - - public function testSelectJoinCross() - { - $select = $this->_selectJoinCross(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" CROSS JOIN "zfbugs_products"', $sql); - } - - /** - * Test support for schema-qualified table names in join(), - * e.g. join('schema.table', 'condition') - */ - - public function testSelectJoinQualified() - { - $select = $this->_selectJoinQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "dummy"."zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id"', $sql); - } - - /** - * Test adding a JOIN USING to a Zend_Db_Select object. - */ - - public function testSelectJoinUsing() - { - $select = $this->_selectJoinUsing(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfbugs_products"."product_id" = "zfproducts"."product_id" WHERE ("zfbugs_products"."product_id" < 3)', $sql); - } - - /** - * Test adding a JOIN INNER USING to a Zend_Db_Select object. - */ - - public function testSelectJoinInnerUsing() - { - $select = $this->_selectJoinInnerUsing(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".*, "zfbugs_products".* FROM "zfproducts" INNER JOIN "zfbugs_products" ON "zfbugs_products"."product_id" = "zfproducts"."product_id" WHERE ("zfbugs_products"."product_id" < 3)', $sql); - } - - public function testSelectJoinWithNocolumns() - { - $select = $this->_selectJoinWithNocolumns(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" INNER JOIN "zfbugs" ON "zfbugs"."bug_id" = 1 INNER JOIN "zfbugs_products" ON "zfproducts"."product_id" = "zfbugs_products"."product_id" AND "zfbugs_products"."bug_id" = "zfbugs"."bug_id"', $sql); - } - - /** - * Test adding a WHERE clause to a Zend_Db_Select object. - */ - - public function testSelectWhere() - { - $select = $this->_selectWhere(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2)', $sql); - } - - /** - * Test adding an array in the WHERE clause to a Zend_Db_Select object. - */ - - public function testSelectWhereArray() - { - $select = $this->_selectWhereArray(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" IN (1, 2, 3))', $sql); - } - - /** - * test adding more WHERE conditions, - * which should be combined with AND by default. - */ - - public function testSelectWhereAnd() - { - $select = $this->_selectWhereAnd(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2) AND ("product_id" = 1)', $sql); - } - - /** - * Test support for where() with a parameter, - * e.g. where('id = ?', 1). - */ - - public function testSelectWhereWithParameter() - { - $select = $this->_selectWhereWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2)', $sql); - } - - /** - * Test support for where() with a parameter, - * e.g. where('id = ?', 1). - */ - - public function testSelectWhereWithType() - { - $select = $this->_selectWhereWithType(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 2)', $sql); - } - - /** - * Test support for where() with a float parameter, - * e.g. where('id = ?', 1). - */ - - public function testSelectWhereWithTypeFloat() - { - $select = $this->_selectWhereWithTypeFloat(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfprice".* FROM "zfprice" WHERE ("price_total" = 200.450000)', $sql); - } - - /** - * * Test adding an OR WHERE clause to a Zend_Db_Select object. - */ - - public function testSelectWhereOr() - { - $select = $this->_selectWhereOr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 1) OR ("product_id" = 2)', $sql); - } - - /** - * Test support for where() with a parameter, - * e.g. orWhere('id = ?', 2). - */ - - public function testSelectWhereOrWithParameter() - { - $select = $this->_selectWhereOrWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE ("product_id" = 1) OR ("product_id" = 2)', $sql); - } - - /** - * Test adding a GROUP BY clause to a Zend_Db_Select object. - */ - - public function testSelectGroupBy() - { - $select = $this->_selectGroupBy(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for qualified table in group(), - * e.g. group('schema.table'). - */ - - public function testSelectGroupByQualified() - { - $select = $this->_selectGroupByQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "zfbugs_products"."bug_id" ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for Zend_Db_Expr in group(), - * e.g. group(new Zend_Db_Expr('id+1')) - */ - - public function testSelectGroupByExpr() - { - $select = $this->_selectGroupByExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "bug_id"+1 AS "bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id"+1 ORDER BY "bug_id"+1', $sql); - } - - /** - * Test support for automatic conversion of a SQL - * function to a Zend_Db_Expr in group(), - * e.g. group('LOWER(title)') should give the same - * result as group(new Zend_Db_Expr('LOWER(title)')). - */ - - - public function testSelectGroupByAutoExpr() - { - $select = $this->_selectGroupByAutoExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT ABS("zfbugs_products"."bug_id") AS "bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY ABS("zfbugs_products"."bug_id") ORDER BY ABS("zfbugs_products"."bug_id") ASC', $sql); - } - - /** - * Test adding a HAVING clause to a Zend_Db_Select object. - */ - - public function testSelectHaving() - { - $select = $this->_selectHaving(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) ORDER BY "bug_id" ASC', $sql); - } - - - public function testSelectHavingAnd() - { - $select = $this->_selectHavingAnd(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) AND (COUNT(*) = 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for parameter in having(), - * e.g. having('count(*) > ?', 1). - */ - - - public function testSelectHavingWithParameter() - { - $select = $this->_selectHavingWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test adding a HAVING clause to a Zend_Db_Select object. - */ - - - public function testSelectHavingOr() - { - $select = $this->_selectHavingOr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) OR (COUNT(*) = 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test support for parameter in orHaving(), - * e.g. orHaving('count(*) > ?', 1). - */ - - public function testSelectHavingOrWithParameter() - { - $select = $this->_selectHavingOrWithParameter(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfbugs_products"."bug_id", COUNT(*) AS "thecount" FROM "zfbugs_products" GROUP BY "bug_id" HAVING (COUNT(*) > 1) OR (COUNT(*) = 1) ORDER BY "bug_id" ASC', $sql); - } - - /** - * Test adding an ORDER BY clause to a Zend_Db_Select object. - */ - - public function testSelectOrderBy() - { - $select = $this->_selectOrderBy(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC', $sql); - } - - - public function testSelectOrderByArray() - { - $select = $this->_selectOrderByArray(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_name" ASC, "product_id" ASC', $sql); - } - - - public function testSelectOrderByAsc() - { - $select = $this->_selectOrderByAsc(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC', $sql); - } - - - public function testSelectOrderByDesc() - { - $select = $this->_selectOrderByDesc(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" DESC', $sql); - } - - /** - * Test support for qualified table in order(), - * e.g. order('schema.table'). - */ - - public function testSelectOrderByQualified() - { - $select = $this->_selectOrderByQualified(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "zfproducts"."product_id" ASC', $sql); - } - - /** - * Test support for Zend_Db_Expr in order(), - * e.g. order(new Zend_Db_Expr('id+1')). - */ - - public function testSelectOrderByExpr() - { - $select = $this->_selectOrderByExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY 1', $sql); - } - - /** - * Test automatic conversion of SQL functions to - * Zend_Db_Expr, e.g. order('LOWER(title)') - * should give the same result as - * order(new Zend_Db_Expr('LOWER(title)')). - */ - - public function testSelectOrderByAutoExpr() - { - $select = $this->_selectOrderByAutoExpr(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY ABS("zfproducts"."product_id") ASC', $sql); - } - - /** - * Test ORDER BY clause that contains multiple lines. - * See ZF-1822, which says that the regexp matching - * ASC|DESC fails when string is multi-line. - */ - - public function testSelectOrderByMultiLine() - { - $select = $this->_selectOrderByMultiLine(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" DESC', $sql); - } - - /** - * Test adding a LIMIT clause to a Zend_Db_Select object. - */ - - public function testSelectLimit() - { - $select = $this->_selectLimit(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 0', $sql); - } - - - public function testSelectLimitNone() - { - $select = $this->_selectLimitNone(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC', $sql); - } - - - public function testSelectLimitOffset() - { - $select = $this->_selectLimitOffset(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 1', $sql); - } - - /** - * Test the limitPage() method of a Zend_Db_Select object. - */ - - public function testSelectLimitPageOne() - { - $select = $this->_selectLimitPageOne(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 0', $sql); - } - - - public function testSelectLimitPageTwo() - { - $select = $this->_selectLimitPageTwo(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" ORDER BY "product_id" ASC LIMIT 1 OFFSET 1', $sql); - } - - public function testSelectUnionString() - { - $select = $this->_selectUnionString(); - $sql = preg_replace('/\\s+/', ' ', $select->__toString()); - $this->assertEquals('SELECT "bug_id" AS "id", "bug_status" AS "name" FROM "zfbugs" UNION SELECT "product_id" AS "id", "product_name" AS "name" FROM "zfproducts" ORDER BY "id" ASC', $sql); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Table/Select/TestCommon.php b/tests/Zend/Db/Table/Select/TestCommon.php deleted file mode 100644 index 1438c7214222a75529d42546bc5a104f616a546f..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/Select/TestCommon.php +++ /dev/null @@ -1,199 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 6923 2007-11-25 02:00:06Z peptolab $ - */ - - -/** - * @see Zend_Db_Select_TestCommon - */ -require_once 'Zend/Db/Select/TestCommon.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Table_Select_TestCommon extends Zend_Db_Select_TestCommon -{ - - /** - * @var array of Zend_Db_Table_Abstract - */ - protected $_table = array(); - - public function setUp() - { - parent::setUp(); - - $this->_table['accounts'] = $this->_getTable('Zend_Db_Table_TableAccounts'); - $this->_table['bugs'] = $this->_getTable('Zend_Db_Table_TableBugs'); - $this->_table['bugs_products'] = $this->_getTable('Zend_Db_Table_TableBugsProducts'); - $this->_table['products'] = $this->_getTable('Zend_Db_Table_TableProducts'); - } - - protected function _getTable($tableClass, $options = array()) - { - if (is_array($options) && !isset($options['db'])) { - $options['db'] = $this->_db; - } - @Zend_Loader::loadClass($tableClass); - $table = new $tableClass($options); - return $table; - } - - /** - * Get a Zend_Db_Table to provide the base select() - */ - protected function _getSelectTable($table) - { - if (!array_key_exists($table, $this->_table)) { - throw new Zend_Exception('Non-existent table name'); - } - - return $this->_table[$table]; - } - - /** - * Test adding a FOR UPDATE clause to a Zend_Db_Select object. - */ - protected function _selectForReadOnly($fields) - { - $table = $this->_getSelectTable('products'); - - $select = $table->select() - ->from($table, $fields); - return $select; - } - - /** - * Test adding the FOR UPDATE query modifier to a Zend_Db_Select object. - * - */ - public function testSelectForReadOnly() - { - $select = $this->_selectForReadOnly(array('count' => 'COUNT(*)')); - $this->assertTrue($select->isReadOnly()); - - $select = $this->_selectForReadOnly(array()); - $this->assertFalse($select->isReadOnly()); - - $select = $this->_selectForReadOnly(array('*')); - $this->assertFalse($select->isReadOnly()); - } - - /** - * Test adding a JOIN to a Zend_Db_Select object. - */ - protected function _selectForJoinZendDbTable() - { - $table = $this->_getSelectTable('products'); - - $select = $table->select() - ->join(array('p' => 'zfbugs_products'), 'p.product_id = zfproduct.id', 'p.bug_id'); - return $select; - } - - /** - * Test adding a join to the select object without setting integrity check to false. - * - */ - public function testSelectForJoinZendDbTable() - { - $select = $this->_selectForJoinZendDbTable(); - - try { - $query = $select->assemble(); - $this->fail('Expected to catch Zend_Db_Table_Select_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Select_Exception', $e); - $this->assertEquals('Select query cannot join with another table', $e->getMessage()); - } - } - - /** - * Test adding a FOR UPDATE clause to a Zend_Db_Select object. - */ - protected function _selectForToString1($tableName = null, $fields = array('*'), $useTable = true) - { - $table = $this->_getSelectTable($tableName); - - $select = $table->select(); - - if ($useTable) { - $select->from($table, $fields); - } - - return $select; - } - - /** - * Test adding a FOR UPDATE clause to a Zend_Db_Select object. - */ - protected function _selectForToString2($tableName, $fields = array('*')) - { - $select = $this->_db->select() - ->from($tableName, $fields); - return $select; - } - - /** - * Test string conversion to ensure Zend_Db_Table_Select is identical - * to that of Zend_Db_Select. - * - */ - public function testSelectForToString() - { - // Test for all fields and no default table name on select - $select1 = $this->_selectForToString1('products', null, false); - $select2 = $this->_selectForToString2('zfproducts'); - $this->assertEquals($select1->assemble(), $select2->assemble()); - - // Test for all fields by default - $select1 = $this->_selectForToString1('products'); - $select2 = $this->_selectForToString2('zfproducts'); - $this->assertEquals($select1->assemble(), $select2->assemble()); - - // Test for selected fields - $select1 = $this->_selectForToString1('products', array('product_id', 'DISTINCT(product_name)')); - $select2 = $this->_selectForToString2('zfproducts', array('product_id', 'DISTINCT(product_name)')); - $this->assertEquals($select1->assemble(), $select2->assemble()); - } - - /** - * Test to see if a Zend_Db_Table_Select object returns the table it's been - * instantiated from. - * - */ - public function testDbSelectHasTableInstance() - { - $table = $this->_getSelectTable('products'); - $select = $table->select(); - - $this->assertType('Zend_Db_Table_TableProducts', $select->getTable()); - } -} diff --git a/tests/Zend/Db/Table/StaticTest.php b/tests/Zend/Db/Table/StaticTest.php deleted file mode 100644 index 60644d5f42f17ec95850b3eb13fa7adcccf2a5ba..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/StaticTest.php +++ /dev/null @@ -1,41 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/Table/TestCommon.php'; - -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_Table_StaticTest extends PHPUnit_Framework_TestCase -{ - - public function testStatic() - { - $this->markTestIncomplete('Static table tests are not implemented yet'); - } - - public function getDriver() - { - return 'Static'; - } - -} diff --git a/tests/Zend/Db/Table/TableAccounts.php b/tests/Zend/Db/Table/TableAccounts.php deleted file mode 100644 index dd07f56d6575117183c3270dd0533eda6e0e474d..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableAccounts.php +++ /dev/null @@ -1,45 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableAccounts.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_Abstract - */ -require_once 'Zend/Db/Table/Abstract.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableAccounts extends Zend_Db_Table_Abstract -{ - protected $_name = 'zfaccounts'; - protected $_dependentTables = array('Zend_Db_Table_TableBugs'); -} diff --git a/tests/Zend/Db/Table/TableAccountsCustom.php b/tests/Zend/Db/Table/TableAccountsCustom.php deleted file mode 100644 index 831d7d8091377b811f8cc61b6c3b23fd6f797f5a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableAccountsCustom.php +++ /dev/null @@ -1,59 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableAccountsCustom.php 4631 2007-04-30 21:12:37Z darby $ - */ - - -/** - * @see Zend_Db_Table_TableAccounts - */ -require_once 'Zend/Db/Table/TableAccounts.php'; - - -/** - * @see Zend_Db_Table_Row_TestMyRow - */ -require_once 'Zend/Db/Table/Row/TestMyRow.php'; - - -/** - * @see Zend_Db_Table_Row_TestMyRowset - */ -require_once 'Zend/Db/Table/Rowset/TestMyRowset.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableAccountsCustom extends Zend_Db_Table_TableAccounts -{ - protected $_rowClass = 'Zend_Db_Table_Row_TestMyRow'; - protected $_rowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - - protected $_dependentTables = array('Zend_Db_Table_TableBugsCustom'); -} diff --git a/tests/Zend/Db/Table/TableBugs.php b/tests/Zend/Db/Table/TableBugs.php deleted file mode 100644 index 84919a4d63b5525da1f2502d929eefb38dd399eb..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableBugs.php +++ /dev/null @@ -1,67 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableBugs.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_Abstract - */ -require_once 'Zend/Db/Table/Abstract.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableBugs extends Zend_Db_Table_Abstract -{ - - protected $_name = 'zfbugs'; - protected $_primary = 'bug_id'; // Deliberate non-array value - - protected $_dependentTables = array('Zend_Db_Table_TableBugsProducts'); - - protected $_referenceMap = array( - 'Reporter' => array( - 'columns' => array('reported_by'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_name') - ), - 'Engineer' => array( - 'columns' => array('assigned_to'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_name') - ), - 'Verifier' => array( - 'columns' => array('verified_by'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_name') - ) - ); - -} diff --git a/tests/Zend/Db/Table/TableBugsCustom.php b/tests/Zend/Db/Table/TableBugsCustom.php deleted file mode 100644 index 45df19f3ab13b7946604d64251206fdf30df9a42..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableBugsCustom.php +++ /dev/null @@ -1,92 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableBugsCustom.php 5896 2007-07-27 20:04:24Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_TableBugs - */ -require_once 'Zend/Db/Table/TableBugs.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableBugsCustom extends Zend_Db_Table_TableBugs -{ - public $isMetadataFromCache = false; - - protected $_rowClass = 'Zend_Db_Table_Row_TestMyRow'; - protected $_rowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - - protected $_dependentTables = array('Zend_Db_Table_TableBugsProductsCustom'); - - protected $_referenceMap = array( - 'Reporter' => array( - 'columns' => array('reported_by'), - 'refTableClass' => 'Zend_Db_Table_TableAccountsCustom', - 'refColumns' => array('account_name'), - 'onDelete' => self::CASCADE, - 'onUpdate' => self::CASCADE - ), - 'Engineer' => array( - 'columns' => 'assigned_to', - 'refTableClass' => 'Zend_Db_Table_TableAccountsCustom', - 'refColumns' => 'account_name' - ), - 'Verifier' => array( - 'columns' => 'verified_by', - 'refTableClass' => 'Zend_Db_Table_TableAccountsCustom', - 'refColumns' => 'account_name' - ) - ); - - /** - * Public proxy to setup functionality - * - * @return void - */ - public function setup() - { - $this->_setup(); - } - - /** - * Turnkey for initialization of a table object. - * - * @return void - */ - protected function _setup() - { - $this->_setupDatabaseAdapter(); - $this->_setupTableName(); - $this->isMetadataFromCache = $this->_setupMetadata(); - $this->_setupPrimaryKey(); - } -} diff --git a/tests/Zend/Db/Table/TableBugsProducts.php b/tests/Zend/Db/Table/TableBugsProducts.php deleted file mode 100644 index 8e0577ce96d14eb570087a07568d97f48d11aa85..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableBugsProducts.php +++ /dev/null @@ -1,62 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableBugsProducts.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_Abstract - */ -require_once 'Zend/Db/Table/Abstract.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableBugsProducts extends Zend_Db_Table_Abstract -{ - protected $_name = 'zfbugs_products'; - - protected $_referenceMap = array( - 'Bug' => array( - 'columns' => 'bug_id', // Deliberate non-array value - 'refTableClass' => 'Zend_Db_Table_TableBugs', - 'refColumns' => array('bug_id'), - 'onDelete' => -1, // Deliberate false value - 'onUpdate' => -1 // Deliberate false value - ), - 'Product' => array( - 'columns' => array('product_id'), - 'refTableClass' => 'Zend_Db_Table_TableProducts', - 'refColumns' => array('product_id'), - 'onDelete' => self::CASCADE, - 'onUpdate' => self::CASCADE - ) - ); - -} diff --git a/tests/Zend/Db/Table/TableBugsProductsCustom.php b/tests/Zend/Db/Table/TableBugsProductsCustom.php deleted file mode 100644 index 6c6953d92ee937bb7c187f1a23f872640de48d9c..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableBugsProductsCustom.php +++ /dev/null @@ -1,74 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableBugsProductsCustom.php 4778 2007-05-11 18:25:32Z darby $ - */ - - -/** - * @see Zend_Db_Table_TableBugsProducts - */ -require_once 'Zend/Db/Table/TableBugsProducts.php'; - - -/** - * @see Zend_Db_Table_Row_TestMyRow - */ -require_once 'Zend/Db/Table/Row/TestMyRow.php'; - - -/** - * @see Zend_Db_Table_Row_TestMyRowset - */ -require_once 'Zend/Db/Table/Rowset/TestMyRowset.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableBugsProductsCustom extends Zend_Db_Table_TableBugsProducts -{ - protected $_rowClass = 'Zend_Db_Table_Row_TestMyRow'; - protected $_rowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - - protected $_referenceMap = array( - 'Bug' => array( - 'columns' => 'bug_id', - 'refTableClass' => 'Zend_Db_Table_TableBugsCustom', - 'refColumns' => 'bug_id', - 'onDelete' => self::CASCADE, - 'onUpdate' => self::CASCADE - ), - 'Product' => array( - 'columns' => 'product_id', - 'refTableClass' => 'Zend_Db_Table_TableProductsCustom', - 'refColumns' => 'product_id', - 'onDelete' => 'anything but self::CASCADE', - 'onUpdate' => 'anything but self::CASCADE' - ) - ); -} diff --git a/tests/Zend/Db/Table/TableProducts.php b/tests/Zend/Db/Table/TableProducts.php deleted file mode 100644 index 73d51f4893650fcd63cc26ad4f501ea8a64f2aaf..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableProducts.php +++ /dev/null @@ -1,45 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableProducts.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_Abstract - */ -require_once 'Zend/Db/Table/Abstract.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableProducts extends Zend_Db_Table_Abstract -{ - protected $_name = 'zfproducts'; - protected $_dependentTables = array('Zend_Db_Table_TableBugsProducts'); -} diff --git a/tests/Zend/Db/Table/TableProductsCustom.php b/tests/Zend/Db/Table/TableProductsCustom.php deleted file mode 100644 index 24c859e59cfe1aaa61cebb0a6f1c6e4e08f7c105..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableProductsCustom.php +++ /dev/null @@ -1,59 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableProductsCustom.php 4631 2007-04-30 21:12:37Z darby $ - */ - - -/** - * @see Zend_Db_Table_TableProducts - */ -require_once 'Zend/Db/Table/TableProducts.php'; - - -/** - * @see Zend_Db_Table_Row_TestMyRow - */ -require_once 'Zend/Db/Table/Row/TestMyRow.php'; - - -/** - * @see Zend_Db_Table_Row_TestMyRowset - */ -require_once 'Zend/Db/Table/Rowset/TestMyRowset.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_Table_TableProductsCustom extends Zend_Db_Table_TableProducts -{ - protected $_rowClass = 'Zend_Db_Table_Row_TestMyRow'; - protected $_rowsetClass = 'Zend_Db_Table_Rowset_TestMyRowset'; - - protected $_dependentTables = array('Zend_Db_Table_TableBugsProductsCustom'); -} diff --git a/tests/Zend/Db/Table/TableSpecial.php b/tests/Zend/Db/Table/TableSpecial.php deleted file mode 100644 index e07ed8a5882f7b37d3cf3345b4349de68d0e290b..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TableSpecial.php +++ /dev/null @@ -1,42 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableSpecial.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_Table_Abstract - */ -require_once 'Zend/Db/Table/Abstract.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -class Zend_Db_Table_TableSpecial extends Zend_Db_Table_Abstract -{ - // no configuration declared -} - -class zfbugs_products extends Zend_Db_Table_Abstract -{ - // no configuration declared -} diff --git a/tests/Zend/Db/Table/TestCommon.php b/tests/Zend/Db/Table/TestCommon.php deleted file mode 100644 index 4ba56f756fc12c8220053a2d7fb983bf11549330..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TestCommon.php +++ /dev/null @@ -1,1456 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCommon.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Table_TestSetup - */ -require_once 'Zend/Db/Table/TestSetup.php'; - -/** - * @see Zend_Registry - */ -require_once 'Zend/Registry.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Table_TestCommon extends Zend_Db_Table_TestSetup -{ - - public function testTableConstructor() - { - $bugs = $this->_table['bugs']; - $info = $bugs->info(); - - $config = array('db' => $this->_db, - 'schema' => $info['schema'], - 'name' => $info['name'], - 'primary' => $info['primary'], - 'cols' => $info['cols'], - 'metadata' => $info['metadata'], - 'metadataCache' => null, - 'rowClass' => $info['rowClass'], - 'rowsetClass' => $info['rowsetClass'], - 'referenceMap' => $info['referenceMap'], - 'dependentTables' => $info['dependentTables'], - 'sequence' => $info['sequence'], - 'unknownKey' => 'testValue'); - - $table = new Zend_Db_Table_TableBugs($config); - } - - public function testTableInfo() - { - $bugs = $this->_table['bugs']; - $this->assertType('Zend_Db_Table_Abstract', $bugs); - $info = $bugs->info(); - - $keys = array( - Zend_Db_Table_Abstract::SCHEMA, - Zend_Db_Table_Abstract::NAME, - Zend_Db_Table_Abstract::COLS, - Zend_Db_Table_Abstract::PRIMARY, - Zend_Db_Table_Abstract::METADATA, - Zend_Db_Table_Abstract::ROW_CLASS, - Zend_Db_Table_Abstract::ROWSET_CLASS, - Zend_Db_Table_Abstract::REFERENCE_MAP, - Zend_Db_Table_Abstract::DEPENDENT_TABLES, - Zend_Db_Table_Abstract::SEQUENCE, - ); - - $this->assertEquals($keys, array_keys($info)); - - $this->assertEquals('zfbugs', $info['name']); - - $this->assertEquals(8, count($info['cols'])); - $cols = array( - 'bug_id', - 'bug_description', - 'bug_status', - 'created_on', - 'updated_on', - 'reported_by', - 'assigned_to', - 'verified_by' - ); - $this->assertEquals($cols, $info['cols']); - - $this->assertEquals(1, count($info['primary'])); - $pk = array('bug_id'); - $this->assertEquals($pk, array_values($info['primary'])); - - $name = $bugs->info(Zend_Db_Table_Abstract::NAME); - $this->assertEquals('zfbugs', $name); - - try { - $value = $bugs->info('_non_existent_'); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e); - $this->assertEquals('There is no table information for the key "_non_existent_"', $e->getMessage()); - } - } - - /** - * Ensures expected behavior when a table is assigned a Row class of stdClass - * - * @return void - */ - public function testTableSetRowClassStdclass() - { - $productRowset = $this->_table['products']->setRowClass('stdClass')->fetchAll(); - - $this->assertEquals( - 3, - $productRowsetCount = count($productRowset), - "Expected rowset with 3 elements; got $productRowsetCount" - ); - - foreach ($productRowset as $productRow) { - $this->assertThat( - $productRow, - $this->isInstanceOf('stdClass'), - 'Expected row to be instance of stdClass; got ' . get_class($productRow) - ); - } - } - - /** - * Ensures expected behavior when a table is assigned a Rowset class of stdClass - * - * @return void - */ - public function testTableSetRowsetClassStdclass() - { - $productRowset = $this->_table['products']->setRowsetClass('stdClass')->fetchAll(); - - $this->assertThat( - $productRowset, - $this->isInstanceOf('stdClass'), - 'Expected rowset to be instance of stdClass; got ' . get_class($productRowset) - ); - } - - public function testTableImplicitName() - { - Zend_Loader::loadClass('Zend_Db_Table_TableSpecial'); - // TableSpecial.php contains class bugs_products too. - $table = new zfbugs_products(array('db' => $this->_db)); - $info = $table->info(); - $this->assertContains('name', array_keys($info)); - $this->assertEquals('zfbugs_products', $info['name']); - } - - public function testTableOptionName() - { - $tableName = 'zfbugs'; - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName) - ); - $info = $table->info(); - $this->assertContains('name', array_keys($info)); - $this->assertEquals($tableName, $info['name']); - } - - public function testTableOptionSchema() - { - $schemaName = $this->_util->getSchema(); - $tableName = 'zfbugs'; - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName, 'schema' => $schemaName) - ); - $info = $table->info(); - $this->assertContains('schema', array_keys($info)); - $this->assertEquals($schemaName, $info['schema']); - } - - public function testTableArgumentAdapter() - { - $table = $this->_getTable('Zend_Db_Table_TableBugs', - $this->_db); - $db = $table->getAdapter(); - $this->assertSame($this->_db, $db); - } - - public function testTableOptionAdapter() - { - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array('db' => $this->_db)); - $db = $table->getAdapter(); - $this->assertSame($this->_db, $db); - } - - public function testTableOptionRowClass() - { - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array('rowClass' => 'stdClass')); - $rowClass = $table->getRowClass(); - $this->assertEquals($rowClass, 'stdClass'); - - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array('rowsetClass' => 'stdClass')); - $rowsetClass = $table->getRowsetClass(); - $this->assertEquals($rowsetClass, 'stdClass'); - } - - public function testTableGetRowClass() - { - $table = $this->_table['products']; - $this->assertType('Zend_Db_Table_Abstract', $table); - - $rowClass = $table->getRowClass(); - $this->assertEquals($rowClass, 'Zend_Db_Table_Row'); - - $rowsetClass = $table->getRowsetClass(); - $this->assertEquals($rowsetClass, 'Zend_Db_Table_Rowset'); - } - - public function testTableOptionReferenceMap() - { - $refReporter = array( - 'columns' => array('reported_by'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_id') - ); - $refEngineer = array( - 'columns' => array('assigned_to'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_id') - ); - $refMap = array( - 'Reporter' => $refReporter, - 'Engineer' => $refEngineer - ); - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array('referenceMap' => $refMap)); - - $this->assertEquals($refReporter, $table->getReference('Zend_Db_Table_TableAccounts')); - $this->assertEquals($refReporter, $table->getReference('Zend_Db_Table_TableAccounts', 'Reporter')); - $this->assertEquals($refEngineer, $table->getReference('Zend_Db_Table_TableAccounts', 'Engineer')); - } - - public function testTableExceptionOptionReferenceMap() - { - $refReporter = array( - 'columns' => array('reported_by'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_id') - ); - $refEngineer = array( - 'columns' => array('assigned_to'), - 'refTableClass' => 'Zend_Db_Table_TableAccounts', - 'refColumns' => array('account_id') - ); - $refMap = array( - 'Reporter' => $refReporter, - 'Engineer' => $refEngineer - ); - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array('referenceMap' => $refMap)); - - try { - $ref = $table->getReference('Zend_Db_Table_TableAccounts', 'Verifier'); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e); - $this->assertEquals('No reference rule "Verifier" from table Zend_Db_Table_TableBugs to table Zend_Db_Table_TableAccounts', $e->getMessage()); - } - - try { - $ref = $table->getReference('Zend_Db_Table_TableProducts'); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e); - $this->assertEquals('No reference from table Zend_Db_Table_TableBugs to table Zend_Db_Table_TableProducts', $e->getMessage()); - } - - try { - $ref = $table->getReference('Zend_Db_Table_TableProducts', 'Product'); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e); - $this->assertEquals('No reference rule "Product" from table Zend_Db_Table_TableBugs to table Zend_Db_Table_TableProducts', $e->getMessage()); - } - - try { - $ref = $table->getReference('Zend_Db_Table_TableProducts', 'Reporter'); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e); - $this->assertEquals('Reference rule "Reporter" does not reference table Zend_Db_Table_TableProducts', $e->getMessage()); - } - - } - - public function testTableOptionDependentTables() - { - $depTables = array('Zend_Db_Table_Foo'); - $table = $this->_getTable('Zend_Db_Table_TableBugs', - array('dependentTables' => $depTables)); - $this->assertEquals($depTables, $table->getDependentTables()); - } - - public function testTableSetRowClass() - { - $table = $this->_table['products']; - $this->assertType('Zend_Db_Table_Abstract', $table); - - $table->setRowClass('stdClass'); - $rowClass = $table->getRowClass(); - $this->assertEquals($rowClass, 'stdClass'); - - $table->setRowsetClass('stdClass'); - $rowsetClass = $table->getRowsetClass(); - $this->assertEquals($rowsetClass, 'stdClass'); - } - - public function testTableSetDefaultAdapter() - { - /** - * Don't use _getTable() method because it defaults the adapter - */ - Zend_Loader::loadClass('Zend_Db_Table_TableBugs'); - Zend_Db_Table_Abstract::setDefaultAdapter($this->_db); - $db = Zend_Db_Table_Abstract::getDefaultAdapter(); - $this->assertSame($this->_db, $db); - $table = new Zend_Db_Table_TableBugs(); - $db = $table->getAdapter(); - $this->assertSame($this->_db, $db); - } - - public function testTableWithNoAdapterAndNoDefaultAdapter() - { - Zend_Db_Table_Abstract::setDefaultAdapter(null); - $this->assertNull(Zend_Db_Table_Abstract::getDefaultAdapter()); - try { - $table = new Zend_Db_Table_TableBugs(); - $this->fail('Zend_Db_Table_Exception should be thrown'); - }catch(Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - } - } - - public function testTableSetDefaultAdapterNull() - { - Zend_Db_Table_Abstract::setDefaultAdapter($this->_db); - $db = Zend_Db_Table_Abstract::getDefaultAdapter(); - $this->assertSame($this->_db, $db); - Zend_Db_Table_Abstract::setDefaultAdapter(); - $this->assertNull(Zend_Db_Table_Abstract::getDefaultAdapter()); - } - - public function testTableSetDefaultAdapterRegistry() - { - /** - * Don't use _getTable() method because it defaults the adapter - */ - Zend_Loader::loadClass('Zend_Db_Table_TableBugs'); - Zend_Registry::set('registered_db', $this->_db); - Zend_Db_Table_Abstract::setDefaultAdapter('registered_db'); - $db = Zend_Db_Table_Abstract::getDefaultAdapter(); - $this->assertSame($this->_db, $db); - $table = new Zend_Db_Table_TableBugs(); - $db = $table->getAdapter(); - $this->assertSame($this->_db, $db); - } - - public function testTableSetDefaultAdapterException() - { - try { - Zend_Db_Table_Abstract::setDefaultAdapter(new stdClass()); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored", $e->getMessage()); - } - - try { - Zend_Db_Table_Abstract::setDefaultAdapter(327); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored", $e->getMessage()); - } - } - - public function testTableExceptionPrimaryKeyNotSpecified() - { - try { - $table = $this->_getTable('Zend_Db_Table_TableBugs', array('primary' => '')); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertContains("Primary key column(s)", $e->getMessage()); - $this->assertContains("are not columns in this table", $e->getMessage()); - } - } - - public function testTableExceptionInvalidPrimaryKey() - { - try { - $table = new Zend_Db_Table_TableBugs(array('primary' => 'foo')); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertContains("Primary key column(s)", $e->getMessage()); - $this->assertContains("are not columns in this table", $e->getMessage()); - } - } - - public function testTableExceptionNoPrimaryKey() - { - // create a table that has no primary key - $this->_util->createTable('noprimarykey', array('id' => 'INTEGER')); - $tableName = $this->_util->getTableName('noprimarykey'); - - try { - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName)); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals('A table must have a primary key, but none was found', $e->getMessage()); - } - - $this->_util->dropTable($tableName); - } - - public function testTableWithNoPrimaryKeyButOptionSpecifiesOne() - { - // create a table that has no primary key constraint - $this->_util->createTable('noprimarykey', array('id' => 'INTEGER')); - $tableName = $this->_util->getTableName('noprimarykey'); - - try { - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName, 'primary' => 'id')); - } catch (Zend_Exception $e) { - $this->fail('Expected to succeed without a Zend_Db_Table_Exception'); - } - - $info = $table->info(); - $this->assertEquals(array(1=>'id'), $info['primary']); - - $this->_util->dropTable($tableName); - } - - public function testTableAdapterException() - { - Zend_Loader::loadClass('Zend_Db_Table_TableBugs'); - - /** - * options array points 'db' to integer scalar - */ - try { - $table = new Zend_Db_Table_TableBugs(array('db' => 327)); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored", $e->getMessage()); - } - - /** - * options array points 'db' to Registry key containing integer scalar - */ - Zend_Registry::set('registered_db', 327); - try { - $table = new Zend_Db_Table_TableBugs(array('db' => 'registered_db')); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored", $e->getMessage()); - } - } - - public function testTableFindSingleRow() - { - $table = $this->_table['bugs']; - $rowset = $table->find(1); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(1, count($rowset)); - } - - public function testTableFindMultipleRows() - { - $table = $this->_table['bugs']; - $rowset = $table->find(array(1, 2)); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(2, count($rowset)); - } - - public function testTableFindExceptionTooFewKeys() - { - $table = $this->_table['bugs_products']; - try { - $table->find(1); - $this->fail('Expected to catch Zend_Db_Table_Exception for missing key'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals('Too few columns for the primary key', $e->getMessage()); - } - } - - public function testTableFindExceptionTooManyKeys() - { - $table = $this->_table['bugs']; - try { - $table->find(1, 2); - $this->fail('Expected to catch Zend_Db_Table_Exception for incorrect key count'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals('Too many columns for the primary key', $e->getMessage()); - } - } - - public function testTableFindCompoundSingleRow() - { - $table = $this->_table['bugs_products']; - $rowset = $table->find(1, 2); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(1, count($rowset)); - } - - public function testTableFindCompoundMultipleRows() - { - $table = $this->_table['bugs_products']; - $rowset = $table->find(array(1, 1), array(2, 3)); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(2, count($rowset)); - } - - public function testTableFindCompoundMultipleExceptionIncorrectValueCount() - { - $table = $this->_table['bugs_products']; - try { - $rowset = $table->find(array(1, 1), 2); - $this->fail('Expected to catch Zend_Db_Table_Exception for incorrect key count'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals('Missing value(s) for the primary key', $e->getMessage()); - } - } - - public function testTableInsert() - { - $table = $this->_table['bugs']; - $row = array ( - 'bug_id' => null, - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId(); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals(5, $lastInsertId); - } - - public function testTableInsertWithSchema() - { - $schemaName = $this->_util->getSchema(); - $tableName = 'zfbugs'; - $identifier = join('.', array_filter(array($schemaName, $tableName))); - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName, 'schema' => $schemaName) - ); - - $row = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ); - - $profilerEnabled = $this->_db->getProfiler()->getEnabled(); - $this->_db->getProfiler()->setEnabled(true); - $insertResult = $table->insert($row); - $this->_db->getProfiler()->setEnabled($profilerEnabled); - - $qp = $this->_db->getProfiler()->getLastQueryProfile(); - $tableSpec = $this->_db->quoteIdentifier($identifier, true); - $this->assertContains("INSERT INTO $tableSpec ", $qp->getQuery()); - } - - public function testTableInsertSequence() - { - $table = $this->_getTable('Zend_Db_Table_TableProducts', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfproducts_seq')); - - $row = array ( - 'product_name' => 'Solaris' - ); - $insertResult = $table->insert($row); - $lastInsertId = $this->_db->lastInsertId('zfproducts'); - $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq'); - $this->assertEquals($insertResult, $lastInsertId); - $this->assertEquals($insertResult, $lastSequenceId); - $this->assertEquals(4, $insertResult); - } - - public function testTableInsertNaturalCompound() - { - $table = $this->_table['bugs_products']; - $row = array( - 'bug_id' => 2, - 'product_id' => 1 - ); - $primary = $table->insert($row); - $this->assertType('array', $primary); - $this->assertEquals(2, count($primary)); - $this->assertEquals(array(2, 1), array_values($primary)); - } - - /** - * @todo - * - public function testTableInsertNaturalExceptionKeyViolation() - { - $table = $this->_table['bugs']; - $row = array ( - 'bug_id' => 1, - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - try { - $insertResult = $table->insert($row); - $this->fail('Expected to catch Zend_Db_Table_Exception for key violation'); - } catch (Zend_Exception $e) { - echo "*** caught ".get_class($e)."\n"; - echo "*** ".$e->getMessage()."\n"; - $this->assertEquals('xxx', $e->getMessage()); - } - } - */ - - /** - * @todo - * - public function testTableInsertNaturalCompoundExceptionKeyViolation() - { - $table = $this->_table['bugs_products']; - $row = array( - 'bug_id' => 1, - 'product_id' => 1 - ); - try { - $table->insert($row); - $this->fail('Expected to catch Zend_Db_Table_Exception for key violation'); - } catch (Zend_Exception $e) { - echo "*** caught ".get_class($e)."\n"; - echo "*** ".$e->getMessage()."\n"; - $this->assertEquals('xxx', $e->getMessage()); - } - } - */ - - /** - * See ZF-1739 in our issue tracker. - */ - public function testTableInsertMemoryUsageZf1739() - { - $this->markTestSkipped('Very slow test inserts thousands of rows'); - - $table = $this->_table['products']; - - // insert one row to prime the pump - $table->insert(array('product_name' => "product0")); - - // measure current memory usage - $mem1 = memory_get_usage(); - - // insert a lot of rows - $n = 100000; - for ($i = 1; $i <= $n; $i++) - { - $table->insert(array('product_name' => "product$i")); - if ($i % 1000 == 0) { - echo '.'; - } - } - - // measure new memory usage - $mem2 = memory_get_usage(); - - // compare new memory usage to original - $mem_delta = $mem2-$mem1; - $this->assertThat($mem_delta, $this->lessThan(513)); - } - - public function testTableUpdate() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - $data = array( - $bug_description => 'Implement Do What I Mean function', - $bug_status => 'INCOMPLETE' - ); - $table = $this->_table['bugs']; - $result = $table->update($data, "$bug_id = 2"); - $this->assertEquals(1, $result); - - // Query the row to see if we have the new values. - $rowset = $table->find(2); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(1, count($rowset), "Expecting rowset count to be 1"); - $row = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row->$bug_id, "Expecting row->bug_id to be 2"); - $this->assertEquals($data[$bug_description], $row->$bug_description); - $this->assertEquals($data[$bug_status], $row->$bug_status); - } - - public function testTableUpdateWithSchema() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_description = $this->_db->foldCase('bug_description'); - $bug_status = $this->_db->foldCase('bug_status'); - $schemaName = $this->_util->getSchema(); - $tableName = 'zfbugs'; - $identifier = join('.', array_filter(array($schemaName, $tableName))); - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName, 'schema' => $schemaName) - ); - - $data = array( - $bug_description => 'Implement Do What I Mean function', - $bug_status => 'INCOMPLETE' - ); - - $profilerEnabled = $this->_db->getProfiler()->getEnabled(); - $this->_db->getProfiler()->setEnabled(true); - $result = $table->update($data, "$bug_id = 2"); - $this->_db->getProfiler()->setEnabled($profilerEnabled); - - $this->assertEquals(1, $result); - $qp = $this->_db->getProfiler()->getLastQueryProfile(); - $tableSpec = $this->_db->quoteIdentifier($identifier, true); - $this->assertContains("UPDATE $tableSpec ", $qp->getQuery()); - } - - public function testTableUpdateWhereArray() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_status = $this->_db->quoteIdentifier('bug_status', true); - - $bug_description = $this->_db->foldCase('bug_description'); - $data = array( - $bug_description => 'Synesthesia', - ); - - $where = array( - "$bug_id IN (1, 3)", - "$bug_status != 'UNKNOWN'" - ); - - $this->assertEquals(2, $this->_table['bugs']->update($data, $where)); - - $count = 0; - foreach ($this->_table['bugs']->find(array(1, 3)) as $row) { - $this->assertEquals($data[$bug_description], $row->$bug_description); - ++$count; - } - - $this->assertEquals(2, $count); - } - - public function testTableDelete() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $rowset = $table->find(array(1, 2)); - $this->assertEquals(2, count($rowset)); - - $table->delete("$bug_id = 2"); - - $rowset = $table->find(array(1, 2)); - $this->assertEquals(1, count($rowset)); - } - - public function testTableDeleteWithSchema() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $schemaName = $this->_util->getSchema(); - $tableName = 'zfbugs'; - $identifier = join('.', array_filter(array($schemaName, $tableName))); - $table = $this->_getTable('Zend_Db_Table_TableSpecial', - array('name' => $tableName, 'schema' => $schemaName) - ); - - $profilerEnabled = $this->_db->getProfiler()->getEnabled(); - $this->_db->getProfiler()->setEnabled(true); - $result = $table->delete("$bug_id = 2"); - $this->_db->getProfiler()->setEnabled($profilerEnabled); - - $qp = $this->_db->getProfiler()->getLastQueryProfile(); - $tableSpec = $this->_db->quoteIdentifier($identifier, true); - $this->assertContains("DELETE FROM $tableSpec ", $qp->getQuery()); - } - - public function testTableDeleteWhereArray() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - $bug_status = $this->_db->quoteIdentifier('bug_status', true); - - $where = array( - "$bug_id IN (1, 3)", - "$bug_status != 'UNKNOWN'" - ); - - $this->assertEquals(2, $this->_table['bugs']->delete($where)); - - $this->assertEquals(0, count($this->_table['bugs']->find(array(1, 3)))); - } - - public function testTableCreateRow() - { - $table = $this->_table['bugs']; - $row = $table->createRow(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $this->assertTrue(isset($row->bug_description)); - $this->assertEquals($row, $table->fetchNew()); - } - - public function testTableCreateRowWithData() - { - $table = $this->_table['bugs']; - $data = array ( - 'bug_description' => 'New bug', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'micky', - 'assigned_to' => 'goofy' - ); - $row = $table->createRow($data); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $this->assertTrue(isset($row->bug_description)); - $this->assertEquals('New bug', $row->bug_description); - } - - public function testTableFetchRow() - { - $table = $this->_table['bugs']; - $bug_description = $this->_db->foldCase('bug_description'); - $row = $table->fetchRow(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $this->assertTrue(isset($row->$bug_description)); - } - - public function testTableFetchRowWhere() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $row = $table->fetchRow("$bug_id = 2"); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row->$bug_id); - } - - public function testTableFetchRowWhereArray() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $row = $table->fetchRow(array("$bug_id = ?" => 2)); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row->$bug_id); - } - - public function testTableFetchRowWhereSelect() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $select = $table->select() - ->where("$bug_id = ?", 2); - - $row = $table->fetchRow($select); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row->$bug_id); - } - - public function testTableFetchRowOrderAsc() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $row = $table->fetchRow("$bug_id > 1", "bug_id ASC"); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row->$bug_id); - } - - public function testTableFetchRowOrderSelectAsc() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $select = $table->select() - ->where("$bug_id > ?", 1) - ->order("bug_id ASC"); - - $row = $table->fetchRow($select); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row->$bug_id); - } - - public function testTableFetchRowOrderDesc() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $row = $table->fetchRow(null, "bug_id DESC"); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(4, $row->$bug_id); - } - - public function testTableFetchRowOrderSelectDesc() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $select = $table->select() - ->where("$bug_id > ?", 1) - ->order("bug_id DESC"); - - $row = $table->fetchRow($select); - $this->assertType('Zend_Db_Table_Row_Abstract', $row, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(4, $row->$bug_id); - } - - public function testTableFetchRowEmpty() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $row = $table->fetchRow("$bug_id = -1"); - $this->assertEquals(null, $row, - 'Expecting null result for non-existent row'); - } - - public function testTableFetchAll() - { - $table = $this->_table['bugs']; - $rowset = $table->fetchAll(); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(4, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - } - - public function testTableFetchAllWhere() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $rowset = $table->fetchAll("$bug_id = 2"); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(1, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row1->$bug_id); - } - - public function testTableFetchAllWhereSelect() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - $select = $table->select() - ->where("$bug_id = ?", 2); - - $rowset = $table->fetchAll($select); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(1, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row1->$bug_id); - } - - public function testTableFetchAllOrder() - { - $table = $this->_table['bugs']; - $rowset = $table->fetchAll(null, 'bug_id DESC'); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(4, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(4, $row1->$bug_id); - } - - public function testTableFetchAllOrderSelect() - { - $table = $this->_table['bugs']; - $select = $table->select() - ->order('bug_id DESC'); - - $rowset = $table->fetchAll($select); - $this->assertType('Zend_Db_Table_Rowset_Abstract', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($rowset)); - $this->assertEquals(4, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row_Abstract', $row1, - 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(4, $row1->$bug_id); - } - - public function testTableFetchAllOrderExpr() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $rowset = $table->fetchAll(null, new Zend_Db_Expr("$bug_id + 1 DESC")); - $this->assertType('Zend_Db_Table_Rowset', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset, got '.get_class($rowset)); - $this->assertEquals(4, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row', $row1, - 'Expecting object of type Zend_Db_Table_Row, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(4, $row1->$bug_id); - } - - public function testTableFetchAllLimit() - { - $table = $this->_table['bugs']; - $rowset = $table->fetchAll(null, 'bug_id ASC', 2, 1); - $this->assertType('Zend_Db_Table_Rowset', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset, got '.get_class($rowset)); - $this->assertEquals(2, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row', $row1, - 'Expecting object of type Zend_Db_Table_Row, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row1->$bug_id); - } - - public function testTableFetchAllLimitSelect() - { - $table = $this->_table['bugs']; - $select = $table->select() - ->order('bug_id ASC') - ->limit(2, 1); - - $rowset = $table->fetchAll($select); - $this->assertType('Zend_Db_Table_Rowset', $rowset, - 'Expecting object of type Zend_Db_Table_Rowset, got '.get_class($rowset)); - $this->assertEquals(2, count($rowset)); - $row1 = $rowset->current(); - $this->assertType('Zend_Db_Table_Row', $row1, - 'Expecting object of type Zend_Db_Table_Row, got '.get_class($row1)); - $bug_id = $this->_db->foldCase('bug_id'); - $this->assertEquals(2, $row1->$bug_id); - } - - public function testTableFetchAllEmpty() - { - $bug_id = $this->_db->quoteIdentifier('bug_id', true); - - $table = $this->_table['bugs']; - - $rowset = $table->fetchAll("$bug_id = -1"); - $this->assertEquals(0, count($rowset)); - } - - public function testTableLoadsCustomRowClass() - { - if (class_exists('Zend_Db_Table_Row_TestMyRow')) { - $this->markTestSkipped("Cannot test loading the custom Row class because it is already loaded"); - return; - } - - $this->assertFalse(class_exists('Zend_Db_Table_Row_TestMyRow', false), - 'Expected TestMyRow class not to be loaded (#1)'); - $this->assertFalse(class_exists('Zend_Db_Table_Rowset_TestMyRowset', false), - 'Expected TestMyRowset class not to be loaded (#1)'); - - // instantiating the table does not creat a rowset - // so the custom classes are not loaded yet - $bugsTable = $this->_getTable('Zend_Db_Table_TableBugsCustom'); - - $this->assertFalse(class_exists('Zend_Db_Table_Row_TestMyRow', false), - 'Expected TestMyRow class not to be loaded (#2)'); - $this->assertFalse(class_exists('Zend_Db_Table_Rowset_TestMyRowset', false), - 'Expected TestMyRowset class not to be loaded (#2)'); - - // creating a rowset makes the table load the rowset class - // and the rowset constructor loads the row class. - $bugs = $bugsTable->fetchAll(); - - $this->assertTrue(class_exists('Zend_Db_Table_Row_TestMyRow', false), - 'Expected TestMyRow class to be loaded (#3)'); - $this->assertTrue(class_exists('Zend_Db_Table_Rowset_TestMyRowset', false), - 'Expected TestMyRowset class to be loaded (#3)'); - } - - /** - * Ensures that Zend_Db_Table_Abstract::setDefaultMetadataCache() performs as expected - * - * @return void - */ - public function testTableSetDefaultMetadataCache() - { - $cache = $this->_getCache(); - - Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); - - $this->assertSame($cache, Zend_Db_Table_Abstract::getDefaultMetadataCache()); - - Zend_Db_Table_Abstract::setDefaultMetadataCache(); - - $this->assertNull(Zend_Db_Table_Abstract::getDefaultMetadataCache()); - } - - public function testTableSetDefaultMetadataCacheRegistry() - { - $cache = $this->_getCache(); - Zend_Registry::set('registered_metadata_cache', $cache); - Zend_Db_Table_Abstract::setDefaultMetadataCache('registered_metadata_cache'); - $this->assertSame($cache, Zend_Db_Table_Abstract::getDefaultMetadataCache()); - } - - public function testTableMetadataCacheRegistry() - { - $cache = $this->_getCache(); - - Zend_Registry::set('registered_metadata_cache', $cache); - - $tableBugsCustom1 = $this->_getTable( - 'Zend_Db_Table_TableBugsCustom', - array('metadataCache' => 'registered_metadata_cache') - ); - - $this->assertSame($cache, $tableBugsCustom1->getMetadataCache()); - } - - public function testTableSetDefaultMetadataCacheWriteAccess() - { - $cache = $this->_getCacheNowrite(); - Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); - - try { - $bugsTable = $this->_getTable('Zend_Db_Table_TableBugs'); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e); - $this->assertEquals('Failed saving metadata to metadataCache', $e->getMessage()); - } - - Zend_Db_Table_Abstract::setDefaultMetadataCache(null); - } - - /** - * Ensures that table metadata caching works as expected when the cache object - * is set in the configuration for a new table object. - * - * @return void - */ - public function testTableMetadataCacheNew() - { - $cache = $this->_getCache(); - - $tableBugsCustom1 = $this->_getTable( - 'Zend_Db_Table_TableBugsCustom', - array('metadataCache' => $cache) - ); - - $this->assertType( - 'Zend_Cache_Core', - $tableBugsCustom1->getMetadataCache() - ); - - $this->assertFalse($tableBugsCustom1->isMetadataFromCache); - - $tableBugsCustom1->setup(); - - $this->assertTrue($tableBugsCustom1->isMetadataFromCache); - - $cache->clean(Zend_Cache::CLEANING_MODE_ALL); - - $tableBugsCustom1->setup(); - - $this->assertFalse($tableBugsCustom1->isMetadataFromCache); - } - - /** - * Ensures that table metadata caching works as expected when the default cache object - * is set for the abstract table class. - * - * @return void - */ - public function testTableMetadataCacheClass() - { - $cache = $this->_getCache(); - - Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); - - $tableBugsCustom1 = $this->_getTable('Zend_Db_Table_TableBugsCustom'); - - $this->assertFalse($tableBugsCustom1->isMetadataFromCache); - - $this->assertType( - 'Zend_Cache_Core', - $tableBugsCustom1->getMetadataCache() - ); - - $tableBugsCustom1->setup(); - - $this->assertTrue($tableBugsCustom1->isMetadataFromCache); - - $cache->clean(Zend_Cache::CLEANING_MODE_ALL); - - $tableBugsCustom1->setup(); - - $this->assertFalse($tableBugsCustom1->isMetadataFromCache); - } - - public function testTableSetDefaultMetadataCacheException() - { - try { - Zend_Db_Table_Abstract::setDefaultMetadataCache(new stdClass()); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored", $e->getMessage()); - } - - try { - Zend_Db_Table_Abstract::setDefaultMetadataCache(327); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored", $e->getMessage()); - } - } - - public function testTableMetadataCacheException() - { - Zend_Loader::loadClass('Zend_Db_Table_TableBugs'); - - /** - * options array points 'metadataCache' to integer scalar - */ - try { - $table = new Zend_Db_Table_TableBugs(array('metadataCache' => 327)); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored", $e->getMessage()); - } - - /** - * options array points 'metadataCache' to Registry key containing integer scalar - */ - Zend_Registry::set('registered_metadata_cache', 327); - try { - $table = new Zend_Db_Table_TableBugs(array('metadataCache' => 'registered_metadata_cache')); - $this->fail('Expected to catch Zend_Db_Table_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Db_Table_Exception', $e, - 'Expecting object of type Zend_Db_Table_Exception, got '.get_class($e)); - $this->assertEquals("Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored", $e->getMessage()); - } - } - - public function testTableCascadeUpdate() - { - $table = $this->_table['products']; - $row1 = $table->find(1)->current(); - $rows1 = $row1->findManyToManyRowset('Zend_Db_Table_TableBugs', 'Zend_Db_Table_TableBugsProducts'); - - $product_id = $this->_db->foldCase('product_id'); - $row1->$product_id = 999999; - $row1->save(); - $rows2 = $row1->findManyToManyRowset('Zend_Db_Table_TableBugs', 'Zend_Db_Table_TableBugsProducts'); - - $this->assertEquals(999999, $row1->$product_id); - $this->assertEquals(count($rows1), count($rows2)); - - // Test for 'false' value in cascade config - $bug_id = $this->_db->foldCase('bug_id'); - $row2 = $rows2->current(); - $row2->$bug_id = 999999; - $row2->save(); - } - - public function testTableCascadeDelete() - { - $table = $this->_table['products']; - $row1 = $table->find(2)->current(); - $row1->delete(); - - // Test for 'false' value in cascade config - $table = $this->_table['bugs']; - $row2 = $table->find(1)->current(); - $row2->delete(); - - $table = $this->_table['bugs_products']; - $select = $table->select() - ->where('product_id = ?', 2); - - $rows = $table->fetchAll($select); - $this->assertEquals(0, count($rows)); - } - - /** - * Returns a clean Zend_Cache_Core with File backend - * - * @return Zend_Cache_Core - */ - protected function _getCache() - { - /** - * @see Zend_Cache - */ - require_once 'Zend/Cache.php'; - - $folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - - $frontendOptions = array( - 'automatic_serialization' => true - ); - - $backendOptions = array( - 'cache_dir' => $folder, - 'file_name_prefix' => 'Zend_Db_Table_TestCommon' - ); - - $cacheFrontend = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); - - $cacheFrontend->clean(Zend_Cache::CLEANING_MODE_ALL); - - return $cacheFrontend; - } - - /** - * Returns a clean Zend_Cache_Core with File backend - * - * @return Zend_Cache_Core - */ - protected function _getCacheNowrite() - { - /** - * @see Zend_Cache - */ - require_once 'Zend/Cache.php'; - - $folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_nofiles'; - if (!file_exists($folder)) { - mkdir($folder, 0777); - } - - $frontendOptions = array( - 'automatic_serialization' => true - ); - - $backendOptions = array( - 'cache_dir' => $folder, - 'file_name_prefix' => 'Zend_Db_Table_TestCommon' - ); - - $cacheFrontend = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); - - $cacheFrontend->clean(Zend_Cache::CLEANING_MODE_ALL); - - rmdir($folder); - - return $cacheFrontend; - } - -} diff --git a/tests/Zend/Db/Table/TestSetup.php b/tests/Zend/Db/Table/TestSetup.php deleted file mode 100644 index 5e8ec4b967a175cc0181b8e27b8b070b4167b1f4..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/Table/TestSetup.php +++ /dev/null @@ -1,69 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestSetup.php 4791 2007-05-12 23:54:20Z bkarwin $ - */ - - -/** - * @see Zend_Db_TestSetup - */ -require_once 'Zend/Db/TestSetup.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_Table_TestSetup extends Zend_Db_TestSetup -{ - - /** - * @var array of Zend_Db_Table_Abstract - */ - protected $_table = array(); - - public function setUp() - { - parent::setUp(); - - $this->_table['accounts'] = $this->_getTable('Zend_Db_Table_TableAccounts'); - $this->_table['bugs'] = $this->_getTable('Zend_Db_Table_TableBugs'); - $this->_table['bugs_products'] = $this->_getTable('Zend_Db_Table_TableBugsProducts'); - $this->_table['products'] = $this->_getTable('Zend_Db_Table_TableProducts'); - } - - protected function _getTable($tableClass, $options = array()) - { - if (is_array($options) && !isset($options['db'])) { - $options['db'] = $this->_db; - } - Zend_Loader::loadClass($tableClass); - $table = new $tableClass($options); - return $table; - } - -} diff --git a/tests/Zend/Db/TestSetup.php b/tests/Zend/Db/TestSetup.php deleted file mode 100644 index d34b944145552a3edd469e490099de38618a74a6..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestSetup.php +++ /dev/null @@ -1,123 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestSetup.php 6847 2007-11-18 05:24:21Z peptolab $ - */ - - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - -/** - * @see Zend_Db - */ -require_once 'Zend/Db.php'; - -/** - * PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_TestSetup extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Db_TestUtil - */ - protected $_util = null; - - /** - * @var Zend_Db_Adapter_Abstract - */ - protected $_db = null; - - public abstract function getDriver(); - - /** - * Subclasses should call parent::setUp() before - * doing their own logic, e.g. creating metadata. - */ - public function setUp() - { - $this->_setUpTestUtil(); - $this->_setUpAdapter(); - $this->_util->setUp($this->_db); - } - - /** - * Get a TestUtil class for the current RDBMS brand. - */ - protected function _setUpTestUtil() - { - $driver = $this->getDriver(); - $utilClass = "Zend_Db_TestUtil_{$driver}"; - Zend_Loader::loadClass($utilClass); - $this->_util = new $utilClass(); - } - - /** - * Open a new database connection - */ - protected function _setUpAdapter() - { - $this->_db = Zend_Db::factory($this->getDriver(), $this->_util->getParams()); - try { - $conn = $this->_db->getConnection(); - } catch (Zend_Exception $e) { - $this->_db = null; - $this->assertType('Zend_Db_Adapter_Exception', $e, - 'Expecting Zend_Db_Adapter_Exception, got ' . get_class($e)); - $this->markTestSkipped($e->getMessage()); - } - } - - /** - * Subclasses should call parent::tearDown() after - * doing their own logic, e.g. deleting metadata. - */ - public function tearDown() - { - $this->_util->tearDown(); - $this->_db = null; - } - -} diff --git a/tests/Zend/Db/TestUtil/Common.php b/tests/Zend/Db/TestUtil/Common.php deleted file mode 100644 index 046bdd1d24cc98176b23c4e964246ade2c26e98a..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Common.php +++ /dev/null @@ -1,478 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Common.php 7508 2008-01-19 03:12:38Z peptolab $ - */ - - -/** - * @see Zend_Db_Expr - */ -require_once 'Zend/Db/Expr.php'; - -/** - * PHPUnit_Util_Filter - */ -// require_once 'PHPUnit/Util/Filter.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_TestUtil_Common -{ - /** - * @var Zend_Db_Adapter_Abstract - */ - protected $_db = null; - - /** - * @var array - */ - protected $_tables = array(); - - /** - * @var array - */ - protected $_sequences = array(); - - protected function _getSqlCreateTable($tableName) - { - return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - - protected function _getSqlCreateTableType() - { - return null; - } - - protected function _getSqlDropTable($tableName) - { - return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - - public function getSqlType($type) - { - return $type; - } - - public function createTable($tableId, array $columns = array()) - { - if (!$columns) { - $columns = $this->{'_getColumns'.$tableId}(); - } - $tableName = $this->getTableName($tableId); - $this->dropTable($tableName); - - if (isset($this->_tables[$tableName])) { - return; - } - $sql = $this->_getSqlCreateTable($tableName); - if (!$sql) { - return; - } - $sql .= " (\n\t"; - - $pKey = null; - $pKeys = array(); - if (isset($columns['PRIMARY KEY'])) { - $pKey = $columns['PRIMARY KEY']; - unset($columns['PRIMARY KEY']); - foreach (explode(',', $pKey) as $pKeyCol) { - $pKeys[] = $this->_db->quoteIdentifier($pKeyCol, true); - } - $pKey = implode(', ', $pKeys); - } - - foreach ($columns as $columnName => $type) { - $col[] = $this->_db->quoteIdentifier($columnName, true) . ' ' . $this->getSqlType($type); - } - - if ($pKey) { - $col[] = "PRIMARY KEY ($pKey)"; - } - - $sql .= implode(",\n\t", $col); - $sql .= "\n)" . $this->_getSqlCreateTableType(); - $result = $this->_rawQuery($sql); - if ($result === false) { - throw new Zend_Db_Exception("Statement failed:\n$sql\nError: " . $this->_db->getConnection()->error); - } - $this->_tables[$tableName] = true; - } - - public function dropTable($tableName = null) - { - if (!$tableName) { - foreach ($this->_tableName as $tab) { - $this->dropTable($tab); - } - return; - } - - $sql = $this->_getSqlDropTable($tableName); - if (!$sql) { - return; - } - $result = $this->_rawQuery($sql); - if ($result === false) { - throw new Zend_Db_Exception("DROP TABLE statement failed:\n$sql\nError: " . $this->_db->getConnection()->error); - } - unset($this->_tables[$tableName]); - } - - protected function _getSqlCreateSequence($sequenceName) - { - return null; - } - - protected function _getSqlDropSequence($sequenceName) - { - return null; - } - - public function createSequence($sequenceName) - { - $this->dropSequence($sequenceName); - if (isset($this->_sequences[$sequenceName])) { - return; - } - $sql = $this->_getSqlCreateSequence($sequenceName); - if (!$sql) { - return; - } - $result = $this->_rawQuery($sql); - if ($result === false) { - throw new Zend_Db_Exception("CREATE SEQUENCE statement failed:\n$sql\nError: " . $this->_db->getConnection()->error); - } - $this->_sequences[$sequenceName] = true; - } - - public function dropSequence($sequenceName = null) - { - if (!$sequenceName) { - foreach (array_keys($this->_sequences) as $seq) { - $this->dropSequence($seq); - } - return; - } - - $sql = $this->_getSqlDropSequence($sequenceName); - if (!$sql) { - return; - } - $result = $this->_rawQuery($sql); - if ($result === false) { - throw new Zend_Db_Exception("DROP SEQUENCE statement failed:\n$sql\nError: " . $this->_db->getConnection()->error); - } - unset($this->_sequences[$sequenceName]); - } - - public function getParams(array $constants = array()) - { - $params = array(); - foreach ($constants as $key => $constant) { - if (defined($constant)) { - $params[$key] = constant($constant); - } - } - return $params; - } - - public function getSchema() - { - $param = $this->getParams(); - - if (isset($param['dbname']) && strpos($param['dbname'], ':') === false) { - return $param['dbname']; - } - - return null; - } - - protected $_tableName = array( - 'Accounts' => 'zfaccounts', - 'Products' => 'zfproducts', - 'Bugs' => 'zfbugs', - 'BugsProducts' => 'zfbugs_products', - 'noquote' => 'zfnoquote', - 'noprimarykey' => 'zfnoprimarykey', - 'Documents' => 'zfdocuments', - 'Price' => 'zfprice', - 'AltBugsProducts' => 'zfalt_bugs_products', - ); - - public function getTableName($tableId) - { - if (!isset($this->_tableName)) { - throw new Exception("Invalid table id '$tableId'"); - } - if (array_key_exists($tableId, $this->_tableName)) { - return $this->_tableName[$tableId]; - } else { - return $tableId; - } - } - - protected function _getColumnsBugs() - { - return array( - 'bug_id' => 'IDENTITY', - 'bug_description' => 'VARCHAR(100)', - 'bug_status' => 'VARCHAR(20)', - 'created_on' => 'DATETIME', - 'updated_on' => 'DATETIME', - 'reported_by' => 'VARCHAR(100)', - 'assigned_to' => 'VARCHAR(100)', - 'verified_by' => 'VARCHAR(100)' - ); - } - - protected function _getColumnsAccounts() - { - return array( - 'account_name' => 'VARCHAR(100) NOT NULL', - 'PRIMARY KEY' => 'account_name' - ); - } - - protected function _getColumnsProducts() - { - return array( - 'product_id' => 'IDENTITY', - 'product_name' => 'VARCHAR(100)' - ); - } - - protected function _getColumnsBugsProducts() - { - return array( - 'bug_id' => 'INTEGER NOT NULL', - 'product_id' => 'INTEGER NOT NULL', - 'PRIMARY KEY' => 'bug_id,product_id' - ); - } - - protected function _getColumnsDocuments() - { - return array( - 'doc_id' => 'INTEGER NOT NULL', - 'doc_clob' => 'CLOB', - 'doc_blob' => 'BLOB', - 'PRIMARY KEY' => 'doc_id' - ); - } - - protected function _getColumnsPrice() - { - return array( - 'product_id' => 'INTEGER NOT NULL', - 'price_name' => 'VARCHAR(100)', - 'price_total' => 'DECIMAL(10,2) NOT NULL', - 'PRIMARY KEY' => 'product_id' - ); - } - - protected function _getDataAccounts() - { - return array( - array('account_name' => 'mmouse'), - array('account_name' => 'dduck'), - array('account_name' => 'goofy'), - ); - } - - protected function _getDataBugs() - { - return array( - array( - 'bug_description' => 'System needs electricity to run', - 'bug_status' => 'NEW', - 'created_on' => '2007-04-01', - 'updated_on' => '2007-04-01', - 'reported_by' => 'goofy', - 'assigned_to' => 'mmouse', - 'verified_by' => 'dduck' - ), - array( - 'bug_description' => 'Implement Do What I Mean function', - 'bug_status' => 'VERIFIED', - 'created_on' => '2007-04-02', - 'updated_on' => '2007-04-02', - 'reported_by' => 'goofy', - 'assigned_to' => 'mmouse', - 'verified_by' => 'dduck' - ), - array( - 'bug_description' => 'Where are my keys?', - 'bug_status' => 'FIXED', - 'created_on' => '2007-04-03', - 'updated_on' => '2007-04-03', - 'reported_by' => 'dduck', - 'assigned_to' => 'mmouse', - 'verified_by' => 'dduck' - ), - array( - 'bug_description' => 'Bug no product', - 'bug_status' => 'INCOMPLETE', - 'created_on' => '2007-04-04', - 'updated_on' => '2007-04-04', - 'reported_by' => 'mmouse', - 'assigned_to' => 'goofy', - 'verified_by' => 'dduck' - ) - ); - } - - protected function _getDataProducts() - { - return array( - array('product_name' => 'Windows'), - array('product_name' => 'Linux'), - array('product_name' => 'OS X'), - ); - } - - protected function _getDataBugsProducts() - { - return array( - array( - 'bug_id' => 1, - 'product_id' => 1 - ), - array( - 'bug_id' => 1, - 'product_id' => 2 - ), - array( - 'bug_id' => 1, - 'product_id' => 3 - ), - array( - 'bug_id' => 2, - 'product_id' => 3 - ), - array( - 'bug_id' => 3, - 'product_id' => 2 - ), - array( - 'bug_id' => 3, - 'product_id' => 3 - ), - ); - } - - protected function _getDataDocuments() - { - return array ( - array( - 'doc_id' => 1, - 'doc_clob' => 'this is the clob that never ends...'. - 'this is the clob that never ends...'. - 'this is the clob that never ends...', - 'doc_blob' => 'this is the blob that never ends...'. - 'this is the blob that never ends...'. - 'this is the blob that never ends...' - ) - ); - } - - protected function _getDataPrice() - { - return array( - array( - 'product_id' => 1, - 'price_name' => 'Price 1', - 'price_total' => 200.45 - ) - ); - } - - public function populateTable($tableId) - { - $tableName = $this->getTableName($tableId); - $data = $this->{'_getData'.$tableId}(); - foreach ($data as $row) { - $sql = 'INSERT INTO ' . $this->_db->quoteIdentifier($tableName, true); - $cols = array(); - $vals = array(); - foreach ($row as $col => $val) { - $cols[] = $this->_db->quoteIdentifier($col, true); - if ($val instanceof Zend_Db_Expr) { - $vals[] = $val->__toString(); - } else { - $vals[] = $this->_db->quote($val); - } - } - $sql .= ' (' . implode(', ', $cols) . ')'; - $sql .= ' VALUES (' . implode(', ', $vals) . ')'; - $result = $this->_rawQuery($sql); - if ($result === false) { - throw new Zend_Db_Exception("Statement failed:\n$sql\nError: " . $this->_db->getConnection()->error); - } - } - } - - public function setUp(Zend_Db_Adapter_Abstract $db) - { - $this->setAdapter($db); - - $this->createTable('Accounts'); - $this->populateTable('Accounts'); - - $this->createTable('Products'); - $this->populateTable('Products'); - - $this->createTable('Bugs'); - $this->populateTable('Bugs'); - - $this->createTable('BugsProducts'); - $this->populateTable('BugsProducts'); - - $this->createTable('Documents'); - $this->populateTable('Documents'); - - $this->createTable('Price'); - $this->populateTable('Price'); - } - - public function setAdapter(Zend_Db_Adapter_Abstract $db) - { - $this->_db = $db; - } - - public function tearDown() - { - $this->dropTable(); - $this->dropSequence(); - $this->_db->closeConnection(); - } - - protected abstract function _rawQuery($sql); - -} diff --git a/tests/Zend/Db/TestUtil/Db2.php b/tests/Zend/Db/TestUtil/Db2.php deleted file mode 100644 index 437ba130e792462d278f30bc4628900e6a1047d8..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Db2.php +++ /dev/null @@ -1,156 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Db/TestUtil/Common.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_TestUtil_Db2 extends Zend_Db_TestUtil_Common -{ - - public function setUp(Zend_Db_Adapter_Abstract $db) - { - $this->setAdapter($db); - $this->createSequence('zfproducts_seq'); - parent::setUp($db); - } - - public function getParams(array $constants = array()) - { - $constants = array( - 'host' => 'TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME', - 'username' => 'TESTS_ZEND_DB_ADAPTER_DB2_USERNAME', - 'password' => 'TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD', - 'dbname' => 'TESTS_ZEND_DB_ADAPTER_DB2_DATABASE', - 'port' => 'TESTS_ZEND_DB_ADAPTER_DB2_PORT' - ); - return parent::getParams($constants); - } - - public function getSchema() - { - $desc = $this->_db->describeTable('zfproducts'); - return $desc['product_id']['SCHEMA_NAME']; - } - - /** - * For DB2, override the Products table to use an - * explicit sequence-based column. - */ - protected function _getColumnsProducts() - { - return array( - 'product_id' => 'INT NOT NULL PRIMARY KEY', - 'product_name' => 'VARCHAR(100)' - ); - } - - protected function _getDataProducts() - { - $data = parent::_getDataProducts(); - foreach ($data as &$row) { - $row['product_id'] = new Zend_Db_Expr('NEXTVAL FOR '.$this->_db->quoteIdentifier('zfproducts_seq', true)); - } - return $data; - } - - protected function _getDataDocuments() - { - return array ( - array( - 'doc_id' => 1, - 'doc_clob' => 'this is the clob that never ends...'. - 'this is the clob that never ends...'. - 'this is the clob that never ends...', - 'doc_blob' => new Zend_Db_Expr("BLOB('this is the blob that never ends...". - "this is the blob that never ends...". - "this is the blob that never ends...')") - ) - ); - } - - public function getSqlType($type) - { - if ($type == 'IDENTITY') { - return 'INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY'; - } - if ($type == 'DATETIME') { - return 'DATE'; - } - return $type; - } - - protected function _getSqlCreateTable($tableName) - { - $tableList = $this->_db->fetchCol('SELECT UPPER(T.TABLE_NAME) FROM SYSIBM.TABLES T ' - . $this->_db->quoteInto(' WHERE UPPER(T.TABLE_NAME) = UPPER(?)', $tableName) - ); - if (in_array(strtoupper($tableName), $tableList)) { - return null; - } - return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - - protected function _getSqlDropTable($tableName) - { - $tableList = $this->_db->fetchCol('SELECT UPPER(T.TABLE_NAME) FROM SYSIBM.TABLES T ' - . $this->_db->quoteInto(' WHERE UPPER(T.TABLE_NAME) = UPPER(?)', $tableName) - ); - if (in_array(strtoupper($tableName), $tableList)) { - return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - return null; - } - - protected function _getSqlCreateSequence($sequenceName) - { - $seqList = $this->_db->fetchCol('SELECT UPPER(S.SEQNAME) FROM SYSIBM.SYSSEQUENCES S ' - . $this->_db->quoteInto(' WHERE UPPER(S.SEQNAME) = UPPER(?)', $sequenceName) - ); - if (in_array(strtoupper($sequenceName), $seqList)) { - return null; - } - return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true) . ' AS INT START WITH 1 INCREMENT BY 1 MINVALUE 1'; - } - - protected function _getSqlDropSequence($sequenceName) - { - $seqList = $this->_db->fetchCol('SELECT UPPER(S.SEQNAME) FROM SYSIBM.SYSSEQUENCES S ' - . $this->_db->quoteInto(' WHERE UPPER(S.SEQNAME) = UPPER(?)', $sequenceName) - ); - if (in_array(strtoupper($sequenceName), $seqList)) { - return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true) . ' RESTRICT'; - } - return null; - } - - protected function _rawQuery($sql) - { - $conn = $this->_db->getConnection(); - $result = db2_exec($conn, $sql); - if (!$result) { - $e = db2_stmt_errormsg(); - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL error for \"$sql\": $e"); - } - } - -} diff --git a/tests/Zend/Db/TestUtil/Mysqli.php b/tests/Zend/Db/TestUtil/Mysqli.php deleted file mode 100644 index ce67c7aabdd896c5959c8f00b30be7179be4073e..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Mysqli.php +++ /dev/null @@ -1,117 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mysqli.php 6847 2007-11-18 05:24:21Z peptolab $ - */ - - -/** - * @see Zend_Db_TestUtil_Common - */ -require_once 'Zend/Db/TestUtil/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage Table - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Mysqli extends Zend_Db_TestUtil_Common -{ - - public function getParams(array $constants = array()) - { - $constants = array( - 'host' => 'TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME', - 'username' => 'TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME', - 'password' => 'TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD', - 'dbname' => 'TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE', - 'port' => 'TESTS_ZEND_DB_ADAPTER_MYSQL_PORT' - ); - return parent::getParams($constants); - } - - public function getSqlType($type) - { - if ($type == 'IDENTITY') { - return 'INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT'; - } - if ($type == 'CLOB') { - return 'TEXT'; - } - return $type; - } - - protected function _getSqlCreateTable($tableName) - { - return 'CREATE TABLE IF NOT EXISTS ' . $this->_db->quoteIdentifier($tableName); - } - - protected function _getSqlCreateTableType() - { - return ' ENGINE=InnoDB'; - } - - protected function _getSqlDropTable($tableName) - { - return 'DROP TABLE IF EXISTS ' . $this->_db->quoteIdentifier($tableName); - } - - protected function _rawQuery($sql) - { - $mysqli = $this->_db->getConnection(); - $retval = $mysqli->query($sql); - if (!$retval) { - $e = $mysqli->error; - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL error for \"$sql\": $e"); - } - } - - public function setUp(Zend_Db_Adapter_Abstract $db) - { - parent::setUp($db); - - $this->_createTestProcedure(); - } - - public function tearDown() - { - $this->_dropTestProcedure(); - - parent::tearDown(); - } - - protected function _createTestProcedure() - { - $this->_rawQuery('DROP PROCEDURE IF EXISTS zf_test_procedure'); - $this->_rawQuery('CREATE PROCEDURE zf_test_procedure(IN param1 INTEGER) BEGIN SELECT * FROM zfproducts WHERE product_id = param1; END'); - } - - protected function _dropTestProcedure() - { - $this->_rawQuery('DROP PROCEDURE IF EXISTS zf_test_procedure'); - } -} diff --git a/tests/Zend/Db/TestUtil/Oracle.php b/tests/Zend/Db/TestUtil/Oracle.php deleted file mode 100644 index 229fbb4db03eb7895d5fba43cf5814a9c898b778..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Oracle.php +++ /dev/null @@ -1,50 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Db_TestUtil_Pdo_Oci - * @see Zend_Db_TestUtil_Common - */ -require_once 'Zend/Db/TestUtil/Pdo/Oci.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Db_TestUtil_Oracle extends Zend_Db_TestUtil_Pdo_Oci -{ - - protected function _rawQuery($sql) - { - $conn = $this->_db->getConnection(); - $stmt = oci_parse($conn, $sql); - if (!$stmt) { - $e = oci_error($conn); - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL parse error for \"$sql\": ".$e['message']); - } - $retval = oci_execute($stmt); - if (!$retval) { - $e = oci_error($conn); - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL execute error for \"$sql\": ".$e['message']); - } - } - -} diff --git a/tests/Zend/Db/TestUtil/Pdo/Common.php b/tests/Zend/Db/TestUtil/Pdo/Common.php deleted file mode 100644 index d9bf713abaf2540b676262e2350d2ac1e5ec3c6d..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Common.php +++ /dev/null @@ -1,53 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Common.php 4969 2007-05-25 19:16:50Z darby $ - */ - - -/** - * @see Zend_Db_TestUtil_Common - */ -require_once 'Zend/Db/TestUtil/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Db_TestUtil_Pdo_Common extends Zend_Db_TestUtil_Common -{ - protected function _rawQuery($sql) - { - $conn = $this->_db->getConnection(); - $retval = $conn->query($sql); - if (!$retval) { - $e = $conn->error; - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL error for \"$sql\": $e"); - } - } -} diff --git a/tests/Zend/Db/TestUtil/Pdo/Ibm.php b/tests/Zend/Db/TestUtil/Pdo/Ibm.php deleted file mode 100644 index 177f952405b5a8a8b2f40ed8e4888900ccf7a8bf..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Ibm.php +++ /dev/null @@ -1,187 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $$ - */ - - -/** - * @see Zend_Db_TestUtil_Db2 - */ -require_once 'Zend/Db/TestUtil/Db2.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Pdo_Ibm extends Zend_Db_TestUtil_Db2 -{ - public function getSchema() - { - $desc = $this->_db->describeTable('zfproducts'); - return $desc['product_id']['SCHEMA_NAME']; - } - - protected function _getDataProducts() - { - $data = parent::_getDataProducts(); - - $server = $this->getServer(); - if ($server == 'IDS') { - foreach ($data as &$row) { - $row['product_id'] = new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq', true) . ".NEXTVAL"); - } - } - return $data; - } - - protected function _getDataDocuments() - { - $server = $this->getServer(); - - if ($server == 'IDS') { - return array ( - array( - 'doc_id' => 1, - 'doc_clob' => 'this is the clob that never ends...'. - 'this is the clob that never ends...'. - 'this is the clob that never ends...', - 'doc_blob' => 'this is the blob that never ends...'. - 'this is the blob that never ends...'. - 'this is the blob that never ends...' - ) - ); - } - - return parent::_getDataDocuments(); - } - - public function getSqlType($type) - { - $server = $this->getServer(); - - if ($server == 'IDS') { - - if ($type == 'IDENTITY') { - return 'SERIAL(1) PRIMARY KEY'; - } - if ($type == 'DATETIME') { - return 'DATE'; - } - return $type; - } - return parent::getSqlType($type); - } - - protected function _getSqlCreateTable($tableName) - { - $server = $this->getServer(); - - if ($server == 'IDS') { - $tableList = $this->_db->fetchCol('SELECT T.TABNAME FROM SYSTABLES T ' - . $this->_db->quoteInto(' WHERE T.TABNAME = ?', $tableName) - ); - if (in_array($tableName, $tableList)) { - return null; - } - return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - - return parent::_getSqlCreateTable($tableName); - } - - protected function _getSqlDropTable($tableName) - { - $server = $this->getServer(); - - if ($server == 'IDS') { - $tableList = $this->_db->fetchCol('SELECT T.TABNAME FROM SYSTABLES T ' - . $this->_db->quoteInto(' WHERE T.TABNAME = ?', $tableName) - ); - if (in_array($tableName, $tableList)) { - return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - return null; - } - - return parent::_getSqlDropTable($tableName); - } - - protected function _getSqlCreateSequence($sequenceName) - { - $server = $this->getServer(); - - if ($server == 'IDS') { - $seqList = $this->_db->fetchCol('SELECT S.TABNAME FROM SYSTABLES S ' - . $this->_db->quoteInto(' WHERE S.TABNAME = ?', $sequenceName) - . " AND S.TABTYPE = 'Q'" - ); - - if (in_array($sequenceName, $seqList)) { - return null; - } - return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true) . ' START WITH 1 INCREMENT BY 1 MINVALUE 1'; - } - - return parent::_getSqlCreateSequence($sequenceName); - } - - protected function _getSqlDropSequence($sequenceName) - { - $server = $this->getServer(); - - if ($server == 'IDS') { - $seqList = $this->_db->fetchCol('SELECT S.TABNAME FROM SYSTABLES S ' - . $this->_db->quoteInto(' WHERE S.TABNAME = ?', $sequenceName) - . " AND S.TABTYPE = 'Q'" - ); - - if (in_array($sequenceName, $seqList)) { - return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true); - } - return null; - } - - return parent::_getSqlDropSequence($sequenceName); - } - - public function getServer() - { - return substr($this->_db->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3); - } - - protected function _rawQuery($sql) - { - $conn = $this->_db->getConnection(); - $retval = $conn->query($sql); - if (!$retval) { - $e = $conn->error; - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL error for \"$sql\": $e"); - } - } -} diff --git a/tests/Zend/Db/TestUtil/Pdo/Mssql.php b/tests/Zend/Db/TestUtil/Pdo/Mssql.php deleted file mode 100644 index 3069968d0168e9728ac6f198831b6d0e40c6e22b..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Mssql.php +++ /dev/null @@ -1,113 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mssql.php 7529 2008-01-20 12:34:41Z thomas $ - */ - - -/** - * @see Zend_Db_TestUtil_Pdo_Common - */ -require_once 'Zend/Db/TestUtil/Pdo/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Pdo_Mssql extends Zend_Db_TestUtil_Pdo_Common -{ - - public function getParams(array $constants = array()) - { - $constants = array ( - 'host' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME', - 'username' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME', - 'password' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD', - 'dbname' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE', - 'port' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PORT' - ); - - return parent::getParams($constants); - } - - public function getSqlType($type) - { - if ($type == 'IDENTITY') { - return 'INT NOT NULL IDENTITY PRIMARY KEY'; - } - return $type; - } - - protected function _getColumnsDocuments() - { - return array( - 'doc_id' => 'INTEGER NOT NULL', - 'doc_clob' => 'VARCHAR(8000)', - 'doc_blob' => 'VARCHAR(8000)', - 'PRIMARY KEY' => 'doc_id' - ); - } - - protected function _getColumnsBugs() - { - return array( - 'bug_id' => 'IDENTITY', - 'bug_description' => 'VARCHAR(100) NULL', - 'bug_status' => 'VARCHAR(20) NULL', - 'created_on' => 'DATETIME NULL', - 'updated_on' => 'DATETIME NULL', - 'reported_by' => 'VARCHAR(100) NULL', - 'assigned_to' => 'VARCHAR(100) NULL', - 'verified_by' => 'VARCHAR(100) NULL' - ); - } - - protected function _getSqlCreateTable($tableName) - { - $sql = "exec sp_tables @table_name = " . $this->_db->quoteIdentifier($tableName, true); - $stmt = $this->_db->query($sql); - $tableList = $stmt->fetchAll(Zend_Db::FETCH_ASSOC); - - if (count($tableList) > 0 && $tableName == $tableList[0]['TABLE_NAME']) { - return null; - } - return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName); - } - - protected function _getSqlDropTable($tableName) - { - $sql = "exec sp_tables @table_name = " . $this->_db->quoteIdentifier($tableName, true); - $stmt = $this->_db->query($sql); - $tableList = $stmt->fetchAll(Zend_Db::FETCH_ASSOC); - - if (count($tableList) > 0 && $tableName == $tableList[0]['TABLE_NAME']) { - return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName); - } - return null; - } - -} diff --git a/tests/Zend/Db/TestUtil/Pdo/Mysql.php b/tests/Zend/Db/TestUtil/Pdo/Mysql.php deleted file mode 100644 index 49f0038ec8aa0468a9314fab62e0582f0d5eb746..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Mysql.php +++ /dev/null @@ -1,69 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mysql.php 6847 2007-11-18 05:24:21Z peptolab $ - */ - - -/** - * @see Zend_Db_TestUtil_Mysqli - */ -require_once 'Zend/Db/TestUtil/Mysqli.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Pdo_Mysql extends Zend_Db_TestUtil_Mysqli -{ - protected function _rawQuery($sql) - { - $conn = $this->_db->getConnection(); - $retval = $conn->exec($sql); - if ($retval === false) { - $e = $conn->error; - require_once 'Zend/Db/Exception.php'; - throw new Zend_Db_Exception("SQL error for \"$sql\": $e"); - } - } - - public function getParams(array $constants = array()) - { - $constants = parent::getParams($constants); - - if (!isset($constants['driver_options'])) { - $constants['driver_options'] = array(); - } - - if (!isset($constants['driver_options'][PDO::MYSQL_ATTR_USE_BUFFERED_QUERY])) { - $constants['driver_options'][PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = true; - } - - return $constants; - } -} - diff --git a/tests/Zend/Db/TestUtil/Pdo/Oci.php b/tests/Zend/Db/TestUtil/Pdo/Oci.php deleted file mode 100644 index 99647c28ea87136b796db66a4c129981045376a9..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Oci.php +++ /dev/null @@ -1,157 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Oci.php 6294 2007-09-11 18:02:19Z bkarwin $ - */ - - -/** - * @see Zend_Db_TestUtil_Pdo_Common - */ -require_once 'Zend/Db/TestUtil/Pdo/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Pdo_Oci extends Zend_Db_TestUtil_Pdo_Common -{ - - public function setUp(Zend_Db_Adapter_Abstract $db) - { - $this->_db = $db; - $this->createSequence('zfbugs_seq'); - $this->createSequence('zfproducts_seq'); - parent::setUp($db); - } - - public function getParams(array $constants = array()) - { - $constants = array ( - 'host' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME', - 'username' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME', - 'password' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD', - 'dbname' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_SID' - ); - return parent::getParams($constants); - } - - public function getSqlType($type) - { - if (preg_match('/VARCHAR(.*)/', $type, $matches)) { - return 'VARCHAR2' . $matches[1]; - } - if ($type == 'IDENTITY') { - return 'NUMBER(11) PRIMARY KEY'; - } - if ($type == 'INTEGER') { - return 'NUMBER(11)'; - } - if ($type == 'DATETIME') { - return 'TIMESTAMP'; - } - return $type; - } - - protected function _getSqlCreateTable($tableName) - { - $tableList = $this->_db->fetchCol('SELECT UPPER(TABLE_NAME) FROM ALL_TABLES ' - . $this->_db->quoteInto(' WHERE UPPER(TABLE_NAME) = UPPER(?)', $tableName) - ); - if (in_array(strtoupper($tableName), $tableList)) { - return null; - } - return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - - protected function _getSqlDropTable($tableName) - { - $tableList = $this->_db->fetchCol('SELECT UPPER(TABLE_NAME) FROM ALL_TABLES ' - . $this->_db->quoteInto(' WHERE UPPER(TABLE_NAME) = UPPER(?)', $tableName) - ); - if (in_array(strtoupper($tableName), $tableList)) { - return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true); - } - return null; - } - - protected function _getSqlCreateSequence($sequenceName) - { - $seqList = $this->_db->fetchCol('SELECT UPPER(SEQUENCE_NAME) FROM ALL_SEQUENCES ' - . $this->_db->quoteInto(' WHERE UPPER(SEQUENCE_NAME) = UPPER(?)', $sequenceName) - ); - if (in_array(strtoupper($sequenceName), $seqList)) { - return null; - } - return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true); - } - - protected function _getSqlDropSequence($sequenceName) - { - $seqList = $this->_db->fetchCol('SELECT UPPER(SEQUENCE_NAME) FROM ALL_SEQUENCES ' - . $this->_db->quoteInto(' WHERE UPPER(SEQUENCE_NAME) = UPPER(?)', $sequenceName) - ); - if (in_array(strtoupper($sequenceName), $seqList)) { - return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true); - } - return null; - } - - protected function _getDataBugs() - { - $data = parent::_getDataBugs(); - foreach ($data as &$row) { - $row['bug_id'] = new Zend_Db_Expr($this->_db->quoteIdentifier('zfbugs_seq', true).'.NEXTVAL'); - $row['created_on'] = new Zend_Db_Expr($this->_db->quoteInto('DATE ?', $row['created_on'])); - $row['updated_on'] = new Zend_Db_Expr($this->_db->quoteInto('DATE ?', $row['updated_on'])); - } - return $data; - } - - protected function _getDataDocuments() - { - $data = parent::_getDataDocuments(); - foreach ($data as &$row) { - $quoted = $this->_db->quote($row['doc_clob']); - $hex = bin2hex($row['doc_clob']); - $row['doc_clob'] = new Zend_Db_Expr("TO_CLOB($quoted)"); - $row['doc_blob'] = new Zend_Db_Expr("TO_BLOB(HEXTORAW('$hex'))"); - - } - return $data; - } - - protected function _getDataProducts() - { - $data = parent::_getDataProducts(); - foreach ($data as &$row) { - $row['product_id'] = new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq', true).'.NEXTVAL'); - } - return $data; - } - -} diff --git a/tests/Zend/Db/TestUtil/Pdo/Pgsql.php b/tests/Zend/Db/TestUtil/Pdo/Pgsql.php deleted file mode 100644 index 93d2a3d11058314694b381b0b032fab1a717082c..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Pgsql.php +++ /dev/null @@ -1,149 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Pgsql.php 6294 2007-09-11 18:02:19Z bkarwin $ - */ - - -/** - * @see Zend_Db_TestUtil_Pdo_Common - */ -require_once 'Zend/Db/TestUtil/Pdo/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Pdo_Pgsql extends Zend_Db_TestUtil_Pdo_Common -{ - - public function setUp(Zend_Db_Adapter_Abstract $db) - { - $this->_db = $db; - $this->createSequence('zfproducts_seq'); - parent::setUp($db); - } - - public function getParams(array $constants = array()) - { - $constants = array ( - 'host' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME', - 'username' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME', - 'password' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD', - 'dbname' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE' - ); - return parent::getParams($constants); - } - - public function getSchema() - { - return 'public'; - } - - /** - * For PostgreSQL, override the Products table to use an - * explicit sequence-based column. - */ - protected function _getColumnsProducts() - { - return array( - 'product_id' => 'INT NOT NULL PRIMARY KEY', - 'product_name' => 'VARCHAR(100)' - ); - } - - protected function _getDataProducts() - { - $data = parent::_getDataProducts(); - foreach ($data as &$row) { - $row['product_id'] = new Zend_Db_Expr('NEXTVAL('.$this->_db->quote('zfproducts_seq').')'); - } - return $data; - } - - public function getSqlType($type) - { - if ($type == 'IDENTITY') { - return 'SERIAL PRIMARY KEY'; - } - if ($type == 'DATETIME') { - return 'TIMESTAMP'; - } - if ($type == 'CLOB') { - return 'TEXT'; - } - if ($type == 'BLOB') { - return 'TEXT'; - } - return $type; - } - - protected function _getSqlCreateTable($tableName) - { - $tableList = $this->_db->fetchCol('SELECT relname AS table_name FROM pg_class ' - . $this->_db->quoteInto(' WHERE relkind = \'r\' AND relname = ?', $tableName) - ); - if (in_array($tableName, $tableList)) { - return null; - } - return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName); - } - - protected function _getSqlDropTable($tableName) - { - $tableList = $this->_db->fetchCol('SELECT relname AS table_name FROM pg_class ' - . $this->_db->quoteInto(' WHERE relkind = \'r\' AND relname = ?', $tableName) - ); - if (in_array($tableName, $tableList)) { - return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName); - } - return null; - } - - protected function _getSqlCreateSequence($sequenceName) - { - $seqList = $this->_db->fetchCol('SELECT relname AS sequence_name FROM pg_class ' - . $this->_db->quoteInto(' WHERE relkind = \'S\' AND relname = ?', $sequenceName) - ); - if (in_array($sequenceName, $seqList)) { - return null; - } - return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName); - } - - protected function _getSqlDropSequence($sequenceName) - { - $seqList = $this->_db->fetchCol('SELECT relname AS sequence_name FROM pg_class ' - . $this->_db->quoteInto(' WHERE relkind = \'S\' AND relname = ?', $sequenceName) - ); - if (in_array($sequenceName, $seqList)) { - return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName); - } - return null; - } - -} diff --git a/tests/Zend/Db/TestUtil/Pdo/Sqlite.php b/tests/Zend/Db/TestUtil/Pdo/Sqlite.php deleted file mode 100644 index b202a2f4c8bb934986c1957ca5ed61c047042130..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Pdo/Sqlite.php +++ /dev/null @@ -1,70 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sqlite.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_TestUtil_Pdo_Common - */ -require_once 'Zend/Db/TestUtil/Pdo/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Pdo_Sqlite extends Zend_Db_TestUtil_Pdo_Common -{ - - public function getParams(array $constants = array()) - { - $constants = array ( - 'dbname' => 'TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE' - ); - return parent::getParams($constants); - } - - protected function _getSqlCreateTable($tableName) - { - return 'CREATE TABLE IF NOT EXISTS ' . $this->_db->quoteIdentifier($tableName); - } - - protected function _getSqlDropTable($tableName) - { - return 'DROP TABLE IF EXISTS ' . $this->_db->quoteIdentifier($tableName); - } - - public function getSqlType($type) - { - if ($type == 'IDENTITY') { - return 'INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT'; - } - return $type; - } - -} diff --git a/tests/Zend/Db/TestUtil/Static.php b/tests/Zend/Db/TestUtil/Static.php deleted file mode 100644 index 02d1c2f2b1e7d6bbebcf0fab7da4bed1f1cf309d..0000000000000000000000000000000000000000 --- a/tests/Zend/Db/TestUtil/Static.php +++ /dev/null @@ -1,57 +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_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Static.php 4700 2007-05-04 04:25:11Z bkarwin $ - */ - - -/** - * @see Zend_Db_TestUtil_Common - */ -require_once 'Zend/Db/TestUtil/Common.php'; - - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Db - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Db_TestUtil_Static extends Zend_Db_TestUtil_Common -{ - - public function getParams(array $constants = array()) - { - $constants = array( - 'dbname' => 'dummy', - ); - return $constants; - } - - protected function _rawQuery($sql) - { - // no-op - } - -} diff --git a/tests/Zend/DebugTest.php b/tests/Zend/DebugTest.php deleted file mode 100644 index 98fc2aac26b402cb7504fcdec0e33a34b5d738ff..0000000000000000000000000000000000000000 --- a/tests/Zend/DebugTest.php +++ /dev/null @@ -1,94 +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_Debug - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * Zend_Debug - */ -require_once 'Zend/Debug.php'; - -/** - * @category Zend - * @package Zend_Debug - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_DebugTest extends PHPUnit_Framework_TestCase -{ - - public function testDebugDefaultSapi() - { - $sapi = php_sapi_name(); - Zend_Debug::setSapi(null); - $data = 'string'; - $result = Zend_Debug::Dump($data, null, false); - $this->assertEquals($sapi, Zend_Debug::getSapi()); - } - - public function testDebugDump() - { - Zend_Debug::setSapi('cli'); - $data = 'string'; - $result = Zend_Debug::Dump($data, null, false); - $result = str_replace(array(PHP_EOL, "\n"), '_', $result); - $expected = "__string(6) \"string\"__"; - $this->assertEquals($expected, $result); - } - - public function testDebugCgi() - { - Zend_Debug::setSapi('cgi'); - $data = 'string'; - $result = Zend_Debug::Dump($data, null, false); - $this->assertEquals("<pre>string(6) "string"\n</pre>", $result); - } - - public function testDebugDumpEcho() - { - Zend_Debug::setSapi('cli'); - $data = 'string'; - - ob_start(); - $result1 = Zend_Debug::Dump($data, null, true); - $result2 = ob_get_contents(); - ob_end_clean(); - - $this->assertContains('string(6) "string"', $result1); - $this->assertEquals($result1, $result2); - } - - public function testDebugDumpLabel() - { - Zend_Debug::setSapi('cli'); - $data = 'string'; - $label = 'LABEL'; - $result = Zend_Debug::Dump($data, $label, false); - $result = str_replace(array(PHP_EOL, "\n"), '_', $result); - $expected = "_{$label} _string(6) \"string\"__"; - $this->assertEquals($expected, $result); - } - -} diff --git a/tests/Zend/Dojo/AllTests.php b/tests/Zend/Dojo/AllTests.php deleted file mode 100644 index 41bf1aa19aefd5f2d3b7ebd96e29e7b00966d83e..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/AllTests.php +++ /dev/null @@ -1,66 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10050 2008-07-12 02:34:20Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_AllTests::main'); -} - -require_once 'Zend/Dojo/DojoTest.php'; -require_once 'Zend/Dojo/DataTest.php'; -require_once 'Zend/Dojo/Form/AllTests.php'; -require_once 'Zend/Dojo/View/AllTests.php'; - -/** - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dojo'); - - $suite->addTestSuite('Zend_Dojo_DojoTest'); - $suite->addTestSuite('Zend_Dojo_DataTest'); - $suite->addTest(Zend_Dojo_Form_AllTests::suite()); - $suite->addTest(Zend_Dojo_View_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_AllTests::main') { - Zend_Dojo_AllTests::main(); -} diff --git a/tests/Zend/Dojo/DataTest.php b/tests/Zend/Dojo/DataTest.php deleted file mode 100644 index c12f8af29caf1cfb6e7fa8b9d4ea4b58139470fe..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/DataTest.php +++ /dev/null @@ -1,589 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DataTest.php 11283 2008-09-08 16:08:43Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_DataTest::main'); -} - -require_once 'Zend/Dojo/Data.php'; - -/** - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_DataTest extends PHPUnit_Framework_TestCase -{ - public $dojoData; - - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_DataTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->dojoData = new Zend_Dojo_Data; - } - - public function testIdentifierShouldBeNullByDefault() - { - $this->assertNull($this->dojoData->getIdentifier()); - } - - public function testIdentifierShouldBeMutable() - { - $this->testIdentifierShouldBeNullByDefault(); - $this->dojoData->setIdentifier('id'); - $this->assertEquals('id', $this->dojoData->getIdentifier()); - } - - public function testNullIdentifierShouldBeAllowed() - { - $this->dojoData->setIdentifier('foo'); - $this->assertEquals('foo', $this->dojoData->getIdentifier()); - $this->dojoData->setIdentifier(null); - $this->assertNull($this->dojoData->getIdentifier()); - } - - public function testIntegerIdentifierShouldBeAllowed() - { - $this->dojoData->setIdentifier(2); - $this->assertSame(2, $this->dojoData->getIdentifier()); - } - - /** - * @expectedException Zend_Dojo_Exception - */ - public function testSetIdentifierShouldThrowExceptionOnInvalidType() - { - $this->dojoData->setIdentifier(true); - } - - public function testLabelShouldBeNullByDefault() - { - $this->assertNull($this->dojoData->getLabel()); - } - - public function testLabelShouldBeMutable() - { - $this->testLabelShouldBeNullByDefault(); - $this->dojoData->setLabel('title'); - $this->assertEquals('title', $this->dojoData->getLabel()); - } - - public function testLabelShouldBeNullable() - { - $this->testLabelShouldBeMutable(); - $this->dojoData->setLabel(null); - $this->assertNull($this->dojoData->getLabel()); - } - - public function testAddItemShouldThrowExceptionIfNoIdentifierPresentInObject() - { - $item = array( - 'id' => '1', - 'title' => 'foo', - 'url' => 'http://www.example.com/', - ); - try { - $this->dojoData->addItem($item); - $this->fail('Should throw exception if no identifier present'); - } catch (Zend_Dojo_Exception $e) { - $this->assertContains('identifier', $e->getMessage()); - } - } - - public function testAddItemShouldThrowExceptionIfNoIdentifierPresentInItem() - { - $item = array( - 'title' => 'foo', - 'url' => 'http://www.example.com/', - ); - $this->dojoData->setIdentifier('id'); - try { - $this->dojoData->addItem($item); - $this->fail('Should throw exception if no identifier present'); - } catch (Zend_Dojo_Exception $e) { - $this->assertContains('identifier', $e->getMessage()); - } - } - - public function testAddItemShouldAcceptArray() - { - $item = array( - 'id' => '1', - 'title' => 'foo', - 'url' => 'http://www.example.com/', - ); - $this->dojoData->setIdentifier('id'); - $this->dojoData->addItem($item); - $this->assertEquals(1, count($this->dojoData)); - $this->assertSame($item, $this->dojoData->getItem(1)); - } - - public function testAddItemShouldAcceptStdObject() - { - $item = array( - 'id' => '1', - 'title' => 'foo', - 'url' => 'http://www.example.com/', - ); - $obj = (object) $item; - $this->dojoData->setIdentifier('id'); - $this->dojoData->addItem($obj); - $this->assertEquals(1, count($this->dojoData)); - $this->assertSame($item, $this->dojoData->getItem(1)); - } - - public function testAddItemShouldAcceptObjectImplementingToArray() - { - $obj = new Zend_Dojo_DataTest_DataObject; - $this->dojoData->setIdentifier('id'); - $this->dojoData->addItem($obj); - $this->assertEquals(1, count($this->dojoData)); - $this->assertSame($obj->item, $this->dojoData->getItem('foo')); - } - - public function testAddItemShouldThrowErrorOnInvalidItem() - { - $this->dojoData->setIdentifier('id'); - try { - $this->dojoData->addItem('foo'); - $this->fail('Invalid item should throw error'); - } catch (Zend_Dojo_Exception $e) { - $this->assertContains('Only arrays and objects', $e->getMessage()); - } - } - - public function testAddItemShouldAllowSpecifyingIdentifier() - { - $item = array( - 'title' => 'foo', - 'url' => 'http://www.example.com/', - ); - $this->dojoData->setIdentifier('id'); - $this->dojoData->addItem($item, 'foo'); - $this->assertEquals(1, count($this->dojoData)); - $stored = $this->dojoData->getItem('foo'); - $this->assertTrue(array_key_exists('id', $stored)); - $this->assertEquals('foo', $stored['id']); - foreach ($item as $key => $value) { - $this->assertTrue(array_key_exists($key, $stored)); - $this->assertEquals($value, $stored[$key]); - } - } - - public function testOverwritingItemsShouldNotBeAllowedFromAddItem() - { - $this->testAddItemShouldAcceptArray(); - $item = array( - 'id' => '1', - 'title' => 'foo', - 'url' => 'http://www.example.com/', - ); - try { - $this->dojoData->addItem($item); - $this->fail('Overwriting items via addItem() should throw error'); - } catch (Zend_Dojo_Exception $e) { - $this->assertContains('not allowed', $e->getMessage()); - } - } - - public function testSetItemShouldOverwriteExistingItem() - { - $this->testAddItemShouldAcceptArray(); - $item = array( - 'id' => '1', - 'title' => 'bar', - 'url' => 'http://www.foo.com/', - ); - $this->assertNotSame($item, $this->dojoData->getItem(1)); - $this->dojoData->setItem($item); - $this->assertEquals(1, count($this->dojoData)); - $this->assertSame($item, $this->dojoData->getItem(1)); - } - - public function testSetItemShouldAddItemIfNonexistent() - { - $item = array( - 'id' => '1', - 'title' => 'bar', - 'url' => 'http://www.foo.com/', - ); - $this->dojoData->setIdentifier('id'); - $this->assertEquals(0, count($this->dojoData)); - $this->dojoData->setItem($item); - $this->assertEquals(1, count($this->dojoData)); - $this->assertSame($item, $this->dojoData->getItem(1)); - } - - public function testAddItemsShouldAcceptArray() - { - $items = array( - array ( - 'id' => 1, - 'title' => 'Foo', - 'email' => 'foo@bar', - ), - array ( - 'id' => 2, - 'title' => 'Bar', - 'email' => 'bar@bar', - ), - array ( - 'id' => 3, - 'title' => 'Baz', - 'email' => 'baz@bar', - ), - ); - $this->dojoData->setIdentifier('id'); - $this->assertEquals(0, count($this->dojoData)); - $this->dojoData->addItems($items); - $this->assertEquals(3, count($this->dojoData)); - $this->assertSame($items[0], $this->dojoData->getItem(1)); - $this->assertSame($items[1], $this->dojoData->getItem(2)); - $this->assertSame($items[2], $this->dojoData->getItem(3)); - } - - public function testAddItemsShouldAcceptTraversableObject() - { - $obj = new Zend_Dojo_DataTest_DataCollection; - $this->dojoData->setIdentifier('id'); - $this->assertEquals(0, count($this->dojoData)); - $this->dojoData->addItems($obj); - $this->assertEquals(3, count($this->dojoData)); - $this->assertSame($obj->items[0]->toArray(), $this->dojoData->getItem(1)); - $this->assertSame($obj->items[1]->toArray(), $this->dojoData->getItem(2)); - $this->assertSame($obj->items[2]->toArray(), $this->dojoData->getItem(3)); - } - - /** - * @expectedException Zend_Dojo_Exception - */ - public function testAddItemsShouldThrowExceptionForInvalidItems() - { - $this->dojoData->addItems('foo'); - } - - public function testSetItemsShouldOverwriteAllCurrentItems() - { - $this->testAddItemsShouldAcceptArray(); - $items = $this->dojoData->getItems(); - $obj = new Zend_Dojo_DataTest_DataCollection; - $this->dojoData->setItems($obj); - $this->assertEquals(3, count($this->dojoData)); - $this->assertNotSame($items, $this->dojoData->getItems()); - } - - public function testRemoveItemShouldRemoveItemSpecifiedByIdentifier() - { - $this->testAddItemsShouldAcceptArray(); - $this->assertNotNull($this->dojoData->getItem(1)); - $this->dojoData->removeItem(1); - $this->assertNull($this->dojoData->getItem(1)); - $this->assertEquals(2, count($this->dojoData)); - } - - public function testClearItemsShouldRemoveAllItems() - { - $this->testAddItemsShouldAcceptArray(); - $this->dojoData->clearItems(); - $this->assertEquals(0, count($this->dojoData)); - } - - public function testGetItemShouldReturnNullIfNoMatchingItemExists() - { - $this->assertNull($this->dojoData->getItem('bogus')); - } - - public function testGetItemsShouldReturnArrayOfItems() - { - $this->testAddItemsShouldAcceptArray(); - $items = $this->dojoData->getItems(); - $this->assertTrue(is_array($items)); - } - - public function testConstructorShouldSetIdentifierItemsAndLabelWhenPassed() - { - $items = array( - array ( - 'id' => 1, - 'title' => 'Foo', - 'email' => 'foo@bar', - ), - array ( - 'id' => 2, - 'title' => 'Bar', - 'email' => 'bar@bar', - ), - array ( - 'id' => 3, - 'title' => 'Baz', - 'email' => 'baz@bar', - ), - ); - $data = new Zend_Dojo_Data('id', $items, 'title'); - $this->assertEquals('id', $data->getIdentifier()); - $this->assertEquals('title', $data->getLabel()); - foreach ($items as $item) { - $this->assertTrue($data->hasItem($item['id'])); - } - } - - public function testShouldSerializeToArray() - { - $this->testAddItemsShouldAcceptTraversableObject(); - $array = $this->dojoData->toArray(); - $this->assertTrue(is_array($array)); - $this->assertTrue(array_key_exists('identifier', $array)); - $this->assertEquals($this->dojoData->getIdentifier(), $array['identifier']); - $this->assertEquals(array_values($this->dojoData->getItems()), $array['items']); - } - - public function testSerializingToArrayShouldIncludeLabelIfPresent() - { - $this->testShouldSerializeToArray(); - $this->dojoData->setLabel('title'); - $array = $this->dojoData->toArray(); - $this->assertTrue(is_array($array)); - $this->assertTrue(array_key_exists('label', $array)); - $this->assertEquals($this->dojoData->getLabel(), $array['label']); - } - - public function testSerializingToArrayShouldThrowErrorIfNoIdentifierInObject() - { - $this->testAddItemsShouldAcceptTraversableObject(); - $this->dojoData->setIdentifier(null); - try { - $array = $this->dojoData->toArray(); - $this->fail('Serialization to array should throw error when no identifier is present in object'); - } catch (Zend_Dojo_Exception $e) { - $this->assertContains('present', $e->getMessage()); - } - } - - public function testShouldSerializeToJson() - { - $this->testAddItemsShouldAcceptTraversableObject(); - $json = $this->dojoData->toJson(); - $this->assertSame($this->dojoData->toArray(), Zend_Json::decode($json)); - } - - public function testShouldSerializeToStringAsJson() - { - $this->testAddItemsShouldAcceptTraversableObject(); - $json = $this->dojoData->toJson(); - $this->assertSame($json, $this->dojoData->__toString()); - } - - public function testShouldImplementArrayAccess() - { - $this->assertTrue($this->dojoData instanceof ArrayAccess); - $this->testAddItemsShouldAcceptTraversableObject(); - $this->assertEquals($this->dojoData->getItem(1), $this->dojoData[1]); - $this->dojoData[4] = array( - 'title' => 'ArrayAccess', - 'meta' => 'fun', - ); - $this->assertTrue(isset($this->dojoData[4])); - $this->assertEquals($this->dojoData->getItem(4), $this->dojoData[4]); - unset($this->dojoData[4]); - $this->assertFalse(isset($this->dojoData[4])); - } - - public function testShouldImplementIterator() - { - $this->assertTrue($this->dojoData instanceof Iterator); - $this->testAddItemsShouldAcceptTraversableObject(); - foreach ($this->dojoData as $key => $item) { - $this->assertTrue(is_array($item)); - $this->assertEquals($key, $item['id']); - } - } - - public function testShouldImplementCountable() - { - $this->assertTrue($this->dojoData instanceof Countable); - } - - public function testShouldAllowPopulationFromJson() - { - $data = array( - 'identifier' => 'id', - 'label' => 'title', - 'items' => array( - array('id' => 1, 'title' => 'One', 'name' => 'First'), - array('id' => 2, 'title' => 'Two', 'name' => 'Second'), - array('id' => 3, 'title' => 'Three', 'name' => 'Third'), - array('id' => 4, 'title' => 'Four', 'name' => 'Fourth'), - ), - ); - require_once 'Zend/Json.php'; - $json = Zend_Json::encode($data); - $dojoData = new Zend_Dojo_Data(); - $dojoData->fromJson($json); - $test = $dojoData->toArray(); - $this->assertEquals($data, $test); - } - - /** - * @expectedException Zend_Dojo_Exception - */ - public function testFromJsonShouldThrowExceptionOnInvalidData() - { - $this->dojoData->fromJson(new stdClass); - } - - /** - * @group ZF-3841 - */ - public function testDataContainerShouldAcceptAdditionalMetadataPerKey() - { - $this->assertNull($this->dojoData->getMetadata('numRows')); - $this->dojoData->setMetadata('numRows', 100); - $this->assertEquals(100, $this->dojoData->getMetadata('numRows')); - } - - /** - * @group ZF-3841 - */ - public function testDataContainerShouldAcceptAdditionalMetadataEnMasse() - { - $metadata = $this->dojoData->getMetadata(); - $this->assertTrue(is_array($metadata)); - $this->assertTrue(empty($metadata)); - - $metadata = array('numRows' => 100, 'sort' => 'name'); - $this->dojoData->setMetadata($metadata); - $test = $this->dojoData->getMetadata(); - $this->assertEquals($metadata, $test); - } - - /** - * @group ZF-3841 - */ - public function testDataContainerShouldAllowClearingIndividualMetadataItems() - { - $this->testDataContainerShouldAcceptAdditionalMetadataEnMasse(); - $this->dojoData->clearMetadata('numRows'); - $metadata = $this->dojoData->getMetadata(); - $this->assertEquals(1, count($metadata)); - $this->assertFalse(array_key_exists('numRows', $metadata)); - $this->assertTrue(array_key_exists('sort', $metadata)); - } - - /** - * @group ZF-3841 - */ - public function testDataContainerShouldAllowClearingMetadataEnMasse() - { - $this->testDataContainerShouldAcceptAdditionalMetadataEnMasse(); - $this->dojoData->clearMetadata(); - $metadata = $this->dojoData->getMetadata(); - $this->assertEquals(0, count($metadata)); - } - - /** - * @group ZF-3841 - */ - public function testSerializingToArrayShouldIncludeMetadata() - { - $this->testDataContainerShouldAcceptAdditionalMetadataEnMasse(); - $this->dojoData->setIdentifier('id'); - $array = $this->dojoData->toArray(); - $this->assertTrue(array_key_exists('numRows', $array)); - $this->assertTrue(array_key_exists('sort', $array)); - } -} - -class Zend_Dojo_DataTest_DataObject -{ - public $item = array( - 'id' => 'foo', - 'title' => 'Foo', - 'email' => 'foo@foo.com', - ); - - public function toArray() - { - return $this->item; - } -} - -class Zend_Dojo_DataTest_DataCollection implements Iterator -{ - public $items = array(); - - public function __construct() - { - for ($i = 1; $i < 4; ++$i) { - $item = new Zend_Dojo_DataTest_DataObject; - $item->item['id'] = $i; - $item->item['title'] .= $i; - $this->items[] = $item; - } - } - - public function current() - { - return current($this->items); - } - - public function key() - { - return key($this->items); - } - - public function next() - { - return next($this->items); - } - - public function rewind() - { - return reset($this->items); - } - - public function valid() - { - return (bool) $this->current(); - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_DataTest::main') { - Zend_Dojo_DataTest::main(); -} diff --git a/tests/Zend/Dojo/DojoTest.php b/tests/Zend/Dojo/DojoTest.php deleted file mode 100644 index 1b3ce00533c32eeab755873b6f285fd33548fd48..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/DojoTest.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -// Call Zend_Dojo_FormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_DojoTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Dojo */ -require_once 'Zend/Dojo.php'; - -/** Zend_Form */ -require_once 'Zend/Form.php'; - -/** Zend_Form_Element */ -require_once 'Zend/Form/Element.php'; - -/** Zend_Form_SubForm */ -require_once 'Zend/Form/SubForm.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Dojo - */ -class Zend_Dojo_DojoTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_DojoTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getForm() - { - $form = new Zend_Form(); - $form->addElement('text', 'foo') - ->addElement('text', 'bar') - ->addElement('text', 'baz') - ->addElement('text', 'bat'); - $subForm = new Zend_Form_SubForm(); - $subForm->addElement('text', 'foo') - ->addElement('text', 'bar') - ->addElement('text', 'baz') - ->addElement('text', 'bat'); - $form->addDisplayGroup(array('foo', 'bar'), 'foobar') - ->addSubForm($subForm, 'sub') - ->setView(new Zend_View); - return $form; - } - - public function testEnableFormShouldSetAppropriateDecoratorAndElementPaths() - { - $form = $this->getForm(); - Zend_Dojo::enableForm($form); - - $decPluginLoader = $form->getPluginLoader('decorator'); - $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - - $elPluginLoader = $form->getPluginLoader('element'); - $paths = $elPluginLoader->getPaths('Zend_Dojo_Form_Element'); - $this->assertTrue(is_array($paths)); - - $decPluginLoader = $form->baz->getPluginLoader('decorator'); - $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - - $decPluginLoader = $form->foobar->getPluginLoader(); - $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - - $decPluginLoader = $form->sub->getPluginLoader('decorator'); - $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - - $elPluginLoader = $form->sub->getPluginLoader('element'); - $paths = $elPluginLoader->getPaths('Zend_Dojo_Form_Element'); - $this->assertTrue(is_array($paths)); - } - - public function testEnableFormShouldSetAppropriateDefaultDisplayGroup() - { - $form = $this->getForm(); - Zend_Dojo::enableForm($form); - $this->assertEquals('Zend_Dojo_Form_DisplayGroup', $form->getDefaultDisplayGroupClass()); - } - - public function testEnableFormShouldSetAppropriateViewHelperPaths() - { - $form = $this->getForm(); - Zend_Dojo::enableForm($form); - $view = $form->getView(); - $helperLoader = $view->getPluginLoader('helper'); - $paths = $helperLoader->getPaths('Zend_Dojo_View_Helper'); - $this->assertTrue(is_array($paths)); - } - - public function testEnableViewShouldSetAppropriateViewHelperPaths() - { - $view = new Zend_View; - Zend_Dojo::enableView($view); - $helperLoader = $view->getPluginLoader('helper'); - $paths = $helperLoader->getPaths('Zend_Dojo_View_Helper'); - $this->assertTrue(is_array($paths)); - } -} - -// Call Zend_Dojo_DojoTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_DojoTest::main") { - Zend_Dojo_DojoTest::main(); -} diff --git a/tests/Zend/Dojo/Form/AllTests.php b/tests/Zend/Dojo/Form/AllTests.php deleted file mode 100644 index f37fe0850fda3f640b7e68ed1a6c192bf28fb5ff..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/AllTests.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_Form_AllTests::main'); -} -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Dojo/Form/Decorator/AllTests.php'; -require_once 'Zend/Dojo/Form/Element/AllTests.php'; -require_once 'Zend/Dojo/Form/FormTest.php'; -require_once 'Zend/Dojo/Form/SubFormTest.php'; - -/** - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dojo_Form'); - - $suite->addTest(Zend_Dojo_Form_Decorator_AllTests::suite()); - $suite->addTest(Zend_Dojo_Form_Element_AllTests::suite()); - $suite->addTestSuite('Zend_Dojo_Form_FormTest'); - $suite->addTestSuite('Zend_Dojo_Form_SubFormTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_Form_AllTests::main') { - Zend_Dojo_Form_AllTests::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/AccordionContainerTest.php b/tests/Zend/Dojo/Form/Decorator/AccordionContainerTest.php deleted file mode 100644 index ed6a6ff079f408e54acf156eeb37ac16a43782a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/AccordionContainerTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AccordionContainerTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_AccordionContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_AccordionContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_AccordionContainer */ -require_once 'Zend/Dojo/Form/Decorator/AccordionContainer.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_AccordionContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_AccordionContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_AccordionContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_AccordionContainer(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.AccordionContainer"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_AccordionContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_AccordionContainerTest::main") { - Zend_Dojo_Form_Decorator_AccordionContainerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/AccordionPaneTest.php b/tests/Zend/Dojo/Form/Decorator/AccordionPaneTest.php deleted file mode 100644 index e817eafb9c44f3070b72452b8aba8a791695af97..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/AccordionPaneTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AccordionPaneTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_AccordionPaneTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_AccordionPaneTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_AccordionPane */ -require_once 'Zend/Dojo/Form/Decorator/AccordionPane.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_AccordionPane. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_AccordionPaneTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_AccordionPaneTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_AccordionPane(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.AccordionPane"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_AccordionPaneTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_AccordionPaneTest::main") { - Zend_Dojo_Form_Decorator_AccordionPaneTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/AllTests.php b/tests/Zend/Dojo/Form/Decorator/AllTests.php deleted file mode 100644 index ffec4ba9b24f33916a69c2e815f8912531627456..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/AllTests.php +++ /dev/null @@ -1,76 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_Form_Decorator_AllTests::main'); -} - -require_once 'Zend/Dojo/Form/Decorator/AccordionContainerTest.php'; -require_once 'Zend/Dojo/Form/Decorator/AccordionPaneTest.php'; -require_once 'Zend/Dojo/Form/Decorator/BorderContainerTest.php'; -require_once 'Zend/Dojo/Form/Decorator/DijitContainerTest.php'; -require_once 'Zend/Dojo/Form/Decorator/DijitElementTest.php'; -require_once 'Zend/Dojo/Form/Decorator/DijitFormTest.php'; -require_once 'Zend/Dojo/Form/Decorator/SplitContainerTest.php'; -require_once 'Zend/Dojo/Form/Decorator/StackContainerTest.php'; -require_once 'Zend/Dojo/Form/Decorator/TabContainerTest.php'; - -/** - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dojo - Form_Decorator'); - - $suite->addTestSuite('Zend_Dojo_Form_Decorator_AccordionContainerTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_AccordionPaneTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_BorderContainerTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_DijitContainerTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_DijitElementTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_DijitFormTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_SplitContainerTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_StackContainerTest'); - $suite->addTestSuite('Zend_Dojo_Form_Decorator_TabContainerTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_Form_Decorator_AllTests::main') { - Zend_Dojo_Form_Decorator_AllTests::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/BorderContainerTest.php b/tests/Zend/Dojo/Form/Decorator/BorderContainerTest.php deleted file mode 100644 index 8cd9cbb2a5a31f46fd25febb538364d56fdc7276..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/BorderContainerTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BorderContainerTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_BorderContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_BorderContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_BorderContainer */ -require_once 'Zend/Dojo/Form/Decorator/BorderContainer.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_BorderContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_BorderContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_BorderContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_BorderContainer(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.BorderContainer"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_BorderContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_BorderContainerTest::main") { - Zend_Dojo_Form_Decorator_BorderContainerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/DijitContainerTest.php b/tests/Zend/Dojo/Form/Decorator/DijitContainerTest.php deleted file mode 100644 index e2aec7cd6c1bc0ad4e43514b4667608f20363d28..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/DijitContainerTest.php +++ /dev/null @@ -1,252 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DijitContainerTest.php 10043 2008-07-11 15:41:54Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_DijitContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_DijitContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_DijitContainer */ -require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php'; - -/** Zend_Dojo_Form_Decorator_ContentPane */ -require_once 'Zend/Dojo/Form/Decorator/ContentPane.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form/SubForm.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_DijitContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_DijitContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_DijitContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->errors = array(); - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_ContentPane(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_SubForm(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - /** - * Handle an error (for testing notices) - * - * @param int $errno - * @param string $errstr - * @return void - */ - public function handleError($errno, $errstr) - { - $this->errors[] = $errstr; - } - - public function testRetrievingElementAttributesShouldOmitDijitParams() - { - $attribs = $this->decorator->getAttribs(); - $this->assertTrue(is_array($attribs)); - $this->assertFalse(array_key_exists('dijitParams', $attribs)); - } - - public function testRetrievingDijitParamsShouldOmitNormalAttributes() - { - $params = $this->decorator->getDijitParams(); - $this->assertTrue(is_array($params)); - $this->assertFalse(array_key_exists('class', $params)); - $this->assertFalse(array_key_exists('style', $params)); - } - - public function testLegendShouldBeUsedAsTitleByDefault() - { - $this->element->setLegend('Foo Bar'); - $this->assertEquals('Foo Bar', $this->decorator->getTitle()); - } - - public function testLegendOptionShouldBeUsedAsFallbackTitleWhenNoLegendPresentInElement() - { - $this->decorator->setOption('legend', 'Legend Option') - ->setOption('title', 'Title Option'); - $options = $this->decorator->getOptions(); - $this->assertEquals('Legend Option', $this->decorator->getTitle(), var_export($options, 1)); - } - - public function testTitleOptionShouldBeUsedAsFinalFallbackTitleWhenNoLegendPresentInElement() - { - $this->decorator->setOption('title', 'Title Option'); - $options = $this->decorator->getOptions(); - $this->assertEquals('Title Option', $this->decorator->getTitle(), var_export($options, 1)); - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldTriggerErrorWhenDuplicateDijitDetected() - { - $this->view->dojo()->addDijit('foo-ContentPane', array('dojoType' => 'dijit.layout.ContentPane')); - - $handler = set_error_handler(array($this, 'handleError')); - $html = $this->decorator->render(''); - restore_error_handler(); - - $this->assertFalse(empty($this->errors), var_export($this->errors, 1)); - $found = false; - foreach ($this->errors as $error) { - if (strstr($error, 'Duplicate')) { - $found = true; - break; - } - } - $this->assertTrue($found); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.ContentPane"', $html); - } - - /** - * @expectedException Zend_Form_Decorator_Exception - */ - public function testAbsenceOfHelperShouldRaiseException() - { - $decorator = new Zend_Dojo_Form_Decorator_DijitContainerTest_Example(); - $helper = $decorator->getHelper(); - } - - public function testShouldAllowPassingDijitParamsAsOptions() - { - $element = new Zend_Dojo_Form_SubForm(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - )); - $dijitParams = array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ); - $this->decorator->setElement($element); - $this->decorator->setOption('dijitParams', $dijitParams); - $test = $this->decorator->getDijitParams(); - foreach ($dijitParams as $key => $value) { - $this->assertEquals($value, $test[$key]); - } - } - - public function testShouldUseLegendAttribAsTitleIfNoTitlePresent() - { - $element = new Zend_Dojo_Form_SubForm(); - $element->setAttribs(array( - 'name' => 'foo', - 'legend' => 'FooBar', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - )) - ->setView($this->view); - $this->decorator->setElement($element); - $html = $this->decorator->render(''); - $this->assertContains('FooBar', $html); - } -} - -class Zend_Dojo_Form_Decorator_DijitContainerTest_Example extends Zend_Dojo_Form_Decorator_DijitContainer -{ -} - -// Call Zend_Dojo_Form_Decorator_DijitContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_DijitContainerTest::main") { - Zend_Dojo_Form_Decorator_DijitContainerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/DijitElementTest.php b/tests/Zend/Dojo/Form/Decorator/DijitElementTest.php deleted file mode 100644 index 8040c0f0d55685e8c0fac34470961998a76d21b4..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/DijitElementTest.php +++ /dev/null @@ -1,218 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DijitElementTest.php 10043 2008-07-11 15:41:54Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_DijitElementTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_DijitElementTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_DijitElement */ -require_once 'Zend/Dojo/Form/Decorator/DijitElement.php'; - -/** Zend_Dojo_Form_Element_TextBox */ -require_once 'Zend/Dojo/Form/Element/TextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_DijitElement. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_DijitElementTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_DijitElementTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->errors = array(); - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_DijitElement(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_TextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'TextBox', - 'trim' => true, - 'propercase' => true, - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - /** - * Handle an error (for testing notices) - * - * @param int $errno - * @param string $errstr - * @return void - */ - public function handleError($errno, $errstr) - { - $this->errors[] = $errstr; - } - - public function testRetrievingElementAttributesShouldOmitDijitParams() - { - $attribs = $this->decorator->getElementAttribs(); - $this->assertTrue(is_array($attribs)); - $this->assertFalse(array_key_exists('dijitParams', $attribs)); - $this->assertFalse(array_key_exists('propercase', $attribs)); - $this->assertFalse(array_key_exists('trim', $attribs)); - } - - public function testRetrievingDijitParamsShouldOmitNormalAttributes() - { - $params = $this->decorator->getDijitParams(); - $this->assertTrue(is_array($params)); - $this->assertFalse(array_key_exists('class', $params)); - $this->assertFalse(array_key_exists('style', $params)); - $this->assertFalse(array_key_exists('value', $params)); - $this->assertFalse(array_key_exists('label', $params)); - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldTriggerErrorWhenDuplicateDijitDetected() - { - $this->view->dojo()->addDijit('foo', array('dojoType' => 'dijit.form.TextBox')); - - $handler = set_error_handler(array($this, 'handleError')); - $html = $this->decorator->render(''); - restore_error_handler(); - $this->assertFalse(empty($this->errors), var_export($this->errors, 1)); - $found = false; - foreach ($this->errors as $error) { - if (strstr($error, 'Duplicate')) { - $found = true; - break; - } - } - $this->assertTrue($found); - } - - public function testShouldAllowAddingAndRetrievingIndividualDijitParams() - { - $this->assertNull($this->decorator->getDijitParam('bogus')); - $this->decorator->setDijitParam('bogus', 'value'); - $this->assertEquals('value', $this->decorator->getDijitParam('bogus')); - } - - /** - * @expectedException Zend_Form_Decorator_Exception - */ - public function testRenderingShouldThrowExceptionWhenNoViewObjectRegistered() - { - $element = new Zend_Dojo_Form_Element_TextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'TextBox', - 'trim' => true, - 'propercase' => true, - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - $this->decorator->setElement($element); - $html = $this->decorator->render(''); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.form.TextBox"', $html); - } - - public function testRenderingShouldSetRequiredDijitParamWhenElementIsRequired() - { - $this->element->setRequired(true); - $html = $this->decorator->render(''); - $this->assertContains('required="', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_DijitElementTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_DijitElementTest::main") { - Zend_Dojo_Form_Decorator_DijitElementTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/DijitFormTest.php b/tests/Zend/Dojo/Form/Decorator/DijitFormTest.php deleted file mode 100644 index fe303c8199a102b9e5f08ad468245500dcac1d16..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/DijitFormTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DijitFormTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_DijitFormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_DijitFormTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_DijitForm */ -require_once 'Zend/Dojo/Form/Decorator/DijitForm.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_DijitForm. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_DijitFormTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_DijitFormTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_DijitForm(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.form.Form"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_DijitFormTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_DijitFormTest::main") { - Zend_Dojo_Form_Decorator_DijitFormTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/SplitContainerTest.php b/tests/Zend/Dojo/Form/Decorator/SplitContainerTest.php deleted file mode 100644 index 7ddbe6b5c78a42834dc98291196e6cf10cd755a6..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/SplitContainerTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SplitContainerTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_SplitContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_SplitContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_SplitContainer */ -require_once 'Zend/Dojo/Form/Decorator/SplitContainer.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_SplitContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_SplitContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_SplitContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_SplitContainer(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.SplitContainer"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_SplitContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_SplitContainerTest::main") { - Zend_Dojo_Form_Decorator_SplitContainerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/StackContainerTest.php b/tests/Zend/Dojo/Form/Decorator/StackContainerTest.php deleted file mode 100644 index 1bb41b477ca8a3392b144af57930693c80353edf..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/StackContainerTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StackContainerTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_StackContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_StackContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_StackContainer */ -require_once 'Zend/Dojo/Form/Decorator/StackContainer.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_StackContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_StackContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_StackContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_StackContainer(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.StackContainer"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_StackContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_StackContainerTest::main") { - Zend_Dojo_Form_Decorator_StackContainerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Decorator/TabContainerTest.php b/tests/Zend/Dojo/Form/Decorator/TabContainerTest.php deleted file mode 100644 index 77943240be2f7830de94221206e6aab5dfd97797..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Decorator/TabContainerTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TabContainerTest.php 10032 2008-07-10 16:47:19Z matthew $ - */ - -// Call Zend_Dojo_Form_Decorator_TabContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Decorator_TabContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Decorator_TabContainer */ -require_once 'Zend/Dojo/Form/Decorator/TabContainer.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Decorator_TabContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Decorator_TabContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Decorator_TabContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->decorator = new Zend_Dojo_Form_Decorator_TabContainer(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form(); - $element->setAttribs(array( - 'name' => 'foo', - 'style' => 'width: 300px; height: 500px;', - 'class' => 'someclass', - 'dijitParams' => array( - 'labelAttr' => 'foobar', - 'typeAttr' => 'barbaz', - ), - )); - return $element; - } - - public function testRenderingShouldEnableDojo() - { - $html = $this->decorator->render(''); - $this->assertTrue($this->view->dojo()->isEnabled()); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->decorator->render(''); - $this->assertContains('dojoType="dijit.layout.TabContainer"', $html); - } -} - -// Call Zend_Dojo_Form_Decorator_TabContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Decorator_TabContainerTest::main") { - Zend_Dojo_Form_Decorator_TabContainerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/AllTests.php b/tests/Zend/Dojo/Form/Element/AllTests.php deleted file mode 100644 index 913d8534a88035042d37314961a62740c5958ada..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/AllTests.php +++ /dev/null @@ -1,92 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 11343 2008-09-10 20:03:02Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_Form_Element_AllTests::main'); -} - -require_once 'Zend/Dojo/Form/Element/CheckBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/ComboBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/CurrencyTextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/DateTextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/DijitTest.php'; -require_once 'Zend/Dojo/Form/Element/FilteringSelectTest.php'; -require_once 'Zend/Dojo/Form/Element/HorizontalSliderTest.php'; -require_once 'Zend/Dojo/Form/Element/NumberSpinnerTest.php'; -require_once 'Zend/Dojo/Form/Element/NumberTextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/PasswordTextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/RadioButtonTest.php'; -require_once 'Zend/Dojo/Form/Element/SubmitButtonTest.php'; -require_once 'Zend/Dojo/Form/Element/TextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/TextareaTest.php'; -require_once 'Zend/Dojo/Form/Element/TimeTextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/ValidationTextBoxTest.php'; -require_once 'Zend/Dojo/Form/Element/VerticalSliderTest.php'; - -/** - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dojo - Form_Element'); - - $suite->addTestSuite('Zend_Dojo_Form_Element_CheckBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_ComboBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_CurrencyTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_DateTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_DijitTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_FilteringSelectTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_HorizontalSliderTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_NumberSpinnerTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_NumberTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_PasswordTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_RadioButtonTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_SubmitButtonTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_TextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_TextareaTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_TimeTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_ValidationTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_Form_Element_VerticalSliderTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_Form_Element_AllTests::main') { - Zend_Dojo_Form_Element_AllTests::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/ButtonTest.php b/tests/Zend/Dojo/Form/Element/ButtonTest.php deleted file mode 100644 index 4e35144d557de53127b52d79f9719dec7b5c381c..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/ButtonTest.php +++ /dev/null @@ -1,183 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ButtonTest.php 10091 2008-07-15 03:46:37Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_ButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_ButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_Button */ -require_once 'Zend/Dojo/Form/Element/Button.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Translate */ -require_once 'Zend/Translate.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_ButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_ButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_Button('foo'); - return $element; - } - - public function testGetLabelReturnsNameIfNoValuePresent() - { - $this->assertEquals($this->element->getName(), $this->element->getLabel()); - } - - public function testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered() - { - $translations = include dirname(__FILE__) . '/_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $this->element->setTranslator($translate) - ->setLabel('submit'); - $test = $this->element->getLabel(); - $this->assertEquals($translations['submit'], $test); - } - - public function testTranslatedLabelIsRendered() - { - $this->testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered(); - $this->element->setView($this->getView()); - $decorator = $this->element->getDecorator('DijitElement'); - $decorator->setElement($this->element); - $html = $decorator->render(''); - $this->assertRegexp('/<(input|button)[^>]*?(value="Submit Button")/', $html, 'Label: ' . $this->element->getLabel() . "\nHTML: " . $html); - } - - public function testConstructorSetsLabelToNameIfNoLabelProvided() - { - $button = new Zend_Dojo_Form_Element_Button('foo'); - $this->assertEquals('foo', $button->getName()); - $this->assertEquals('foo', $button->getLabel()); - } - - public function testCanPassLabelAsParameterToConstructor() - { - $button = new Zend_Dojo_Form_Element_Button('foo', 'Label'); - $this->assertEquals('Label', $button->getLabel()); - } - - public function testLabelIsTranslatedWhenTranslationAvailable() - { - require_once 'Zend/Translate.php'; - $translations = array('Label' => 'This is the Submit Label'); - $translate = new Zend_Translate('array', $translations); - $button = new Zend_Dojo_Form_Element_Button('foo', 'Label'); - $button->setTranslator($translate); - $this->assertEquals($translations['Label'], $button->getLabel()); - } - - public function testIsCheckedReturnsFalseWhenNoValuePresent() - { - $this->assertFalse($this->element->isChecked()); - } - - public function testIsCheckedReturnsFalseWhenValuePresentButDoesNotMatchLabel() - { - $this->assertFalse($this->element->isChecked()); - $this->element->setValue('bar'); - $this->assertFalse($this->element->isChecked()); - } - - public function testIsCheckedReturnsTrueWhenValuePresentAndMatchesLabel() - { - $this->testIsCheckedReturnsFalseWhenNoValuePresent(); - $this->element->setValue('foo'); - $this->assertTrue($this->element->isChecked()); - } - - public function testShouldRenderButtonDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.Button"', $html); - } -} - -// Call Zend_Dojo_Form_Element_ButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_ButtonTest::main") { - Zend_Dojo_Form_Element_ButtonTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/CheckBoxTest.php b/tests/Zend/Dojo/Form/Element/CheckBoxTest.php deleted file mode 100644 index 0e5c99bfe14c6324250e6ff53672c648789e894d..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/CheckBoxTest.php +++ /dev/null @@ -1,260 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CheckBoxTest.php 11293 2008-09-08 18:54:34Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_CheckBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_CheckBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_CheckBox */ -require_once 'Zend/Dojo/Form/Element/CheckBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_CheckBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_CheckBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_CheckBox( - 'foo', - array( - 'label' => 'CheckBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testCheckedFlagIsFalseByDefault() - { - $this->assertFalse($this->element->checked); - } - - public function testCheckedAttributeNotRenderedByDefault() - { - $html = $this->element->render(); - $this->assertNotContains('checked="checked"', $html); - } - - public function testCheckedAttributeRenderedWhenCheckedFlagTrue() - { - $this->element->checked = true; - $html = $this->element->render(); - $this->assertContains('checked="checked"', $html); - } - - public function testCheckedValueDefaultsToOne() - { - $this->assertEquals(1, $this->element->getCheckedValue()); - } - - public function testUncheckedValueDefaultsToZero() - { - $this->assertEquals(0, $this->element->getUncheckedValue()); - } - - public function testCanSetCheckedValue() - { - $this->testCheckedValueDefaultsToOne(); - $this->element->setCheckedValue('foo'); - $this->assertEquals('foo', $this->element->getCheckedValue()); - } - - public function testCanSetUncheckedValue() - { - $this->testUncheckedValueDefaultsToZero(); - $this->element->setUncheckedValue('foo'); - $this->assertEquals('foo', $this->element->getUncheckedValue()); - } - - public function testValueInitiallyUncheckedValue() - { - $this->assertEquals($this->element->getUncheckedValue(), $this->element->getValue()); - } - - public function testSettingValueToCheckedValueSetsWithEquivalentValue() - { - $this->testValueInitiallyUncheckedValue(); - $this->element->setValue($this->element->getCheckedValue()); - $this->assertEquals($this->element->getCheckedValue(), $this->element->getValue()); - } - - public function testSettingValueToAnythingOtherThanCheckedValueSetsAsUncheckedValue() - { - $this->testSettingValueToCheckedValueSetsWithEquivalentValue(); - $this->element->setValue('bogus'); - $this->assertEquals($this->element->getUncheckedValue(), $this->element->getValue()); - } - - public function testSettingCheckedFlagToTrueSetsValueToCheckedValue() - { - $this->testValueInitiallyUncheckedValue(); - $this->element->setChecked(true); - $this->assertEquals($this->element->getCheckedValue(), $this->element->getValue()); - } - - public function testSettingCheckedFlagToFalseSetsValueToUncheckedValue() - { - $this->testSettingCheckedFlagToTrueSetsValueToCheckedValue(); - $this->element->setChecked(false); - $this->assertEquals($this->element->getUncheckedValue(), $this->element->getValue()); - } - - public function testSettingValueToCheckedValueMarksElementAsChecked() - { - $this->testValueInitiallyUncheckedValue(); - $this->element->setValue($this->element->getCheckedValue()); - $this->assertTrue($this->element->checked); - } - - public function testSettingValueToUncheckedValueMarksElementAsNotChecked() - { - $this->testSettingValueToCheckedValueMarksElementAsChecked(); - $this->element->setValue($this->element->getUncheckedValue()); - $this->assertFalse($this->element->checked); - } - - public function testIsCheckedShouldReflectCurrentCheckedStatus() - { - $this->element->setChecked(true); - $this->assertTrue($this->element->isChecked()); - $this->element->setChecked(false); - $this->assertFalse($this->element->isChecked()); - } - - public function testSetOptionsSetsInitialValueAccordingToCheckedAndUncheckedValues() - { - $options = array( - 'checkedValue' => 'foo', - 'uncheckedValue' => 'bar', - ); - - $element = new Zend_Dojo_Form_Element_CheckBox('test', $options); - $this->assertEquals($options['uncheckedValue'], $element->getValue()); - } - - public function testSetOptionsSetsInitialValueAccordingToSubmittedValues() - { - $options = array( - 'test1' => array( - 'value' => 'foo', - 'checkedValue' => 'foo', - 'uncheckedValue' => 'bar', - ), - 'test2' => array( - 'value' => 'bar', - 'checkedValue' => 'foo', - 'uncheckedValue' => 'bar', - ), - ); - - foreach ($options as $current) { - $element = new Zend_Dojo_Form_Element_CheckBox('test', $current); - $this->assertEquals($current['value'], $element->getValue()); - $this->assertEquals($current['checkedValue'], $element->getCheckedValue()); - $this->assertEquals($current['uncheckedValue'], $element->getUncheckedValue()); - } - } - - public function testShouldRenderCheckBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.CheckBox"', $html); - } - - /** - * @group ZF-3879 - */ - public function testOptionsShouldNotBeRenderedAsElementAttribute() - { - $html = $this->element->render(); - $this->assertNotContains('options="', $html, $html); - } -} - -// Call Zend_Dojo_Form_Element_CheckBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_CheckBoxTest::main") { - Zend_Dojo_Form_Element_CheckBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/ComboBoxTest.php b/tests/Zend/Dojo/Form/Element/ComboBoxTest.php deleted file mode 100644 index 456043f789b9b238c4324a28e6b5eb2f95c753c5..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/ComboBoxTest.php +++ /dev/null @@ -1,174 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ComboBoxTest.php 10724 2008-08-06 15:31:23Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_ComboBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_ComboBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_ComboBox */ -require_once 'Zend/Dojo/Form/Element/ComboBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_ComboBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_ComboBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_ComboBox( - 'foo', - array( - 'label' => 'ComboBox', - ) - ); - return $element; - } - - public function testSettingStoreIdShouldProxyToStoreDijitParam() - { - $this->element->setStoreId('someStore'); - $this->assertTrue($this->element->hasDijitParam('store')); - $store = $this->element->getDijitParam('store'); - $this->assertTrue(array_key_exists('store', $store)); - $this->assertEquals('someStore', $store['store']); - $this->assertEquals($this->element->getStoreId(), $store['store']); - } - - public function testSettingStoreTypeShouldProxyToStoreDijitParam() - { - $this->element->setStoreType('dojo.data.ItemFileReadStore'); - $this->assertTrue($this->element->hasDijitParam('store')); - $store = $this->element->getDijitParam('store'); - $this->assertTrue(array_key_exists('type', $store)); - $this->assertEquals('dojo.data.ItemFileReadStore', $store['type']); - $this->assertEquals($this->element->getStoreType(), $store['type']); - } - - public function testSettingStoreParamsShouldProxyToStoreDijitParam() - { - $this->element->setStoreParams(array('url' => '/js/foo.json')); - $this->assertTrue($this->element->hasDijitParam('store')); - $store = $this->element->getDijitParam('store'); - $this->assertTrue(array_key_exists('params', $store)); - $this->assertEquals(array('url' => '/js/foo.json'), $store['params']); - $this->assertEquals($this->element->getStoreParams(), $store['params']); - } - - public function testAutocompleteAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getAutocomplete()); - $this->assertFalse(array_key_exists('autocomplete', $this->element->dijitParams)); - $this->element->setAutocomplete(true); - $this->assertTrue($this->element->getAutocomplete()); - $this->assertTrue(array_key_exists('autocomplete', $this->element->dijitParams)); - } - - /**#@+ - * @see ZF-3286 - */ - public function testShouldNeverRegisterInArrayValidatorAutomatically() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->assertFalse($this->element->getValidator('InArray')); - $this->element->isValid('test'); - $this->assertFalse($this->element->getValidator('InArray')); - } - /**#@-*/ - - public function testShouldRenderComboBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.ComboBox"', $html); - } -} - -// Call Zend_Dojo_Form_Element_ComboBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_ComboBoxTest::main") { - Zend_Dojo_Form_Element_ComboBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/CurrencyTextBoxTest.php b/tests/Zend/Dojo/Form/Element/CurrencyTextBoxTest.php deleted file mode 100644 index b7912983062aedc7c1dcaad0fb86de8b6171bd0e..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/CurrencyTextBoxTest.php +++ /dev/null @@ -1,168 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CurrencyTextBoxTest.php 10079 2008-07-14 10:56:37Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_CurrencyTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_CurrencyTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_CurrencyTextBox */ -require_once 'Zend/Dojo/Form/Element/CurrencyTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_CurrencyTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_CurrencyTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_CurrencyTextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'CurrencyTextBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testShouldExtendNumberTextBox() - { - $this->assertTrue($this->element instanceof Zend_Dojo_Form_Element_NumberTextBox); - } - - public function testCurrencyAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getCurrency()); - $this->assertNull($this->element->getDijitParam('currency')); - $this->element->setCurrency('USD'); - $this->assertEquals('USD', $this->element->getCurrency()); - $this->assertEquals('USD', $this->element->getDijitParam('currency')); - } - - public function testFractionalAccessorsShouldProxyToConstraints() - { - $this->assertFalse($this->element->getFractional()); - $this->assertFalse(array_key_exists('constraints', $this->element->dijitParams)); - $this->element->setFractional(true); - $this->assertTrue($this->element->getFractional()); - $this->assertEquals('true', $this->element->dijitParams['constraints']['fractional']); - } - - public function testSymbolAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getSymbol()); - $this->assertFalse($this->element->hasConstraint('symbol')); - $this->element->setSymbol('USD'); - $this->assertEquals('USD', $this->element->getSymbol()); - $this->assertEquals('USD', $this->element->getConstraint('symbol')); - } - - public function testSymbolMutatorShouldCastToStringAndUppercaseAndLimitTo3Chars() - { - $this->element->setSymbol('usdollar'); - $this->assertEquals('USD', $this->element->getSymbol()); - $this->assertEquals('USD', $this->element->getConstraint('symbol')); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testSymbolMutatorShouldRaiseExceptionWhenFewerThan3CharsProvided() - { - $this->element->setSymbol('$'); - } - - public function testShouldRenderCurrencyTextBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.CurrencyTextBox"', $html); - } -} - -// Call Zend_Dojo_Form_Element_CurrencyTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_CurrencyTextBoxTest::main") { - Zend_Dojo_Form_Element_CurrencyTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/DateTextBoxTest.php b/tests/Zend/Dojo/Form/Element/DateTextBoxTest.php deleted file mode 100644 index 2ada54f25b0c0d0de0369f5eae0d831e7f263e61..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/DateTextBoxTest.php +++ /dev/null @@ -1,203 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DateTextBoxTest.php 10079 2008-07-14 10:56:37Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_DateTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_DateTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_DateTextBox */ -require_once 'Zend/Dojo/Form/Element/DateTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_DateTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_DateTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_DateTextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'DateTextBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testAmPmAccessorsShouldProxyToConstraints() - { - $this->assertFalse($this->element->getAmPm()); - $constraints = $this->element->getConstraints(); - $this->assertFalse(array_key_exists('am,pm', $constraints)); - $this->element->setAmPm(true); - $this->assertTrue($this->element->getAmPm()); - $constraints = $this->element->getConstraints(); - $this->assertTrue(array_key_exists('am,pm', $constraints)); - $this->assertEquals('true', $this->element->dijitParams['constraints']['am,pm']); - } - - public function testStrictAccessorsShouldProxyToConstraints() - { - $this->assertFalse($this->element->getStrict()); - $constraints = $this->element->getConstraints(); - $this->assertFalse(array_key_exists('strict', $constraints)); - $this->element->setStrict(true); - $this->assertTrue($this->element->getStrict()); - $constraints = $this->element->getConstraints(); - $this->assertTrue(array_key_exists('strict', $constraints)); - $this->assertEquals('true', $this->element->dijitParams['constraints']['strict']); - } - - public function testLocaleAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getLocale()); - $constraints = $this->element->getConstraints(); - $this->assertFalse(array_key_exists('locale', $constraints)); - $this->element->setLocale('en-US'); - $this->assertEquals('en-US', $this->element->getLocale()); - $constraints = $this->element->getConstraints(); - $this->assertEquals('en-US', $this->element->dijitParams['constraints']['locale']); - } - - public function testFormatLengthAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getFormatLength()); - $constraints = $this->element->getConstraints(); - $this->assertFalse(array_key_exists('formatLength', $constraints)); - $this->element->setFormatLength('long'); - $this->assertEquals('long', $this->element->getFormatLength()); - $constraints = $this->element->getConstraints(); - $this->assertEquals('long', $this->element->dijitParams['constraints']['formatLength']); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testFormatLengthMutatorShouldThrowExceptionWithInvalidFormatLength() - { - $this->element->setFormatLength('foobar'); - } - - public function testSelectorAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getSelector()); - $constraints = $this->element->getConstraints(); - $this->assertFalse(array_key_exists('selector', $constraints)); - $this->element->setSelector('time'); - $this->assertEquals('time', $this->element->getSelector()); - $constraints = $this->element->getConstraints(); - $this->assertEquals('time', $this->element->dijitParams['constraints']['selector']); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testSelectorMutatorShouldThrowExceptionWithInvalidSelector() - { - $this->element->setSelector('foobar'); - } - - public function testDatePatternAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getDatePattern()); - $this->assertFalse($this->element->hasConstraint('datePattern')); - $this->element->setDatePattern('EEE, MMM d, Y'); - $this->assertEquals('EEE, MMM d, Y', $this->element->getDatePattern()); - $this->assertEquals('EEE, MMM d, Y', $this->element->dijitParams['constraints']['datePattern']); - } - - public function testShouldRenderDateTextBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.DateTextBox"', $html); - } -} - -// Call Zend_Dojo_Form_Element_DateTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_DateTextBoxTest::main") { - Zend_Dojo_Form_Element_DateTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/DijitTest.php b/tests/Zend/Dojo/Form/Element/DijitTest.php deleted file mode 100644 index fc1f657faf92c6a2f6a3a380877841a8014b2831..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/DijitTest.php +++ /dev/null @@ -1,154 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DijitTest.php 10076 2008-07-13 12:58:08Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_DijitTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_DijitTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_TextBox */ -require_once 'Zend/Dojo/Form/Element/TextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_DijitTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_DijitTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_TextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'TextBox', - 'trim' => true, - 'propercase' => true, - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testShouldAbstractDijitParameterManipulation() - { - $params = $this->element->getDijitParams(); - $this->assertSame($this->element->dijitParams, $params); - - $this->assertFalse($this->element->hasDijitParam('foo')); - $this->element->setDijitParam('foo', 'bar'); - $this->assertTrue($this->element->hasDijitParam('foo')); - $this->element->removeDijitParam('foo'); - $this->assertFalse($this->element->hasDijitParam('foo')); - $this->element->clearDijitParams(); - $params = $this->element->getDijitParams(); - $this->assertTrue(empty($params)); - $this->assertTrue(empty($this->element->dijitParams)); - } - - public function testDijitElementDecoratorShouldBeEnabledByDefault() - { - $decorator = $this->element->getDecorator('DijitElement'); - $this->assertTrue($decorator instanceof Zend_Dojo_Form_Decorator_DijitElement, get_class($decorator)); - } - - public function testRenderingShouldCreateDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.TextBox"', $html); - } - - public function testElementShouldDojoEnableViewObject() - { - $this->element->setView(new Zend_View); - $view = $this->element->getView(); - $loader = $view->getPluginLoader('helper'); - $paths = $loader->getPaths('Zend_Dojo_View_Helper'); - $this->assertTrue(is_array($paths)); - } -} - -// Call Zend_Dojo_Form_Element_DijitTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_DijitTest::main") { - Zend_Dojo_Form_Element_DijitTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/FilteringSelectTest.php b/tests/Zend/Dojo/Form/Element/FilteringSelectTest.php deleted file mode 100644 index d46a88243563d9215a2faed99e791fe3f8007a55..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/FilteringSelectTest.php +++ /dev/null @@ -1,155 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FilteringSelectTest.php 10724 2008-08-06 15:31:23Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_FilteringSelectTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_FilteringSelectTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_FilteringSelect */ -require_once 'Zend/Dojo/Form/Element/FilteringSelect.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_FilteringSelectTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_FilteringSelectTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_FilteringSelect( - 'foo', - array( - 'value' => 'some text', - 'label' => 'FilteringSelect', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testShouldRenderFilteringSelectDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.FilteringSelect"', $html); - } - - /**#@+ - * @see ZF-3286 - */ - public function testShouldRegisterInArrayValidatorWhenNoStoreProvided() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->assertFalse($this->element->getValidator('InArray')); - $this->element->isValid('test'); - $validator = $this->element->getValidator('InArray'); - $this->assertTrue($validator instanceof Zend_Validate_InArray); - } - - public function testShouldNotRegisterInArrayValidatorWhenStoreProvided() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->element->setStoreId('fooStore') - ->setStoreType('dojo.data.ItemFileReadStore') - ->setStoreParams(array('url' => '/foo')); - $this->assertFalse($this->element->getValidator('InArray')); - $this->element->isValid('test'); - $this->assertFalse($this->element->getValidator('InArray')); - } - /**#@-*/ -} - -// Call Zend_Dojo_Form_Element_FilteringSelectTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_FilteringSelectTest::main") { - Zend_Dojo_Form_Element_FilteringSelectTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/HorizontalSliderTest.php b/tests/Zend/Dojo/Form/Element/HorizontalSliderTest.php deleted file mode 100644 index a14305aff86473fb501299de810b7c83598d6d66..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/HorizontalSliderTest.php +++ /dev/null @@ -1,351 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HorizontalSliderTest.php 10038 2008-07-10 21:45:16Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_HorizontalSliderTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_HorizontalSliderTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_HorizontalSlider */ -require_once 'Zend/Dojo/Form/Element/HorizontalSlider.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_HorizontalSliderTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_HorizontalSliderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_HorizontalSlider( - 'foo', - array( - 'value' => 'some text', - 'label' => 'HorizontalSlider', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testClickSelectAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getClickSelect()); - $this->assertFalse(array_key_exists('clickSelect', $this->element->dijitParams)); - $this->element->setClickSelect(true); - $this->assertTrue($this->element->getClickSelect()); - $this->assertTrue($this->element->dijitParams['clickSelect']); - } - - public function testIntermediateChangesAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getIntermediateChanges()); - $this->assertFalse(array_key_exists('intermediateChanges', $this->element->dijitParams)); - $this->element->setIntermediateChanges(true); - $this->assertTrue($this->element->getIntermediateChanges()); - $this->assertTrue($this->element->dijitParams['intermediateChanges']); - } - - public function testShowButtonsAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getShowButtons()); - $this->assertFalse(array_key_exists('showButtons', $this->element->dijitParams)); - $this->element->setShowButtons(true); - $this->assertTrue($this->element->getShowButtons()); - $this->assertTrue($this->element->dijitParams['showButtons']); - } - - public function testDiscreteValuesAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getDiscreteValues()); - $this->assertFalse(array_key_exists('discreteValues', $this->element->dijitParams)); - $this->element->setDiscreteValues(20); - $this->assertEquals(20, $this->element->getDiscreteValues()); - $this->assertEquals(20, $this->element->dijitParams['discreteValues']); - } - - public function testMinimumAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getMinimum()); - $this->assertFalse(array_key_exists('minimum', $this->element->dijitParams)); - $this->element->setMinimum(20); - $this->assertEquals(20, $this->element->getMinimum()); - $this->assertEquals(20, $this->element->dijitParams['minimum']); - } - - public function testMaximumAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getMaximum()); - $this->assertFalse(array_key_exists('maximum', $this->element->dijitParams)); - $this->element->setMaximum(20); - $this->assertEquals(20, $this->element->getMaximum()); - $this->assertEquals(20, $this->element->dijitParams['maximum']); - } - - public function testPageIncrementAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getPageIncrement()); - $this->assertFalse(array_key_exists('pageIncrement', $this->element->dijitParams)); - $this->element->setPageIncrement(20); - $this->assertEquals(20, $this->element->getPageIncrement()); - $this->assertEquals(20, $this->element->dijitParams['pageIncrement']); - } - - public function testSettingTopDecorationDijitShouldProxyToTopDecorationDijitParam() - { - $this->element->setTopDecorationDijit('HorizontalRule'); - $this->assertTrue($this->element->hasDijitParam('topDecoration')); - $topDecoration = $this->element->getDijitParam('topDecoration'); - - $test = $this->element->getTopDecoration(); - $this->assertSame($topDecoration, $test); - - $this->assertTrue(array_key_exists('dijit', $topDecoration)); - $this->assertEquals('HorizontalRule', $topDecoration['dijit']); - } - - public function testSettingTopDecorationContainerShouldProxyToTopDecorationDijitParam() - { - $this->element->setTopDecorationContainer('top'); - $this->assertTrue($this->element->hasDijitParam('topDecoration')); - $topDecoration = $this->element->getDijitParam('topDecoration'); - - $test = $this->element->getTopDecoration(); - $this->assertSame($topDecoration, $test); - - $this->assertTrue(array_key_exists('container', $topDecoration)); - $this->assertEquals('top', $topDecoration['container']); - } - - public function testSettingTopDecorationLabelsShouldProxyToTopDecorationDijitParam() - { - $labels = array('0%', '50%', '100%'); - $this->element->setTopDecorationLabels($labels); - $this->assertTrue($this->element->hasDijitParam('topDecoration')); - $topDecoration = $this->element->getDijitParam('topDecoration'); - - $test = $this->element->getTopDecoration(); - $this->assertSame($topDecoration, $test); - - $this->assertTrue(array_key_exists('labels', $topDecoration)); - $this->assertSame($labels, $topDecoration['labels']); - } - - public function testSettingTopDecorationParamsShouldProxyToTopDecorationDijitParam() - { - $params = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setTopDecorationParams($params); - $this->assertTrue($this->element->hasDijitParam('topDecoration')); - $topDecoration = $this->element->getDijitParam('topDecoration'); - - $test = $this->element->getTopDecoration(); - $this->assertSame($topDecoration, $test); - - $this->assertTrue(array_key_exists('params', $topDecoration)); - $this->assertSame($params, $topDecoration['params']); - } - - public function testSettingTopDecorationAttribsShouldProxyToTopDecorationDijitParam() - { - $attribs = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setTopDecorationAttribs($attribs); - $this->assertTrue($this->element->hasDijitParam('topDecoration')); - $topDecoration = $this->element->getDijitParam('topDecoration'); - - $test = $this->element->getTopDecoration(); - $this->assertSame($topDecoration, $test); - - $this->assertTrue(array_key_exists('attribs', $topDecoration)); - $this->assertSame($attribs, $topDecoration['attribs']); - } - - public function testSettingBottomDecorationDijitShouldProxyToBottomDecorationDijitParam() - { - $this->element->setBottomDecorationDijit('HorizontalRule'); - $this->assertTrue($this->element->hasDijitParam('bottomDecoration')); - $bottomDecoration = $this->element->getDijitParam('bottomDecoration'); - - $test = $this->element->getBottomDecoration(); - $this->assertSame($bottomDecoration, $test); - - $this->assertTrue(array_key_exists('dijit', $bottomDecoration)); - $this->assertEquals('HorizontalRule', $bottomDecoration['dijit']); - } - - public function testSettingBottomDecorationContainerShouldProxyToBottomDecorationDijitParam() - { - $this->element->setBottomDecorationContainer('bottom'); - $this->assertTrue($this->element->hasDijitParam('bottomDecoration')); - $bottomDecoration = $this->element->getDijitParam('bottomDecoration'); - - $test = $this->element->getBottomDecoration(); - $this->assertSame($bottomDecoration, $test); - - $this->assertTrue(array_key_exists('container', $bottomDecoration)); - $this->assertEquals('bottom', $bottomDecoration['container']); - } - - public function testSettingBottomDecorationLabelsShouldProxyToBottomDecorationDijitParam() - { - $labels = array('0%', '50%', '100%'); - $this->element->setBottomDecorationLabels($labels); - $this->assertTrue($this->element->hasDijitParam('bottomDecoration')); - $bottomDecoration = $this->element->getDijitParam('bottomDecoration'); - - $test = $this->element->getBottomDecoration(); - $this->assertSame($bottomDecoration, $test); - - $this->assertTrue(array_key_exists('labels', $bottomDecoration)); - $this->assertSame($labels, $bottomDecoration['labels']); - } - - public function testSettingBottomDecorationParamsShouldProxyToBottomDecorationDijitParam() - { - $params = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setBottomDecorationParams($params); - $this->assertTrue($this->element->hasDijitParam('bottomDecoration')); - $bottomDecoration = $this->element->getDijitParam('bottomDecoration'); - - $test = $this->element->getBottomDecoration(); - $this->assertSame($bottomDecoration, $test); - - $this->assertTrue(array_key_exists('params', $bottomDecoration)); - $this->assertSame($params, $bottomDecoration['params']); - } - - public function testSettingBottomDecorationAttribsShouldProxyToBottomDecorationDijitParam() - { - $attribs = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setBottomDecorationAttribs($attribs); - $this->assertTrue($this->element->hasDijitParam('bottomDecoration')); - $bottomDecoration = $this->element->getDijitParam('bottomDecoration'); - - $test = $this->element->getBottomDecoration(); - $this->assertSame($bottomDecoration, $test); - - $this->assertTrue(array_key_exists('attribs', $bottomDecoration)); - $this->assertSame($attribs, $bottomDecoration['attribs']); - } - - public function testShouldRenderHorizontalSliderDijit() - { - $this->element->setMinimum(-10) - ->setMaximum(10) - ->setDiscreteValues(11); - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.HorizontalSlider"', $html); - } -} - -// Call Zend_Dojo_Form_Element_HorizontalSliderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_HorizontalSliderTest::main") { - Zend_Dojo_Form_Element_HorizontalSliderTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/NumberSpinnerTest.php b/tests/Zend/Dojo/Form/Element/NumberSpinnerTest.php deleted file mode 100644 index 9a3b0809588b4f503b54dbdfa49a85cd26533ff2..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/NumberSpinnerTest.php +++ /dev/null @@ -1,193 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NumberSpinnerTest.php 10069 2008-07-12 23:48:03Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_NumberSpinnerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_NumberSpinnerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_NumberSpinner */ -require_once 'Zend/Dojo/Form/Element/NumberSpinner.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_NumberSpinnerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_NumberSpinnerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_NumberSpinner( - 'foo', - array( - 'value' => 'some text', - 'label' => 'NumberSpinner', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testDefaultTimeoutAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getDefaultTimeout()); - $this->assertFalse(array_key_exists('defaultTimeout', $this->element->dijitParams)); - $this->element->setDefaultTimeout(20); - $this->assertEquals(20, $this->element->getDefaultTimeout()); - $this->assertEquals(20, $this->element->dijitParams['defaultTimeout']); - } - - public function testTimeoutChangeRateAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getTimeoutChangeRate()); - $this->assertFalse(array_key_exists('timeoutChangeRate', $this->element->dijitParams)); - $this->element->setTimeoutChangeRate(20); - $this->assertEquals(20, $this->element->getTimeoutChangeRate()); - $this->assertEquals(20, $this->element->dijitParams['timeoutChangeRate']); - } - - public function testLargeDeltaAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getLargeDelta()); - $this->assertFalse(array_key_exists('largeDelta', $this->element->dijitParams)); - $this->element->setLargeDelta(20); - $this->assertEquals(20, $this->element->getLargeDelta()); - $this->assertEquals(20, $this->element->dijitParams['largeDelta']); - } - - public function testSmallDeltaAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getSmallDelta()); - $this->assertFalse(array_key_exists('smallDelta', $this->element->dijitParams)); - $this->element->setSmallDelta(20); - $this->assertEquals(20, $this->element->getSmallDelta()); - $this->assertEquals(20, $this->element->dijitParams['smallDelta']); - } - - public function testIntermediateChangesAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getIntermediateChanges()); - $this->assertFalse(array_key_exists('intermediateChanges', $this->element->dijitParams)); - $this->element->setIntermediateChanges(true); - $this->assertTrue($this->element->getIntermediateChanges()); - $this->assertTrue($this->element->dijitParams['intermediateChanges']); - } - - public function testRangeMessageAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getRangeMessage()); - $this->assertFalse(array_key_exists('rangeMessage', $this->element->dijitParams)); - $this->element->setRangeMessage('foo'); - $this->assertEquals('foo', $this->element->getRangeMessage()); - $this->assertEquals('foo', $this->element->dijitParams['rangeMessage']); - } - - public function testMinAccessorsShouldProxyToConstraintsDijitParam() - { - $this->assertNull($this->element->getMin()); - $this->assertFalse(array_key_exists('constraints', $this->element->dijitParams)); - $this->element->setMin(5); - $this->assertEquals(5, $this->element->getMin()); - $this->assertEquals(5, $this->element->dijitParams['constraints']['min']); - } - - public function testMaxAccessorsShouldProxyToConstraintsDijitParam() - { - $this->assertNull($this->element->getMax()); - $this->assertFalse(array_key_exists('constraints', $this->element->dijitParams)); - $this->element->setMax(5); - $this->assertEquals(5, $this->element->getMax()); - $this->assertEquals(5, $this->element->dijitParams['constraints']['max']); - } - - public function testShouldRenderNumberSpinnerDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.NumberSpinner"', $html); - } -} - -// Call Zend_Dojo_Form_Element_NumberSpinnerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_NumberSpinnerTest::main") { - Zend_Dojo_Form_Element_NumberSpinnerTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/NumberTextBoxTest.php b/tests/Zend/Dojo/Form/Element/NumberTextBoxTest.php deleted file mode 100644 index 0ab88122ad148a3876861e5aebec19baa043263f..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/NumberTextBoxTest.php +++ /dev/null @@ -1,179 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NumberTextBoxTest.php 10079 2008-07-14 10:56:37Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_NumberTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_NumberTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_NumberTextBox */ -require_once 'Zend/Dojo/Form/Element/NumberTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_NumberTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_NumberTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_NumberTextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'NumberTextBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testLocaleAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getLocale()); - $this->assertNull($this->element->getConstraint('locale')); - $this->element->setLocale('en-US'); - $this->assertEquals('en-US', $this->element->getLocale()); - $this->assertTrue($this->element->hasConstraint('locale')); - $this->assertEquals('en-US', $this->element->dijitParams['constraints']['locale']); - } - - public function testPatternAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getPattern()); - $this->assertFalse($this->element->hasConstraint('pattern')); - $this->element->setPattern('###0.#####'); - $this->assertEquals('###0.#####', $this->element->getPattern()); - $this->assertTrue($this->element->hasConstraint('pattern')); - $this->assertEquals('###0.#####', $this->element->dijitParams['constraints']['pattern']); - } - - public function testTypeAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getType()); - $this->assertFalse($this->element->hasConstraint('type')); - $this->element->setType('percent'); - $this->assertEquals('percent', $this->element->getType()); - $this->assertTrue($this->element->hasConstraint('type')); - $this->assertEquals('percent', $this->element->dijitParams['constraints']['type']); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testTypeMutatorShouldThrowExceptionWithInvalidType() - { - $this->element->setType('foobar'); - } - - public function testPlacesAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getPlaces()); - $this->assertFalse($this->element->hasConstraint('places')); - $this->element->setPlaces(3); - $this->assertEquals(3, $this->element->getPlaces()); - $this->assertTrue($this->element->hasConstraint('places')); - $this->assertEquals(3, $this->element->dijitParams['constraints']['places']); - } - - public function testStrictAccessorsShouldProxyToConstraints() - { - $this->assertFalse($this->element->getStrict()); - $this->assertFalse($this->element->hasConstraint('strict')); - $this->element->setStrict(true); - $this->assertTrue($this->element->getStrict()); - $this->assertTrue($this->element->hasConstraint('strict')); - $this->assertEquals('true', $this->element->dijitParams['constraints']['strict']); - } - - public function testShouldRenderNumberTextBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.NumberTextBox"', $html); - } -} - -// Call Zend_Dojo_Form_Element_NumberTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_NumberTextBoxTest::main") { - Zend_Dojo_Form_Element_NumberTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/PasswordTextBoxTest.php b/tests/Zend/Dojo/Form/Element/PasswordTextBoxTest.php deleted file mode 100644 index 9f3c1369861a442e3d1651b81b241a8e133139d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/PasswordTextBoxTest.php +++ /dev/null @@ -1,127 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PasswordTextBoxTest.php 10668 2008-08-05 13:01:56Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_PasswordTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_PasswordTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_PasswordTextBox */ -require_once 'Zend/Dojo/Form/Element/PasswordTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_PasswordTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_PasswordTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_PasswordTextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'PasswordTextBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testShouldRenderValidationTextBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.ValidationTextBox"', $html); - } - - public function testShouldRenderPasswordInput() - { - $html = $this->element->render(); - $this->assertRegexp('/<input[^>]*(type="password")/', $html); - } -} - -// Call Zend_Dojo_Form_Element_PasswordTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_PasswordTextBoxTest::main") { - Zend_Dojo_Form_Element_PasswordTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/RadioButtonTest.php b/tests/Zend/Dojo/Form/Element/RadioButtonTest.php deleted file mode 100644 index a0d62514fda29ef5c59be531c5f67b38ea8aaf0f..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/RadioButtonTest.php +++ /dev/null @@ -1,224 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RadioButtonTest.php 10647 2008-08-04 20:25:30Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_RadioButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_RadioButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_RadioButton */ -require_once 'Zend/Dojo/Form/Element/RadioButton.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_RadioButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_RadioButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_RadioButton( - 'foo', - array( - 'value' => 'bar', - 'label' => 'RadioButton', - 'class' => 'someclass', - 'style' => 'width: 100px;', - 'multiOptions' => array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz', - ), - ) - ); - return $element; - } - - public function testShouldAllowSpecifyingSeparatorText() - { - $this->element->setSeparator('<br />'); - $this->assertEquals('<br />', $this->element->getSeparator()); - } - - public function testAddingAnOptionShouldResetOptionsToArrayIfScalar() - { - $this->element->options = 'foo'; - $this->element->addMultiOption('bar', 'baz'); - $this->assertTrue(is_array($this->element->options)); - } - - public function testAddMultiOptionsShouldPassKeyValueArraysAsIndividualOptions() - { - $this->element->addMultiOptions(array( - array('key' => 'foo', 'value' => 'bar'), - array('key' => 'bar', 'value' => 'baz'), - )); - $this->assertEquals('bar', $this->element->getMultiOption('foo')); - $this->assertEquals('baz', $this->element->getMultiOption('bar')); - } - - public function testShouldAllowRemovingIndividualOptions() - { - $this->element->removeMultiOption('bar'); - $this->assertNull($this->element->getMultiOption('bar')); - } - - public function testOptionsShouldBeTranslatable() - { - $translations = array( - 'Foo' => 'This is Foo', - 'Bar' => 'This is Bar', - 'Baz' => 'This is Baz', - ); - require_once 'Zend/Translate.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $this->element->setTranslator($translate); - $html = $this->element->render(); - foreach ($translations as $string) { - $this->assertContains($string, $html); - } - } - - public function testShouldRenderRadioButtonDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.RadioButton"', $html); - } - - public function testPassingValueShouldMarkThatValueCheckedWhenRendering() - { - $html = $this->element->render(); - if (!preg_match('/(<input[^>]*(id="foo-bar")[^>]*>)/', $html, $matches)) { - $this->fail('Did not find radio option matching bar'); - } - $this->assertContains('checked="checked"', $matches[1]); - } - - /**#+ - * @see ZF-3286 - */ - public function testShouldRegisterInArrayValidatorByDefault() - { - $this->assertTrue($this->element->registerInArrayValidator()); - } - - public function testShouldAllowSpecifyingWhetherOrNotToUseInArrayValidator() - { - $this->testShouldRegisterInArrayValidatorByDefault(); - $this->element->setRegisterInArrayValidator(false); - $this->assertFalse($this->element->registerInArrayValidator()); - $this->element->setRegisterInArrayValidator(true); - $this->assertTrue($this->element->registerInArrayValidator()); - } - - public function testInArrayValidatorShouldBeRegisteredAfterValidation() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->assertFalse($this->element->getValidator('InArray')); - $this->element->isValid('test'); - $validator = $this->element->getValidator('InArray'); - $this->assertTrue($validator instanceof Zend_Validate_InArray); - } - - public function testShouldNotValidateIfValueIsNotInArray() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->assertFalse($this->element->getValidator('InArray')); - $this->assertFalse($this->element->isValid('test')); - } - /**#@-*/ -} - -// Call Zend_Dojo_Form_Element_RadioButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_RadioButtonTest::main") { - Zend_Dojo_Form_Element_RadioButtonTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/SubmitButtonTest.php b/tests/Zend/Dojo/Form/Element/SubmitButtonTest.php deleted file mode 100644 index 9e5201a12ccbee936492480cbab533400e87814c..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/SubmitButtonTest.php +++ /dev/null @@ -1,189 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SubmitButtonTest.php 10668 2008-08-05 13:01:56Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_SubmitButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_SubmitButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_SubmitButton */ -require_once 'Zend/Dojo/Form/Element/SubmitButton.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Translate */ -require_once 'Zend/Translate.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_SubmitButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_SubmitButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_SubmitButton('foo'); - return $element; - } - - public function testGetLabelReturnsNameIfNoValuePresent() - { - $this->assertEquals($this->element->getName(), $this->element->getLabel()); - } - - public function testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered() - { - $translations = include dirname(__FILE__) . '/_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $this->element->setTranslator($translate) - ->setLabel('submit'); - $test = $this->element->getLabel(); - $this->assertEquals($translations['submit'], $test); - } - - public function testTranslatedLabelIsRendered() - { - $this->testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered(); - $this->element->setView($this->getView()); - $decorator = $this->element->getDecorator('DijitElement'); - $decorator->setElement($this->element); - $html = $decorator->render(''); - $this->assertRegexp('/<(input|button)[^>]*?(value="Submit Button")/', $html, 'Label: ' . $this->element->getLabel() . "\nHTML: " . $html); - } - - public function testConstructorSetsLabelToNameIfNoLabelProvided() - { - $button = new Zend_Dojo_Form_Element_SubmitButton('foo'); - $this->assertEquals('foo', $button->getName()); - $this->assertEquals('foo', $button->getLabel()); - } - - public function testCanPassLabelAsParameterToConstructor() - { - $button = new Zend_Dojo_Form_Element_SubmitButton('foo', 'Label'); - $this->assertEquals('Label', $button->getLabel()); - } - - public function testLabelIsTranslatedWhenTranslationAvailable() - { - require_once 'Zend/Translate.php'; - $translations = array('Label' => 'This is the Submit Label'); - $translate = new Zend_Translate('array', $translations); - $button = new Zend_Dojo_Form_Element_SubmitButton('foo', 'Label'); - $button->setTranslator($translate); - $this->assertEquals($translations['Label'], $button->getLabel()); - } - - public function testIsCheckedReturnsFalseWhenNoValuePresent() - { - $this->assertFalse($this->element->isChecked()); - } - - public function testIsCheckedReturnsFalseWhenValuePresentButDoesNotMatchLabel() - { - $this->assertFalse($this->element->isChecked()); - $this->element->setValue('bar'); - $this->assertFalse($this->element->isChecked()); - } - - public function testIsCheckedReturnsTrueWhenValuePresentAndMatchesLabel() - { - $this->testIsCheckedReturnsFalseWhenNoValuePresent(); - $this->element->setValue('foo'); - $this->assertTrue($this->element->isChecked()); - } - - public function testShouldRenderButtonDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.Button"', $html); - } - - public function testShouldRenderSubmitInput() - { - $html = $this->element->render(); - $this->assertContains('type="submit"', $html); - } -} - -// Call Zend_Dojo_Form_Element_SubmitButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_SubmitButtonTest::main") { - Zend_Dojo_Form_Element_SubmitButtonTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/TextBoxTest.php b/tests/Zend/Dojo/Form/Element/TextBoxTest.php deleted file mode 100644 index a84797a73658e3e7d590550a64655b4492938867..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/TextBoxTest.php +++ /dev/null @@ -1,160 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TextBoxTest.php 10038 2008-07-10 21:45:16Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_TextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_TextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_TextBox */ -require_once 'Zend/Dojo/Form/Element/TextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_TextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_TextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_TextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'TextBox', - 'trim' => true, - 'propercase' => true, - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testLowercaseAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getLowercase()); - $this->assertFalse(array_key_exists('lowercase', $this->element->dijitParams)); - $this->element->setLowercase(true); - $this->assertTrue($this->element->getLowercase()); - $this->assertTrue($this->element->dijitParams['lowercase']); - } - - public function testPropercaseAccessorsShouldProxyToDijitParams() - { - $this->assertTrue($this->element->getPropercase()); - $this->assertTrue(array_key_exists('propercase', $this->element->dijitParams)); - $this->element->setPropercase(false); - $this->assertFalse($this->element->getPropercase()); - } - - public function testUppercaseAccessorsShouldProxyToDijitParams() - { - $this->assertFalse($this->element->getUppercase()); - $this->assertFalse(array_key_exists('uppercase', $this->element->dijitParams)); - $this->element->setUppercase(true); - $this->assertTrue($this->element->getUppercase()); - $this->assertTrue($this->element->dijitParams['uppercase']); - } - - public function testTrimAccessorsShouldProxyToDijitParams() - { - $this->assertTrue($this->element->getTrim()); - $this->assertTrue(array_key_exists('trim', $this->element->dijitParams)); - $this->element->setTrim(false); - $this->assertFalse($this->element->getTrim()); - } - - public function testMaxLengthAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getMaxLength()); - $this->assertFalse(array_key_exists('maxLength', $this->element->dijitParams)); - $this->element->setMaxLength(20); - $this->assertEquals(20, $this->element->getMaxLength()); - $this->assertEquals(20, $this->element->dijitParams['maxLength']); - } -} - -// Call Zend_Dojo_Form_Element_TextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_TextBoxTest::main") { - Zend_Dojo_Form_Element_TextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/TextareaTest.php b/tests/Zend/Dojo/Form/Element/TextareaTest.php deleted file mode 100644 index e70907ac6b1d05861ac7d1ac87a0ed0f1eb65ea6..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/TextareaTest.php +++ /dev/null @@ -1,121 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TextareaTest.php 10038 2008-07-10 21:45:16Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_TextareaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_TextareaTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_Textarea */ -require_once 'Zend/Dojo/Form/Element/Textarea.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_TextareaTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_TextareaTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_Textarea( - 'foo', - array( - 'value' => 'some text', - 'label' => 'Textarea', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testShouldRenderTextareaDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.Textarea"', $html); - } -} - -// Call Zend_Dojo_Form_Element_TextareaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_TextareaTest::main") { - Zend_Dojo_Form_Element_TextareaTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/TimeTextBoxTest.php b/tests/Zend/Dojo/Form/Element/TimeTextBoxTest.php deleted file mode 100644 index 06ed7700799b4f93154fde61afab01a154fe077c..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/TimeTextBoxTest.php +++ /dev/null @@ -1,190 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TimeTextBoxTest.php 10079 2008-07-14 10:56:37Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_TimeTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_TimeTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_TimeTextBox */ -require_once 'Zend/Dojo/Form/Element/TimeTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_TimeTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_TimeTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_TimeTextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'TimeTextBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testShouldExtendDateTextBox() - { - $this->assertTrue($this->element instanceof Zend_Dojo_Form_Element_DateTextBox); - } - - public function testTimePatternAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getTimePattern()); - $this->assertFalse($this->element->hasConstraint('timePattern')); - $this->element->setTimePattern('h:mm a'); - $this->assertEquals('h:mm a', $this->element->getTimePattern()); - $this->assertTrue($this->element->hasConstraint('timePattern')); - $this->assertEquals('h:mm a', $this->element->dijitParams['constraints']['timePattern']); - } - - public function testClickableIncrementAccessorsShouldProxyToConstraints() - { - $this->assertNull($this->element->getClickableIncrement()); - $this->assertFalse($this->element->hasConstraint('clickableIncrement')); - $this->element->setClickableIncrement('T00:15:00'); - $this->assertEquals('T00:15:00', $this->element->getClickableIncrement()); - $this->assertTrue($this->element->hasConstraint('clickableIncrement')); - $this->assertEquals('T00:15:00', $this->element->dijitParams['constraints']['clickableIncrement']); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testClickableIncrementMutatorShouldRaiseExceptionOnInvalidFormat() - { - $this->element->setClickableIncrement('en-US'); - } - - public function testVisibleIncrementAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getVisibleIncrement()); - $this->assertFalse($this->element->hasConstraint('visibleIncrement')); - $this->element->setVisibleIncrement('T00:15:00'); - $this->assertEquals('T00:15:00', $this->element->getVisibleIncrement()); - $this->assertTrue($this->element->hasConstraint('visibleIncrement')); - $this->assertEquals('T00:15:00', $this->element->dijitParams['constraints']['visibleIncrement']); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testVisibleIncrementMutatorShouldRaiseExceptionOnInvalidFormat() - { - $this->element->setVisibleIncrement('en-US'); - } - - public function testVisibleRangeAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getVisibleRange()); - $this->assertFalse($this->element->hasConstraint('visibleRange')); - $this->element->setVisibleRange('T00:15:00'); - $this->assertEquals('T00:15:00', $this->element->getVisibleRange()); - $this->assertTrue($this->element->hasConstraint('visibleRange')); - $this->assertEquals('T00:15:00', $this->element->dijitParams['constraints']['visibleRange']); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testVisibleRangeMutatorShouldRaiseExceptionOnInvalidFormat() - { - $this->element->setVisibleRange('en-US'); - } - - public function testShouldRenderTimeTextBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.TimeTextBox"', $html); - } -} - -// Call Zend_Dojo_Form_Element_TimeTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_TimeTextBoxTest::main") { - Zend_Dojo_Form_Element_TimeTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/ValidationTextBoxTest.php b/tests/Zend/Dojo/Form/Element/ValidationTextBoxTest.php deleted file mode 100644 index d8c11913af37f0f0ab3ab02d910f1a4e618a8010..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/ValidationTextBoxTest.php +++ /dev/null @@ -1,185 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ValidationTextBoxTest.php 10079 2008-07-14 10:56:37Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_ValidationTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_ValidationTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_ValidationTextBox */ -require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_ValidationTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_ValidationTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_ValidationTextBox( - 'foo', - array( - 'value' => 'some text', - 'label' => 'ValidationTextBox', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testInvalidMessageAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getInvalidMessage()); - $this->assertFalse(array_key_exists('invalidMessage', $this->element->dijitParams)); - $this->element->setInvalidMessage('message'); - $this->assertEquals('message', $this->element->getInvalidMessage()); - $this->assertEquals('message', $this->element->dijitParams['invalidMessage']); - } - - public function testPromptMessageAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getPromptMessage()); - $this->assertFalse(array_key_exists('promptMessage', $this->element->dijitParams)); - $this->element->setPromptMessage('message'); - $this->assertEquals('message', $this->element->getPromptMessage()); - $this->assertEquals('message', $this->element->dijitParams['promptMessage']); - } - - public function testRegExpAccessorsShouldProxyToDijitParams() - { - $this->assertNull($this->element->getRegExp()); - $this->assertFalse(array_key_exists('regExp', $this->element->dijitParams)); - $this->element->setRegExp('[\w]+'); - $this->assertEquals('[\w]+', $this->element->getRegExp()); - $this->assertEquals('[\w]+', $this->element->dijitParams['regExp']); - } - - public function testConstraintsAccessorsShouldProxyToDijitParams() - { - $constraints = $this->element->getConstraints(); - $this->assertTrue(empty($constraints)); - $this->assertFalse(array_key_exists('constraints', $this->element->dijitParams)); - - $constraints = array('foo' => 'bar', 'bar' => 'baz'); - $this->element->setConstraints($constraints); - $this->assertSame($constraints, $this->element->getConstraints()); - $this->assertSame($constraints, $this->element->dijitParams['constraints']); - } - - public function testShouldAllowSettingRetrievingAndRemovingInvididualConstraints() - { - $constraints = $this->element->getConstraints(); - $this->assertTrue(empty($constraints)); - $this->assertFalse($this->element->hasDijitParam('constraints')); - - $this->element->setConstraint('foo', 'bar'); - $this->assertTrue($this->element->hasConstraint('foo')); - $this->assertEquals('bar', $this->element->getConstraint('foo')); - $this->assertTrue($this->element->hasDijitParam('constraints')); - $this->assertEquals('bar', $this->element->dijitParams['constraints']['foo']); - - $this->element->removeConstraint('foo'); - $this->assertFalse($this->element->hasConstraint('foo')); - $this->assertTrue($this->element->hasDijitParam('constraints')); - $this->assertTrue(empty($this->element->dijitParams['constraints'])); - } - - public function testShouldAllowClearingConstraints() - { - $this->testConstraintsAccessorsShouldProxyToDijitParams(); - $this->element->clearConstraints(); - $this->assertFalse($this->element->hasDijitParam('constraints')); - } - - public function testShouldRenderValidationTextBoxDijit() - { - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.ValidationTextBox"', $html); - } -} - -// Call Zend_Dojo_Form_Element_ValidationTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_ValidationTextBoxTest::main") { - Zend_Dojo_Form_Element_ValidationTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/VerticalSliderTest.php b/tests/Zend/Dojo/Form/Element/VerticalSliderTest.php deleted file mode 100644 index 499ad4235ae79f5fff8e82512e076f00256189a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/VerticalSliderTest.php +++ /dev/null @@ -1,288 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: VerticalSliderTest.php 10038 2008-07-10 21:45:16Z matthew $ - */ - -// Call Zend_Dojo_Form_Element_VerticalSliderTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_VerticalSliderTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_Form_Element_VerticalSlider */ -require_once 'Zend/Dojo/Form/Element/VerticalSlider.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_Form_Element_Dijit. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_Form_Element_VerticalSliderTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_VerticalSliderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->element = $this->getElement(); - $this->element->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Dojo_Form_Element_VerticalSlider( - 'foo', - array( - 'value' => 'some text', - 'label' => 'VerticalSlider', - 'class' => 'someclass', - 'style' => 'width: 100px;', - ) - ); - return $element; - } - - public function testSettingLeftDecorationDijitShouldProxyToLeftDecorationDijitParam() - { - $this->element->setLeftDecorationDijit('VerticalRule'); - $this->assertTrue($this->element->hasDijitParam('leftDecoration')); - $leftDecoration = $this->element->getDijitParam('leftDecoration'); - - $test = $this->element->getLeftDecoration(); - $this->assertSame($leftDecoration, $test); - - $this->assertTrue(array_key_exists('dijit', $leftDecoration)); - $this->assertEquals('VerticalRule', $leftDecoration['dijit']); - } - - public function testSettingLeftDecorationContainerShouldProxyToLeftDecorationDijitParam() - { - $this->element->setLeftDecorationContainer('left'); - $this->assertTrue($this->element->hasDijitParam('leftDecoration')); - $leftDecoration = $this->element->getDijitParam('leftDecoration'); - - $test = $this->element->getLeftDecoration(); - $this->assertSame($leftDecoration, $test); - - $this->assertTrue(array_key_exists('container', $leftDecoration)); - $this->assertEquals('left', $leftDecoration['container']); - } - - public function testSettingLeftDecorationLabelsShouldProxyToLeftDecorationDijitParam() - { - $labels = array('0%', '50%', '100%'); - $this->element->setLeftDecorationLabels($labels); - $this->assertTrue($this->element->hasDijitParam('leftDecoration')); - $leftDecoration = $this->element->getDijitParam('leftDecoration'); - - $test = $this->element->getLeftDecoration(); - $this->assertSame($leftDecoration, $test); - - $this->assertTrue(array_key_exists('labels', $leftDecoration)); - $this->assertSame($labels, $leftDecoration['labels']); - } - - public function testSettingLeftDecorationParamsShouldProxyToLeftDecorationDijitParam() - { - $params = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setLeftDecorationParams($params); - $this->assertTrue($this->element->hasDijitParam('leftDecoration')); - $leftDecoration = $this->element->getDijitParam('leftDecoration'); - - $test = $this->element->getLeftDecoration(); - $this->assertSame($leftDecoration, $test); - - $this->assertTrue(array_key_exists('params', $leftDecoration)); - $this->assertSame($params, $leftDecoration['params']); - } - - public function testSettingLeftDecorationAttribsShouldProxyToLeftDecorationDijitParam() - { - $attribs = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setLeftDecorationAttribs($attribs); - $this->assertTrue($this->element->hasDijitParam('leftDecoration')); - $leftDecoration = $this->element->getDijitParam('leftDecoration'); - - $test = $this->element->getLeftDecoration(); - $this->assertSame($leftDecoration, $test); - - $this->assertTrue(array_key_exists('attribs', $leftDecoration)); - $this->assertSame($attribs, $leftDecoration['attribs']); - } - - public function testSettingRightDecorationDijitShouldProxyToRightDecorationDijitParam() - { - $this->element->setRightDecorationDijit('VerticalRule'); - $this->assertTrue($this->element->hasDijitParam('rightDecoration')); - $rightDecoration = $this->element->getDijitParam('rightDecoration'); - - $test = $this->element->getRightDecoration(); - $this->assertSame($rightDecoration, $test); - - $this->assertTrue(array_key_exists('dijit', $rightDecoration)); - $this->assertEquals('VerticalRule', $rightDecoration['dijit']); - } - - public function testSettingRightDecorationContainerShouldProxyToRightDecorationDijitParam() - { - $this->element->setRightDecorationContainer('right'); - $this->assertTrue($this->element->hasDijitParam('rightDecoration')); - $rightDecoration = $this->element->getDijitParam('rightDecoration'); - - $test = $this->element->getRightDecoration(); - $this->assertSame($rightDecoration, $test); - - $this->assertTrue(array_key_exists('container', $rightDecoration)); - $this->assertEquals('right', $rightDecoration['container']); - } - - public function testSettingRightDecorationLabelsShouldProxyToRightDecorationDijitParam() - { - $labels = array('0%', '50%', '100%'); - $this->element->setRightDecorationLabels($labels); - $this->assertTrue($this->element->hasDijitParam('rightDecoration')); - $rightDecoration = $this->element->getDijitParam('rightDecoration'); - - $test = $this->element->getRightDecoration(); - $this->assertSame($rightDecoration, $test); - - $this->assertTrue(array_key_exists('labels', $rightDecoration)); - $this->assertSame($labels, $rightDecoration['labels']); - } - - public function testSettingRightDecorationParamsShouldProxyToRightDecorationDijitParam() - { - $params = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setRightDecorationParams($params); - $this->assertTrue($this->element->hasDijitParam('rightDecoration')); - $rightDecoration = $this->element->getDijitParam('rightDecoration'); - - $test = $this->element->getRightDecoration(); - $this->assertSame($rightDecoration, $test); - - $this->assertTrue(array_key_exists('params', $rightDecoration)); - $this->assertSame($params, $rightDecoration['params']); - } - - public function testSettingRightDecorationAttribsShouldProxyToRightDecorationDijitParam() - { - $attribs = array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'list' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ); - $this->element->setRightDecorationAttribs($attribs); - $this->assertTrue($this->element->hasDijitParam('rightDecoration')); - $rightDecoration = $this->element->getDijitParam('rightDecoration'); - - $test = $this->element->getRightDecoration(); - $this->assertSame($rightDecoration, $test); - - $this->assertTrue(array_key_exists('attribs', $rightDecoration)); - $this->assertSame($attribs, $rightDecoration['attribs']); - } - - public function testShouldRenderVerticalSliderDijit() - { - $this->element->setMinimum(-10) - ->setMaximum(10) - ->setDiscreteValues(11); - $html = $this->element->render(); - $this->assertContains('dojoType="dijit.form.VerticalSlider"', $html); - } -} - -// Call Zend_Dojo_Form_Element_VerticalSliderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_VerticalSliderTest::main") { - Zend_Dojo_Form_Element_VerticalSliderTest::main(); -} diff --git a/tests/Zend/Dojo/Form/Element/_files/locale/array.php b/tests/Zend/Dojo/Form/Element/_files/locale/array.php deleted file mode 100644 index b277ef382c4bcc628eceac9f41727f64466277eb..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/Element/_files/locale/array.php +++ /dev/null @@ -1,33 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: array.php 10091 2008-07-15 03:46:37Z matthew $ - */ - -return array( - 'notDigits' => 'Translating the notDigits string', - 'stringEmpty' => 'Translating the stringEmpty string', - 'isEmpty' => 'Translating the isEmpty string', - - 'submit' => 'Submit Button', - 'foovalue' => 'Foo Value', - 'barvalue' => 'Bar Value', - 'Foo' => 'Foo Translation', - 'Bar' => 'Bar Translation', -); diff --git a/tests/Zend/Dojo/Form/FormTest.php b/tests/Zend/Dojo/Form/FormTest.php deleted file mode 100644 index 8482dd581424bbe28646272e3f4d81ee49066565..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/FormTest.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -// Call Zend_Dojo_Form_FormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_FormTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Dojo_Form */ -require_once 'Zend/Dojo/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Dojo_Form and Zend_Dojo_Form_DisplayGroup - */ -class Zend_Dojo_Form_FormTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_FormTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->form = new Zend_Dojo_Form(); - $this->form->addElement('TextBox', 'foo') - ->addDisplayGroup(array('foo'), 'dg') - ->setView(new Zend_View()); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testDojoFormDecoratorPathShouldBeRegisteredByDefault() - { - $paths = $this->form->getPluginLoader('decorator')->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testDojoFormElementPathShouldBeRegisteredByDefault() - { - $paths = $this->form->getPluginLoader('element')->getPaths('Zend_Dojo_Form_Element'); - $this->assertTrue(is_array($paths)); - } - - public function testDojoFormElementDecoratorPathShouldBeRegisteredByDefault() - { - $paths = $this->form->foo->getPluginLoader('decorator')->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testDojoFormDisplayGroupDecoratorPathShouldBeRegisteredByDefault() - { - $paths = $this->form->dg->getPluginLoader()->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testDefaultDisplayGroupClassShouldBeDojoDisplayGroupByDefault() - { - $this->assertEquals('Zend_Dojo_Form_DisplayGroup', $this->form->getDefaultDisplayGroupClass()); - } - - public function testDefaultDecoratorsShouldIncludeDijitForm() - { - $this->assertNotNull($this->form->getDecorator('DijitForm')); - } - - public function testShouldRegisterDojoViewHelperPath() - { - $view = $this->form->getView(); - $loader = $view->getPluginLoader('helper'); - $paths = $loader->getPaths('Zend_Dojo_View_Helper'); - $this->assertTrue(is_array($paths)); - } - - public function testDisplayGroupShouldRegisterDojoViewHelperPath() - { - $this->form->dg->setView(new Zend_View()); - $view = $this->form->dg->getView(); - $loader = $view->getPluginLoader('helper'); - $paths = $loader->getPaths('Zend_Dojo_View_Helper'); - $this->assertTrue(is_array($paths)); - } -} - -// Call Zend_Dojo_Form_FormTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_FormTest::main") { - Zend_Dojo_Form_FormTest::main(); -} diff --git a/tests/Zend/Dojo/Form/SubFormTest.php b/tests/Zend/Dojo/Form/SubFormTest.php deleted file mode 100644 index e9f9f27856139b78971f37878fed274589ad3739..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/Form/SubFormTest.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -// Call Zend_Dojo_Form_SubFormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_SubFormTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Dojo_Form_SubForm */ -require_once 'Zend/Dojo/Form/SubForm.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Dojo_SubForm - */ -class Zend_Dojo_Form_SubFormTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_SubFormTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->form = new Zend_Dojo_Form_SubForm(); - $this->form->addElement('TextBox', 'foo') - ->addDisplayGroup(array('foo'), 'dg') - ->setView(new Zend_View()); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testDojoFormDecoratorPathShouldBeRegisteredByDefault() - { - $paths = $this->form->getPluginLoader('decorator')->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testDojoFormElementPathShouldBeRegisteredByDefault() - { - $paths = $this->form->getPluginLoader('element')->getPaths('Zend_Dojo_Form_Element'); - $this->assertTrue(is_array($paths)); - } - - public function testDojoFormElementDecoratorPathShouldBeRegisteredByDefault() - { - $paths = $this->form->foo->getPluginLoader('decorator')->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testDojoFormDisplayGroupDecoratorPathShouldBeRegisteredByDefault() - { - $paths = $this->form->dg->getPluginLoader()->getPaths('Zend_Dojo_Form_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testDefaultDisplayGroupClassShouldBeDojoDisplayGroupByDefault() - { - $this->assertEquals('Zend_Dojo_Form_DisplayGroup', $this->form->getDefaultDisplayGroupClass()); - } - - public function testDefaultDecoratorsShouldIncludeContentPane() - { - $this->assertNotNull($this->form->getDecorator('ContentPane')); - } - - public function testShouldRegisterDojoViewHelperPath() - { - $view = $this->form->getView(); - $loader = $view->getPluginLoader('helper'); - $paths = $loader->getPaths('Zend_Dojo_View_Helper'); - $this->assertTrue(is_array($paths)); - } -} - -// Call Zend_Dojo_Form_SubFormTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_SubFormTest::main") { - Zend_Dojo_Form_SubFormTest::main(); -} diff --git a/tests/Zend/Dojo/View/AllTests.php b/tests/Zend/Dojo/View/AllTests.php deleted file mode 100644 index 7118eee6ef2fab21622db9fbd06a567348974616..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/AllTests.php +++ /dev/null @@ -1,60 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 9799 2008-06-27 01:54:36Z dasprid $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_View_AllTests::main'); -} - -require_once 'Zend/Dojo/View/Helper/AllTests.php'; - -/** - * @category Zend - * @package Zend_Dojo_View - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dojo_View'); - - $suite->addTest(Zend_Dojo_View_Helper_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_View_AllTests::main') { - Zend_Dojo_View_AllTests::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/AccordionContainerTest.php b/tests/Zend/Dojo/View/Helper/AccordionContainerTest.php deleted file mode 100644 index 9a6f2e005186eaa1f2ab5765b0bd8380482ea133..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/AccordionContainerTest.php +++ /dev/null @@ -1,171 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AccordionContainerTest.php 10067 2008-07-12 21:05:32Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_AccordionContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_AccordionContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_AccordionContainer */ -require_once 'Zend/Dojo/View/Helper/AccordionContainer.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_AccordionContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_AccordionContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_AccordionContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_AccordionContainer(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - $html = ''; - for ($i = 1; $i < 6; ++$i) { - $id = 'pane' . $i; - $title = 'Pane ' . $i; - $content = 'This is the content of pane ' . $i; - $html .= $this->view->accordionPane($id, $content, array('title' => $title)); - } - return $this->helper->accordionContainer('container', $html, array(), array('style' => 'height: 200px; width: 100px;')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.AccordionContainer")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.AccordionContainer")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('container')); - } - - public function testShouldAllowCapturingNestedContent() - { - $this->helper->captureStart('foo', array(), array('style' => 'height: 200px; width: 100px;')); - $this->view->accordionPane()->captureStart('bar', array('title' => 'Captured Pane')); - echo "Captured content started\n"; - $this->view->accordionPane()->captureStart('baz', array('title' => 'Nested Pane')); - echo 'Nested Content'; - echo $this->view->accordionPane()->captureEnd('baz'); - echo "Captured content ended\n"; - echo $this->view->accordionPane()->captureEnd('bar'); - $html = $this->helper->captureEnd('foo'); - $this->assertRegexp('/<div[^>]*(id="bar")/', $html); - $this->assertRegexp('/<div[^>]*(id="baz")/', $html); - $this->assertRegexp('/<div[^>]*(id="foo")/', $html); - $this->assertEquals(2, substr_count($html, 'dijit.layout.AccordionPane')); - $this->assertEquals(1, substr_count($html, 'dijit.layout.AccordionContainer')); - $this->assertContains('started', $html); - $this->assertContains('ended', $html); - $this->assertContains('Nested Content', $html); - } - - /** - * @expectedException Zend_Dojo_View_Exception - */ - public function testCapturingShouldRaiseErrorWhenDuplicateIdDiscovered() - { - $this->helper->captureStart('foo', array(), array('style' => 'height: 200px; width: 100px;')); - $this->view->accordionPane()->captureStart('bar', array('title' => 'Captured Pane')); - $this->view->accordionPane()->captureStart('bar', array('title' => 'Captured Pane')); - echo 'Captured Content'; - echo $this->view->accordionPane()->captureEnd('bar'); - echo $this->view->accordionPane()->captureEnd('bar'); - $html = $this->helper->captureEnd('foo'); - } - - /** - * @expectedException Zend_Dojo_View_Exception - */ - public function testCapturingShouldRaiseErrorWhenNonexistentIdPassedToEnd() - { - $this->helper->captureStart('foo', array(), array('style' => 'height: 200px; width: 100px;')); - $html = $this->helper->captureEnd('bar'); - } -} - -// Call Zend_Dojo_View_Helper_AccordionContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_AccordionContainerTest::main") { - Zend_Dojo_View_Helper_AccordionContainerTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/AccordionPaneTest.php b/tests/Zend/Dojo/View/Helper/AccordionPaneTest.php deleted file mode 100644 index ba63bf7f39eb927d3a7018d69f2efa88a8f8dc9e..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/AccordionPaneTest.php +++ /dev/null @@ -1,120 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AccordionPaneTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_AccordionPaneTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_AccordionPaneTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_AccordionPane */ -require_once 'Zend/Dojo/View/Helper/AccordionPane.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_AccordionPane. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_AccordionPaneTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_AccordionPaneTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_AccordionPane(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - return $this->view->accordionPane('pane1', 'This is the pane content', array('title' => 'Pane 1')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.AccordionPane")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.AccordionPane")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('pane1')); - } -} - -// Call Zend_Dojo_View_Helper_AccordionPaneTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_AccordionPaneTest::main") { - Zend_Dojo_View_Helper_AccordionPaneTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/AllTests.php b/tests/Zend/Dojo/View/Helper/AllTests.php deleted file mode 100644 index 2785af5d2f4378dd54195597378ea39c99543234..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/AllTests.php +++ /dev/null @@ -1,110 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 11343 2008-09-10 20:03:02Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_View_Helper_AllTests::main'); -} - -require_once 'Zend/Dojo/View/Helper/DojoTest.php'; -require_once 'Zend/Dojo/View/Helper/AccordionContainerTest.php'; -require_once 'Zend/Dojo/View/Helper/AccordionPaneTest.php'; -require_once 'Zend/Dojo/View/Helper/BorderContainerTest.php'; -require_once 'Zend/Dojo/View/Helper/ButtonTest.php'; -require_once 'Zend/Dojo/View/Helper/CheckBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/ComboBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/ContentPaneTest.php'; -require_once 'Zend/Dojo/View/Helper/CurrencyTextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/DateTextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/FilteringSelectTest.php'; -require_once 'Zend/Dojo/View/Helper/FormTest.php'; -require_once 'Zend/Dojo/View/Helper/HorizontalSliderTest.php'; -require_once 'Zend/Dojo/View/Helper/NumberSpinnerTest.php'; -require_once 'Zend/Dojo/View/Helper/NumberTextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/PasswordTextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/RadioButtonTest.php'; -require_once 'Zend/Dojo/View/Helper/SubmitButtonTest.php'; -require_once 'Zend/Dojo/View/Helper/SplitContainerTest.php'; -require_once 'Zend/Dojo/View/Helper/StackContainerTest.php'; -require_once 'Zend/Dojo/View/Helper/TabContainerTest.php'; -require_once 'Zend/Dojo/View/Helper/TextareaTest.php'; -require_once 'Zend/Dojo/View/Helper/TextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/TimeTextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/ValidationTextBoxTest.php'; -require_once 'Zend/Dojo/View/Helper/VerticalSliderTest.php'; - -/** - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dojo - View_Helper'); - - $suite->addTestSuite('Zend_Dojo_View_Helper_DojoTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_AccordionContainerTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_AccordionPaneTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_BorderContainerTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_ButtonTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_CheckBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_ComboBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_ContentPaneTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_CurrencyTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_DateTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_FilteringSelectTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_FormTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_HorizontalSliderTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_NumberSpinnerTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_NumberTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_PasswordTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_RadioButtonTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_SubmitButtonTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_SplitContainerTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_StackContainerTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_TabContainerTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_TextareaTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_TextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_TimeTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_ValidationTextBoxTest'); - $suite->addTestSuite('Zend_Dojo_View_Helper_VerticalSliderTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dojo_View_Helper_AllTests::main') { - Zend_Dojo_View_Helper_AllTests::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/BorderContainerTest.php b/tests/Zend/Dojo/View/Helper/BorderContainerTest.php deleted file mode 100644 index f20c50a7263a7d8b3af16b75e556336bdf7f0fe2..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/BorderContainerTest.php +++ /dev/null @@ -1,126 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BorderContainerTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_BorderContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_BorderContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_BorderContainer */ -require_once 'Zend/Dojo/View/Helper/BorderContainer.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_BorderContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_BorderContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_BorderContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_BorderContainer(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - $html = ''; - foreach (array('top', 'bottom', 'center', 'left', 'right') as $pane) { - $id = $pane . 'Pane'; - $content = 'This is the content of pane ' . $pane; - $html .= $this->view->contentPane($id, $content, array('region' => $pane)); - } - return $this->helper->borderContainer('container', $html, array('design' => 'headline')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.BorderContainer")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.BorderContainer")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('container')); - } -} - -// Call Zend_Dojo_View_Helper_BorderContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_BorderContainerTest::main") { - Zend_Dojo_View_Helper_BorderContainerTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/ButtonTest.php b/tests/Zend/Dojo/View/Helper/ButtonTest.php deleted file mode 100644 index 2bbd64fd785f507a253808f0116adc1103984b61..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/ButtonTest.php +++ /dev/null @@ -1,129 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ButtonTest.php 10091 2008-07-15 03:46:37Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_ButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_ButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_Button */ -require_once 'Zend/Dojo/View/Helper/Button.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_Button. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_ButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_ButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_Button(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->button( - 'elementId', - 'foo', - array(), - array(), - array( - 'checked' => 'foo', - 'unChecked' => 'bar', - ) - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<button[^>]*(dojoType="dijit.form.Button")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<button[^>]*(dojoType="dijit.form.Button")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } -} - -// Call Zend_Dojo_View_Helper_ButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_ButtonTest::main") { - Zend_Dojo_View_Helper_ButtonTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/CheckBoxTest.php b/tests/Zend/Dojo/View/Helper/CheckBoxTest.php deleted file mode 100644 index 2e5454260d52129a4aa5467e5740e4bb69384cae..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/CheckBoxTest.php +++ /dev/null @@ -1,173 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CheckBoxTest.php 11290 2008-09-08 18:39:34Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_CheckBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_CheckBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_CheckBox */ -require_once 'Zend/Dojo/View/Helper/CheckBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_CheckBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_CheckBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_CheckBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_CheckBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->checkBox( - 'elementId', - 'foo', - array(), - array(), - array( - 'checked' => 'foo', - 'unChecked' => 'bar', - ) - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.CheckBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.CheckBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateHiddenElementWithUncheckedValue() - { - $html = $this->getElement(); - if (!preg_match('/(<input[^>]*(type="hidden")[^>]*>)/s', $html, $m)) { - $this->fail('Missing hidden element with unchecked value'); - } - $this->assertContains('value="bar"', $m[1]); - } - - public function testShouldCheckElementWhenValueMatchesCheckedValue() - { - $html = $this->getElement(); - if (!preg_match('/(<input[^>]*(type="checkbox")[^>]*>)/s', $html, $m)) { - $this->fail('Missing checkbox element: ' . $html); - } - $this->assertContains('checked="checked"', $m[1]); - } - - /** - * @see ZF-4006 - * @group ZF-4006 - */ - public function testElementShouldUseCheckedValueForCheckboxInput() - { - $html = $this->helper->checkBox('foo', '0', array(), array(), array( - 'checkedValue' => '1', - 'unCheckedValue' => '0', - )); - if (!preg_match('#(<input[^>]*(?:type="checkbox")[^>]*>)#s', $html, $matches)) { - $this->fail('Did not find checkbox in html: ' . $html); - } - $this->assertContains('value="1"', $matches[1]); - $this->assertNotContains('checked', $matches[1]); - } - - /** - * @group ZF-3878 - */ - public function testElementShouldCreateAppropriateIdWhenNameIncludesArrayNotation() - { - $html = $this->helper->checkBox('foo[bar]', '0'); - $this->assertContains('id="foo-bar"', $html); - } -} - -// Call Zend_Dojo_View_Helper_CheckBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_CheckBoxTest::main") { - Zend_Dojo_View_Helper_CheckBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/ComboBoxTest.php b/tests/Zend/Dojo/View/Helper/ComboBoxTest.php deleted file mode 100644 index ab401c5c26f088a529be93a5f739fee8bbca3565..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/ComboBoxTest.php +++ /dev/null @@ -1,212 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ComboBoxTest.php 11015 2008-08-24 21:17:21Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_ComboBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_ComboBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_ComboBox */ -require_once 'Zend/Dojo/View/Helper/ComboBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_ComboBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_ComboBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_ComboBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_ComboBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElementAsSelect() - { - return $this->helper->comboBox( - 'elementId', - 'someCombo', - array(), - array(), - array( - 'red' => 'Rouge', - 'blue' => 'Bleu', - 'white' => 'Blanc', - 'orange' => 'Orange', - 'black' => 'Noir', - 'green' => 'Vert', - ) - ); - } - - public function getElementAsRemoter() - { - return $this->helper->comboBox( - 'elementId', - 'someCombo', - array( - 'store' => array( - 'store' => 'stateStore', - 'type' => 'dojo.data.ItemFileReadStore', - 'params' => array( - 'url' => 'states.txt' - ) - ), - 'searchAttr' => 'name' - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreationAsSelect() - { - $html = $this->getElementAsSelect(); - $this->assertRegexp('/<select[^>]*(dojoType="dijit.form.ComboBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreationAsSelect() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElementAsSelect(); - $this->assertNotRegexp('/<select[^>]*(dojoType="dijit.form.ComboBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldAllowDeclarativeDijitCreationAsRemoter() - { - $html = $this->getElementAsRemoter(); - if (!preg_match('/(<input[^>]*(dojoType="dijit.form.ComboBox"))/', $html, $m)) { - $this->fail('Did not create text input as remoter: ' . $html); - } - $this->assertContains('type="text"', $m[1]); - } - - public function testShouldAllowProgrammaticDijitCreationAsRemoter() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElementAsRemoter(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.ComboBox")/', $html); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - - $found = false; - $scripts = $this->view->dojo()->getJavascript(); - foreach ($scripts as $js) { - if (strstr($js, 'var stateStore;')) { - $found = true; - break; - } - } - $this->assertTrue($found, 'No store declaration found: ' . var_export($scripts, 1)); - - $found = false; - $actions = $this->view->dojo()->getOnloadActions(); - foreach ($actions as $action) { - if (strstr($action, 'stateStore = ')) { - $found = true; - break; - } - } - $this->assertTrue($found, 'No store onLoad action found: ' . var_export($actions, 1)); - } - - public function testShouldAllowAlternateNotationToSpecifyRemoter() - { - $html = $this->helper->comboBox( - 'elementId', - 'someCombo', - array( - 'store' => 'stateStore', - 'storeType' => 'dojo.data.ItemFileReadStore', - 'storeParams' => array('url' => 'states.txt'), - 'searchAttr' => 'name', - ) - ); - if (!preg_match('/(<input[^>]*(dojoType="dijit.form.ComboBox"))/', $html, $m)) { - $this->fail('Did not create text input as remoter: ' . $html); - } - $this->assertContains('type="text"', $m[1]); - if (!preg_match('/(<div[^>]*(?:dojoType="dojo.data.ItemFileReadStore")[^>]*>)/', $html, $m)) { - $this->fail('Did not create data store: ' . $html); - } - $this->assertContains('url="states.txt"', $m[1]); - } -} - -// Call Zend_Dojo_View_Helper_ComboBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_ComboBoxTest::main") { - Zend_Dojo_View_Helper_ComboBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/ContentPaneTest.php b/tests/Zend/Dojo/View/Helper/ContentPaneTest.php deleted file mode 100644 index 7fd70950c7f724476a28136ac6b46d40f83b77b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/ContentPaneTest.php +++ /dev/null @@ -1,143 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ContentPaneTest.php 11745 2008-10-08 18:25:37Z zendbot $ - */ - -// Call Zend_Dojo_View_Helper_ContentPaneTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_ContentPaneTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_ContentPane */ -require_once 'Zend/Dojo/View/Helper/ContentPane.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_ContentPane. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_ContentPaneTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_ContentPaneTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_ContentPane(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - return $this->view->contentPane('pane1', 'This is the pane content', array('title' => 'Pane 1')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.ContentPane")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.ContentPane")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('pane1')); - } - - /** - * @group ZF-3877 - */ - public function testContentPaneMarkupShouldNotContainNameAttribute() - { - $html = $this->view->contentPane('pane1', 'This is the pane content', array('id' => 'pane', 'title' => 'Pane 1')); - $this->assertNotContains('name="/', $html, $html); - - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->view->contentPane('pane1', 'This is the pane content', array('id' => 'pane', 'title' => 'Pane 1')); - $this->assertNotContains('name="/', $html, $html); - } - - /** - * @group ZF-4522 - */ - public function testCaptureStartShouldReturnVoid() - { - $test = $this->view->contentPane()->captureStart('pane1'); - $this->view->contentPane()->captureEnd('pane1'); - $this->assertNull($test); - } -} - -// Call Zend_Dojo_View_Helper_ContentPaneTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_ContentPaneTest::main") { - Zend_Dojo_View_Helper_ContentPaneTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/CurrencyTextBoxTest.php b/tests/Zend/Dojo/View/Helper/CurrencyTextBoxTest.php deleted file mode 100644 index 936dfedbab0bf37137cd93e9478158db84dd7f9c..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/CurrencyTextBoxTest.php +++ /dev/null @@ -1,135 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CurrencyTextBoxTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_CurrencyTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_CurrencyTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_CurrencyTextBox */ -require_once 'Zend/Dojo/View/Helper/CurrencyTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_CurrencyTextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_CurrencyTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_CurrencyTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_CurrencyTextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->currencyTextBox( - 'elementId', - '3', - array( - 'required' => true, - 'constraints' => '{fractional:true}', - 'currency' => 'USD', - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.CurrencyTextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.CurrencyTextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_CurrencyTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_CurrencyTextBoxTest::main") { - Zend_Dojo_View_Helper_CurrencyTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/DateTextBoxTest.php b/tests/Zend/Dojo/View/Helper/DateTextBoxTest.php deleted file mode 100644 index 9d4751ec13a8b38aef9059ef670e7b60ee6d8177..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/DateTextBoxTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DateTextBoxTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_DateTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_DateTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_DateTextBox */ -require_once 'Zend/Dojo/View/Helper/DateTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_DateTextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_DateTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_DateTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_DateTextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->dateTextBox( - 'elementId', - '2008-07-07', - array( - 'required' => true, - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.DateTextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.DateTextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_DateTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_DateTextBoxTest::main") { - Zend_Dojo_View_Helper_DateTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/DojoTest.php b/tests/Zend/Dojo/View/Helper/DojoTest.php deleted file mode 100644 index 6c87530129d8ca77506901167998a66ceb50485e..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/DojoTest.php +++ /dev/null @@ -1,854 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DojoTest.php 11745 2008-10-08 18:25:37Z zendbot $ - */ - -// Call Zend_Dojo_View_Helper_DojoTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_DojoTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** Zend_Dojo_View_Helper_Dojo_Container */ -require_once 'Zend/Dojo/View/Helper/Dojo/Container.php'; - -/** Zend_Dojo */ -require_once 'Zend/Dojo.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Dojo_View_Helper_Dojo. - * - * @category Zend - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_DojoTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_DojoTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_Dojo_Container(); - $this->helper->setView($this->view); - Zend_Registry::set('Zend_Dojo_View_Helper_Dojo', $this->helper); - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function testViewPropertyShouldBeNullByDefault() - { - $helper = new Zend_Dojo_View_Helper_Dojo(); - $this->assertNull($helper->view); - } - - public function testShouldBeAbleToSetViewProperty() - { - $this->assertTrue($this->helper->view instanceof Zend_View_Interface); - } - - public function testNoModulesShouldBeRegisteredByDefault() - { - $modules = $this->helper->getModules(); - $this->assertTrue(empty($modules)); - } - - public function testShouldBeAbleToRequireModules() - { - $this->helper->requireModule('foo.bar'); - $modules = $this->helper->getModules(); - $this->assertContains('foo.bar', $modules); - } - - /** - * @group ZF-3914 - */ - public function testShouldAllowRequiringMultipleModulesAtOnce() - { - $modules = array('foo.bar', 'bar.baz', 'baz.bat'); - $this->helper->requireModule($modules); - $test = $this->helper->getModules(); - foreach ($modules as $module) { - $this->assertTrue(in_array($module, $test)); - } - } - - public function testInvalidModuleNameShouldThrowExceptionDuringRegistration() - { - try { - $this->helper->requireModule('foo#$!bar'); - $this->fail('Invalid module name should throw exception during registration'); - } catch (Zend_Dojo_View_Exception $e) { - $this->assertContains('invalid character', $e->getMessage()); - } - } - - /** - * @group ZF-3916 - */ - public function testRequireModuleShouldAllowDashAndUnderscoreCharacters() - { - $this->helper->requireModule('dojox.highlight.language._www'); - $this->helper->requireModule('dojo.NodeList-fx'); - } - - public function testShouldNotRegisterDuplicateModules() - { - $this->helper->requireModule('foo.bar'); - $this->helper->requireModule('foo.bar'); - $modules = $this->helper->getModules(); - $this->assertContains('foo.bar', $modules); - $this->assertEquals(1, count($modules)); - } - - public function testModulePathsShouldBeEmptyByDefault() - { - $paths = $this->helper->getModulePaths(); - $this->assertTrue(empty($paths)); - } - - public function testShouldBeAbleToRegisterModulePaths() - { - $this->helper->registerModulePath('custom', '../custom'); - $paths = $this->helper->getModulePaths(); - $this->assertTrue(array_key_exists('custom', $paths), var_export($paths, 1)); - $this->assertContains('../custom', $paths); - } - - public function testShouldNotBeAbleToRegisterDuplicateModulePaths() - { - $this->helper->registerModulePath('custom', '../custom'); - $this->helper->registerModulePath('custom', '../custom'); - $paths = $this->helper->getModulePaths(); - $this->assertEquals(1, count($paths)); - $this->assertTrue(array_key_exists('custom', $paths)); - $this->assertContains('../custom', $paths); - } - - public function testShouldBeDisabledByDefault() - { - $this->assertFalse($this->helper->isEnabled()); - } - - public function testCallingAUseMethodShouldEnableHelper() - { - $this->testShouldBeDisabledByDefault(); - $this->helper->setCdnVersion('1.0'); - $this->assertTrue($this->helper->isEnabled()); - $this->helper->disable(); - $this->assertFalse($this->helper->isEnabled()); - $this->helper->setLocalPath('/js/dojo/dojo.js'); - $this->assertTrue($this->helper->isEnabled()); - } - - public function testShouldUtilizeCdnByDefault() - { - $this->helper->enable(); - $this->assertTrue($this->helper->useCdn()); - } - - public function testShouldUseAolCdnByDefault() - { - $this->assertEquals(Zend_Dojo::CDN_BASE_AOL, $this->helper->getCdnBase()); - } - - public function testShouldAllowSpecifyingCdnBasePath() - { - $this->testShouldUseAolCdnByDefault(); - $this->helper->setCdnBase(Zend_Dojo::CDN_BASE_GOOGLE); - $this->assertEquals(Zend_Dojo::CDN_BASE_GOOGLE, $this->helper->getCdnBase()); - } - - public function testShouldUseLatestVersionWhenUsingCdnByDefault() - { - $this->helper->enable(); - $this->assertEquals('1.1.1', $this->helper->getCdnVersion()); - } - - public function testShouldAllowSpecifyingDojoVersionWhenUtilizingCdn() - { - $this->helper->setCdnVersion('1.0'); - $this->assertEquals('1.0', $this->helper->getCdnVersion()); - } - - public function testShouldUseAolCdnDojoPathByDefault() - { - $this->assertEquals(Zend_Dojo::CDN_DOJO_PATH_AOL, $this->helper->getCdnDojoPath()); - } - - public function testShouldAllowSpecifyingCdnDojoPath() - { - $this->testShouldUseAolCdnDojoPathByDefault(); - $this->helper->setCdnDojoPath(Zend_Dojo::CDN_DOJO_PATH_GOOGLE); - $this->assertEquals(Zend_Dojo::CDN_DOJO_PATH_GOOGLE, $this->helper->getCdnDojoPath()); - } - - public function testShouldAllowSpecifyingLocalDojoInstall() - { - $this->helper->setLocalPath('/js/dojo/dojo.js'); - $this->assertTrue($this->helper->useLocalPath()); - } - - public function testShouldAllowSpecifyingDjConfig() - { - $this->helper->setDjConfig(array('parseOnLoad' => 'true')); - $config = $this->helper->getDjConfig(); - $this->assertTrue(is_array($config)); - $this->assertTrue(array_key_exists('parseOnLoad', $config)); - $this->assertEquals('true', $config['parseOnLoad']); - } - - public function testShouldAllowRetrievingIndividualDjConfigKeys() - { - $this->helper->setDjConfigOption('parseOnLoad', 'true'); - $this->assertEquals('true', $this->helper->getDjConfigOption('parseOnLoad')); - } - - public function testGetDjConfigShouldReturnEmptyArrayByDefault() - { - $this->assertSame(array(), $this->helper->getDjConfig()); - } - - public function testGetDjConfigOptionShouldReturnNullWhenKeyDoesNotExist() - { - $this->assertNull($this->helper->getDjConfigOption('bogus')); - } - - public function testGetDjConfigOptionShouldAllowSpecifyingDefaultValue() - { - $this->assertEquals('bar', $this->helper->getDjConfigOption('foo', 'bar')); - } - - public function testDjConfigShouldSerializeToJson() - { - $this->helper->setDjConfigOption('parseOnLoad', true) - ->enable(); - $html = $this->helper->__toString(); - $this->assertContains('var djConfig = ', $html, var_export($html, 1)); - $this->assertContains('"parseOnLoad":', $html, $html); - } - - public function testShouldAllowSpecifyingStylesheetByModuleName() - { - $this->helper->addStylesheetModule('dijit.themes.tundra'); - $stylesheets = $this->helper->getStylesheetModules(); - $this->assertContains('dijit.themes.tundra', $stylesheets); - } - - public function testDuplicateStylesheetModulesShouldNotBeAllowed() - { - $this->helper->addStylesheetModule('dijit.themes.tundra'); - $stylesheets = $this->helper->getStylesheetModules(); - $this->assertContains('dijit.themes.tundra', $stylesheets); - - $this->helper->addStylesheetModule('dijit.themes.tundra'); - $stylesheets = $this->helper->getStylesheetModules(); - $this->assertEquals(1, count($stylesheets)); - $this->assertContains('dijit.themes.tundra', $stylesheets); - } - - /** - * @group ZF-3916 - */ - public function testAddingStylesheetModuleShouldAllowDashAndUnderscoreCharacters() - { - $this->helper->addStylesheetModule('dojox._highlight.pygments'); - $this->helper->addStylesheetModule('dojo.NodeList-fx.styles'); - } - - - public function testInvalidStylesheetModuleNameShouldThrowException() - { - try { - $this->helper->addStylesheetModule('foo/bar/baz'); - $this->fail('invalid module designation should throw exception'); - } catch (Zend_Dojo_View_Exception $e) { - $this->assertContains('Invalid', $e->getMessage()); - } - } - - public function testRenderingModuleStylesheetShouldProperlyCreatePaths() - { - $this->helper->enable() - ->addStylesheetModule('dijit.themes.tundra'); - $html = $this->helper->__toString(); - $this->assertContains('dijit/themes/tundra/tundra.css', $html); - } - - public function testShouldAllowSpecifyingLocalStylesheet() - { - $this->helper->addStylesheet('/css/foo.css'); - $css = $this->helper->getStylesheets(); - $this->assertTrue(is_array($css)); - $this->assertContains('/css/foo.css', $css); - } - - public function testShouldNotAllowSpecifyingDuplicateLocalStylesheets() - { - $this->testShouldAllowSpecifyingLocalStylesheet(); - $this->helper->addStylesheet('/css/foo.css'); - $css = $this->helper->getStylesheets(); - $this->assertTrue(is_array($css)); - $this->assertEquals(1, count($css)); - $this->assertContains('/css/foo.css', $css); - } - - public function testShouldAllowSpecifyingOnLoadFunctionPointer() - { - $this->helper->addOnLoad('foo'); - $onLoad = $this->helper->getOnLoadActions(); - $this->assertTrue(is_array($onLoad)); - $this->assertEquals(1, count($onLoad)); - $action = array_shift($onLoad); - $this->assertTrue(is_string($action)); - $this->assertEquals('foo', $action); - } - - public function testShouldAllowCapturingOnLoadActions() - { - $this->helper->onLoadCaptureStart(); ?> -function() { - bar(); - baz(); -} -<?php $this->helper->onLoadCaptureEnd(); - $onLoad = $this->helper->getOnLoadActions(); - $this->assertTrue(is_array($onLoad)); - $this->assertEquals(1, count($onLoad)); - $action = array_shift($onLoad); - $this->assertTrue(is_string($action)); - $this->assertContains('function() {', $action); - $this->assertContains('bar();', $action); - $this->assertContains('baz();', $action); - } - - public function testShouldNotAllowSpecifyingDuplicateOnLoadActions() - { - $this->helper->addOnLoad('foo'); - $this->helper->addOnLoad('foo'); - $onLoad = $this->helper->getOnLoadActions(); - $this->assertTrue(is_array($onLoad)); - $this->assertEquals(1, count($onLoad)); - $action = array_shift($onLoad); - $this->assertEquals('foo', $action); - } - - public function testDojoMethodShouldReturnContainer() - { - $helper = new Zend_Dojo_View_Helper_Dojo(); - $this->assertSame($this->helper, $helper->dojo()); - } - - public function testHelperStorageShouldPersistBetweenViewObjects() - { - $view1 = $this->getView(); - $dojo1 = $view1->getHelper('dojo'); - $view2 = $this->getView(); - $dojo2 = $view1->getHelper('dojo'); - $this->assertSame($dojo1, $dojo2); - } - - public function testSerializingToStringShouldReturnEmptyStringByDefault() - { - $this->assertEquals('', $this->helper->__toString()); - } - - public function testEnablingHelperShouldCauseStringSerializationToWork() - { - $this->setupDojo(); - $html = $this->helper->__toString(); - $doc = new DOMDocument; - $doc->loadHTML($html); - $xPath = new DOMXPath($doc); - $results = $xPath->query('//script'); - $this->assertEquals(3, $results->length); - for ($i = 0; $i < 3; ++$i) { - $script = $doc->saveXML($results->item($i)); - switch ($i) { - case 0: - $this->assertContains('var djConfig = ', $script); - $this->assertContains('parseOnLoad', $script); - break; - case 1: - $this->assertContains('src="http://o.aolcdn.com/dojo/1.1/dojo/dojo.xd.js"', $script); - $this->assertContains('/>', $script); - break; - case 2: - $this->assertContains('dojo.registerModulePath("custom", "../custom")', $script, $script); - $this->assertContains('dojo.require("dijit.layout.ContentPane")', $script, $script); - $this->assertContains('dojo.require("custom.foo")', $script, $script); - $this->assertContains('dojo.addOnLoad(foo)', $script, $script); - break; - } - } - - $results = $xPath->query('//style'); - $this->assertEquals(1, $results->length, $html); - $style = $doc->saveXML($results->item(0)); - $this->assertContains('@import', $style); - $this->assertEquals(2, substr_count($style, '@import')); - $this->assertEquals(1, substr_count($style, 'http://o.aolcdn.com/dojo/1.1/'), $style); - $this->assertContains('css/custom.css', $style); - $this->assertContains('dijit/themes/tundra/tundra.css', $style); - } - - public function testStringSerializationShouldBeDoctypeAware() - { - $view = $this->getView(); - $view->doctype('HTML4_LOOSE'); - $this->helper->setView($view); - $this->setupDojo(); - $html = $this->helper->__toString(); - $this->assertRegexp('|<style [^>]*>[\r\n]+\s*<!--|', $html); - $this->assertRegexp('|<script [^>]*>[\r\n]+\s*//<!--|', $html); - - $this->helper = new Zend_Dojo_View_Helper_Dojo(); - $view->doctype('XHTML1_STRICT'); - $this->helper->setView($view); - $this->setupDojo(); - $html = $this->helper->__toString(); - - /** - * @todo should stylesheets be escaped as CDATA when isXhtml()? - */ - $this->assertRegexp('|<style [^>]*>[\r\n]+\s*<!--|', $html); - $this->assertRegexp('|<script [^>]*>[\r\n]+\s*//<!\[CDATA\[|', $html); - } - - public function testDojoHelperContainerPersistsBetweenViewObjects() - { - $this->setupDojo(); - - $view = $this->getView(); - $this->assertNotSame($this->view, $view); - $helper = $view->dojo(); - $this->assertSame($this->helper, $helper); - } - - public function testShouldUseProgrammaticDijitCreationByDefault() - { - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammatic()); - } - - public function testShouldAllowSpecifyingDeclarativeDijitCreation() - { - $this->testShouldUseProgrammaticDijitCreationByDefault(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useDeclarative()); - } - - public function testShouldAllowSpecifyingProgrammaticDijitCreationWithNoScriptGeneration() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(-1); - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammatic()); - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript()); - } - - public function testAddingProgrammaticDijitsShouldAcceptIdAndArrayOfDijitParams() - { - $this->helper->addDijit('foo', array('dojoType' => 'dijit.form.Form')); - $dijits = $this->helper->getDijits(); - $this->assertTrue(is_array($dijits)); - $this->assertEquals(1, count($dijits)); - $dijit = array_shift($dijits); - $this->assertTrue(is_array($dijit)); - $this->assertEquals(2, count($dijit)); - $this->assertTrue(array_key_exists('id', $dijit)); - $this->assertTrue(array_key_exists('params', $dijit)); - $this->assertEquals('foo', $dijit['id']); - $this->assertTrue(is_array($dijit['params'])); - $this->assertEquals(1, count($dijit['params'])); - $this->assertTrue(array_key_exists('dojoType', $dijit['params'])); - $this->assertEquals('dijit.form.Form', $dijit['params']['dojoType']); - } - - /** - * @expectedException Zend_Dojo_View_Exception - */ - public function testAddingDuplicateProgrammaticDijitsShouldRaiseExceptions() - { - $this->helper->addDijit('foo', array('dojoType' => 'dijit.form.Form')); - $this->helper->addDijit('foo', array('dojoType' => 'dijit.form.ComboBox')); - } - - public function testSettingProgrammaticDijitsShouldOverwriteExistingDijits() - { - $this->testAddingProgrammaticDijitsShouldAcceptIdAndArrayOfDijitParams(); - $this->helper->setDijit('foo', array('dojoType' => 'dijit.form.ComboBox')); - $dijits = $this->helper->getDijits(); - $this->assertTrue(is_array($dijits)); - $this->assertEquals(1, count($dijits)); - $dijit = array_shift($dijits); - $this->assertEquals('dijit.form.ComboBox', $dijit['params']['dojoType']); - } - - public function testShouldAllowAddingMultipleDijitsAtOnce() - { - $dijits = array( - 'foo' => array( - 'dojoType' => 'dijit.form.Form' - ), - 'bar' => array( - 'dojoType' => 'dijit.form.TextBox', - ), - ); - $this->helper->addDijits($dijits); - $test = $this->helper->getDijits(); - $this->assertTrue(is_array($test)); - $this->assertEquals(2, count($test)); - $keys = array(); - foreach ($test as $dijit) { - $keys[] = $dijit['id']; - } - $this->assertSame(array_keys($dijits), $keys); - } - - public function testSettingMultipleDijitsAtOnceShouldOverwriteAllDijits() - { - $this->testAddingProgrammaticDijitsShouldAcceptIdAndArrayOfDijitParams(); - $dijits = array( - 'bar' => array( - 'dojoType' => 'dijit.form.Form' - ), - 'baz' => array( - 'dojoType' => 'dijit.form.TextBox', - ), - ); - $this->helper->setDijits($dijits); - $test = $this->helper->getDijits(); - $this->assertTrue(is_array($test)); - $this->assertEquals(2, count($test)); - $keys = array(); - foreach ($test as $dijit) { - $keys[] = $dijit['id']; - } - $this->assertSame(array_keys($dijits), $keys); - } - - public function testRetrievingDijitsByIdShouldReturnJustParams() - { - $this->helper->addDijit('foo', array('dojoType' => 'dijit.form.Form')); - $params = $this->helper->getDijit('foo'); - $this->assertTrue(is_array($params)); - $this->assertEquals(1, count($params), var_export($params, 1)); - $this->assertTrue(array_key_exists('dojoType', $params)); - $this->assertEquals('dijit.form.Form', $params['dojoType']); - } - - public function testShouldAllowRemovingIndividualDijits() - { - $this->helper->addDijit('foo', array('dojoType' => 'dijit.form.Form')); - $dijits = $this->helper->getDijits(); - $this->assertTrue(is_array($dijits)); - $this->assertEquals(1, count($dijits)); - $this->helper->removeDijit('foo'); - $dijits = $this->helper->getDijits(); - $this->assertTrue(is_array($dijits)); - $this->assertEquals(0, count($dijits)); - } - - public function testShouldAllowClearingAllDijits() - { - $this->testShouldAllowAddingMultipleDijitsAtOnce(); - $this->helper->clearDijits(); - $dijits = $this->helper->getDijits(); - $this->assertTrue(is_array($dijits)); - $this->assertEquals(0, count($dijits)); - } - - public function testShouldAllowRetrievingDijitsAsJsonArray() - { - $this->testShouldAllowAddingMultipleDijitsAtOnce(); - $json = $this->helper->dijitsToJson(); - $array = Zend_Json::decode($json); - $this->assertTrue(is_array($array)); - - $keys = array(); - foreach ($array as $dijit) { - $keys[] = $dijit['id']; - $this->assertTrue(array_key_exists('params', $dijit)); - $this->assertTrue(is_array($dijit['params'])); - } - $this->assertSame(array('foo', 'bar'), $keys); - } - - public function testRenderingShouldCreateZendDijitsObjectAndAddOnloadForDijitsWhenDijitsArePresent() - { - $this->helper->enable(); - $this->testShouldAllowAddingMultipleDijitsAtOnce(); - $json = $this->helper->dijitsToJson(); - $html = $this->helper->__toString(); - $this->assertContains($json, $html, $html); - - $found = false; - foreach ($this->helper->getOnLoadActions() as $action) { - if (strstr($action, 'dojo.mixin')) { - $found = true; - break; - } - } - $this->assertTrue($found, 'Dijit onload action not created'); - $this->assertContains($action, $html); - } - - public function testShouldAllowAddingArbitraryJsToPrimaryDojoScriptTag() - { - $this->helper->enable(); - $this->helper->addJavascript('var foo = "bar";'); - $html = $this->helper->__toString(); - $found = false; - if (preg_match_all('|<script[^>]*>(.*?)(</script>)|s', $html, $m)) { - foreach ($m[1] as $script) { - if (strstr($script, 'var foo = "bar";')) { - $found = true; - break; - } - } - } - $this->assertTrue($found, 'Js not found: ' . $html); - } - - public function testShouldAllowClearingArbitraryJsStack() - { - $this->testShouldAllowAddingArbitraryJsToPrimaryDojoScriptTag(); - $this->helper->clearJavascript(); - $js = $this->helper->getJavascript(); - $this->assertTrue(is_array($js)); - $this->assertEquals(0, count($js)); - } - - public function testShouldNotAllowAddingDuplicateArbitraryJsToPrimaryDojoScriptTag() - { - $this->helper->addJavascript('var foo = "bar";'); - $this->helper->addJavascript('var foo = "bar";'); - $js = $this->helper->getJavascript(); - $this->assertTrue(is_array($js)); - $this->assertEquals(1, count($js), var_export($js, 1)); - $this->assertEquals('var foo = "bar";', $js[0]); - } - - public function testShouldAllowCapturingArbitraryJsToPrimaryDojoScriptTag() - { - $this->helper->javascriptCaptureStart(); - echo 'var foo = "bar";'; - $this->helper->javascriptCaptureEnd(); - $js = $this->helper->getJavascript(); - $this->assertEquals(1, count($js)); - $this->assertContains('var foo = "bar";', $js[0]); - } - - public function testNoLayersShouldBeRegisteredByDefault() - { - $layers = $this->helper->getLayers(); - $this->assertTrue(is_array($layers)); - $this->assertTrue(empty($layers)); - } - - public function testShouldAllowAddingLayers() - { - $this->testNoLayersShouldBeRegisteredByDefault(); - $this->helper->addLayer('/js/foo/foo.xd.js'); - $layers = $this->helper->getLayers(); - $this->assertEquals(1, count($layers)); - $this->assertEquals('/js/foo/foo.xd.js', $layers[0]); - - $this->helper->addLayer('/js/bar/bar.xd.js'); - $layers = $this->helper->getLayers(); - $this->assertEquals(2, count($layers)); - $this->assertEquals('/js/foo/foo.xd.js', $layers[0]); - $this->assertEquals('/js/bar/bar.xd.js', $layers[1]); - } - - public function testShouldNotAllowDuplicateLayers() - { - $this->testShouldAllowAddingLayers(); - $this->helper->addLayer('/js/foo/foo.xd.js'); - $layers = $this->helper->getLayers(); - $this->assertEquals(2, count($layers)); - $this->assertEquals('/js/foo/foo.xd.js', $layers[0]); - $this->assertEquals('/js/bar/bar.xd.js', $layers[1]); - } - - public function testShouldAllowRemovingLayers() - { - $this->testShouldAllowAddingLayers(); - $this->helper->removeLayer('/js/foo/foo.xd.js'); - $layers = $this->helper->getLayers(); - $this->assertEquals(1, count($layers)); - $this->assertEquals('/js/bar/bar.xd.js', $layers[0]); - } - - public function testShouldAllowClearingLayers() - { - $this->testShouldAllowAddingLayers(); - $this->helper->clearLayers(); - $layers = $this->helper->getLayers(); - $this->assertTrue(is_array($layers)); - $this->assertTrue(empty($layers)); - } - - public function testShouldRenderScriptTagsWithLayersWhenLayersAreRegistered() - { - $this->setupDojo(); - $this->testShouldAllowAddingLayers(); - $html = $this->helper->__toString(); - $doc = new DOMDocument; - $doc->loadHTML($html); - $xPath = new DOMXPath($doc); - $results = $xPath->query('//script'); - - $found = array(); - for ($i = 0; $i < $results->length; ++$i) { - $script = $doc->saveXML($results->item($i)); - foreach (array('foo', 'bar') as $layerType) { - $layer = sprintf('/js/%s/%s.xd.js', $layerType, $layerType); - if (strstr($script, $layer)) { - $found[] = $layerType; - break; - } - } - } - $this->assertSame(array('foo', 'bar'), $found); - } - - /** - * @expectedException Zend_Dojo_View_Exception - */ - public function testCallingMethodThatDoesNotExistInContainerShouldRaiseException() - { - $dojo = new Zend_Dojo_View_Helper_Dojo(); - $dojo->bogus(); - } - - public function testShouldAllowSpecifyingDeclarativeUsage() - { - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useDeclarative()); - } - - public function testShouldAllowSpecifyingProgrammaticUsageWithNoScriptGeneration() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(-1); - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript()); - } - - public function testInvalidFlagPassedToUseProgrammaticShouldUseProgrammaticWithScripts() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic('foo'); - $this->assertFalse(Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript()); - $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammatic()); - } - - /** - * @see ZF-3962 - * @group ZF-3962 - */ - public function testHelperShouldAllowDisablingParseOnLoadWithDeclarativeStyle() - { - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - $this->helper->requireModule('dijit.layout.ContentPane') - ->setDjConfigOption('parseOnLoad', 'false') - ->enable(); - $html = $this->helper->__toString(); - if (!preg_match('/(var djConfig = .*?(?:};))/s', $html, $matches)) { - $this->fail('Failed to find djConfig settings: ' . $html); - } - $this->assertNotContains('"parseOnLoad":true', $matches[1]); - } - - /** - * @group ZF-4522 - */ - public function testOnLoadCaptureStartShouldReturnVoid() - { - $test = $this->helper->onLoadCaptureStart(); - $this->helper->onLoadCaptureEnd(); - $this->assertNull($test); - } - - /** - * @group ZF-4522 - */ - public function testJavascriptCaptureStartShouldReturnVoid() - { - $test = $this->helper->javascriptCaptureStart(); - $this->helper->javascriptCaptureEnd(); - $this->assertNull($test); - } - - public function setupDojo() - { - $this->helper->requireModule('dijit.layout.ContentPane') - ->registerModulePath('custom', '../custom') - ->requireModule('custom.foo') - ->setCdnVersion('1.1') - ->setDjConfig(array('parseOnLoad' => 'true')) - ->addStylesheetModule('dijit.themes.tundra') - ->addStylesheet('/css/custom.css') - ->addOnLoad('foo'); - } -} - -// Call Zend_Dojo_View_Helper_DojoTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_DojoTest::main") { - Zend_Dojo_View_Helper_DojoTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/FilteringSelectTest.php b/tests/Zend/Dojo/View/Helper/FilteringSelectTest.php deleted file mode 100644 index d0ed4e9abc4ced117001ab28d85cc47762f9d36f..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/FilteringSelectTest.php +++ /dev/null @@ -1,180 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FilteringSelectTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_FilteringSelectTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_FilteringSelectTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_FilteringSelect */ -require_once 'Zend/Dojo/View/Helper/FilteringSelect.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_FilteringSelect. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_FilteringSelectTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_FilteringSelectTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_FilteringSelect(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElementAsSelect() - { - return $this->helper->filteringSelect( - 'elementId', - 'someCombo', - array(), - array(), - array( - 'red' => 'Rouge', - 'blue' => 'Bleu', - 'white' => 'Blanc', - 'orange' => 'Orange', - 'black' => 'Noir', - 'green' => 'Vert', - ) - ); - } - - public function getElementAsRemoter() - { - return $this->helper->filteringSelect( - 'elementId', - 'someCombo', - array( - 'store' => array( - 'store' => 'stateStore', - 'type' => 'dojo.data.ItemFileReadStore', - 'params' => array( - 'url' => 'states.txt' - ) - ), - 'searchAttr' => 'name' - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreationAsSelect() - { - $html = $this->getElementAsSelect(); - $this->assertRegexp('/<select[^>]*(dojoType="dijit.form.FilteringSelect")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreationAsSelect() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElementAsSelect(); - $this->assertNotRegexp('/<select[^>]*(dojoType="dijit.form.FilteringSelect")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldAllowDeclarativeDijitCreationAsRemoter() - { - $html = $this->getElementAsRemoter(); - if (!preg_match('/(<input[^>]*(dojoType="dijit.form.FilteringSelect"))/', $html, $m)) { - $this->fail('Did not create text input as remoter: ' . $html); - } - $this->assertContains('type="text"', $m[1]); - } - - public function testShouldAllowProgrammaticDijitCreationAsRemoter() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElementAsRemoter(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.FilteringSelect")/', $html); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - - $found = false; - $scripts = $this->view->dojo()->getJavascript(); - foreach ($scripts as $js) { - if (strstr($js, 'var stateStore;')) { - $found = true; - break; - } - } - $this->assertTrue($found, 'No store declaration found: ' . var_export($scripts, 1)); - } -} - -// Call Zend_Dojo_View_Helper_FilteringSelectTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_FilteringSelectTest::main") { - Zend_Dojo_View_Helper_FilteringSelectTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/FormTest.php b/tests/Zend/Dojo/View/Helper/FormTest.php deleted file mode 100644 index 22234a6cdfac9917915bcc95384a9f03d06da319..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/FormTest.php +++ /dev/null @@ -1,134 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FormTest.php 10196 2008-07-18 22:01:18Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_FormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_FormTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_Form */ -require_once 'Zend/Dojo/View/Helper/Form.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_Form. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_FormTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_FormTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_Form(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getForm() - { - return $this->helper->form('myForm', array('action' => '/foo'), ''); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getForm(); - $this->assertRegexp('/<form[^>]*(dojoType="dijit.form.Form")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getForm(); - $this->assertNotRegexp('/<form[^>]*(dojoType="dijit.form.Form")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('myForm')); - } - - public function testOnlyIdShouldBeNecessary() - { - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - $html = $this->view->form('foo'); - $this->assertRegexp('/<form[^>]*(dojoType="dijit.form.Form")/', $html, $html); - $this->assertRegexp('/<form[^>]*(id="foo")/', $html, $html); - } - - public function testShouldNotRenderIdAsHtmlIdWhenIdPassedAsAttrib() - { - $html = $this->helper->form('foo', array('id' => 'bar')); - $this->assertRegexp('/<form[^>]*(id="bar")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_FormTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_FormTest::main") { - Zend_Dojo_View_Helper_FormTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/HorizontalSliderTest.php b/tests/Zend/Dojo/View/Helper/HorizontalSliderTest.php deleted file mode 100644 index 50c925cc91ea80cfc78f3af601ef3fb9af1217b4..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/HorizontalSliderTest.php +++ /dev/null @@ -1,264 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HorizontalSliderTest.php 10066 2008-07-12 20:26:33Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_HorizontalSliderTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_HorizontalSliderTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_HorizontalSlider */ -require_once 'Zend/Dojo/View/Helper/HorizontalSlider.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_HorizontalSlider. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_HorizontalSliderTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_HorizontalSliderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_HorizontalSlider(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->horizontalSlider( - 'elementId', - '', - array( - 'minimum' => -10, - 'maximum' => 10, - 'discreteValues' => 11, - 'topDecoration' => array( - 'labels' => array( - ' ', - '20%', - '40%', - '60%', - '80%', - ' ', - ), - 'container' => 'top', - 'attribs' => array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - 'dijit' => 'HorizontalRuleLabels', - ), - 'bottomDecoration' => array( - 'labels' => array( - '0%', - '50%', - '100%', - ), - 'attribs' => array( - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - ), - 'leftDecoration' => array( - 'labels' => array( - ' ', - '20%', - '40%', - '60%', - '80%', - ' ', - ), - 'attribs' => array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - 'dijit' => 'VerticalRuleLabels', - ), - 'rightDecoration' => array( - 'labels' => array( - '0%', - '50%', - '100%', - ), - 'attribs' => array( - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - ), - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.form.HorizontalSlider")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.form.HorizontalSlider")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId-slider')); - } - - public function testShouldCreateOnChangeAttributeByDefault() - { - $html = $this->getElement(); - $this->assertContains('onChange="dojo.byId(\'elementId\').value = arguments[0];"', $html, $html); - } - - public function testShouldCreateHiddenElementWithValue() - { - $html = $this->getElement(); - if (!preg_match('/(<input[^>]*(type="hidden")[^>]*>)/', $html, $m)) { - $this->fail('No hidden element found'); - } - $this->assertContains('id="elementId"', $m[1]); - $this->assertContains('value="', $m[1]); - } - - public function testShouldCreateTopAndBottomDecorationsWhenRequested() - { - $html = $this->getElement(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.form.HorizontalRule")/', $html, $html); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.form.HorizontalRuleLabels")/', $html, $html); - $this->assertContains('topDecoration', $html); - $this->assertContains('bottomDecoration', $html); - } - - public function testShouldIgnoreLeftAndRightDecorationsWhenPassed() - { - $html = $this->getElement(); - $this->assertNotContains('leftDecoration', $html); - $this->assertNotContains('rightDecoration', $html); - } - - /** - * @expectedException Zend_Dojo_View_Exception - */ - public function testSliderShouldRaiseExceptionIfMissingRequiredParameters() - { - $this->helper->prepareSlider('foo', 4); - } - - public function testShouldAllowPassingLabelParametersViaDecorationParameters() - { - $html = $this->helper->horizontalSlider( - 'elementId', - '', - array( - 'minimum' => -10, - 'maximum' => 10, - 'discreteValues' => 11, - 'topDecoration' => array( - 'labels' => array( - ' ', - '20%', - '40%', - '60%', - '80%', - ' ', - ), - 'params' => array( - 'required' => true, - 'labels' => array( - 'minimum' => 5, - ) - ), - 'dijit' => 'HorizontalRuleLabels', - ), - ) - ); - $this->assertContains('required="', $html); - $this->assertContains('minimum="', $html); - } -} - -// Call Zend_Dojo_View_Helper_HorizontalSliderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_HorizontalSliderTest::main") { - Zend_Dojo_View_Helper_HorizontalSliderTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/NumberSpinnerTest.php b/tests/Zend/Dojo/View/Helper/NumberSpinnerTest.php deleted file mode 100644 index a679fdcb4599f1cb3bba239e115d4af194bad472..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/NumberSpinnerTest.php +++ /dev/null @@ -1,163 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NumberSpinnerTest.php 10091 2008-07-15 03:46:37Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_NumberSpinnerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_NumberSpinnerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_NumberSpinner */ -require_once 'Zend/Dojo/View/Helper/NumberSpinner.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_NumberSpinner. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_NumberSpinnerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_NumberSpinnerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_NumberSpinner(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->numberSpinner( - 'elementId', - '5', - array( - 'smallDelta' => '10', - 'min' => 9, - 'max' => 1550, - 'places' => 0, - 'required' => true, - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.NumberSpinner")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.NumberSpinner")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } - - public function testShouldJsonEncodeConstraints() - { - $html = $this->getElement(); - if (!preg_match('/constraints="(.*?)(" )/', $html, $m)) { - $this->fail('Did not serialize constraints'); - } - $constraints = str_replace("'", '"', $m[1]); - $constraints = Zend_Json::decode($constraints); - $this->assertTrue(is_array($constraints), var_export($m[1], 1)); - $this->assertTrue(array_key_exists('min', $constraints)); - $this->assertTrue(array_key_exists('max', $constraints)); - $this->assertTrue(array_key_exists('places', $constraints)); - } - - public function testInvalidConstraintsShouldBeStrippedPriorToRendering() - { - $html = $this->helper->numberSpinner( - 'foo', - 5, - array ( - 'constraints' => 'bogus', - ) - ); - $this->assertNotContains('constraints="', $html); - } -} - -// Call Zend_Dojo_View_Helper_NumberSpinnerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_NumberSpinnerTest::main") { - Zend_Dojo_View_Helper_NumberSpinnerTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/NumberTextBoxTest.php b/tests/Zend/Dojo/View/Helper/NumberTextBoxTest.php deleted file mode 100644 index 6fe6d37f5c1b5fc79a5ad442020aeb1ec17b44a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/NumberTextBoxTest.php +++ /dev/null @@ -1,134 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NumberTextBoxTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_NumberTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_NumberTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_NumberTextBox */ -require_once 'Zend/Dojo/View/Helper/NumberTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_NumberTextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_NumberTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_NumberTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_NumberTextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->numberTextBox( - 'elementId', - '2008-07-07', - array( - 'required' => true, - 'constraints' => '{min:-20000,max:20000,places:0}', - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.NumberTextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.NumberTextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_NumberTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_NumberTextBoxTest::main") { - Zend_Dojo_View_Helper_NumberTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/PasswordTextBoxTest.php b/tests/Zend/Dojo/View/Helper/PasswordTextBoxTest.php deleted file mode 100644 index 9d4668e0576a139d8877f749685c78df60701f58..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/PasswordTextBoxTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PasswordTextBoxTest.php 10668 2008-08-05 13:01:56Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_PasswordTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_PasswordTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_PasswordTextBox */ -require_once 'Zend/Dojo/View/Helper/PasswordTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_PasswordTextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_PasswordTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_PasswordTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_PasswordTextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->passwordTextBox( - 'elementId', - 'foobar', - array( - 'required' => true, - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.ValidationTextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.ValidationTextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreatePasswordInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="password")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_PasswordTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_PasswordTextBoxTest::main") { - Zend_Dojo_View_Helper_PasswordTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/RadioButtonTest.php b/tests/Zend/Dojo/View/Helper/RadioButtonTest.php deleted file mode 100644 index 43b626034cee3a4a5e730e3e33d03fbf4f9d6077..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/RadioButtonTest.php +++ /dev/null @@ -1,129 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RadioButtonTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_RadioButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_RadioButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_RadioButton */ -require_once 'Zend/Dojo/View/Helper/RadioButton.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_RadioButton. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_RadioButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_RadioButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_RadioButton(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->radioButton( - 'elementId', - 'foo', - array(), - array(), - array( - 'checked' => 'foo', - 'unChecked' => 'bar', - ) - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.RadioButton")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.RadioButton")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } -} - -// Call Zend_Dojo_View_Helper_RadioButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_RadioButtonTest::main") { - Zend_Dojo_View_Helper_RadioButtonTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/SplitContainerTest.php b/tests/Zend/Dojo/View/Helper/SplitContainerTest.php deleted file mode 100644 index 6bd825354e09df4b35a2e7b4ae684a6f8eb13bfe..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/SplitContainerTest.php +++ /dev/null @@ -1,126 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SplitContainerTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_SplitContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_SplitContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_SplitContainer */ -require_once 'Zend/Dojo/View/Helper/SplitContainer.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_SplitContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_SplitContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_SplitContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_SplitContainer(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - $html = ''; - foreach (array('top', 'bottom', 'center', 'left', 'right') as $pane) { - $id = $pane . 'Pane'; - $content = 'This is the content of pane ' . $pane; - $html .= $this->view->contentPane($id, $content, array('region' => $pane)); - } - return $this->helper->splitContainer('container', $html, array('design' => 'headline')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.SplitContainer")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.SplitContainer")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('container')); - } -} - -// Call Zend_Dojo_View_Helper_SplitContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_SplitContainerTest::main") { - Zend_Dojo_View_Helper_SplitContainerTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/StackContainerTest.php b/tests/Zend/Dojo/View/Helper/StackContainerTest.php deleted file mode 100644 index 47d905cb94fef9823132c41bb1fa7ae952129867..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/StackContainerTest.php +++ /dev/null @@ -1,126 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StackContainerTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_StackContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_StackContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_StackContainer */ -require_once 'Zend/Dojo/View/Helper/StackContainer.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_StackContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_StackContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_StackContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_StackContainer(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - $html = ''; - foreach (array('top', 'bottom', 'center', 'left', 'right') as $pane) { - $id = $pane . 'Pane'; - $content = 'This is the content of pane ' . $pane; - $html .= $this->view->contentPane($id, $content, array('region' => $pane)); - } - return $this->helper->stackContainer('container', $html, array('design' => 'headline')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.StackContainer")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.StackContainer")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('container')); - } -} - -// Call Zend_Dojo_View_Helper_StackContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_StackContainerTest::main") { - Zend_Dojo_View_Helper_StackContainerTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/SubmitButtonTest.php b/tests/Zend/Dojo/View/Helper/SubmitButtonTest.php deleted file mode 100644 index 1e2254c2f40b59d776b74a5b94edbaa6d17710b4..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/SubmitButtonTest.php +++ /dev/null @@ -1,127 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SubmitButtonTest.php 10628 2008-08-04 14:30:19Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_SubmitButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_SubmitButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_SubmitButton */ -require_once 'Zend/Dojo/View/Helper/SubmitButton.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_SubmitButton. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_SubmitButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_SubmitButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_SubmitButton(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->submitButton( - 'elementId', - 'foo', - array(), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="submit")/', $html, $html); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.Button")/', $html, $html); - $this->assertRegexp('/<input[^>]*(label="foo")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.Button")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } -} - -// Call Zend_Dojo_View_Helper_SubmitButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_SubmitButtonTest::main") { - Zend_Dojo_View_Helper_SubmitButtonTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/TabContainerTest.php b/tests/Zend/Dojo/View/Helper/TabContainerTest.php deleted file mode 100644 index d582ca154544663beec0b85b456186bc937b4754..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/TabContainerTest.php +++ /dev/null @@ -1,126 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TabContainerTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_TabContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_TabContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_TabContainer */ -require_once 'Zend/Dojo/View/Helper/TabContainer.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_TabContainer. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_TabContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_TabContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_TabContainer(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getContainer() - { - $html = ''; - foreach (array('top', 'bottom', 'center', 'left', 'right') as $pane) { - $id = $pane . 'Pane'; - $content = 'This is the content of pane ' . $pane; - $html .= $this->view->contentPane($id, $content, array('region' => $pane)); - } - return $this->helper->tabContainer('container', $html, array('design' => 'headline')); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getContainer(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.TabContainer")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getContainer(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.TabContainer")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('container')); - } -} - -// Call Zend_Dojo_View_Helper_TabContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_TabContainerTest::main") { - Zend_Dojo_View_Helper_TabContainerTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/TextBoxTest.php b/tests/Zend/Dojo/View/Helper/TextBoxTest.php deleted file mode 100644 index 64061c8049a23de938f451bd0f955b70a7eb9721..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/TextBoxTest.php +++ /dev/null @@ -1,135 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TextBoxTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_TextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_TextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_TextBox */ -require_once 'Zend/Dojo/View/Helper/TextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_TextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_TextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_TextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_TextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->textBox( - 'elementId', - 'someText', - array( - 'required' => true, - 'trim' => true, - 'propercase' => true, - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.TextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.TextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_TextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_TextBoxTest::main") { - Zend_Dojo_View_Helper_TextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/TextareaTest.php b/tests/Zend/Dojo/View/Helper/TextareaTest.php deleted file mode 100644 index d9abea60849d5f05f5d2af1737443a1159b57784..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/TextareaTest.php +++ /dev/null @@ -1,131 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TextareaTest.php 10257 2008-07-21 14:12:42Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_TextareaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_TextareaTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_Textarea */ -require_once 'Zend/Dojo/View/Helper/Textarea.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_Textarea. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_TextareaTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_TextareaTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_Textarea(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->textarea( - 'elementId', - 'some content', - array(), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<textarea[^>]*(dojoType="dijit.form.Textarea")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<textarea[^>]*(dojoType="dijit.form.Textarea")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testPassingIdAsAttributeShouldOverrideUsingNameAsId() - { - $html = $this->helper->textarea('foo[bar]', '', array(), array('id' => 'foo-bar')); - $this->assertContains('id="foo-bar"', $html); - } -} - -// Call Zend_Dojo_View_Helper_TextareaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_TextareaTest::main") { - Zend_Dojo_View_Helper_TextareaTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/TimeTextBoxTest.php b/tests/Zend/Dojo/View/Helper/TimeTextBoxTest.php deleted file mode 100644 index edd26cf1b81c9159358bfd38eb968557ca5d2e2f..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/TimeTextBoxTest.php +++ /dev/null @@ -1,133 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TimeTextBoxTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_TimeTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_TimeTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_TimeTextBox */ -require_once 'Zend/Dojo/View/Helper/TimeTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_TimeTextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_TimeTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_TimeTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_TimeTextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->timeTextBox( - 'elementId', - '2008-07-07', - array( - 'required' => true, - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.TimeTextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.TimeTextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_TimeTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_TimeTextBoxTest::main") { - Zend_Dojo_View_Helper_TimeTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/ValidationTextBoxTest.php b/tests/Zend/Dojo/View/Helper/ValidationTextBoxTest.php deleted file mode 100644 index 84e641104d8a47c7528d4ece024359fff58de4ea..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/ValidationTextBoxTest.php +++ /dev/null @@ -1,134 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ValidationTextBoxTest.php 9994 2008-07-08 17:16:24Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_ValidationTextBoxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_ValidationTextBoxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_ValidationTextBox */ -require_once 'Zend/Dojo/View/Helper/ValidationTextBox.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_ValidationTextBox. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_ValidationTextBoxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_ValidationTextBoxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_ValidationTextBox(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->validationTextBox( - 'elementId', - '2008-07-07', - array( - 'required' => true, - 'regExp' => '[\w]+', - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(dojoType="dijit.form.ValidationTextBox")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.ValidationTextBox")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId')); - } - - public function testShouldCreateTextInput() - { - $html = $this->getElement(); - $this->assertRegexp('/<input[^>]*(type="text")/', $html); - } -} - -// Call Zend_Dojo_View_Helper_ValidationTextBoxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_ValidationTextBoxTest::main") { - Zend_Dojo_View_Helper_ValidationTextBoxTest::main(); -} diff --git a/tests/Zend/Dojo/View/Helper/VerticalSliderTest.php b/tests/Zend/Dojo/View/Helper/VerticalSliderTest.php deleted file mode 100644 index 28ad650f70060574df61166441bd49362b45f46d..0000000000000000000000000000000000000000 --- a/tests/Zend/Dojo/View/Helper/VerticalSliderTest.php +++ /dev/null @@ -1,223 +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_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: VerticalSliderTest.php 10066 2008-07-12 20:26:33Z matthew $ - */ - -// Call Zend_Dojo_View_Helper_VerticalSliderTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_VerticalSliderTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_Dojo_View_Helper_VerticalSlider */ -require_once 'Zend/Dojo/View/Helper/VerticalSlider.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Dojo_View_Helper_Dojo */ -require_once 'Zend/Dojo/View/Helper/Dojo.php'; - -/** - * Test class for Zend_Dojo_View_Helper_VerticalSlider. - * - * @package Zend_Dojo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dojo_View_Helper_VerticalSliderTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_VerticalSliderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Registry::_unsetInstance(); - Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); - - $this->view = $this->getView(); - $this->helper = new Zend_Dojo_View_Helper_VerticalSlider(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); - return $view; - } - - public function getElement() - { - return $this->helper->verticalSlider( - 'elementId', - '', - array( - 'minimum' => -10, - 'maximum' => 10, - 'discreteValues' => 11, - 'topDecoration' => array( - 'labels' => array( - ' ', - '20%', - '40%', - '60%', - '80%', - ' ', - ), - 'attribs' => array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - 'dijit' => 'VerticalRuleLabels', - ), - 'bottomDecoration' => array( - 'labels' => array( - '0%', - '50%', - '100%', - ), - 'attribs' => array( - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - ), - 'leftDecoration' => array( - 'labels' => array( - ' ', - '20%', - '40%', - '60%', - '80%', - ' ', - ), - 'attribs' => array( - 'container' => array( - 'style' => 'height:1.2em; font-size=75%;color:gray;', - ), - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - 'dijit' => 'VerticalRuleLabels', - ), - 'rightDecoration' => array( - 'labels' => array( - '0%', - '50%', - '100%', - ), - 'attribs' => array( - 'labels' => array( - 'style' => 'height:1em; font-size=75%;color:gray;', - ), - ), - ), - ), - array() - ); - } - - public function testShouldAllowDeclarativeDijitCreation() - { - $html = $this->getElement(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.form.VerticalSlider")/', $html, $html); - } - - public function testShouldAllowProgrammaticDijitCreation() - { - Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); - $html = $this->getElement(); - $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.form.VerticalSlider")/', $html); - $this->assertNotNull($this->view->dojo()->getDijit('elementId-slider')); - } - - public function testShouldCreateOnChangeAttributeByDefault() - { - $html = $this->getElement(); - $this->assertContains('onChange="dojo.byId(\'elementId\').value = arguments[0];"', $html, $html); - } - - public function testShouldCreateHiddenElementWithValue() - { - $html = $this->getElement(); - if (!preg_match('/(<input[^>]*(type="hidden")[^>]*>)/', $html, $m)) { - $this->fail('No hidden element found'); - } - $this->assertContains('id="elementId"', $m[1]); - $this->assertContains('value="', $m[1]); - } - - public function testShouldCreateLeftAndRightDecorationsWhenRequested() - { - $html = $this->getElement(); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.form.VerticalRule")/', $html, $html); - $this->assertRegexp('/<div[^>]*(dojoType="dijit.form.VerticalRuleLabels")/', $html, $html); - $this->assertContains('leftDecoration', $html); - $this->assertContains('rightDecoration', $html); - } - - public function testShouldIgnoreTopAndBottomDecorationsWhenPassed() - { - $html = $this->getElement(); - $this->assertNotContains('topDecoration', $html); - $this->assertNotContains('bottomDecoration', $html); - } -} - -// Call Zend_Dojo_View_Helper_VerticalSliderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_VerticalSliderTest::main") { - Zend_Dojo_View_Helper_VerticalSliderTest::main(); -} diff --git a/tests/Zend/Dom/AllTests.php b/tests/Zend/Dom/AllTests.php deleted file mode 100644 index 942ef90c1ae0140e394bdb28440efa709c835502..0000000000000000000000000000000000000000 --- a/tests/Zend/Dom/AllTests.php +++ /dev/null @@ -1,62 +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_Dom - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 9799 2008-06-27 01:54:36Z dasprid $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Dom_AllTests::main'); -} - -require_once 'Zend/Dom/QueryTest.php'; -require_once 'Zend/Dom/Query/Css2XpathTest.php'; - -/** - * @category Zend - * @package Zend_Dom - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Dom_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Dom'); - - $suite->addTestSuite('Zend_Dom_QueryTest'); - $suite->addTestSuite('Zend_Dom_Query_Css2XpathTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Dom_AllTests::main') { - Zend_Dom_AllTests::main(); -} diff --git a/tests/Zend/Dom/Query/Css2XpathTest.php b/tests/Zend/Dom/Query/Css2XpathTest.php deleted file mode 100644 index a7b59424a064ffc2e07230a993dd4218f6fd83f2..0000000000000000000000000000000000000000 --- a/tests/Zend/Dom/Query/Css2XpathTest.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -// Call Zend_Dom_Query_Css2XpathTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dom_Query_Css2XpathTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Dom_Query_Css2Xpath */ -require_once 'Zend/Dom/Query/Css2Xpath.php'; - -/** - * Test class for Zend_Dom_Query_Css2Xpath. - */ -class Zend_Dom_Query_Css2XpathTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dom_Query_Css2XpathTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testTransformShouldBeCalledStatically() - { - Zend_Dom_Query_Css2Xpath::transform(''); - } - - public function testTransformShouldReturnStringByDefault() - { - $test = Zend_Dom_Query_Css2Xpath::transform(''); - $this->assertTrue(is_string($test)); - } - - public function testTransformShouldReturnMultiplePathsWhenExpressionContainsCommas() - { - $test = Zend_Dom_Query_Css2Xpath::transform('#foo, #bar'); - $this->assertTrue(is_array($test)); - $this->assertEquals(2, count($test)); - } - - public function testTransformShouldRecognizeHashSymbolAsId() - { - $test = Zend_Dom_Query_Css2Xpath::transform('#foo'); - $this->assertEquals("//*[@id='foo']", $test); - } - - public function testTransformShouldRecognizeDotSymbolAsClass() - { - $test = Zend_Dom_Query_Css2Xpath::transform('.foo'); - $this->assertEquals("//*[contains(@class, ' foo ')]", $test); - } - - public function testTransformShouldAssumeSpacesToIndicateRelativeXpathQueries() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div#foo .bar'); - $this->assertContains(' | ', $test); - $expected = array( - "//div[@id='foo']//*[contains(@class, ' bar ')]", - "//div[@id='foo'][contains(@class, ' bar ')]", - ); - foreach ($expected as $path) { - $this->assertContains($path, $test); - } - } - - public function testTransformShouldWriteChildSelectorsAsAbsoluteXpathRelations() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div#foo>span'); - $this->assertEquals("//div[@id='foo']/span", $test); - } - - public function testMultipleComplexCssSpecificationShouldTransformToExpectedXpath() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div#foo span.bar, #bar li.baz a'); - $this->assertTrue(is_array($test)); - $expected = array( - "//div[@id='foo']//span[contains(@class, ' bar ')]", - "//*[@id='bar']//li[contains(@class, ' baz ')]//a", - ); - $this->assertEquals(count($expected), count($test)); - foreach ($test as $path) { - $this->assertContains($path, $expected); - } - } - - public function testClassNotationWithoutSpecifiedTagShouldResultInMultipleQueries() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div.foo .bar a .baz span'); - $this->assertContains(' | ', $test); - $segments = array( - "//div[contains(@class, ' foo ')]//*[contains(@class, ' bar ')]//a//*[contains(@class, ' baz ')]//span", - "//div[contains(@class, ' foo ')]//*[contains(@class, ' bar ')]//a[contains(@class, ' baz ')]//span", - "//div[contains(@class, ' foo ')][contains(@class, ' bar ')]//a//*[contains(@class, ' baz ')]//span", - "//div[contains(@class, ' foo ')][contains(@class, ' bar ')]//a[contains(@class, ' baz ')]//span", - ); - foreach ($segments as $xpath) { - $this->assertContains($xpath, $test); - } - } - - public function testShouldAllowEqualitySelectionOfArbitraryAttributes() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div[foo="bar"]'); - $this->assertEquals("//div[@foo='bar']", $test); - } - - public function testShouldCastAttributeNamesToLowerCase() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div[dojoType="bar"]'); - $this->assertEquals("//div[@dojotype='bar']", $test); - } - - public function testShouldAllowContentSubSelectionOfArbitraryAttributes() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div[foo~="bar"]'); - $this->assertEquals("//div[contains(@foo, ' bar ')]", $test); - } - - public function testShouldAllowContentMatchingOfArbitraryAttributes() - { - $test = Zend_Dom_Query_Css2Xpath::transform('div[foo*="bar"]'); - $this->assertEquals("//div[contains(@foo, 'bar')]", $test); - } -} - -// Call Zend_Dom_Query_Css2XpathTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dom_Query_Css2XpathTest::main") { - Zend_Dom_Query_Css2XpathTest::main(); -} diff --git a/tests/Zend/Dom/QueryTest.php b/tests/Zend/Dom/QueryTest.php deleted file mode 100644 index 4b172a2ba9e4aece2e01b3c5a10ab33ecb9fbae5..0000000000000000000000000000000000000000 --- a/tests/Zend/Dom/QueryTest.php +++ /dev/null @@ -1,188 +0,0 @@ -<?php -// Call Zend_Dom_QueryTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Dom_QueryTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Dom_Query */ -require_once 'Zend/Dom/Query.php'; - -/** - * Test class for Zend_Dom_Query. - */ -class Zend_Dom_QueryTest extends PHPUnit_Framework_TestCase -{ - public $html; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Dom_QueryTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->query = new Zend_Dom_Query(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getHtml() - { - if (null === $this->html) { - $this->html = file_get_contents(dirname(__FILE__) . '/_files/sample.xhtml'); - } - return $this->html; - } - - public function loadHtml() - { - $this->query->setDocument($this->getHtml()); - } - - public function testConstructorShouldNotRequireArguments() - { - $query = new Zend_Dom_Query(); - } - - public function testConstructorShouldAcceptDocumentString() - { - $html = $this->getHtml(); - $query = new Zend_Dom_Query($html); - $this->assertSame($html, $query->getDocument()); - } - - public function testDocShouldBeNullByDefault() - { - $this->assertNull($this->query->getDocument()); - } - - public function testDocTypeShouldBeNullByDefault() - { - $this->assertNull($this->query->getDocumentType()); - } - - public function testShouldAllowSettingDocument() - { - $this->testDocShouldBeNullByDefault(); - $this->loadHtml(); - $this->assertEquals($this->getHtml(), $this->query->getDocument()); - } - - public function testDocumentTypeShouldBeAutomaticallyDiscovered() - { - $this->loadHtml(); - $this->assertEquals(Zend_Dom_Query::DOC_XHTML, $this->query->getDocumentType()); - $this->query->setDocument('<?xml version="1.0"?><root></root>'); - $this->assertEquals(Zend_Dom_Query::DOC_XML, $this->query->getDocumentType()); - $this->query->setDocument('<html><body></body></html>'); - $this->assertEquals(Zend_Dom_Query::DOC_HTML, $this->query->getDocumentType()); - } - - public function testQueryingWithoutRegisteringDocumentShouldThrowException() - { - try { - $this->query->query('.foo'); - $this->fail('Querying without registering document should throw exception'); - } catch (Zend_Dom_Exception $e) { - $this->assertContains('no document', $e->getMessage()); - } - } - - public function testQueryingInvalidDocumentShouldThrowException() - { - $this->query->setDocumentXml('some bogus string'); - try { - $this->query->query('.foo'); - $this->fail('Querying invalid document should throw exception'); - } catch (Zend_Dom_Exception $e) { - $this->assertContains('Error parsing', $e->getMessage()); - } - } - - public function testQueryShouldReturnResultObject() - { - $this->loadHtml(); - $test = $this->query->query('.foo'); - $this->assertTrue($test instanceof Zend_Dom_Query_Result); - } - - public function testResultShouldIndicateNumberOfFoundNodes() - { - $this->loadHtml(); - $result = $this->query->query('.foo'); - $message = 'Xpath: ' . $result->getXpathQuery() . "\n"; - $this->assertEquals(3, count($result), $message); - } - - public function testResultShouldAllowIteratingOverFoundNodes() - { - $this->loadHtml(); - $result = $this->query->query('.foo'); - $this->assertEquals(3, count($result)); - foreach ($result as $node) { - $this->assertTrue($node instanceof DOMNode, var_export($result, 1)); - } - } - - public function testQueryShouldFindNodesWithMultipleClasses() - { - $this->loadHtml(); - $result = $this->query->query('.footerblock .last'); - $this->assertEquals(1, count($result), $result->getXpathQuery()); - } - - public function testQueryShouldFindNodesWithArbitraryAttributeSelectorsExactly() - { - $this->loadHtml(); - $result = $this->query->query('div[dojoType="FilteringSelect"]'); - $this->assertEquals(1, count($result), $result->getXpathQuery()); - } - - public function testQueryShouldFindNodesWithArbitraryAttributeSelectorsAsDiscreteWords() - { - $this->loadHtml(); - $result = $this->query->query('li[dojoType~="bar"]'); - $this->assertEquals(2, count($result), $result->getXpathQuery()); - } - - public function testQueryShouldFindNodesWithArbitraryAttributeSelectorsAndAttributeValue() - { - $this->loadHtml(); - $result = $this->query->query('li[dojoType*="bar"]'); - $this->assertEquals(2, count($result), $result->getXpathQuery()); - } - - public function testQueryXpathShouldAllowQueryingArbitraryUsingXpath() - { - $this->loadHtml(); - $result = $this->query->queryXpath('//li[contains(@dojotype, "bar")]'); - $this->assertEquals(2, count($result), $result->getXpathQuery()); - } -} - -// Call Zend_Dom_QueryTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Dom_QueryTest::main") { - Zend_Dom_QueryTest::main(); -} diff --git a/tests/Zend/Dom/_files/sample.xhtml b/tests/Zend/Dom/_files/sample.xhtml deleted file mode 100644 index c250c54ed03448fc16d2a7f498f2e1474d176816..0000000000000000000000000000000000000000 --- a/tests/Zend/Dom/_files/sample.xhtml +++ /dev/null @@ -1,125 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> -<head> - <title>Sample HTML Content for DOM Queries</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -</head> -<body> - <div id="header"> - <h1> - <a href="#"><img src="img/icon.png" class="right" alt="Logo" - height="79" width="80" border="0" /></a> - Page Title<br /> - <span class="subtitle">SubTitle</span> - </h1> - </div> - - <ul id="topnav"> - <li class="current"><a href="#">Home</a></li> - <li><a href="#">About</a></li> - <li><a href="#">Misc</a></li> - <li><a href="#">Wiki</a></li> - </ul> - - <div id="main"> - <div id="content"> - <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed at dui quis magna - viverra sagittis. Donec sed nibh ut pede pretium ultricies. Mauris viverra - tempus dui. Donec dolor risus, mollis sed, pulvinar id, faucibus ac, nisl. Duis - eu erat at erat tempus euismod. Suspendisse sodales lacus vitae libero. Sed - suscipit commodo enim. Pellentesque erat. Cras orci. Pellentesque non nunc. Cras - diam libero, feugiat vel, accumsan et, laoreet mattis, purus. Pellentesque - volutpat hendrerit justo. Cras vehicula. Vestibulum cursus gravida est. - Curabitur pede. Mauris consectetuer rutrum dolor. Ut a turpis ac metus - sollicitudin dignissim.</p> - - <p>Praesent blandit, nisi in egestas mattis, lectus tortor vehicula massa, commodo - vehicula diam lacus consequat lectus. In vitae pede eget leo faucibus - condimentum. Pellentesque nisi. Ut condimentum elit vitae mi. Morbi neque erat, - mollis nec, volutpat sed, placerat sit amet, ligula. Morbi eleifend. Morbi - auctor condimentum ipsum. In ac purus. Sed vitae magna. Sed volutpat vestibulum - leo. Phasellus id nibh.</p> - - <p>Fusce blandit elementum leo. Proin id erat. In dignissim orci vulputate libero - cursus volutpat. Ut vitae arcu non nulla sagittis laoreet. Suspendisse sed - tortor ac risus placerat convallis. Donec nulla ipsum, tempus et, porttitor - quis, blandit vel, tortor. Donec condimentum. Aliquam felis dui, consectetuer - ultricies, euismod eu, pretium non, sem. Sed ultricies, tortor non vulputate - tempor, urna leo sagittis libero, ut feugiat nulla tellus et ligula. Suspendisse - eget est. Vestibulum interdum mi at felis. Fusce dictum. Fusce a enim at ipsum - consectetuer molestie. Integer rhoncus. Cum sociis natoque penatibus et magnis - dis parturient montes, nascetur ridiculus mus. Donec rhoncus mattis arcu.</p> - - <p>Proin id nisi. Vivamus eu risus. Vivamus et enim et turpis volutpat bibendum. - Nunc nunc ipsum, semper sit amet, pellentesque in, venenatis sit amet, elit. - Suspendisse potenti. Cras lacinia, nisl vel vulputate pellentesque, lacus tellus - lobortis ipsum, sed pellentesque neque felis ac orci. Sed pellentesque. - Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac - turpis egestas. Etiam lacus enim, facilisis eu, suscipit ac, condimentum ut, - ante. Aenean convallis mattis enim. Aliquam pretium. Etiam quam. Donec - tincidunt. Pellentesque id ante ut orci gravida semper. Cum sociis natoque - penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce - bibendum elit vel sem cursus ultrices. Nunc in purus. Ut consectetuer, nulla ac - porta hendrerit, ligula eros blandit nulla, at ornare dui odio vel justo. Morbi - tellus nulla, sodales eget, aliquet ac, varius vitae, pede. Pellentesque - habitant morbi tristique senectus et netus et malesuada fames ac turpis - egestas.</p> - - <p>Vestibulum urna. Proin hendrerit neque et tellus. Duis luctus congue sem. - Aliquam ultricies orci nec enim. Nam velit eros, feugiat posuere, ultricies - vitae, consequat nec, urna. In ipsum neque, porta sed, ornare nec, cursus et, - mauris. Nam eget urna. Suspendisse venenatis nulla nec urna lacinia bibendum. - Morbi tempor lobortis nisl. Nulla ut eros. Fusce id tortor ut diam vulputate - consectetuer. Nulla vel augue. Nulla ac tellus sed orci pulvinar dictum. Proin - lobortis. Fusce consequat auctor ante. Donec bibendum fringilla nunc. Donec - viverra, urna ac auctor dapibus, augue ipsum tristique lacus, sed feugiat nibh - nibh quis purus. Donec orci est, pharetra laoreet, laoreet id, mattis ut, odio. - In lacus sem, rutrum tristique, dignissim ac, imperdiet ac, lacus. </p> - </div> - - <div id="subnav"> - <div class="navblock"> - <form action="/login" method="post"> - Username:<br /> - <input name="username" id="username" type="text" value="" /><br /> - Password:<br /> - <input name="password" id="password" type="password" value="" /><br /> - <input name="login" id="login" type="submit" value="Login" /> - </form> - </div> - - <div class="navblock" dojoType="FilteringSelect"> - <ul> - <li class="foo" dojoType="foo bar">Item 1</li> - <li class="foo current">Item 2</li> - <li class="foo" dojoType="foo bar">Item 3</li> - </ul> - </div> - </div> - </div> - - <div id="footer"> - <div class="footerblock first"> - <p class="attribution"> - © 2008 - present, <br /> - Zend Framework - </p> - <a href="/about">About</a><br /> - <a href="/contact">Contact</a><br /> - </div> - - <div class="footerblock last"> - <h4>More:</h4> - <ul> - <li>Ohloh profile</li> - <li>Facebook</li> - <li>Plaxo Pulse</li> - <li>LinkedIn</li> - <li>del.icious</li> - <li>Twitter</li> - <li>SlideShare</li> - </ul> - </div> - </div> -</body> -</html> diff --git a/tests/Zend/Feed/AllTests.php b/tests/Zend/Feed/AllTests.php deleted file mode 100644 index ccc884c543395db81a7f389b397d8995191601bd..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/AllTests.php +++ /dev/null @@ -1,83 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Feed_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -require_once 'Zend/Feed/ArrayAccessTest.php'; -require_once 'Zend/Feed/AtomEntryOnlyTest.php'; -require_once 'Zend/Feed/AtomPublishingTest.php'; -require_once 'Zend/Feed/CountTest.php'; -require_once 'Zend/Feed/ElementTest.php'; -require_once 'Zend/Feed/ImportTest.php'; -require_once 'Zend/Feed/IteratorTest.php'; -require_once 'Zend/Feed/Entry/RssTest.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Feed'); - - $suite->addTestSuite('Zend_Feed_ArrayAccessTest'); - $suite->addTestSuite('Zend_Feed_AtomEntryOnlyTest'); - $suite->addTestSuite('Zend_Feed_AtomPublishingTest'); - $suite->addTestSuite('Zend_Feed_CountTest'); - $suite->addTestSuite('Zend_Feed_ElementTest'); - $suite->addTestSuite('Zend_Feed_ImportTest'); - $suite->addTestSuite('Zend_Feed_IteratorTest'); - $suite->addTestSuite('Zend_Feed_Entry_RssTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Feed_AllTests::main') { - Zend_Feed_AllTests::main(); -} diff --git a/tests/Zend/Feed/ArrayAccessTest.php b/tests/Zend/Feed/ArrayAccessTest.php deleted file mode 100644 index 752f54291778825b4b75a34556003be6130def13..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/ArrayAccessTest.php +++ /dev/null @@ -1,99 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ArrayAccessTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - - -/** - * @see Zend_Feed - */ -require_once 'Zend/Feed.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_ArrayAccessTest extends PHPUnit_Framework_TestCase -{ - protected $_feed; - protected $_nsfeed; - - public function setUp() - { - $this->_feed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeed.xml'); - $this->_nsfeed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeedNamespaced.xml'); - } - - public function testExists() - { - $this->assertFalse(isset($this->_feed[-1]), 'Negative array access should fail'); - $this->assertTrue(isset($this->_feed['version']), 'Feed version should be set'); - - $this->assertFalse(isset($this->_nsfeed[-1]), 'Negative array access should fail'); - $this->assertTrue(isset($this->_nsfeed['version']), 'Feed version should be set'); - } - - public function testGet() - { - $this->assertEquals($this->_feed['version'], '1.0', 'Feed version should be 1.0'); - $this->assertEquals($this->_nsfeed['version'], '1.0', 'Feed version should be 1.0'); - } - - public function testSet() - { - $this->_feed['category'] = 'tests'; - $this->assertTrue(isset($this->_feed['category']), 'Feed category should be set'); - $this->assertEquals($this->_feed['category'], 'tests', 'Feed category should be tests'); - - $this->_nsfeed['atom:category'] = 'tests'; - $this->assertTrue(isset($this->_nsfeed['atom:category']), 'Feed category should be set'); - $this->assertEquals($this->_nsfeed['atom:category'], 'tests', 'Feed category should be tests'); - - // Changing an existing index. - $oldEntry = $this->_feed['version']; - $this->_feed['version'] = '1.1'; - $this->assertTrue($oldEntry != $this->_feed['version'], 'Version should have changed'); - } - - public function testUnset() - { - $feed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeed.xml'); - unset($feed['version']); - $this->assertFalse(isset($feed['version']), 'Version should be unset'); - $this->assertEquals('', $feed['version'], 'Version should be equal to the empty string'); - - $nsfeed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeedNamespaced.xml'); - unset($nsfeed['version']); - $this->assertFalse(isset($nsfeed['version']), 'Version should be unset'); - $this->assertEquals('', $nsfeed['version'], 'Version should be equal to the empty string'); - } - -} diff --git a/tests/Zend/Feed/AtomEntryOnlyTest.php b/tests/Zend/Feed/AtomEntryOnlyTest.php deleted file mode 100644 index 7e5100b17a434d8ee766c5dd97268580deafcb36..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/AtomEntryOnlyTest.php +++ /dev/null @@ -1,65 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AtomEntryOnlyTest.php 10317 2008-07-23 19:15:34Z matthew $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Feed - */ -require_once 'Zend/Feed.php'; - -/** - * @see Zend_Feed_Atom - */ -require_once 'Zend/Feed/Atom.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_AtomEntryOnlyTest extends PHPUnit_Framework_TestCase -{ - - public function testEntryOnly() - { - $feed = new Zend_Feed_Atom(null, file_get_contents(dirname(__FILE__) . '/_files/TestAtomFeedEntryOnly.xml')); - - $this->assertEquals(1, $feed->count(), 'The entry-only feed should report one entry.'); - - foreach ($feed as $entry); - $this->assertEquals('Zend_Feed_Entry_Atom', get_class($entry), - 'The single entry should be an instance of Zend_Feed_Entry_Atom'); - - $this->assertEquals('1', $entry->id(), 'The single entry should have id 1'); - $this->assertEquals('Bug', $entry->title(), 'The entry\'s title should be "Bug"'); - } - -} diff --git a/tests/Zend/Feed/AtomPublishingTest.php b/tests/Zend/Feed/AtomPublishingTest.php deleted file mode 100644 index 92e0398acbdbbaa9c0aca5741f90f242451e7b95..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/AtomPublishingTest.php +++ /dev/null @@ -1,148 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AtomPublishingTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Feed_Entry_Atom - */ -require_once 'Zend/Feed/Entry/Atom.php'; - -/** - * @see Zend_Http_Client_File - */ -require_once 'Zend/Http/Client.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_AtomPublishingTest extends PHPUnit_Framework_TestCase -{ - protected $_uri; - - public function setUp() - { - $this->_uri = 'http://fubar.com/myFeed'; - } - - public function tearDown() - { - Zend_Feed::setHttpClient(new Zend_Http_Client()); - } - - public function testPost() - { - Zend_Feed::setHttpClient(new TestClient()); - - $entry = new Zend_Feed_Entry_Atom(); - - /* Give the entry its initial values. */ - $entry->title = 'Entry 1'; - $entry->content = '1.1'; - $entry->content['type'] = 'text'; - - /* Do the initial post. The base feed URI is the same as the - * POST URI, so just supply save() with that. */ - $entry->save($this->_uri); - - /* $entry will be filled in with any elements returned by the - * server (id, updated, link rel="edit", etc). */ - $this->assertEquals('1', $entry->id(), 'Expected id to be 1'); - $this->assertEquals('Entry 1', $entry->title(), 'Expected title to be "Entry 1"'); - $this->assertEquals('1.1', $entry->content(), 'Expected content to be "1.1"'); - $this->assertEquals('text', $entry->content['type'], 'Expected content/type to be "text"'); - $this->assertEquals('2005-05-23T16:26:00-08:00', $entry->updated(), 'Expected updated date of 2005-05-23T16:26:00-08:00'); - $this->assertEquals('http://fubar.com/myFeed/1/1/', $entry->link('edit'), 'Expected edit URI of http://fubar.com/myFeed/1/1/'); - } - - public function testEdit() - { - Zend_Feed::setHttpClient(new TestClient()); - $contents = file_get_contents(dirname(__FILE__) . '/_files/AtomPublishingTest-before-update.xml'); - - /* The base feed URI is the same as the POST URI, so just supply the - * Zend_Feed_Entry_Atom object with that. */ - $entry = new Zend_Feed_Entry_Atom($this->_uri, $contents); - - /* Initial state. */ - $this->assertEquals('2005-05-23T16:26:00-08:00', $entry->updated(), 'Initial state of updated timestamp does not match'); - $this->assertEquals('http://fubar.com/myFeed/1/1/', $entry->link('edit'), 'Initial state of edit link does not match'); - - /* Just change the entry's properties directly. */ - $entry->content = '1.2'; - - /* Then save the changes. */ - $entry->save(); - - /* New state. */ - $this->assertEquals('1.2', $entry->content(), 'Content change did not stick'); - $this->assertEquals('2005-05-23T16:27:00-08:00', $entry->updated(), 'New updated link is not correct'); - $this->assertEquals('http://fubar.com/myFeed/1/2/', $entry->link('edit'), 'New edit link is not correct'); - } -} - -/** - * A test wrapper around Zend_Http_Client, not actually performing - * the request. - * - */ -class TestClient extends Zend_Http_Client -{ - public function request($method = null) - { - $code = 400; - $body = ''; - - switch ($method) { - case self::POST: - $code = 201; - $body = file_get_contents(dirname(__FILE__) . '/_files/AtomPublishingTest-created-entry.xml'); - break; - - case self::PUT: - $doc1 = new DOMDocument(); - $doc1->load(dirname(__FILE__) . '/_files/AtomPublishingTest-expected-update.xml'); - $doc2 = new DOMDocument(); - $doc2->loadXML($this->raw_post_data); - if ($doc1->saveXml() == $doc2->saveXml()) { - $code = 200; - $body = file_get_contents(dirname(__FILE__) . '/_files/AtomPublishingTest-updated-entry.xml'); - } - break; - - default: - break; - } - - return new Zend_Http_Response($code, array(), $body); - } -} diff --git a/tests/Zend/Feed/CountTest.php b/tests/Zend/Feed/CountTest.php deleted file mode 100644 index e553086677b08b8b8be920d98b47d6b22bc5c572..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/CountTest.php +++ /dev/null @@ -1,52 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CountTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Feed - */ -require_once 'Zend/Feed.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_CountTest extends PHPUnit_Framework_TestCase -{ - - public function testCount() - { - $f = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeed.xml'); - $this->assertEquals($f->count(), 2, 'Feed count should be 2'); - } - -} diff --git a/tests/Zend/Feed/ElementTest.php b/tests/Zend/Feed/ElementTest.php deleted file mode 100644 index b722b6277a5aa12360c1c95da0bf036f4baf9106..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/ElementTest.php +++ /dev/null @@ -1,92 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ElementTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Feed_Entry_Atom - */ -require_once 'Zend/Feed/Entry/Atom.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_ElementTest extends PHPUnit_Framework_TestCase -{ - - public function testIsInitialized() - { - $e = new Zend_Feed_Entry_Atom(); - $e->author->name['last'] = 'hagenbuch'; - $e->author->name['first'] = 'chuck'; - $e->author->name->{'chuck:url'} = 'marina.horde.org'; - - $e->author->title['foo'] = 'bar'; - if ($e->pants()) { - $this->fail('<pants> does not exist, it should not have a true value'); - // This should not create an element in the actual tree. - } - if ($e->pants()) { - $this->fail('<pants> should not have been created by testing for it'); - // This should not create an element in the actual tree. - } - - $xml = $e->saveXml(); - - $this->assertFalse(strpos($xml, 'pants'), '<pants> should not be in the xml output'); - $this->assertTrue(strpos($xml, 'marina.horde.org') !== false, 'the url attribute should be set'); - } - - public function testStrings() - { - $xml = "<entry> - <title> Using C++ Intrinsic Functions for Pipelined Text Processing</title> - <id>http://www.oreillynet.com/pub/wlg/8356</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/8356'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - A good C++ programming technique that has almost no published material available on the WWW relates to using the special pipeline instructions in modern CPUs for faster text processing. Here's example code using C++ intrinsic functions to give a fourfold speed increase for a UTF-8 to UTF-16 converter compared to the original C/C++ code. - </div> - </summary> - <author><name>Rick Jelliffe</name></author> - <updated>2005-11-07T08:15:57-08:00</updated> -</entry>"; - - $entry = new Zend_Feed_Entry_Atom('uri', $xml); - - $this->assertTrue($entry->summary instanceof Zend_Feed_Element, '__get access should return an Zend_Feed_Element instance'); - $this->assertFalse($entry->summary() instanceof Zend_Feed_Element, 'method access should not return an Zend_Feed_Element instance'); - $this->assertTrue(is_string($entry->summary()), 'method access should return a string'); - $this->assertFalse(is_string($entry->summary), '__get access should not return a string'); - } - -} diff --git a/tests/Zend/Feed/Entry/RssTest.php b/tests/Zend/Feed/Entry/RssTest.php deleted file mode 100644 index 9ea0067df3a42451a3706b28012e6c5391d811e5..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/Entry/RssTest.php +++ /dev/null @@ -1,80 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AtomEntryOnlyTest.php 7832 2008-02-06 23:42:34Z weppos $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Feed - */ -require_once 'Zend/Feed.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_Entry_RssTest extends PHPUnit_Framework_TestCase -{ - - public function testContentEncodedSupport() - { - $feed = Zend_Feed::importFile(dirname(__FILE__) . '/../_files/TestFeedEntryRssContentEncoded.xml'); - $this->assertType('Zend_Feed_Rss', $feed); - - $item = $feed->current(); - $this->assertType('Zend_Feed_Entry_Rss', $item); - - $this->assertTrue(isset($item->content)); - $this->assertContains( - 'http://framework.zend.com/fisheye/changelog/Zend_Framework/?cs=7757', - $item->content->__toString() - ); - $this->assertContains( - 'http://framework.zend.com/fisheye/changelog/Zend_Framework/?cs=7757', - $item->content() - ); - $item->content = 'foo'; - $this->assertEquals('foo', $item->content->__toString()); - } - - public function testContentEncodedNullIfEmpty() - { - $feed = Zend_Feed::importFile(dirname(__FILE__) . '/../_files/TestFeedEntryRssContentEncoded.xml'); - $this->assertType('Zend_Feed_Rss', $feed); - - $feed->next(); - $item = $feed->current(); - $this->assertType('Zend_Feed_Entry_Rss', $item); - $this->assertFalse(isset($item->content)); - $this->assertNull($item->content()); - // $this->assertNull($item->content); // always return DOMElement Object - } - -} diff --git a/tests/Zend/Feed/ImportTest.php b/tests/Zend/Feed/ImportTest.php deleted file mode 100644 index 825c202d6e27afbb8d5ad13ad1ed984a7904c284..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/ImportTest.php +++ /dev/null @@ -1,443 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ImportTest.php 8649 2008-03-07 19:49:02Z darby $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Feed - */ -require_once 'Zend/Feed.php'; - -/** - * @see Zend_Feed_Builder - */ -require_once 'Zend/Feed/Builder.php'; - -/** - * @see Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @see Zend_Http_Client - */ -require_once 'Zend/Http/Client.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_ImportTest extends PHPUnit_Framework_TestCase -{ - protected $_client; - protected $_feedDir; - - /** - * HTTP client test adapter - * - * @var Zend_Http_Client_Adapter_Test - */ - protected $_adapter; - - public function setUp() - { - $this->_adapter = new Zend_Http_Client_Adapter_Test(); - Zend_Feed::setHttpClient(new Zend_Http_Client(null, array('adapter' => $this->_adapter))); - $this->_client = Zend_Feed::getHttpClient(); - $this->_feedDir = dirname(__FILE__) . '/_files'; - } - - /** - * Test an atom feed generated by google's Blogger platform - */ - public function testAtomGoogle() - { - $this->_importAtomValid('AtomTestGoogle.xml'); - } - - /** - * Test an atom feed generated by mozillaZine.org - */ - public function testAtomMozillazine() - { - $this->_importAtomValid('AtomTestMozillazine.xml'); - } - - /** - * Test an atom feed generated by O'Reilly - */ - public function testAtomOReilly() - { - $this->_importAtomValid('AtomTestOReilly.xml'); - } - - /** - * Test an atom feed generated by PlanetPHP - */ - public function testAtomPlanetPHP() - { - $this->_importAtomValid('AtomTestPlanetPHP.xml'); - } - - /** - * Test a small atom feed - */ - public function testAtomSample1() - { - $this->_importAtomValid('AtomTestSample1.xml'); - } - - /** - * Test a small atom feed without any entries - */ - public function testAtomSample2() - { - $this->_importAtomValid('AtomTestSample2.xml'); - } - - /** - * Test an atom feed with a </entry> tag missing - */ - public function testAtomSample3() - { - $this->_importInvalid('AtomTestSample3.xml'); - } - - /** - * Test an atom feed with links within entries - */ - public function testAtomSample4() - { - $this->_importAtomValid('AtomTestSample4.xml'); - } - - /** - * Test a RSS feed generated by UserLand Frontier v9.5 - */ - public function testRssHarvardLaw() - { - $this->_importRssValid('RssTestHarvardLaw.xml'); - } - - /** - * Test a RSS feed generated by PlanetPHP - */ - public function testRssPlanetPHP() - { - $this->_importRssValid('RssTestPlanetPHP.xml'); - } - - /** - * Test a RSS feed generated by Slashdot - */ - public function testRssSlashdot() - { - $this->_importRssValid('RssTestSlashdot.xml'); - } - - /** - * Test a RSS feed generated by CNN - */ - public function testRssCNN() - { - $this->_importRssValid('RssTestCNN.xml'); - } - - /** - * Test a valid RSS 0.91 sample - */ - public function testRss091Sample1() - { - $this->_importRssValid('RssTest091Sample1.xml'); - } - - /** - * Test a valid RSS 0.91 sample - */ - public function testRss092Sample1() - { - $this->_importRssValid('RssTest092Sample1.xml'); - } - - /** - * Test a valid RSS 1.0 sample - */ - public function testRss100Sample1() - { - $this->_importRssValid('RssTest100Sample1.xml'); - } - - /** - * Test a valid RSS 1.0 sample with some extensions in it - */ - public function testRss100Sample2() - { - $this->_importRssValid('RssTest100Sample2.xml'); - } - - /** - * Test a valid RSS 2.0 sample - */ - public function testRss200Sample1() - { - $this->_importRssValid('RssTest200Sample1.xml'); - } - - /** - * Test the import of a RSS feed from an array - */ - public function testRssImportFullArray() - { - $feed = Zend_Feed::importArray($this->_getFullArray(), 'rss'); - $this->assertType('Zend_Feed_Rss', $feed); - } - - /** - * Test the import of a RSS feed from an array - */ - public function testAtomImportFullArray() - { - $feed = Zend_Feed::importArray($this->_getFullArray(), 'atom'); - } - - /** - * Test the import of a RSS feed from a builder - */ - public function testRssImportFullBuilder() - { - $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'rss'); - $this->assertType('Zend_Feed_Rss', $feed); - } - - /** - * Test the import of a full iTunes RSS feed from a builder - */ - public function testRssImportFulliTunesBuilder() - { - $array = $this->_getFullArray(); - $array['itunes']['author'] = 'iTunes Author'; - $array['itunes']['owner'] = array('name' => 'iTunes Owner', - 'email' => 'itunes@example.com'); - $array['itunes']['image'] = 'http://www.example/itunes.png'; - $array['itunes']['subtitle'] = 'iTunes subtitle'; - $array['itunes']['summary'] = 'iTunes summary'; - $array['itunes']['explicit'] = 'clean'; - $array['itunes']['block'] = 'no'; - $array['itunes']['new-feed-url'] = 'http://www.example/itunes.xml'; - $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($array), 'rss'); - $this->assertType('Zend_Feed_Rss', $feed); - } - - /** - * Test the import of an Atom feed from a builder - */ - public function testAtomImportFullBuilder() - { - $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'atom'); - - } - - /** - * Test the import of an Atom feed from a builder - */ - public function testAtomImportFullBuilderValid() - { - $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'atom'); - - $feed = Zend_Feed::importString($feed->saveXml()); - $this->assertType('Zend_Feed_Atom', $feed); - } - - /** - * Check the validity of the builder import (rss) - */ - public function testRssImportFullBuilderValid() - { - $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'rss'); - $this->assertType('Zend_Feed_Rss', $feed); - $feed = Zend_Feed::importString($feed->saveXml()); - $this->assertType('Zend_Feed_Rss', $feed); - } - - /** - * Test the return of a link() call (atom) - */ - public function testAtomGetLink() - { - $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($this->_getFullArray()), 'atom'); - $this->assertType('Zend_Feed_Atom', $feed); - $feed = Zend_Feed::importString($feed->saveXml()); - $this->assertType('Zend_Feed_Atom', $feed); - $href = $feed->link('self'); - $this->assertEquals('http://www.example.com', $href); - } - - /** - * Imports an invalid feed and ensure everything works as expected - * even if XDebug is running (ZF-2590). - */ - public function testImportInvalidIsXdebugAware() - { - if (!function_exists('xdebug_is_enabled')) { - $this->markTestIncomplete('XDebug not installed'); - } - - $response = new Zend_Http_Response(200, array(), ''); - $this->_adapter->setResponse($response); - - try { - $feed = Zend_Feed::import('http://localhost'); - $this->fail('Expected Zend_Feed_Exception not thrown'); - } catch (Zend_Feed_Exception $e) { - $this->assertType('Zend_Feed_Exception', $e); - $this->assertRegExp('/(XDebug is running|Empty string)/', $e->getMessage()); - } - } - - /** - * Returns the array used by Zend_Feed::importArray - * and Zend_Feed::importBuilder tests - * - * @return array - */ - protected function _getFullArray() - { - $array = array('title' => 'Title of the feed', - 'link' => 'http://www.example.com', - 'description' => 'Description of the feed', - 'author' => 'Olivier Sirven', - 'email' => 'olivier@elma.fr', - 'webmaster' => 'olivier@elma.fr', - 'charset' => 'iso-8859-15', - 'lastUpdate' => time(), - 'published' => strtotime('2007-02-27'), - 'copyright' => 'Common Creative', - 'image' => 'http://www.example/images/icon.png', - 'language' => 'en', - 'ttl' => 60, - 'rating' => ' (PICS-1.1 "http://www.gcf.org/v2.5" labels - on "1994.11.05T08:15-0500" - exp "1995.12.31T23:59-0000" - for "http://www.greatdocs.com/foo.html" - by "George Sanderson, Jr." - ratings (suds 0.5 density 0 color/hue 1))', - 'cloud' => array('domain' => 'rpc.sys.com', - 'path' => '/rpc', - 'registerProcedure' => 'webServices.pingMe', - 'protocol' => 'xml-rpc'), - 'textInput' => array('title' => 'subscribe', - 'description' => 'enter your email address to subscribe by mail', - 'name' => 'email', - 'link' => 'http://www.example.com/subscribe'), - 'skipHours' => array(1, 13, 17), - 'skipDays' => array('Saturday', 'Sunday'), - 'itunes' => array('block' => 'no', - 'keywords' => 'example,itunes,podcast', - 'category' => array(array('main' => 'Technology', - 'sub' => 'Gadgets'), - array('main' => 'Music'))), - 'entries' => array(array('guid' => time(), - 'title' => 'First article', - 'link' => 'http://www.example.com', - 'description' => 'First article description', - 'content' => 'First article <strong>content</strong>', - 'lastUpdate' => time(), - 'comments' => 'http://www.example.com/#comments', - 'commentRss' => 'http://www.example.com/comments.xml', - 'source' => array('title' => 'Original title', - 'url' => 'http://www.domain.com'), - 'category' => array(array('term' => 'test category', - 'scheme' => 'http://www.example.com/scheme'), - array('term' => 'another category') - ), - 'enclosure' => array(array('url' => 'http://www.example.com/podcast.mp3', - 'type' => 'audio/mpeg', - 'length' => '12216320' - ), - array('url' => 'http://www.example.com/podcast2.mp3', - 'type' => 'audio/mpeg', - 'length' => '1221632' - ) - ) - ), - array('title' => 'Second article', - 'link' => 'http://www.example.com/two', - 'description' => 'Second article description', - 'content' => 'Second article <strong>content</strong>', - 'lastUpdate' => time(), - 'comments' => 'http://www.example.com/two/#comments', - 'category' => array(array('term' => 'test category')), - ) - ) - ); - return $array; - } - - /** - * Import an invalid atom feed - */ - protected function _importAtomValid($filename) - { - $response = new Zend_Http_Response(200, array(), file_get_contents("$this->_feedDir/$filename")); - $this->_adapter->setResponse($response); - - $feed = Zend_Feed::import('http://localhost'); - $this->assertType('Zend_Feed_Atom', $feed); - } - - /** - * Import a valid rss feed - */ - protected function _importRssValid($filename) - { - $response = new Zend_Http_Response(200, array(), file_get_contents("$this->_feedDir/$filename")); - $this->_adapter->setResponse($response); - - $feed = Zend_Feed::import('http://localhost'); - $this->assertType('Zend_Feed_Rss', $feed); - } - - /** - * Imports an invalid feed - */ - protected function _importInvalid($filename) - { - $response = new Zend_Http_Response(200, array(), file_get_contents("$this->_feedDir/$filename")); - $this->_adapter->setResponse($response); - - try { - $feed = Zend_Feed::import('http://localhost'); - $this->fail('Expected Zend_Feed_Exception not thrown'); - } catch (Zend_Feed_Exception $e) { - $this->assertType('Zend_Feed_Exception', $e); - } - } -} diff --git a/tests/Zend/Feed/IteratorTest.php b/tests/Zend/Feed/IteratorTest.php deleted file mode 100644 index c18be12d935a647b372634896ba3ffc3391f40d5..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/IteratorTest.php +++ /dev/null @@ -1,124 +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-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IteratorTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Feed - */ -require_once 'Zend/Feed.php'; - - -/** - * @category Zend - * @package Zend_Feed - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Feed_IteratorTest extends PHPUnit_Framework_TestCase -{ - private $_feed; - private $_nsfeed; - - public function setUp() - { - $this->_feed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeed.xml'); - $this->_nsfeed = Zend_Feed::importFile(dirname(__FILE__) . '/_files/TestAtomFeedNamespaced.xml'); - } - - public function testRewind() - { - $times = 0; - foreach ($this->_feed as $f) { - ++$times; - } - - $times2 = 0; - foreach ($this->_feed as $f) { - ++$times2; - } - - $this->assertEquals($times, $times2, 'Feed should have the same number of iterations multiple times through'); - - $times = 0; - foreach ($this->_nsfeed as $f) { - ++$times; - } - - $times2 = 0; - foreach ($this->_nsfeed as $f) { - ++$times2; - } - - $this->assertEquals($times, $times2, 'Feed should have the same number of iterations multiple times through'); - } - - public function testCurrent() - { - foreach ($this->_feed as $f) { - $this->assertType('Zend_Feed_Entry_Atom', $f, 'Each feed entry should be an instance of Zend_Feed_Entry_Atom'); - break; - } - - foreach ($this->_nsfeed as $f) { - $this->assertType('Zend_Feed_Entry_Atom', $f, 'Each feed entry should be an instance of Zend_Feed_Entry_Atom'); - break; - } - } - - public function testKey() - { - $keys = array(); - foreach ($this->_feed as $k => $f) { - $keys[] = $k; - } - $this->assertEquals($keys, array(0, 1), 'Feed should have keys 0 and 1'); - - $keys = array(); - foreach ($this->_nsfeed as $k => $f) { - $keys[] = $k; - } - $this->assertEquals($keys, array(0, 1), 'Feed should have keys 0 and 1'); - } - - public function testNext() - { - $last = null; - foreach ($this->_feed as $current) { - $this->assertFalse($last === $current, 'Iteration should produce a new object each entry'); - $last = $current; - } - - $last = null; - foreach ($this->_nsfeed as $current) { - $this->assertFalse($last === $current, 'Iteration should produce a new object each entry'); - $last = $current; - } - } - -} diff --git a/tests/Zend/Feed/_files/AtomPublishingTest-before-update.xml b/tests/Zend/Feed/_files/AtomPublishingTest-before-update.xml deleted file mode 100644 index cd6591d5b42fcc0c5486a7c8ce54044723983081..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomPublishingTest-before-update.xml +++ /dev/null @@ -1,7 +0,0 @@ -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> - <atom:id>1</atom:id> - <atom:link rel="edit" href="http://fubar.com/myFeed/1/1/"/> - <atom:updated>2005-05-23T16:26:00-08:00</atom:updated> - <atom:title type="text">Entry 1</atom:title> - <atom:content type="text">1.2</atom:content> -</atom:entry> diff --git a/tests/Zend/Feed/_files/AtomPublishingTest-created-entry.xml b/tests/Zend/Feed/_files/AtomPublishingTest-created-entry.xml deleted file mode 100644 index e8e8e8103ad8c3d9f63246d606d9249c70caeb5b..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomPublishingTest-created-entry.xml +++ /dev/null @@ -1,15 +0,0 @@ -<!-- -POST /myFeed - <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> - <atom:title type="text">Entry 1</atom:title> - <atom:content type="text">1.1</atom:content> - </atom:entry> - 201 CREATED ---> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> - <atom:id>1</atom:id> - <atom:link rel="edit" href="http://fubar.com/myFeed/1/1/"/> - <atom:updated>2005-05-23T16:26:00-08:00</atom:updated> - <atom:title type="text">Entry 1</atom:title> - <atom:content type="text">1.1</atom:content> -</atom:entry> diff --git a/tests/Zend/Feed/_files/AtomPublishingTest-expected-update.xml b/tests/Zend/Feed/_files/AtomPublishingTest-expected-update.xml deleted file mode 100644 index cd6591d5b42fcc0c5486a7c8ce54044723983081..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomPublishingTest-expected-update.xml +++ /dev/null @@ -1,7 +0,0 @@ -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> - <atom:id>1</atom:id> - <atom:link rel="edit" href="http://fubar.com/myFeed/1/1/"/> - <atom:updated>2005-05-23T16:26:00-08:00</atom:updated> - <atom:title type="text">Entry 1</atom:title> - <atom:content type="text">1.2</atom:content> -</atom:entry> diff --git a/tests/Zend/Feed/_files/AtomPublishingTest-updated-entry.xml b/tests/Zend/Feed/_files/AtomPublishingTest-updated-entry.xml deleted file mode 100644 index 629dc7cbe0742aee3627c1c5c737084a55b69e82..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomPublishingTest-updated-entry.xml +++ /dev/null @@ -1,18 +0,0 @@ -<!-- -PUT /myFeed/1/1/ - <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> - <atom:id>1</atom:id> - <atom:link rel="edit" href="http://fubar.com/myFeed/1/1/"/> - <atom:updated>2005-05-23T16:26:00-08:00</atom:updated> - <atom:title type="text">Entry 1</atom:title> - <atom:content type="text">1.2</atom:content> - </atom:entry> - 200 OK ---> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> - <atom:id>1</atom:id> - <atom:link rel="edit" href="http://fubar.com/myFeed/1/2/"/> - <atom:updated>2005-05-23T16:27:00-08:00</atom:updated> - <atom:title type="text">Entry 1</atom:title> - <atom:content type="text">1.2</atom:content> -</atom:entry> diff --git a/tests/Zend/Feed/_files/AtomTestGoogle.xml b/tests/Zend/Feed/_files/AtomTestGoogle.xml deleted file mode 100644 index 669ff221b513ba52ee36fb74790f49943e9f4f0c..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestGoogle.xml +++ /dev/null @@ -1,148 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?> - -<feed xmlns="http://purl.org/atom/ns#" version="0.3" xml:lang="en-US"> -<link href="https://www.blogger.com/atom/10861780" rel="service.post" title="Official Google Blog" type="application/atom+xml"/> -<link href="https://www.blogger.com/atom/10861780" rel="service.feed" title="Official Google Blog" type="application/atom+xml"/> -<title mode="escaped" type="text/html">Official Google Blog</title> -<tagline mode="escaped" type="text/html">Googler insights into product and technology news and our culture.</tagline> -<link href="http://googleblog.blogspot.com" rel="alternate" title="Official Google Blog" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780</id> -<modified>2006-01-12T19:55:20Z</modified> -<generator url="http://www.blogger.com/" version="5.15">Blogger</generator> -<info mode="xml" type="text/html"> -<div xmlns="http://www.w3.org/1999/xhtml">This is an Atom formatted XML site feed. It is intended to be viewed in a Newsreader or syndicated to another site. Please visit the <a href="http://help.blogger.com/bin/answer.py?answer=697">Blogger Help</a> for more info.</div> -</info> -<convertLineBreaks xmlns="http://www.blogger.com/atom/ns#">true</convertLineBreaks> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113694886327994245" rel="service.edit" title="Your Google homepage, to go" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2006-01-12T11:53:00-08:00</issued> -<modified>2006-01-12T19:55:20Z</modified> -<created>2006-01-11T03:07:43Z</created> -<link href="http://googleblog.blogspot.com/2006/01/your-google-homepage-to-go.html" rel="alternate" title="Your Google homepage, to go" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113694886327994245</id> -<title mode="escaped" type="text/html">Your Google homepage, to go</title> -<content type="application/xhtml+xml" xml:base="http://googleblog.blogspot.com" xml:space="preserve"> -<div xmlns="http://www.w3.org/1999/xhtml"> -<span class="byline-author">Posted by Abhijit Kalamkar, Software Engineer</span> -<br/> -<br/>Anyone who's ever tried to browse the web on their cell phone knows that it isn't always the best user experience. That's why I'm excited to tell you about <a href="http://mobile.google.com/personalized/index.html">Google Mobile Personalized Home</a>. We've designed a way for you to view the things that you really care about, from your Gmail inbox to news headlines, weather, stock quotes, and feeds (Atom or RSS). The interface is optimized for small screens, and we've arranged things so you don't have to click on a bunch of links to locate what you're after -– your personalized content appears on top, right where it should be. Give it a try, and <a href="mailto:mobile-support@google.com"> let us know</a> how you like it.</div> -</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113632143275337066" rel="service.edit" title="Many Minis" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2006-01-12T09:15:00-08:00</issued> -<modified>2006-01-12T17:18:46Z</modified> -<created>2006-01-03T20:50:32Z</created> -<link href="http://googleblog.blogspot.com/2006/01/many-minis.html" rel="alternate" title="Many Minis" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113632143275337066</id> -<title mode="escaped" type="text/html">Many Minis</title> -<content type="application/xhtml+xml" xml:base="http://googleblog.blogspot.com" xml:space="preserve"> -<div xmlns="http://www.w3.org/1999/xhtml"> -<span class="byline-author">Posted by Rajen Sheth, Product Manager</span> -<br/> -<br/>Today is the one year anniversary of the <a href="http://www.google.com/enterprise/mini/">Google Mini</a>, Google's solution for website and corporate network search, and to celebrate we thought we'd announce a few more of them. The standard Mini lets you search up to 100,000 documents. Now organizations that constantly crank out new content can opt for either of two new Minis: one searches up to 200,000 documents, and another that can manage up to 300,000. All three deliver the same easy setup, intuitive interface and fast, relevant results that the Mini is already bringing to thousands of websites and corporate networks. You're growing, and <a href="http://www.googlestore.com/appliance/product.asp?catid=1">the Mini is growing with you</a>.</div> -</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113599349496410640" rel="service.edit" title="Google Earth in a Mac world (PC too)" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2006-01-10T12:49:00-08:00</issued> -<modified>2006-01-10T21:02:47Z</modified> -<created>2005-12-31T01:44:54Z</created> -<link href="http://googleblog.blogspot.com/2006/01/google-earth-in-mac-world-pc-too.html" rel="alternate" title="Google Earth in a Mac world (PC too)" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113599349496410640</id> -<title mode="escaped" type="text/html">Google Earth in a Mac world (PC too)</title> -<content type="application/xhtml+xml" xml:base="http://googleblog.blogspot.com" xml:space="preserve"> -<div xmlns="http://www.w3.org/1999/xhtml"> -<span class="byline-author">Posted by Chikai Ohazama, Google Earth Team</span> -<br/> -<br/>We feel like proud parents around here. Our eldest, Google Earth for the PC, is officially leaving beta status today, and we couldn't be more pleased. For those of you who downloaded early, upgrade to the latest and discover Google Earth all over again.<br/> -<br/>And we have a brand new member of the family -- Google Earth for Macintosh. We're happy to finally have some good news for the, ahem, vocal Mac enthusiasts we've been hearing from. Let's just say that we have gotten more than a few "requests" for a Mac version of Google Earth. They've gone something like this:<br/> -<br/>1) "When is it coming out? Your website says that you are working on it."<br/> -<br/>2) "You know, Mac users are very heavy graphics/mapping/visualization/design/ architecture/education/real estate/geocaching/social-geo-video-networking fans who would certainly use Google Earth a lot."<br/> -<br/>3) "So when is it coming out?"<br/> -<br/>We heard you loud and clear. The Mac version runs on OS X 10.4 and up. Happy travels throughout <a href="http://earth.google.com/download-earth.html">Google Earth</a>, whether you're on a Mac or a PC.</div> -</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113605351620153422" rel="service.edit" title="A new year for Google Video" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2006-01-09T22:16:00-08:00</issued> -<modified>2006-01-11T20:30:26Z</modified> -<created>2005-12-31T18:25:16Z</created> -<link href="http://googleblog.blogspot.com/2006/01/new-year-for-google-video.html" rel="alternate" title="A new year for Google Video" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113605351620153422</id> -<title mode="escaped" type="text/html">A new year for Google Video</title> -<content mode="escaped" type="text/html" xml:base="http://googleblog.blogspot.com" xml:space="preserve"><span class="byline-author">Posted by Sanjay Raman, Google Video Team</span><br /><br />Till now, Google Video has been about watching videos and clips online, which is really convenient for videos <a href="http://video.google.com/videoplay?docid=-3496860874967925614&q=fastfocus">like this</a>. But wouldn't it be awesome to watch that episode of <span style="font-style: italic;"><a href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DCSI">CSI</a></span> that you missed when even your trusty DVR failed you? This is one reason we've launched the Google Video store, where you can rent or buy from such well-known media partners as <a href="http://video.google.com/cbs.html">CBS</a>, the <a href="http://video.google.com/nba.html">NBA</a>, The <a href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DCharlie_Rose">Charlie Rose Show</a>, and <a href="http://video.google.com/videosearch?q=Sony+BMG">SONY BMG</a>.<br /><br />We’re not only about mainstream content, though -– we have thousands of titles available (and more coming every day) from every imaginable type of producer, including <a href="http://video.google.com/videosearch?q=1896+tsar+nicholas&so=0">this 1896 clip</a> of the coronation of Tsar Nicholas II – one of the earliest known moving images. We’re especially pleased to offer such quality indie features as Ben Rekhi’s <span style="font-style: italic;"><a href="http://video.google.com/videoplay?docid=-1607114503824678810&q=waterborne ">Waterborne</a></span> (Drops Entertainment) and Lerone Wilson’s <span style="font-style: italic;"><a href="http://video.google.com/videoplay?docid=-4929215594503422280&q=aardvark%27d ">Aardvark’d: 12 Weeks with Geeks</a></span> (Boondoggle Films).<br /><br />When we launched our <a href="https://upload.video.google.com">Upload Program</a> earlier this year, people sent in a huge number of free and compelling videos. But since there's a ton of video that can't be offered for free, we built the <a href="http://video.google.com/">Google Video store</a> to give content owners the option to charge for downloads if they'd like. This means producers large and small can distribute their great content in an easy, secure way. Some of your favorite prime time and classic TV shows, sports, music videos, and documentaries are at your fingertips. Want to see how Shaq scored 30 points last night? Download and watch it (and every <a href="http://video.google.com/nba.html">NBA</a> game for the rest of the season) through Google Video.<br /><br />You can play all the videos you download using the all-new Google Video Player. We're especially pleased about the thumbnail navigation for browsing an entire video so you can play any portion with a single click. And there's another thing: if the content is not copy-protected, you can take your favorite videos with you on your <a href="http://www.apple.com/ipod/">iPod</a> or <a href="http://www.us.playstation.com/psp.aspx">PSP</a> -- our "to go" option.<br /><br />Since it's so early in the year, here's a resolution we intend to keep: make sure new features and content continue to roll out, so that you think Google Video is one of the best ways to find video on the web.<br /><br />These video providers are getting us off to a great start:<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Daquarius">Aquarius Health Care Media</a></span>: A leading producer and distributor of healthcare-related videos will pilot with Google Video using a variety of titles covering SIDS, diabetes, and blindness, among other health issues.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=ardustry">Ardustry Home Entertainment</a></span>: Offers substantial libraries of theatrical motion pictures, television series, documentaries and reality programming, music and sports specials, lifestyle titles, and a wide array of “how-to†products.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=bluehighways">BlueHighways TV</a></span>: Programming service that explores the people, stories, traditions and cultures of America. Discovering the sights and sounds of communities across the country with an up-close, laid-back programming style, BlueHighways TV presents a collage of remarkable music, folklore and information for audiences interested in all aspects of American life and heritage. Programming includes <span style="font-style: italic;">Reno's Old Time Music Festival,</span> <span style="font-style: italic;">American Journeys,</span> <span style="font-style: italic;">Stan Hitchcock's Heart to Heart,</span> and <span style="font-style: italic;">Gospel Sampler</span>.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dcaretalk">CareTALK</a></span>: A multimedia brand dedicated to consumer-directed health care offering programming and tools to help modern family caregivers; initially offering 10-20 hours of health and caregiving-related content (10-20 minutes in length).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/cbs.html">CBS</a>: Includes prime time hits such as <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DCSI">CSI</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3Dncis">NCIS</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DSurvivor_Guatemala">Survivor: Guatemala</a>, and The Amazing Race (available spring ’06), as well as classics like <a style="font-style: italic;" href="http://video.google.com/videosearch?q=I+Love+Lucy">I Love Lucy</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DTwilight_Zone">Twilight Zone</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DBrady_Bunch">Brady Bunch</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=Have+Gun+Will+Travel">Have Gun Will Travel</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DMacGyver">MacGyver</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DStar_Trek_Deep_Space_Nine">Star Trek: Deep Space Nine</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DStar_Trek_Voyager">Star Trek: Voyager</a>, and My Three Sons (coming soon).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DCharlie_Rose">The Charlie Rose Show</a>: Includes interviews with Henry Kissinger, Oliver Stone, Quentin Tarantino, Martha Stewart, Martin Scorsese, Harrison Ford, Dan Rather, Charles M. Schulz, Steve Jobs, Jay Leno, Tom Brokaw, and others.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=Cine+Excel&so=0">Cine Excel</a>: Independent producer will trial on Google Video with 3 DVD movie titles: <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=6833548605067650376&q=Cine+Excel">Bikini Hotel </a>(1997), <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=-9198267889833807992&q=Cine+Excel">Tao of Karate</a> (short-film, 1998) and <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=8241854949946868864&q=Cine+Excel">Karate Wars</a> (1998).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=classic+media">Classic Media</a>: Classic Media owns and manages some of the world's most recognizable family properties across all media including feature film, television, home video and consumer products. The company's extensive library features a diverse collection of popular animated and live-action characters. For lentaries are at your fingertips. Want to see how Shaq scored 30 points last night? Download and watch it (and every <a href="http://video.google.com/nba.html">NBA</a> game for the rest of the season) through Google Video.<br /><br />You can play all the videos you download using the all-new Google Video Player. We're especially pleased about the thumbnail navigation for browsing an entire video so you can play any portion with a single click. And there's another thing: if the content is not copy-protected, you can take your favorite videos with you on your <a href="http://www.apple.com/ipod/">iPod</a> or <a href="http://www.us.playstation.com/psp.aspx">PSP</a> -- our "to go" option.<br /><br />Since it's so early in the year, here's a resolution we intend to keep: make sure new features and content continue to roll out, so that you think Google Video is one of the best ways to find video on the web.<br /><br />These video providers are getting us off to a great start:<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Daquarius">Aquarius Health Care Media</a></span>: A leading producer and distributor of healthcare-related videos will pilot with Google Video using a variety of titles covering SIDS, diabetes, and blindness, among other health issues.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=ardustry">Ardustry Home Entertainment</a></span>: Offers substantial libraries of theatrical motion pictures, television series, documentaries and reality programming, music and sports specials, lifestyle titles, and a wide array of “how-to†products.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=bluehighways">BlueHighways TV</a></span>: Programming service that explores the people, stories, traditions and cultures of America. Discovering the sights and sounds of communities across the country with an up-close, laid-back programming style, BlueHighways TV presents a collage of remarkable music, folklore and information for audiences interested in all aspects of American life and heritage. Programming includes <span style="font-style: italic;">Reno's Old Time Music Festival,</span> <span style="font-style: italic;">American Journeys,</span> <span style="font-style: italic;">Stan Hitchcock's Heart to Heart,</span> and <span style="font-style: italic;">Gospel Sampler</span>.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dcaretalk">CareTALK</a></span>: A multimedia brand dedicated to consumer-directed health care offering programming and tools to help modern family caregivers; initially offering 10-20 hours of health and caregiving-related content (10-20 minutes in length).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/cbs.html">CBS</a>: Includes prime time hits such as <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DCSI">CSI</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3Dncis">NCIS</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DSurvivor_Guatemala">Survivor: Guatemala</a>, and The Amazing Race (available spring ’06), as well as classics like <a style="font-style: italic;" href="http://video.google.com/videosearch?q=I+Love+Lucy">I Love Lucy</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DTwilight_Zone">Twilight Zone</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DBrady_Bunch">Brady Bunch</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=Have+Gun+Will+Travel">Have Gun Will Travel</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DMacGyver">MacGyver</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DStar_Trek_Deep_Space_Nine">Star Trek: Deep Space Nine</a>, <a style="font-style: italic;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DStar_Trek_Voyager">Star Trek: Voyager</a>, and My Three Sons (coming soon).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Atvshow%3DCharlie_Rose">The Charlie Rose Show</a>: Includes interviews with Henry Kissinger, Oliver Stone, Quentin Tarantino, Martha Stewart, Martin Scorsese, Harrison Ford, Dan Rather, Charles M. Schulz, Steve Jobs, Jay Leno, Tom Brokaw, and others.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=Cine+Excel&so=0">Cine Excel</a>: Independent producer will trial on Google Video with 3 DVD movie titles: <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=6833548605067650376&q=Cine+Excel">Bikini Hotel </a>(1997), <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=-9198267889833807992&q=Cine+Excel">Tao of Karate</a> (short-film, 1998) and <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=8241854949946868864&q=Cine+Excel">Karate Wars</a> (1998).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=classic+media">Classic Media</a>: Classic Media owns and manages some of the world's most recognizable family properties across all media including feature film, television, home video and consumer products. The company's extensive library features a diverse collection of popular animated and live-action characters. For launch we will have <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=2700527067868455741&q=classic+media">Rocky &amp; Bullwinkle</a>, <span style="font-style: italic;">Casper</span>, <span style="font-style: italic;">Wendy</span>, <span style="font-style: italic;">Richie Rich</span>, <span style="font-style: italic;">Herman & Katnip</span>, <span style="font-style: italic;">Baby Huey</span>, <span style="font-style: italic;">Little Audrey</span>, <a style="font-style: italic;" href="http://video.google.com/videoplay?docid=-3466783103686653836&q=Mighty+Hercules">Mighty Hercules</a>, <span style="font-style: italic;">Little Lulu</span>, and <span style="font-style: italic;">Felix the Cat</span>.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=clearvue">CLEARVUE & SVE</a>: A leading provider of educational K-12 educational video content. They sell DVDs and run a subscription media-on-demand website with video, audio, and images. CLEARVUE &amp; SVE primarily serves large clients such as schools, school districts or entire states. Leveraging Google Video, they have embarked on a new and bold strategy to target individual customers directly. Among the hundreds of videos you will find on Google, topics vary from classic children's literature to detailed explanations about the workings of the human body.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dechelon">Echelon Home Entertainment 2</a></span>: Focuses on independently produced films made by filmmakers from around the world which offer a unique perspective to the traditional genres: drama, action, thriller, comedy, family, animation, classic, B&W, foreign.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dimage_entertainment">Egami Media</a></span>: A subsidiary of Image Entertainment and a leading independent licensee, producer and distributor of home entertainment programming with over 3,000 titles released in North America. Highlighted content in Google Video includes live concert programs include <span style="font-style: italic;">Kiss: Rock the Nation: Live!</span>, <span style="font-style: italic;">Chick Corea: Rendezvous in New York</span>, <span style="font-style: italic;">Roy Orbison: Black & White Night</span>, and dozens more. Other titles include IMAX programs from MacGillivray Freeman, stand-up comedy and independent, foreign and silent film classics.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dfashion_tv">Fashion TV</a>: The only 24 hours a day, 7 days a week fashion, beauty and style TV station worldwide provides glamorous entertainment with emphasis on the latest trends. Google Video content includes fashion show clips and behind the scenes footage from many fashion shows.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dgetty_images">Getty Images' Archive Films Collection</a>: A diverse collection of short clips that capture personalities, moments and eras throughout history -- selected from vintage newsreels and educational film, as well as contemporary news and events from around the world.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dgreencine">GreenCine.com</a>: Feature length independent films, documentaries and classic titles, including works by legendary Polish director Andrzej Wajda (<span style="font-style: italic;">Zemsta</span>) and award-winning actor-director Caveh Zahedi (<span style="font-style: italic;">In the Bathtub of the World</span>).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=HDNet&so=0">HDNet</a>: Co-founded by Mark Cuban, HDNet has agreed to make select original programming from its library available for the launch of Google's first commercial video offering. The programs to be made available come from HDNet's ever growing library of original content including the <span style="font-style: italic;">HDNet World Report</span>, a groundbreaking series featuring news in HD from around the globe; <span style="font-style: italic;">True Music</span>, a popular weekly music series highlighting up-and-coming bands; <span style="font-style: italic;">Higher Definition</span>, a celebrity interview series hosted by Robert Wilonsky; <span style="font-style: italic;">Young, Beautiful and Trying to Make it in Hollywood</span>, following actresses through the hectic process of getting hired in Hollywood; and <span style="font-style: italic;">Deadline</span>, delivering current events and news from around the world from an irreverent point of view.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=heretv">here!</a>: Gay and lesbian U.S. television network featuring original movies and series and film library (independent and foreign films, documentaries and shorts).<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=hollywood+licensing">Hollywood Licensing's HilariousDownloads.com</a></span>: Hollywood Licensing is the entertainment licensing agency which represents the best and most extensive library of hilarious videos in the world. Tapping into a library boasting tens of thousands of clips, they have custom produced 20 packages of funny themes a celebrity interview series hosted by Robert Wilonsky; <span style="font-style: italic;">Young, Beautiful and Trying to Make it in Hollywood</span>, following actresses through the hectic process of getting hired in Hollywood; and <span style="font-style: italic;">Deadline</span>, delivering current events and news from around the world from an irreverent point of view.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=heretv">here!</a>: Gay and lesbian U.S. television network featuring original movies and series and film library (independent and foreign films, documentaries and shorts).<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=hollywood+licensing">Hollywood Licensing's HilariousDownloads.com</a></span>: Hollywood Licensing is the entertainment licensing agency which represents the best and most extensive library of hilarious videos in the world. Tapping into a library boasting tens of thousands of clips, they have custom produced 20 packages of funny themes for Google Video. For example, if you think that your recent home improvements was nothing but a miserable experience, wait until you see a bucket of wet plaster land on a man's face, a house collapsing or a door falling of its hinges for no particular reason.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Ditn">ITN</a>: One of the world's leading news producers, providing news programming for the main commercial broadcasters in the U.K. and its combined news broadcasts reach over two-thirds of the U.K. population. The company has a strong reputation for the creative and innovative use of modern technology, winning the Royal Television Society's 2004 Innovation Award.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Diwatchnow">iWatchNow.com</a>: Titles include Night of the Living Dead (George Romero), The Chronicles of Narnia: The Lion, Witch, and the Wardrobe (original animated film BBC from1979), The Man Who Knew Too Much (Hitchcock), the hard-to-find Comedy's Dirtiest Dozen (with Chris Rock and Tim Allen), and The Little Shop of Horrors (1960).<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=kantola&so=0">Kantola Productions</a>: Captures unique speaking events given by well-known experts at Stanford University. Topics focus on innovative and practical business advice, such as How Leaders Boost Productivity by John H. (Jack) Zenger and <span style="font-style: italic;">Mastery of Speaking as a Leader</span> by Terry Pearce.<br /><br />• <span style="font-weight: bold;"><a href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dlime">LIME</a></span>: “Healthy Living with a Twist†offers entertaining and revealing programming focused on a greener, healthier, more balanced lifestyle. Programming features inspiration from leading experts, authors, and pop culture icons and covers topics including the environment and sustainability, personal growth, alternative health, healthy foods, and business ethics.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=mediazone.com&so=0">MediaZone.com</a>: Programming covers sporting events, TV episodes, movies, how-to programs. Content includes <span style="font-style: italic;">The Rugby Channel presents ‘The Best Tries of 2004’</span> and <span style="font-style: italic;">The All Blacks of New Zealand Vs. Springboks of South Africa</span>.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dtwi+nobel">Nobel Video Library</a>: A library focused on the achievements of individual Nobel Laureate. The series was developed to introduce students to the work of the laureates as well as to support classroom discussion regarding important issues addressed by Nobel Prize winners in recent decades.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=open+championship&so=0">Open Championship</a>: Official programs from the classic golf tournament, the British Open, such as<span style="font-style: italic;"> </span><span style="font-style: italic;">Reflections: Past Open Champions</span>.<br /><br />•<a style="font-weight: bold;" href="http://video.google.com/videosearch?q=plum+tv"> Plum TV</a>: Provides highly localized programming to the nation’s most influential consumers, and strives to be an incubator of groundbreaking new television programming. Each Plum TV station shares branding which links each station as a network, but still provides original programming customized to reflect each community. Plum TV’s programming includes regionally-focused feature pieces, tourist information (weather, traffic reports, restaurant reviews, retail and lodging information), a real estate show, local news and specially targeted entertainment for each community’s interests.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=porchlight+entertainment">PorchLight Entertainment</a>: Porchlight produces family-oriented motion pictures and TV specials. Google Video will offer 36 titles including <span style="font-style: italic;">Enough Already</span> and <span style="font-style: italic;">Role of a Lifetime</span>.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=SOFA+Entertainment&so=0">SOFA Entertainment</a>: Represents pop culture at its best. Featuring several titles from the classic <span style="font-style: italic;">The Ed Sullivan Show</span> along with documentaries, feature films and music programming. SOFA Entertainment truly offers something for everyone. Some highlights include <span style="font-style: italic;">The Very Best of The Ed Sullivan Show - Vol. 1 & Vol. 2.</span><br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=Sony+BMG">SONY BMG MUSIC ENTERTAINMENT</a>: The lineup of launch videos includes offerings from some of SONY BMG's largest global superstar artists, including Christina Aguilera, Beyonce, Kenny Chesney, Destiny's Child, Kelly Clarkson, Alicia Keys, Lil' Flip, Jessica Simpson, Shakira, System of a Down, Switchfoot, Usher, and many more.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=Tai+Seng&so=0">Tai Seng Entertainment</a>: The definitive Asian cinema powerhouse. Known as the best source for Hong Kong films, Tai Seng also releases cinematic masterpieces from all over the Asia region in a variety of languages. Tai Seng brings to your home the best in class from high-octane action to bone-crushing martial arts, from chilling horror to lush swordplay epics. We are proud to showcase with Google some of Asia's biggest hits like Johnnie To's <span style="font-style: italic;">Running On Karma</span>, Korea's sensuously emotional drama <span style="font-style: italic;">Addicted</span>, martial arts Master Yuen Wo Ping's highly acclaimed <span style="font-style: italic;">Tai Chi Master</span>, and Michelle Yeoh's violently elegant <span style="font-style: italic;">Butterfly Sword</span>.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=Teen+Kids+news">Teen Kids News</a>: A dynamic television news program for teens and pre-teens, by teens. The half-hour weekly program provides 10 eyewitness news segments to students in a way that's educational as well as entertaining. Thirty shows with kids reporting on camera are available on Google Video.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=Trinity+Broadcasting+&so=0">Trinity Broadcasting Network</a>: The world's largest religious network and America's most watched faith channel, TBN offers 24 hours of commercial-free inspirational programming that appeal to people in a wide variety of Protestant, Catholic and Messianic Jewish denominations. <span style="font-style: italic;">The Praise the Lord Program</span> is the only live two-hour Christian program in the world. The program brings the highest caliber of guests from well-known celebrities to laypersons for interview, as well as, singers, musicians, evangelists and the coverage of revivals and crusades from around the world. This award-winning program has been on each week night for over 30 years.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videoplay?docid=8592392906577495616&q=in_label%3Aowner%3Dunion">Union</a>: Offers the best of breed from the world of action sports, including snow, skate, bmx, moto, and surfing. Union is owned by Quiksilver Entertainment, Inc. and Global Media Ventures, LLC.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=wilderness+films+india">WFIL</a>: Wilderness Films India Ltd. is a leading producer and library of stock footage captured in India and across Asia. WFIL will offer 100 hours of high quality video, both free and for sale, on Google Video. Topics vary from helicopter skiing in the Himalaya, broadcast coverage of an Everest climb, and rare wildlife such as the takin and the clouded leopard to imagery spanning India's art, culture, technology, peoples, cities, and rural areas.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=wgbh+boston">WGBH</a>: WGBH Boston is America's preeminent public broadcasting producer, the source of fully one-third of PBS's prime-time lineup, along with some of public television's best-known lifestyle shows and children's programs and many public radio favorites. Programming available includes <span style="font-style: italic;">Nova</span>, <span style="font-style: italic;">La Plaza</span> (the longest running Latino program in the country), <span style="font-style: italic;">Thinking Big</span>, and <span style="font-style: italic;">Basic Black</span>. WGBH is the number one producer of Web sites on pbs.org, one of the most trafficked dot-org Web sites in the world. WGBH is a pioneer in educational multimedia and in technologies and services that make media accessible to the 36 million Americans who rely on captioning or video descriptions. WGBH has been recognized with hundreds of honors: Emmys, Peabodys, duPont-Columbia Awards.even two Oscars. In 2002, WGBH was honored with a special institutional Peabody Award for 50 years of excellence.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=WheelsTV&so=0">WheelsTV</a>: Serves both the general audience and the enthusiast with a wide spectrum of vehicle-based entertainment, news and information. WheelsTV Network, WheelsTV On Demand and WheelsTV.net have been developed by the producers of multi-awarding winning automotive programming for Discovery, PBS, Speedvision, Fox and Outdoor Life Networks including <span style="font-style: italic;">Wild About Wheels</span>, <span style="font-style: italic;">Wheels</span>, and <span style="font-style: italic;">Motor Trend Television</span>. WheelsTV Network’s valuable consumer programs include <span style="font-style: italic;">Top 200â„¢ New Vehicle Test Drives</span>. With <span style="font-style: italic;">Top 200</span> on Google, consumers will be able to download virtual test drives of the best selling and most exciting cars on the road today, saving time and money.<br /><br />• <a style="font-weight: bold;" href="http://video.google.com/videosearch?q=in_label%3Aowner%3Dtwi">Wimbledon</a>: Official programs from the Wimbledon Tennis Championships such as <span style="font-style: italic;">Legends of Wimbledon: Bjorn Borg</span>.</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113494967528450491" rel="service.edit" title="The 2006 Anita Borg Scholarships" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2006-01-09T06:27:00-08:00</issued> -<modified>2006-01-09T14:30:23Z</modified> -<created>2005-12-18T23:47:55Z</created> -<link href="http://googleblog.blogspot.com/2006/01/2006-anita-borg-scholarships.html" rel="alternate" title="The 2006 Anita Borg Scholarships" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113494967528450491</id> -<title mode="escaped" type="text/html">The 2006 Anita Borg Scholarships</title> -<content type="application/xhtml+xml" xml:base="http://googleblog.blogspot.com" xml:space="preserve"> -<div xmlns="http://www.w3.org/1999/xhtml"> -<span class="byline-author">Posted by April Yu, University Programs Team, and Emily Nishi, Diversity Program Manager</span> -<br/> -<br/>The wonderfully-named Dr. Anita Borg (1949 - 2003) was a rebel with a cause: ensuring that technology itself has positive outcomes, and dismantling barriers that keep women and minorities from entering computing and technology fields. Today the <a href="http://www.anitaborg.org">Anita Borg Institute for Women and Technology</a> carries on her vision. And because Google shares that passion, we are pleased to sponsor the <a href="http://www.google.com/anitaborg/">2006 Anita Borg Scholarship program</a>. We are inspired by the <a href="http://www.google.com/anitaborg/profiles.html">past scholarship recipients</a> -- and in hopes of finding more, the program is expanded this year to accept applications from students entering their senior year of undergraduate study as well as those enrolled in a graduate program. <a href="http://www.google.com/press/pressrel/anitaborg.html">Last year</a> we awarded 23 scholarships; this year we'd like to do more.<br/> -<br/>Tell your friends, or <a href="http://www.google.com/anitaborg/">apply</a> yourself - the deadline is January 20.</div> -</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113605348414874975" rel="service.edit" title="Make your computer just work" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2006-01-06T16:51:00-08:00</issued> -<modified>2006-01-07T00:54:51Z</modified> -<created>2005-12-31T18:24:44Z</created> -<link href="http://googleblog.blogspot.com/2006/01/make-your-computer-just-work.html" rel="alternate" title="Make your computer just work" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113605348414874975</id> -<title mode="escaped" type="text/html">Make your computer just work</title> -<content mode="escaped" type="text/html" xml:base="http://googleblog.blogspot.com" xml:space="preserve"><span class="byline-author">Posted by Jesse Savage, Google Pack team</span><br /> <br />So you bought a new PC for yourself or a relative during the holidays. There was the initial excitement about its speed and the nice screen – and then it came time to actually get it running. Which meant embarking on some real work -– downloading a browser, a couple of multimedia players, a PDF reader, a toolbar, and maybe something for voice and instant messaging. Don’t forget the anti-spyware and anti-virus apps – you’ve got to have those. Hours, maybe even days, go by. How many wizards have you clicked through, not to mention license agreements and preference pickers? And then you have to ask: did I get everything? And how am I going to keep all of this up to date?<br /> <br />This was the experience both Sergey and Larry had a year ago. And they’re computer guys, after all. Which led them to ask more of us to make it easier for everyone. So we created the <a href="http://pack.google.com">Google Pack</a> -- a one-stop software package that helps you discover, install, and maintain a wide range of essential PC programs. It’s yours today – and it’s something we hope you find to be painless, easy, and even fun (if computer setup can ever be called that). And it’s free. <br /> <br />We worked with a number of technology companies to identify products that are the best of their type to create <a href="http://www.google.com/support/pack">this suite</a>. (We didn’t pay them, and they aren’t paying us.) For PC users running Windows XP, it downloads in minutes and installs in just a few clicks. There’s only one license agreement – and no wizards. And there’s a new tool called the <a href="http://www.google.com/support/pack/bin/answer.py?answer=30252&topic=8326/">Google Updater</a> that keeps all the software in the Google Pack current. Even if you already have some of the software in the Pack, you can use the Google Updater to update and manage it.<br /> <br />There’s one more thing in the Pack that we think you’ll like. The Pack team asked people what kind of screensavers they like best. They kept saying, “I want my own photos as a screensaver, why can’t I do that?†Good question -- lots of people have trouble with this. So we made the <a href="http://www.google.com/support/pack/bin/answer.py?answer=28076&topic=8315">Google Pack Screensaver</a>, which is the easiest possible way to make your photos into an animated photo collage. And now the question for you is: what will you do with all that time you've saved?</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -<entry xmlns="http://purl.org/atom/ns#"> -<link href="https://www.blogger.com/atom/10861780/113599269991367646" rel="service.edit" title="A year of Google blogging" type="application/atom+xml"/> -<author> -<name>A Googler</name> -</author> -<issued>2005-12-30T17:18:00-08:00</issued> -<modified>2006-01-05T21:52:34Z</modified> -<created>2005-12-31T01:31:39Z</created> -<link href="http://googleblog.blogspot.com/2005/12/year-of-google-blogging.html" rel="alternate" title="A year of Google blogging" type="text/html"/> -<id>tag:blogger.com,1999:blog-10861780.post-113599269991367646</id> -<title mode="escaped" type="text/html">A year of Google blogging</title> -<content type="application/xhtml+xml" xml:base="http://googleblog.blogspot.com" xml:space="preserve"> -<div xmlns="http://www.w3.org/1999/xhtml"> -<span class="byline-author">Posted by Karen Wickre, Google Blog team </span> -<br/> -<br/>This is the 201st post to be published on the Google Blog in 2005. In closing out the first full year of our company-wide effort to share news and views, we thought you might be interested in a few factoids. Since we've had Google Analytics running on this blog since June, some of these numbers reflect only half a year. In that time, 4.3 million unique visitors have generated 8.7 million pageviews. Readers have come from all over the world, not just English-speaking countries: 53,001 visitors from Turkey have stopped by, for example; so have 155,691 from France, 29,614 from Thailand and 8,233 from Peru. <br/> -<br/>The most popular posts? Here are a few that have yielded scores of backlinks: <br/> <br/>- <a href="http://googleblog.blogspot.com/2005/09/googlebombing-failure.html">Our explanation of "Googlebombing"</a> <br/>- <a href="http://googleblog.blogspot.com/2005/10/guess-what-just-turned-34.html">A celebration of email and Gmail</a> <br/>- <a href="http://googleblog.blogspot.com/2005/09/illuminated-continent.html">Google Earth's partnership with National Geographic</a> about Africa <br/> -<br/>Several on Google Book Search (formerly known as Google Print), including: <br/>- <a href="http://googleblog.blogspot.com/2005/11/preserving-public-domain-books.html">Preserving public domain books</a> <br/>- <a href="http://googleblog.blogspot.com/2005/09/google-print-and-authors-guild.html">Our statement on the Authors' Guild suit</a> <br/>- and <a href="http://googleblog.blogspot.com/2005/10/point-of-google-print.html">Eric Schmidt's op-ed</a> about Book Search.<br/> <br/>During the year, we've published 38 how-to tips, announced 77 new products and services, and addressed policy questions and legal matters 17 times. We've featured 11 guest bloggers. Forty posts have illuminated something about day to day life at Google; 19 have offered some international perspective. <br/> <br/>In 2006, we'll keep up the Google Blog with more posts, more bloggers, and even more topics. Meanwhile, we really appreciate your interest and feedback, now visible through "Links to this post." We know some of you would like to offer comments directly, and we would like that too, when we can add resources to the blog crew. Meanwhile, our best to you and yours for the New Year.</div> -</content> -<draft xmlns="http://purl.org/atom-blog/ns#">false</draft> -</entry> -</feed> diff --git a/tests/Zend/Feed/_files/AtomTestMozillazine.xml b/tests/Zend/Feed/_files/AtomTestMozillazine.xml deleted file mode 100644 index 2fa18ece5cb97f32e7530413feea1444cafa1b2b..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestMozillazine.xml +++ /dev/null @@ -1,213 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en"> - <title>mozillaZine.org</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/" /> - <modified>2006-01-23T04:04:45-08:00</modified> - <tagline>Your Source for Daily Mozilla News and Advocacy</tagline> - <id>tag:mozillazine.org,2004:1</id> - <copyright>Copyright (c) 2004, The Mozillazine Organization</copyright> - <entry> - <title>Minutes of the mozilla.org Staff Meeting of Monday 9th January 2006</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7935" /> - <modified>2006-01-22T20:04:42-08:00</modified> - <created>2006-01-22T20:04:42-08:00</created> - <issued>2006-01-22T20:04:42-08:00</issued> - <id>tag:mozillazine.org,2004:article7935</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>The <a href="http://groups.google.com/group/mozilla.dev.general/browse_thread/thread/7de43a2673479016/" title="mozilla.dev.general:2005-01-09 - Summary of mozilla.org staff meeting">minutes of the mozilla.org staff meeting held on Monday 9th January 2006</a> are now online. Issues discussed include Firefox 1.5.0.1 release schedule, Thunderbird 1.5 release and Marketing.</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7935">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Minutes of the mozilla.org Staff Meeting of Wednesday 4th January 2006</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7895" /> - <modified>2006-01-12T09:29:47-08:00</modified> - <created>2006-01-12T09:29:47-08:00</created> - <issued>2006-01-12T09:29:47-08:00</issued> - <id>tag:mozillazine.org,2004:article7895</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>The minutes of the mozilla.org staff meeting held on Wednesday 4th January 2006 are now available. Issues discussed include Upcoming Releases, Marketing, Thunderbird, 1.9 Roadmap, Firefox 2 Process and Calendar.</p> - <p>The minutes have been posted to the new mozilla.dev.general newsgroup, which is accessible via news.mozilla.org. The previously announced <a href="http://www.mozillazine.org/talkback.html?article=7849" title="mozillaZine:Mozilla Newsgroups Migration Scheduled">newsgroup migration</a> is in progress. Once mozilla.dev.planning is created, minutes will be posted there.</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7895">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Thunderbird 1.5 Released</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7892" /> - <modified>2006-01-11T18:19:13-08:00</modified> - <created>2006-01-11T18:19:13-08:00</created> - <issued>2006-01-11T18:19:13-08:00</issued> - <id>tag:mozillazine.org,2004:article7892</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p><a href="mailto:mscott@mozilla.org" title="mscott@mozilla.org">Scott MacGregor</a> writes: "The final release of Mozilla Thunderbird 1.5 is now available for download from <a href="http://getthunderbird.com">getthunderbird.com</a>. Users of RC1 should see the update soon. If you are using RC2, then you already have 1.5 final."</p> - <p>"Thunderbird 1.5 introduces several new features including a software update system, spell check as you type, built in phishing detector, auto save as draft, and support for deleting attachments from email messages. Message filtering has also been improved with new filter actions for replying and forwarding. Saved search folders can now search folders across multiple accounts."</p> - <p>"More details can be found in the <a href="http://www.mozilla.com/thunderbird/releases/1.5.html" title="Mozilla Thunderbird 1.5 Release Notes">Mozilla Thunderbird 1.5 Release Notes</a>, and the <a href="http://forums.mozillazine.org/viewforum.php?f=39">support forum staff</a> is available for questions. "</p> - <p>"I wanted to thank everyone in the mozillaZine community who helped test the alphas, the betas, and the release candidates that went into this release. Thank you for trusting Thunderbird with your email throughout the development and release cycle for 1.5. I'm looking forward to working with all of you on 2.0 and beyond!"</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7892">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Firefox Smoketest Day Planned for January 6, 2006</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7859" /> - <modified>2006-01-04T14:14:20-08:00</modified> - <created>2006-01-04T14:14:20-08:00</created> - <issued>2006-01-04T14:14:20-08:00</issued> - <id>tag:mozillazine.org,2004:article7859</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>The <a href="http://weblogs.mozillazine.org/qa/">Mozilla QA team</a> has announced a <a href="http://weblogs.mozillazine.org/qa/archives/2006/01/firefox_smoketest_day_planned.html" title="Mozilla Quality: Firefox Smoketest Day Planned for Jan. 6, 2006">community test day</a> with focus on smoketesting nightly Firefox 1.5.0.1 builds.</p> - <p><a href="http://litmus.mozilla.org/">Litmus tool</a> will be used for this testing event. There is a <a href="http://wiki.mozilla.org/Mozilla_QA_Community:Firefox1.5.0.1_Smoketest_Day" title="Mozilla QA Community:Firefox1.5.0.1 Smoketest Day - wiki.mozilla.org">FAQ</a> posted on the QA community wiki that will have specific instructions on how this testing day will run.</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7859">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Camino 1.0 Beta 2 Released</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7850" /> - <modified>2006-01-02T15:23:18-08:00</modified> - <created>2006-01-02T15:23:18-08:00</created> - <issued>2006-01-02T15:23:18-08:00</issued> - <id>tag:mozillazine.org,2004:article7850</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>Camino 1.0 beta 2 has been released. This latest version of the native Mac OS X browser is replacing 0.8.4 as the stable Camino release on all systems 10.2+. See the <a href="http://www.caminobrowser.org/releases/1.0b2.php">Camino 1.0 Beta 2 Release Notes</a> for more details.</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7850">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Mozilla Newsgroups Migration Scheduled</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7849" /> - <modified>2006-01-02T15:07:27-08:00</modified> - <created>2006-01-02T15:07:27-08:00</created> - <issued>2006-01-02T15:07:27-08:00</issued> - <id>tag:mozillazine.org,2004:article7849</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>Frank Wein has announced that the <a href="http://groups.google.com/group/netscape.public.mozilla.seamonkey/browse_thread/thread/21a3691027dc50ef/" title="netscape.public.mozilla.seamonkey: Migration to new news server and reorganization of netscape.public hierarchy">migration and reorganization of Mozilla newsgroups will take place in January 2006</a>. As announced earlier, the <a href="http://www.mozillazine.org/talkback.html?article=7224" title="mozillaZine: Giganews to Host Mozilla Newsgroups">new newsgroups will be hosted by Giganews</a>. Access to the news server news.mozilla.org will remain free. The new groups will only be propogated to news.mozilla.org, Giganews Servers and Google Groups in an effort to combat news spam. For more information, refer to the <a href="http://www.mozilla.org/community/giganews-migration.html">FAQ</a> and the <a href="http://www.mozilla.org/community/newsgroups.txt">list of new newsgroups</a>. -</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7849">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Mozilla Thunderbird 1.5 Release Candidate 2 Available</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7823" /> - <modified>2005-12-21T13:58:07-08:00</modified> - <created>2005-12-21T13:58:07-08:00</created> - <issued>2005-12-21T13:58:07-08:00</issued> - <id>tag:mozillazine.org,2004:article7823</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p><a href="mailto:mscott@mozilla.org" title="mscott@mozilla.org">Scott MacGregor</a> writes: "The second release candidate of Mozilla Thunderbird 1.5 is now available for download. Mozilla Thunderbird 1.5 RC2 is intended to allow testers to ensure that there are no last-minute problems with the Thunderbird 1.5 code. "</p> - <p>"RC2 contains several key bug fixes that were identified during the RC1 testing cycle. There are no new features or enchancements from RC1. Users of Thunderbird 1.5 RC1 will be offered RC 2 through the software update system."</p> - <p>"Thunderbird 1.5 RC2 can be downloaded from the <a href="http://www.mozilla.org/products/thunderbird/releases/1.5.html" -> Thunderbird 1.5 RC2 Release Notes</a> page, or the <a href="http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/1.5rc2/">Thunderbird 1.5rc2 directory on ftp.mozilla.org</a>. More details can be found in the Release Notes."</p> - <p>"I'd like to single out all of the folks who participated in our QA testing day and our localization testing day. We wouldn't have been able to release RC2 before the holidays without all the volunteers who pitched in. Thank you!"</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7823">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Interview with Mike Beltzner</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7820" /> - <modified>2005-12-20T23:00:29-08:00</modified> - <created>2005-12-20T23:00:29-08:00</created> - <issued>2005-12-20T23:00:29-08:00</issued> - <id>tag:mozillazine.org,2004:article7820</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p><a href="http://djst.org/blog">David Tenser</a> has posted an <a href="http://djst.org/blog/2005/12/19/interview-with-mozillas-user-experience-lead-mike-beltzner/" title="djst's improved nest: Interview with Mozilla’s User Experience Lead Mike Beltzner">interview with Mozilla Foundation's User Experience Lead, Mike Beltzner</a>. The interview was conducted over instant messaging sessions during the last week of November. <a href="http://www.beltzner.ca/mike/">Mike</a> talks about usability studies, design of the Mozilla Developer Central, and the new bookmark system planned for Firefox 2.</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7820">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Gecko 1.9 Trunk and 1.8 Branch Management Plan Posted</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7819" /> - <modified>2005-12-20T18:08:36-08:00</modified> - <created>2005-12-20T18:08:36-08:00</created> - <issued>2005-12-20T18:08:36-08:00</issued> - <id>tag:mozillazine.org,2004:article7819</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p><a href="http://weblogs.mozillazine.org/roadmap/">Brendan Eich</a> has posted a <a href="http://wiki.mozilla.org/Global:1.9_Trunk_1.8_Branch_Plan">draft plan for Gecko 1.9 Trunk and 1.8 Branch Management</a>, including a <a href="http://wiki.mozilla.org/index.php?title=Global:1.9_Trunk_1.8_Branch_Plan#A_Dialog.2C_or_FAQ">FAQ</a> at the mozilla wiki. Comments should be directed as followups to the <a href="http://groups.google.com/group/netscape.public.mozilla.builds/browse_thread/thread/d845b9a616ebf42d/">newsgroup post</a>. -</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7819">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Minutes of the mozilla.org Staff Meeting of Monday 12th December 2005</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7818" /> - <modified>2005-12-20T18:04:08-08:00</modified> - <created>2005-12-20T18:04:08-08:00</created> - <issued>2005-12-20T18:04:08-08:00</issued> - <id>tag:mozillazine.org,2004:article7818</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>The minutes of the <a href="http://groups.google.com/group/netscape.public.mozilla.seamonkey/browse_thread/thread/fd2034cb74bf085b/" title="netscape.public.mozilla.seamonkey: 2005-12-12 - Summary of mozilla.org staff meeting">mozilla.org staff meeting held on Monday 12th December 2005</a> are now online. Issues discussed include Firefox Summit, Engineering, Upgrading, Awards and Newsgroups reorganisation</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7818">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>Minutes of the mozilla.org Staff Meeting of Monday 5th December 2005</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7817" /> - <modified>2005-12-20T18:02:08-08:00</modified> - <created>2005-12-20T18:02:08-08:00</created> - <issued>2005-12-20T18:02:08-08:00</issued> - <id>tag:mozillazine.org,2004:article7817</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p>The minutes of the <a href="http://groups.google.com/group/netscape.public.mozilla.seamonkey/browse_thread/thread/139be9195e0120eb/" title="netscape.public.mozilla.seamonkey: 2005-12-05 - Summary of mozilla.org staff meeting">mozilla.org staff meeting held on Monday 5th December 2005</a> are now online. Issues discussed include Firefox Summit and Engineering.</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7817">Talkback</a></p>]]> - </content> - </entry> - - <entry> - <title>SeaMonkey 1.0 Beta Released</title> - <link rel="alternate" type="text/html" href="http://www.mozillazine.org/talkback.html?article=7815" /> - <modified>2005-12-20T17:41:12-08:00</modified> - <created>2005-12-20T17:41:12-08:00</created> - <issued>2005-12-20T17:41:12-08:00</issued> - <id>tag:mozillazine.org,2004:article7815</id> - <author> - <name>mozillaZine.org</name> - </author> - <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mozillazine.org/"> - <![CDATA[<p><a href="mailto:kairo@kairo.at">Robert Kaiser</a> writes: "Today, the SeaMonkey Council announces a new developer release, <a href="http://www.mozilla.org/projects/seamonkey/releases/">SeaMonkey 1.0 Beta</a>. Compared to the Alpha version released in September, SeaMonkey 1.0 Beta enhances the product with new features like tab drag and drop, but also is the first release branded with the <a href="http://www.mozilla.org/projects/seamonkey/artwork.html">new SeaMonkey logo</a>, which was unveiled earlier this month."</p> - <p>"The <a href="http://www.mozilla.org/projects/seamonkey/releases/seamonkey1.0b/">SeaMonkey 1.0 Beta Release Notes</a> have more information about this test version. All the builds are available from the <a href="http://ftp.mozilla.org/pub/mozilla.org/seamonkey/releases/1.0b/">SeaMonkey 1.0b directory on ftp.mozilla.org</a>."</p>]]> - <![CDATA[<p><a href="http://www.mozillazine.org/talkback.html?article=7815">Talkback</a></p>]]> - </content> - </entry> - -</feed> diff --git a/tests/Zend/Feed/_files/AtomTestOReilly.xml b/tests/Zend/Feed/_files/AtomTestOReilly.xml deleted file mode 100644 index bc9645ee39cf94fb2037121b9f524e3285045475..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestOReilly.xml +++ /dev/null @@ -1,214 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> - -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:itunes='http://www.itunes.com/dtds/podcast-1.0.dtd' -xml:lang='en-US'> - -<title>weblogs.oreilly.com</title> -<link rel="alternate" type="text/html" href="http://weblogs.oreilly.com/" hreflang="en" title="weblogs.oreilly.com" /> -<subtitle type='text'>The O'Reilly Network Weblogs</subtitle> -<rights>Copyright 2005, O'Reilly Media, Inc.</rights> -<id>http://weblogs.oreilly.com/</id> -<updated>2006-01-23T09:16:40-08:00</updated> -<link rel="self" type="application/atom+xml" href="http://www.oreillynet.com/pub/feed/25"/> -<itunes:author>O'Reilly Media, Inc.</itunes:author> -<itunes:category text='Technology' /> -<itunes:explicit>no</itunes:explicit> - -<entry> - <title>Delightful Javascript Libs -- LGPL, Too.</title> - <id>http://www.oreillynet.com/pub/wlg/9085</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9085'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Here are some fundamental, well made JS goodies: Vectorgraphics Library, Drag'nDrop & DHTML Library, Tooltips with JavaScript Lib, and Rotate Image Lib. A pleasure to work with, and LGPL'ed. Also check out the JS Online Function Grapher. - </div> - </summary> - <author><name>Sid Steward</name></author> - <updated>2006-01-23T09:16:40-08:00</updated> -</entry> - -<entry> - <title>Web 2.0: Simple division?</title> - <id>http://www.oreillynet.com/pub/wlg/9084</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9084'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - There's been a lot of talk about the revolutionary change Web 2.0 promises, and it's time to look at the architecture that's leading to that change: a greater split between client and server logic. - </div> - </summary> - <author><name>Simon St. Laurent</name></author> - <updated>2006-01-23T08:15:34-08:00</updated> -</entry> - -<entry> - <title>Don't Give us your Tired Your Poor</title> - <id>http://www.oreillynet.com/pub/wlg/9083</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9083'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Give us your vibrant, exciting, cool, open source Java submissions for this year's OSCON. - </div> - </summary> - <author><name>Daniel H. Steinberg</name></author> - <updated>2006-01-23T07:45:36-08:00</updated> -</entry> - -<entry> - <title>Cutting Through the Patent Thicket</title> - <id>http://www.oreillynet.com/pub/wlg/9082</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9082'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Good succinct summary of the anti-patent argument, including how VC's look at patents and get duped by them. - </div> - </summary> - <author><name>Damien Stolarz</name></author> - <updated>2006-01-23T00:45:30-08:00</updated> -</entry> - -<entry> - <title>The addslashes() Versus mysql_real_escape_string() Debate</title> - <id>http://www.oreillynet.com/pub/wlg/9081</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9081'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Last month, I discussed <a href="http://shiflett.org/archive/177">Google's XSS Vulnerability</a> and provided an <a href="http://shiflett.org/archive/178">example that demonstrates it</a>. I was hoping to highlight why character encoding consistency is important, but apparently the <a href="http://www.sitepoint.com/forums/showthread.php?t=337881"><tt>addslashes()</tt> versus <tt>mysql_real_escape_string()</tt> debate</a> continues. - </div> - </summary> - <author><name>Chris Shiflett</name></author> - <updated>2006-01-22T22:45:11-08:00</updated> -</entry> - -<entry> - <title>RPM Rollback in Fedora Core 4/5</title> - <id>http://www.oreillynet.com/pub/wlg/9080</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9080'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Fedora's yum/rpm system includes a little-known capability: it can rollback a system to a previously-installed state. - </div> - </summary> - <author><name>Chris Tyler</name></author> - <updated>2006-01-22T13:15:12-08:00</updated> -</entry> - -<entry> - <title>Shifting Gears: Switching to Django</title> - <id>http://www.oreillynet.com/pub/wlg/9075</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9075'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - I've been using TurboGears since its public debut around September of last year. I believe it has incredible potential, but I'm finding myself needing something a little different. That something is Django. - </div> - </summary> - <author><name>Jeremy Jones</name></author> - <updated>2006-01-22T12:15:19-08:00</updated> -</entry> - -<entry> - <title>Are We In A Productivity Crisis?</title> - <id>http://www.oreillynet.com/pub/wlg/9079</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9079'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Are we in a new kind of productivity crisis, one in which there is not too little productivity, but too much? - </div> - </summary> - <author><name>Spencer Critchley</name></author> - <updated>2006-01-22T09:45:58-08:00</updated> -</entry> - -<entry> - <title>What Happens When You Edit an Image Stored Outside of iPhoto 6</title> - <id>http://www.oreillynet.com/pub/wlg/9078</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9078'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Is the edited image stored inside or outside of your iPhoto 6 library? - </div> - </summary> - <author><name>Derrick Story</name></author> - <updated>2006-01-22T07:45:58-08:00</updated> -</entry> - -<entry> - <title>Building emacs22 on Mac OS X</title> - <id>http://www.oreillynet.com/pub/wlg/9074</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9074'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Emacs 22 is Mac OS X aware, and can be built either as a Carbon <code>.app</code> double-clickable, or as a typical X11 program. Problem is, the information about how to build it is pretty scattered. Here's what works for me. - </div> - </summary> - <author><name>Chris Adamson</name></author> - <updated>2006-01-21T19:45:53-08:00</updated> -</entry> - -<entry> - <title>hip to bash web2.0, are we?</title> - <id>http://www.oreillynet.com/pub/wlg/9034</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9034'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - It's hip to take some "diggs" at Web 2.0. - </div> - </summary> - <author><name>Timothy M. O'Brien</name></author> - <updated>2006-01-21T15:46:26-08:00</updated> -</entry> - -<entry> - <title>My New Game Development Course at Tufts</title> - <id>http://www.oreillynet.com/pub/wlg/9076</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9076'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - I am teaching a new course at the Tufts University, "Introduction to Game Development," this semester. - </div> - </summary> - <author><name>Ming Chow</name></author> - <updated>2006-01-21T12:46:56-08:00</updated> -</entry> - -<entry> - <title>Tune in to Radio Babylon</title> - <id>http://www.oreillynet.com/pub/wlg/9073</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9073'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - Hardware hacks we'd like to see in iPods, #1 - </div> - </summary> - <author><name>Giles Turnbull</name></author> - <updated>2006-01-20T14:15:54-08:00</updated> -</entry> - -<entry> - <title>A resource for Google maphacks and mashers now at Maphacks,net</title> - <id>http://www.oreillynet.com/pub/wlg/9072</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9072'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - - </div> - </summary> - <author><name>Glenn Letham</name></author> - <updated>2006-01-20T12:16:05-08:00</updated> -</entry> - -<entry> - <title>UK film studio on the hunt for Google earth programmers</title> - <id>http://www.oreillynet.com/pub/wlg/9071</id> - <link rel='alternate' href='http://www.oreillynet.com/pub/wlg/9071'/> - <summary type='xhtml'> - <div xmlns='http://www.w3.org/1999/xhtml'> - - </div> - </summary> - <author><name>Glenn Letham</name></author> - <updated>2006-01-20T11:47:03-08:00</updated> -</entry> - -</feed> - diff --git a/tests/Zend/Feed/_files/AtomTestPlanetPHP.xml b/tests/Zend/Feed/_files/AtomTestPlanetPHP.xml deleted file mode 100644 index 762f01010dca90ddf0fdbea510b14b3341348605..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestPlanetPHP.xml +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0"?> -<feed xmlns="http://www.w3.org/2005/Atom"><title>Planet PHP</title><link rel="alternate" type="text/html" href="http://www.planet-php.net/"/><link rel="self" type="text/html" href="http://www.planet-php.net/atom/"/><subtitle>People blogging about PHP</subtitle><id>http://www.planet-php.net/</id><generator uri="http://planet-php.net/"> - Planet PHP Aggregator - </generator><updated>2006-01-23T16:40:00Z</updated><entry><title type="text">eZ components in Gentoo Linux</title><link rel="alternate" type="text/html" href="http://www.sebastian-bergmann.de/blog/archives/565-eZ-components-in-Gentoo-Linux.html" title="eZ components in Gentoo Linux"/><author><name>Sebastian Bergmann</name></author><id>http://www.sebastian-bergmann.de/blog/archives/565-guid.html</id><updated>2006-01-23T16:40:00Z</updated><published>2006-01-23T16:40:00Z</published><content type="html"><![CDATA[ - The <a href="http://www.sebastian-bergmann.de/blog/exit.php?url_id=8307&entry_id=565" title="http://ez.no/products/ez_components" >eZ components</a>, which provide <i>an enterprise ready general purpose <a href="http://www.sebastian-bergmann.de/blog/exit.php?url_id=8308&entry_id=565" title="http://www.php.net/" >PHP</a> platform</i>, are now available through <a href="http://www.sebastian-bergmann.de/blog/exit.php?url_id=8309&entry_id=565" title="http://www.gentoo.org/" >Gentoo Linux</a>'s portage system:<pre>wopr-mobile ~ # emerge -vp ezc-eZcomponents - -These are the packages that I would merge, in order: - -Calculating dependencies ...done! -[ebuild N ] app-admin/php-toolkit-1.0-r2 0 kB -[ebuild N ] dev-lang/php-5.1.2 0 kB [3] -[ebuild N ] dev-php/PEAR-PEAR-1.4.6 0 kB [2] -[ebuild N ] dev-php5/ezc-Base-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Database-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-PhpGenerator-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Configuration-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-ImageAnalysis-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Archive-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Translation-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Cache-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-ConsoleTools-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-PersistentObject-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-ImageConversion-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Mail-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-UserInput-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Debug-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-EventLog-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Execution-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-eZcomponents-1.0_rc1 0 kB [2] - -Total size of downloads: 0 kB -Portage overlays: - [1] /usr/local/overlay/personal - [2] /usr/local/overlay/cvs - [3] /usr/local/overlay/php/testing - [4] /usr/local/overlay/php/experimental - [5] /usr/local/overlay/gentopia - [6] /usr/local/overlay/xgl</pre> - ]]></content></entry><entry><title type="text">PHP Insecurity</title><link rel="alternate" type="text/html" href="http://shiflett.org/archive/185" title="PHP Insecurity"/><author><name>Chris Shiflett</name></author><id>http://shiflett.org/archive/185</id><updated>2006-01-23T16:15:00Z</updated><published>2006-01-23T16:15:00Z</published><content type="html"><![CDATA[<p><a href="http://www.greebo.net/">Andrew van der Stock</a> has written a <a href="http://www.greebo.net/?p=320">strong criticism</a> of PHP's insecurity. Andrew is a seasoned security expert and a major contributor to <a href="http://www.owasp.org/">OWASP</a>, and he states:</p> -<blockquote>After writing PHP forum software for three years now, I've come to the conclusion that it is basically impossible for normal programmers to write secure PHP code. It takes far too much effort.</blockquote> -<p>He <a href="http://www.greebo.net/?p=320">continues</a>, citing specific areas where he thinks PHP is weak and asserting that "PHP must now mature and take on a proper security architecture."</p> -<p>Many of the insecure features he cites (<tt>register_globals</tt>, <tt>magic_quotes_gpc</tt>, and <tt>safe_mode</tt>) are slated to be removed in <a href="http://shiflett.org/archive/135">PHP 6</a>, but his core complaint seems to revolve around the fact that PHP makes too much power too easily accessible, often granting developers more power and flexibility than they realize (e.g., <a href="http://www.php.net/manual/wrappers.php">wrappers</a>).</p> -<p>Aside from minor language features like taint mode, I don't see what other platforms offer to help prevent inexperienced developers from writing insecure code. Anyone care to enlighten me? :-)</p><p style="margin: 0px; padding: 5px 15px 5px 15px; background: #f1f3fc; border: 1px solid #9fa5ea; color: #676DB8"> - Posted Mon, 23 Jan 2006 16:15:56 GMT in <a href="http://shiflett.org/">Chris Shiflett: The PHP Blog</a><br /> - [ -  - <img border="0" src="http://shiflett.org/images/brainbulb.gif" /> - <a href="http://shiflett.org/archive/185#comments">Discuss</a> -  - | -  - <img border="0" src="http://shiflett.org/images/delicious.gif" /> - <a href="http://del.icio.us/post?url=http%3A%2F%2Fshiflett.org%2Farchive%2F185&title=Chris+Shiflett%3A+PHP+Insecurity">Tag</a> -  - | -  - <img border="0" src="http://shiflett.org/images/digg.gif" /> - <a href="http://digg.com/submit?phase=2&url=http%3A%2F%2Fshiflett.org%2Farchive%2F185">Digg</a> -  - | -  - <img border="0" src="http://shiflett.org/images/furl.gif" /> - <a href="http://furl.net/storeIt.jsp?t=Chris+Shiflett%3A+PHP+Insecurity&u=http%3A%2F%2Fshiflett.org%2Farchive%2F185">Furl</a> -  - | -  - <img border="0" src="http://shiflett.org/images/technorati.gif" /> - <a href="http://technorati.com/cosmos/search.html?url=http%3A%2F%2Fshiflett.org%2Farchive%2F185">Cosmos</a> -  - ] - </p>]]></content></entry><entry><title type="text">Beta release of mobile webmail client (MIMP)</title><link rel="alternate" type="text/html" href="http://janschneider.de/cweb/home/index,channel,25,story,255.html" title="Beta release of mobile webmail client (MIMP)"/><author><name>Horde News</name></author><id>http://janschneider.de/cweb/home/index,channel,25,story,255.html</id><updated>2006-01-23T10:01:00Z</updated><published>2006-01-23T10:01:00Z</published><content type="html"><![CDATA[The beta version of Horde's mobile webmail client, MIMP H3 (1.0-BETA), has been released.]]></content></entry><entry><title type="text">Meet me at php|tek</title><link rel="alternate" type="text/html" href="http://blog.thinkphp.de/archives/81-Meet-me-at-phptek.html" title="Meet me at php|tek"/><author><name>ThinkPHP /dev/blog - PHP</name></author><id>http://blog.thinkphp.de/archives/81-guid.html</id><updated>2006-01-22T22:34:00Z</updated><published>2006-01-22T22:34:00Z</published><content type="html"><![CDATA[ -<p><a href="http://www.phparch.com/tek/">php|tek</a>, the next conference from the <a href="http://www.phparch.com/">php|arch</a> -guys around Marco Tabini who already organized the php|cruise and php|tropics -conferences, will be from April 26th to 28th at Orlando, Florida. As -you can read on the recently published <a href="http://www.phparch.com/tek/tek_schedule.php">schedule</a> -I'll hold two talks. The first talk will be about PHP on the command -line, showing PHP's strength beyond the web which can be helpful to -build, deploy and scale your web-application and even for building apps -completely independent from anything on the web. My second talk will be -about PHP's reflection API. In that session I'll give an introduction -into the API and show how to use it to build modular, dynamic -applications.</p> -<p>If you're in reachable distance you should take the chance to listen and meet PHP developers from all over the world. (Hint: Till January 31st you can get <a -href="http://www.phparch.com/tek/tek_signup.php">early-bird</a> rates!)</p><p>johannes</p> ]]></content></entry><entry><title type="text">Quick Lookup</title><link rel="alternate" type="text/html" href="http://wyome.com/index.php?module=articles&func=display&ptid=10&catid=29-31&aid=507" title="Quick Lookup"/><author><name>John Cox</name></author><id>http://wyome.com/index.php?module=articles&func=display&ptid=10&catid=29-31&aid=507</id><updated>2006-01-22T19:23:00Z</updated><published>2006-01-22T19:23:00Z</published><content type="html"><![CDATA[ <p><a href="http://aonic.net/~qr/info.php">Quick lookup</a> is a very nice little reference tool for lookups of web development documentation. It installs as a simple bookmark which can be changed to your sidebar for look ups of php / css / javascript / mysql documentation. It has a limited scope of features (which isn't a bad thing in my mind):</p> -<blockquote><p>* Multiple tabs<br /> -* PHP / MySQL / CSS / JS reference (MySQL is 55% complete)<br /> -* Examples<br /> -* Search as you type<br /> -* Fast results<br /> -* Remembers your last tab on your revisit<br /> -* Access keys, [alt + (p, m, j, c)]<br /> -</p></blockquote> -<p>I did a cursory install, and it appears to be pretty fast. I think it might be better as part of the <a href="http://chrispederick.com/work/webdeveloper/">Web Developer Extension</a> for Firefox, but as is, I can see the uses.</p> - ]]></content></entry><entry><title type="text">mysql_real_escape_string() versus Prepared Statements</title><link rel="alternate" type="text/html" href="http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html" title="mysql_real_escape_string() versus Prepared Statements"/><author><name>Ilia Alshanetsky</name></author><id>http://ilia.ws/archives/103-guid.html</id><updated>2006-01-22T18:03:00Z</updated><published>2006-01-22T18:03:00Z</published><content type="html"><![CDATA[ -<a href="http://shiflett.org/archive/184">Chris</a> has written a compelling piece about how the use of addslashes() for string escaping in MySQL queries can lead to SQL injection through the abuse of multibyte character sets. In his example he relies on addslashes() to convert an invalid multibyte sequence into a valid one, which also has an embedded ' that is not escaped. And in an ironic twist, the function intended to protect against SQL injection is used to actually trigger it. <br/><br/> -The problem demonstrated, actually goes a bit further, which even makes the prescribed escaping mechanism, mysql_real_escape_string() prone to the same kind of issues affecting addslashes(). The main advantage of the mysql_real_escape_string() over addslashes() lies in the fact that it takes character set into account and thus is able to determine how to properly escape the data. For example, if GBK character set is being used, it will not convert an invalid multibyte sequence 0xbf27 (¿’) into 0xbf5c27 (¿\Â’ or in GBK a single valid multibyte character followed by a single quote). To determine the proper escaping methodology mysql_real_escape_string() needs to know the character set used, which is normally retrieved from the database connection cursor. Herein lies the “trick”. In MySQL there are two ways to change the character set, you can do it by changing in MySQL configuration file (my.cnf) by doing:<br/><br/><div class="bb-code-title">CODE:</div><div class="bb-code">[client]<br/> -default-character-set=GBK</div> <br/><br/> -Or you can change on a per-connection basis, which is a common practice done by people without admin level access to the server via the following query:<br/><br/><div class="bb-code-title">CODE:</div><div class="bb-code">SET CHARACTER SET 'GBK'</div><br/><br/> -The problem with the latter, is that while it most certainly modified the charset it didnÂ’t let the escaping facilities know about it. Which means that mysql_real_escape_string() still works on the basis of the default charset, which if set to latin1 (common default) will make the function work in a manner identical to addslashes() for our purposes. Another word, 0xbf27 will be converted to 0xbf5c27 facilitating the SQL injection. Here is a brief proof of concept.<br/><br/><div class="bb-php-title">PHP:</div><div class="bb-php"><code><font color="#000000"><br/><font color="#0000BB"><?php<br/><br/> -$c </font><font color="#007700">= </font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">, </font><font color="#DD0000">"user"</font><font color="#007700">, </font><font color="#DD0000">"pass"</font><font color="#007700">);<br/></font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"database"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/><br/></font><font color="#FF8000">// change our character set<br/></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"SET CHARACTER SET 'gbk'"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/><br/></font><font color="#FF8000">// create demo table<br/></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"CREATE TABLE users (<br/> -    username VARCHAR(32) PRIMARY KEY,<br/> -    password VARCHAR(32)<br/> -) CHARACTER SET 'GBK'"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"INSERT INTO users VALUES('foo','bar'), ('baz','test')"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/><br/></font><font color="#FF8000">// now the exploit code<br/></font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'username'</font><font color="#007700">] = </font><font color="#0000BB">chr</font><font color="#007700">(</font><font color="#0000BB">0xbf</font><font color="#007700">) . </font><font color="#0000BB">chr</font><font color="#007700">(</font><font color="#0000BB">0x27</font><font color="#007700">) . </font><font color="#DD0000">' OR username = username /*'</font><font color="#007700">; <br/></font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'password'</font><font color="#007700">] = </font><font color="#DD0000">'anything'</font><font color="#007700">; <br/><br/></font></font></code></div><p><i>Truncated by Planet PHP, read more at <a href="http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html">the original</a> (another 2694 bytes)</i></p>]]></content></entry><entry><title type="text">The addslashes() Versus mysql_real_escape_string() Debate</title><link rel="alternate" type="text/html" href="http://shiflett.org/archive/184" title="The addslashes() Versus mysql_real_escape_string() Debate"/><author><name>Chris Shiflett</name></author><id>http://shiflett.org/archive/184</id><updated>2006-01-22T04:15:00Z</updated><published>2006-01-22T04:15:00Z</published><content type="html"><![CDATA[<p>Last month, I discussed <a href="http://shiflett.org/archive/177">Google's XSS Vulnerability</a> and provided an <a href="http://shiflett.org/archive/178">example that demonstrates it</a>. I was hoping to highlight why character encoding consistency is important, but apparently the <a href="http://www.sitepoint.com/forums/showthread.php?t=337881"><tt>addslashes()</tt> versus <tt>mysql_real_escape_string()</tt> debate</a> continues. <a href="http://shiflett.org/archive/178">Demonstrating</a> Google's XSS vulnerability was pretty easy. Demonstrating an SQL injection attack that is immune to <tt>addslashes()</tt> is a bit more involved, but still pretty straightforward.</p> -<p>In <a href="http://en.wikipedia.org/wiki/GBK">GBK</a>, 0xbf27 is not a valid multi-byte character, but 0xbf5c is. Interpreted as single-byte characters, 0xbf27 is 0xbf (¿) followed by 0x27 ('), and 0xbf5c is 0xbf (¿) followed by 0x5c (\).</p> -<p>How does this help? If I want to attempt an SQL injection attack against a MySQL database, having single quotes escaped with a backslash is a bummer. If you're using <tt>addslashes()</tt>, however, I'm in luck. All I need to do is inject something like 0xbf27, and <tt>addslashes()</tt> modifies this to become 0xbf5c27, a valid multi-byte character followed by a single quote. In other words, I can successfully inject a single quote despite your escaping. That's because 0xbf5c is considered to be a single character, not two. Oops, there goes the backslash.</p> -<p>I'm going to use <a href="http://dev.mysql.com/downloads/mysql/5.0.html">MySQL 5.0</a> and PHP's <a href="http://php.net/mysqli">mysqli</a> extension for this demonstration. If you want to try this yourself, make sure you're using GBK. I just changed <tt>/etc/my.cnf</tt>, but that's because I'm testing locally:</p> -<pre class="code">[client] -default-character-set=GBK</pre> -<p>Create a table called <tt>users</tt>:</p> -<pre class="code">CREATE TABLE users -( - username VARCHAR(32) CHARACTER SET GBK, - password VARCHAR(32) CHARACTER SET GBK, - PRIMARY KEY (username) -); -</pre> -<p>The following script mimics a situation where only <tt>addslashes()</tt> is used to escape the data being used in a query:</p> -<pre class="code"><span style="color: #0000BB"><?php <br/><br/>$mysql </span><span style="color: #007700">= array(); <br/><br/></span><span style="color: #0000BB">$db </span><span style="color: #007700">= </span><span style="color: #0000BB">mysqli_init</span><span style="color: #007700">(); <br/></span><span style="color: #0000BB">$db</span><span style="color: #007700">-></span><span style="color: #0000BB">real_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">, </span><span style="color: #DD0000">'myuser'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mypass'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mydb'</span><span style="color: #007700">); <br/><br/></span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">] = </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0xbf</span><span style="color: #007700">) . <br/>                     </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0x27</span><span style="color: #007700">) . <br/>                     </span><span style="color: #DD0000">' OR username = username /*'</span><span style="color: #007700">; <br/></span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'password'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'guess'</span><span style="color: #007700">; <br/><br/></span><span style="color: #0000BB">$mysql</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">] = </span><span style="color: #0000BB">addslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">]); <br/></span><span style="color: #0000BB">$mysql</span><span style="color: #007700">[</span><span style="color: #DD0000">'password'</span><span style="color: #007700">] = </span><span style="color: #0000BB">addslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color</body>"/></pre><p><i>Truncated by Planet PHP, read more at <a href="http://shiflett.org/archive/184">the original</a> (another 4165 bytes)</i></p>]]></content></entry><entry><title type="text">PHP Conferences</title><link rel="alternate" type="text/html" href="http://blog.casey-sweat.us/?p=69" title="PHP Conferences"/><author><name>Jason E. Sweat</name></author><id>http://blog.casey-sweat.us/?p=69</id><updated>2006-01-22T04:04:00Z</updated><published>2006-01-22T04:04:00Z</published><content type="html"><![CDATA[If you have never been to a PHP Conference, you owe it to yourself to make 2006 a year to attend one. There are of course the obvious benefits of attending the presentations and being able to see these presentations first hand as well as being able to interact with the presenters, ask questions, etc. A more subtle benefit is the networking which happens at these conferences. People whom you recognize from email addresses on mailing lists, pseudonyms on forums or names on the covers of PHP books are actually living breathing people (and usually fine, upstanding people at that). PHP conferences are a great opportunity to interact with both the presenters, conference organizers and the other attendees, who likely share many common interests with you, chiefly a passion for PHP and web development.]]></content></entry><entry><title type="text">Back from Norway</title><link rel="alternate" type="text/html" href="http://www.schlitt.info/applications/blog/index.php?/archives/407-Back-from-Norway.html" title="Back from Norway"/><author><name>Tobias Schlitt</name></author><id>http://www.schlitt.info/applications/blog/index.php?/archives/407-guid.html</id><updated>2006-01-22T00:30:00Z</updated><published>2006-01-22T00:30:00Z</published><content type="html"><![CDATA[ -<p>Norway is a somewhat strange country. When I got there - 2 weeks ago to work with Amos, Derick, Fred and Ray on the <a href="http://www.schlitt.info/applications/blog/exit.php?url_id=2247&entry_id=407" title="http://ez.no/products/ez_components" >eZ components</a> - it had the expected amount of snow. A few days later, there was nothing anymore. We had positive celsius values and the weather was really crappy... until Monday. Since then it has been snowing all the time and yesterday we left when it looked like this:</p> - -<p><div style="text-align: center;"><img src="http://schlitt.info/applications/gallery/d/6723-2/pict1285.jpg" width="150" height="113" alt="pict1285.jpg" /></div></p> - -<p>Nice to watch, but not real fun to walk onto. :) Anyway, it's been another great stay in Skien, where the eZ headquarter is and I'm pretty much looking forward to <a href="http://www.schlitt.info/applications/blog/exit.php?url_id=2248&entry_id=407" title="http://ez.no/company/events/ez_publish_conference_2006" >our summer conference</a>, where we plan to have the complete eZ team there and lots of people from the PHP world. Thanks for the great time, folks!</p> - - ]]></content></entry><entry><title type="text">Solar 0.10.0 Released</title><link rel="alternate" type="text/html" href="http://paul-m-jones.com/blog/?p=192" title="Solar 0.10.0 Released"/><author><name>Paul M. Jones</name></author><id>http://paul-m-jones.com/blog/?p=192</id><updated>2006-01-21T21:44:00Z</updated><published>2006-01-21T21:44:00Z</published><content type="html"><![CDATA[The good news is that I've rolled the 0.10.0 release for Solar; the bad news is that it has a ton of changes, and that the release after this will also have large number of changes. Read on for change notes, especially regarding the new MVC architecture.]]></content></entry></feed> diff --git a/tests/Zend/Feed/_files/AtomTestSample1.xml b/tests/Zend/Feed/_files/AtomTestSample1.xml deleted file mode 100644 index 40aa3671b86b3b202757457ff34fbf612f9ce978..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestSample1.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - - <title>Example Feed</title> - <subtitle>Insert witty or insightful remark here</subtitle> - <link href="http://example.org/"/> - <updated>2003-12-13T18:30:02Z</updated> - <author> - <name>John Doe</name> - <email>johndoe@example.com</email> - </author> - <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> - - <entry> - <title>Atom-Powered Robots Run Amok</title> - <link href="http://example.org/2003/12/13/atom03"/> - <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> - <updated>2003-12-13T18:30:02Z</updated> - <summary>Some text.</summary> - </entry> - -</feed> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/AtomTestSample2.xml b/tests/Zend/Feed/_files/AtomTestSample2.xml deleted file mode 100644 index 7a7a628500e889e81d8ca3f4ecb3f1c29916f41a..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestSample2.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - - <title>Example Atom Feed</title> - <updated>2006-01-23T23:04:33Z</updated> - <link rel="self" href="http://www.example.com" /> - <id>http://www.example.com</id> - - <author> - <name>John Doe</name> - <email>John@Example.com</email> - <uri>http://www.example.com</uri> - </author> - -</feed> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/AtomTestSample3.xml b/tests/Zend/Feed/_files/AtomTestSample3.xml deleted file mode 100644 index 0accba88d96f4d19b975e93a3d968d1cfce05d96..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestSample3.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - - <title>Example Atom Feed</title> - <updated>2006-01-23T23:04:33Z</updated> - <link rel="self" href="http://www.example.com" /> - <id>http://www.example.com</id> - - <author> - <name>John Doe</name> - <email>John@Example.com</email> - <uri>http://www.example.com</uri> - </author> - - <entry> - -</feed> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/AtomTestSample4.xml b/tests/Zend/Feed/_files/AtomTestSample4.xml deleted file mode 100644 index 8af5593f771d26f2d8679d27c5402039c4824185..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/AtomTestSample4.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - - <id>http://www.example.com</id> - <title>Example Atom Feed</title> - <updated>2006-01-23T23:04:33Z</updated> - <link rel="self" href="http://www.example.com" /> - - <author> - <name>John Doe</name> - <email>John@Example.com</email> - <uri>http://www.example.com</uri> - </author> - - <entry> - <id>tag:www.example.com,2006-01-23:/post/1234</id> - <title>Mars Attacks Pluto Probe</title> - <updated>2006-01-23T23:04:33Z</updated> - <summary>In upheaval of the tenuous peace between Earth and Mars over the last century, it has been confirmed that a rogue Martian fighter ship suddenly attacked Earth's 2006 probe to Pluto today. Martian delegates have been dispatched to Earth in an effort to quell the political firestorm that has ensued.</summary> - <link rel="alternate" href="/post/1234" /> - </entry> - - <entry> - <id>tag:www.example.com,2006-01-23:/post/1235</id> - <title>Quake Rocks Io</title> - <updated>2006-01-23T23:04:33Z</updated> - <summary>A strong tremor rocked Io this afternoon, and officials are saying that no one has been found alive on Io since the quake.</summary> - <link rel="alternate" href="/post/1235" /> - </entry> - -</feed> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/RssTest091Sample1.xml b/tests/Zend/Feed/_files/RssTest091Sample1.xml deleted file mode 100644 index 65788c3d0e3df0f504a564e84fbd1f40cc8129fc..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTest091Sample1.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<rss version="0.91"> - <channel> - <title>WriteTheWeb</title> - <link>http://writetheweb.com</link> - <description>News for web users that write back</description> - <language>en-us</language> - <copyright>Copyright 2000, WriteTheWeb team.</copyright> - <managingEditor>editor@writetheweb.com</managingEditor> - <webMaster>webmaster@writetheweb.com</webMaster> - <image> - <title>WriteTheWeb</title> - <url>http://writetheweb.com/images/mynetscape88.gif</url> - <link>http://writetheweb.com</link> - <width>88</width> - <height>31</height> - <description>News for web users that write back</description> - </image> - <item> - <title>Giving the world a pluggable Gnutella</title> - <link>http://writetheweb.com/read.php?item=24</link> - <description>WorldOS is a framework on which to build programs that work like Freenet or Gnutella -allowing distributed applications using peer-to-peer routing.</description> - </item> - <item> - <title>Syndication discussions hot up</title> - <link>http://writetheweb.com/read.php?item=23</link> - <description>After a period of dormancy, the Syndication mailing list has become active again, with contributions from leaders in traditional media and Web syndication.</description> - </item> - <item> - <title>Personal web server integrates file sharing and messaging</title> - <link>http://writetheweb.com/read.php?item=22</link> - <description>The Magi Project is an innovative project to create a combined personal web server and messaging system that enables the sharing and synchronization of information across desktop, laptop and palmtop devices.</description> - </item> - <item> - <title>Syndication and Metadata</title> - <link>http://writetheweb.com/read.php?item=21</link> - <description>RSS is probably the best known metadata format around. RDF is probably one of the least understood. In this essay, published on my O'Reilly Network weblog, I argue that the next generation of RSS should be based on RDF.</description> - </item> - <item> - <title>UK bloggers get organised</title> - <link>http://writetheweb.com/read.php?item=20</link> - <description>Looks like the weblogs scene is gathering pace beyond the shores of the US. There's now a UK-specific page on weblogs.com, and a mailing list at egroups.</description> - </item> - <item> - <title>Yournamehere.com more important than anything</title> - <link>http://writetheweb.com/read.php?item=19</link> - <description>Whatever you're publishing on the web, your site name is the most valuable asset you have, according to Carl Steadman.</description> - </item> - </channel> - </rss> diff --git a/tests/Zend/Feed/_files/RssTest092Sample1.xml b/tests/Zend/Feed/_files/RssTest092Sample1.xml deleted file mode 100644 index 5d75c352bd3586e22c6a613d99e441640e0714ca..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTest092Sample1.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0"?> -<!-- RSS generation done by 'Radio UserLand' on Fri, 13 Apr 2001 19:23:02 GMT --> -<rss version="0.92"> - <channel> - <title>Dave Winer: Grateful Dead</title> - <link>http://www.scripting.com/blog/categories/gratefulDead.html</link> - <description>A high-fidelity Grateful Dead song every day. This is where we're experimenting with enclosures on RSS news items that download when you're not using your computer. If it works (it will) it will be the end of the Click-And-Wait multimedia experience on the Internet. </description> - <lastBuildDate>Fri, 13 Apr 2001 19:23:02 GMT</lastBuildDate> - <docs>http://backend.userland.com/rss092</docs> - <managingEditor>dave@userland.com (Dave Winer)</managingEditor> - <webMaster>dave@userland.com (Dave Winer)</webMaster> - <cloud domain="data.ourfavoritesongs.com" port="80" path="/RPC2" registerProcedure="ourFavoriteSongs.rssPleaseNotify" protocol="xml-rpc"/> - <item> - <description>It's been a few days since I added a song to the Grateful Dead channel. Now that there are all these new Radio users, many of whom are tuned into this channel (it's #16 on the hotlist of upstreaming Radio users, there's no way of knowing how many non-upstreaming users are subscribing, have to do something about this..). Anyway, tonight's song is a live version of Weather Report Suite from Dick's Picks Volume 7. It's wistful music. Of course a beautiful song, oft-quoted here on Scripting News. <i>A little change, the wind and rain.</i> -</description> - <enclosure url="http://www.scripting.com/mp3s/weatherReportDicksPicsVol7.mp3" length="6182912" type="audio/mpeg"/> - </item> - <item> - <description>Kevin Drennan started a <a href="http://deadend.editthispage.com/">Grateful Dead Weblog</a>. Hey it's cool, he even has a <a href="http://deadend.editthispage.com/directory/61">directory</a>. <i>A Frontier 7 feature.</i></description> - <source url="http://scriptingnews.userland.com/xml/scriptingNews2.xml">Scripting News</source> - </item> - <item> - <description><a href="http://arts.ucsc.edu/GDead/AGDL/other1.html">The Other One</a>, live instrumental, One From The Vault. Very rhythmic very spacy, you can listen to it many times, and enjoy something new every time.</description> - <enclosure url="http://www.scripting.com/mp3s/theOtherOne.mp3" length="6666097" type="audio/mpeg"/> - </item> - <item> - <description>This is a test of a change I just made. Still diggin..</description> - </item> - <item> - <description>The HTML rendering almost <a href="http://validator.w3.org/check/referer">validates</a>. Close. Hey I wonder if anyone has ever published a style guide for ALT attributes on images? What are you supposed to say in the ALT attribute? I sure don't know. If you're blind send me an email if u cn rd ths. </description> - </item> - <item> - <description><a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/Franklin's_Tower.txt">Franklin's Tower</a>, a live version from One From The Vault.</description> - <enclosure url="http://www.scripting.com/mp3s/franklinsTower.mp3" length="6701402" type="audio/mpeg"/> - </item> - <item> - <description>Moshe Weitzman says Shakedown Street is what I'm lookin for for tonight. I'm listening right now. It's one of my favorites. "Don't tell me this town ain't got no heart." Too bright. I like the jazziness of Weather Report Suite. Dreamy and soft. How about The Other One? "Spanish lady come to me.."</description> - <source url="http://scriptingnews.userland.com/xml/scriptingNews2.xml">Scripting News</source> - </item> - <item> - <description><a href="http://www.scripting.com/mp3s/youWinAgain.mp3">The news is out</a>, all over town..<p> -You've been seen, out runnin round. <p> -The lyrics are <a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/You_Win_Again.txt">here</a>, short and sweet. <p> -<i>You win again!</i> -</description> - <enclosure url="http://www.scripting.com/mp3s/youWinAgain.mp3" length="3874816" type="audio/mpeg"/> - </item> - <item> - <description><a href="http://www.getlyrics.com/lyrics/grateful-dead/wake-of-the-flood/07.htm">Weather Report Suite</a>: "Winter rain, now tell me why, summers fade, and roses die? The answer came. The wind and rain. Golden hills, now veiled in grey, summer leaves have blown away. Now what remains? The wind and rain."</description> - <enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg"/> - </item> - <item> - <description><a href="http://arts.ucsc.edu/gdead/agdl/darkstar.html">Dark Star</a> crashes, pouring its light into ashes.</description> - <enclosure url="http://www.scripting.com/mp3s/darkStar.mp3" length="10889216" type="audio/mpeg"/> - </item> - <item> - <description>DaveNet: <a href="http://davenet.userland.com/2001/01/21/theUsBlues">The U.S. Blues</a>.</description> - </item> - <item> - <description>Still listening to the US Blues. <i>"Wave that flag, wave it wide and high.."</i> Mistake made in the 60s. We gave our country to the assholes. Ah ah. Let's take it back. Hey I'm still a hippie. <i>"You could call this song The United States Blues."</i></description> - </item> - <item> - <description><a href="http://www.sixties.com/html/garcia_stack_0.html"><img src="http://www.scripting.com/images/captainTripsSmall.gif" height="51" width="42" border="0" hspace="10" vspace="10" align="right"></a>In celebration of today's inauguration, after hearing all those great patriotic songs, America the Beautiful, even The Star Spangled Banner made my eyes mist up. It made my choice of Grateful Dead song of the night realllly easy. Here are the <a href="http://searchlyrics2.homestead.com/gd_usblues.html">lyrics</a>. Click on the audio icon to the left to give it a listen. "Red and white, blue suede shoes, I'm Uncle Sam, how do you do?" It's a different kind of patriotic music, but man I love my country and I love Jerry and the band. <i>I truly do!</i></description> - <enclosure url="http://www.scripting.com/mp3s/usBlues.mp3" length="5272510" type="audio/mpeg"/> - </item> - <item> - <description>Grateful Dead: "Tennessee, Tennessee, ain't no place I'd rather be."</description> - <enclosure url="http://www.scripting.com/mp3s/tennesseeJed.mp3" length="3442648" type="audio/mpeg"/> - </item> - <item> - <description>Ed Cone: "Had a nice Deadhead experience with my wife, who never was one but gets the vibe and knows and likes a lot of the music. Somehow she made it to the age of 40 without ever hearing Wharf Rat. We drove to Jersey and back over Christmas with the live album commonly known as Skull and Roses in the CD player much of the way, and it was cool to see her discover one the band's finest moments. That song is unique and underappreciated. Fun to hear that disc again after a few years off -- you get Jerry as blues-guitar hero on Big Railroad Blues and a nice version of Bertha."</description> - <enclosure url="http://www.scripting.com/mp3s/darkStarWharfRat.mp3" length="27503386" type="audio/mpeg"/> - </item> - <item> - <description><a href="http://arts.ucsc.edu/GDead/AGDL/fotd.html">Tonight's Song</a>: "If I get home before daylight I just might get some sleep tonight." </description> - <enclosure url="http://www.scripting.com/mp3s/friendOfTheDevil.mp3" length="3219742" type="audio/mpeg"/> - </item> - <item> - <description><a href="http://arts.ucsc.edu/GDead/AGDL/uncle.html">Tonight's song</a>: "Come hear Uncle John's Band by the river side. Got some things to talk about here beside the rising tide."</description> - <enclosure url="http://www.scripting.com/mp3s/uncleJohnsBand.mp3" length="4587102" type="audio/mpeg"/> - </item> - <item> - <description><a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/Me_and_My_Uncle.txt">Me and My Uncle</a>: "I loved my uncle, God rest his soul, taught me good, Lord, taught me all I know. Taught me so well, I grabbed that gold and I left his dead ass there by the side of the road." -</description> - <enclosure url="http://www.scripting.com/mp3s/meAndMyUncle.mp3" length="2949248" type="audio/mpeg"/> - </item> - <item> - <description>Truckin, like the doo-dah man, once told me gotta play your hand. Sometimes the cards ain't worth a dime, if you don't lay em down.</description> - <enclosure url="http://www.scripting.com/mp3s/truckin.mp3" length="4847908" type="audio/mpeg"/> - </item> - <item> - <description>Two-Way-Web: <a href="http://www.thetwowayweb.com/payloadsForRss">Payloads for RSS</a>. "When I started talking with Adam late last year, he wanted me to think about high quality video on the Internet, and I totally didn't want to hear about it."</description> - </item> - <item> - <description>A touch of gray, kinda suits you anyway..</description> - <enclosure url="http://www.scripting.com/mp3s/touchOfGrey.mp3" length="5588242" type="audio/mpeg"/> - </item> - <item> - <description><a href="http://www.sixties.com/html/garcia_stack_0.html"><img src="http://www.scripting.com/images/captainTripsSmall.gif" height="51" width="42" border="0" hspace="10" vspace="10" align="right"></a>In celebration of today's inauguration, after hearing all those great patriotic songs, America the Beautiful, even The Star Spangled Banner made my eyes mist up. It made my choice of Grateful Dead song of the night realllly easy. Here are the <a href="http://searchlyrics2.homestead.com/gd_usblues.html">lyrics</a>. Click on the audio icon to the left to give it a listen. "Red and white, blue suede shoes, I'm Uncle Sam, how do you do?" It's a different kind of patriotic music, but man I love my country and I love Jerry and the band. <i>I truly do!</i></description> - <enclosure url="http://www.scripting.com/mp3s/usBlues.mp3" length="5272510" type="audio/mpeg"/> - </item> - </channel> - </rss> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/RssTest100Sample1.xml b/tests/Zend/Feed/_files/RssTest100Sample1.xml deleted file mode 100644 index cd884501ddf6556546d562790877e7f7133dd87d..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTest100Sample1.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0"?> - -<rdf:RDF - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns="http://purl.org/rss/1.0/" -> - - <channel rdf:about="http://www.xml.com/xml/news.rss"> - <title>XML.com</title> - <link>http://xml.com/pub</link> - <description> - XML.com features a rich mix of information and services - for the XML community. - </description> - - <image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" /> - - <items> - <rdf:Seq> - <rdf:li resource="http://xml.com/pub/2000/08/09/xslt/xslt.html" /> - <rdf:li resource="http://xml.com/pub/2000/08/09/rdfdb/index.html" /> - </rdf:Seq> - </items> - - <textinput rdf:resource="http://search.xml.com" /> - - </channel> - - <image rdf:about="http://xml.com/universal/images/xml_tiny.gif"> - <title>XML.com</title> - <link>http://www.xml.com</link> - <url>http://xml.com/universal/images/xml_tiny.gif</url> - </image> - - <item rdf:about="http://xml.com/pub/2000/08/09/xslt/xslt.html"> - <title>Processing Inclusions with XSLT</title> - <link>http://xml.com/pub/2000/08/09/xslt/xslt.html</link> - <description> - Processing document inclusions with general XML tools can be - problematic. This article proposes a way of preserving inclusion - information through SAX-based processing. - </description> - </item> - - <item rdf:about="http://xml.com/pub/2000/08/09/rdfdb/index.html"> - <title>Putting RDF to Work</title> - <link>http://xml.com/pub/2000/08/09/rdfdb/index.html</link> - <description> - Tool and API support for the Resource Description Framework - is slowly coming of age. Edd Dumbill takes a look at RDFDB, - one of the most exciting new RDF toolkits. - </description> - </item> - - <textinput rdf:about="http://search.xml.com"> - <title>Search XML.com</title> - <description>Search XML.com's XML collection</description> - <name>s</name> - <link>http://search.xml.com</link> - </textinput> - -</rdf:RDF> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/RssTest100Sample2.xml b/tests/Zend/Feed/_files/RssTest100Sample2.xml deleted file mode 100644 index 5b4cbc4650ed88807a3c94ac9fb01c76b2295a23..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTest100Sample2.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<rdf:RDF - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" - xmlns:co="http://purl.org/rss/1.0/modules/company/" - xmlns:ti="http://purl.org/rss/1.0/modules/textinput/" - xmlns="http://purl.org/rss/1.0/" -> - - <channel rdf:about="http://meerkat.oreillynet.com/?_fl=rss1.0"> - <title>Meerkat</title> - <link>http://meerkat.oreillynet.com</link> - <description>Meerkat: An Open Wire Service</description> - <dc:publisher>The O'Reilly Network</dc:publisher> - <dc:creator>Rael Dornfest (mailto:rael@oreilly.com)</dc:creator> - <dc:rights>Copyright © 2000 O'Reilly & Associates, Inc.</dc:rights> - <dc:date>2000-01-01T12:00+00:00</dc:date> - <sy:updatePeriod>hourly</sy:updatePeriod> - <sy:updateFrequency>2</sy:updateFrequency> - <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase> - - <image rdf:resource="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg" /> - - <items> - <rdf:Seq> - <rdf:li resource="http://c.moreover.com/click/here.pl?r123" /> - </rdf:Seq> - </items> - - <textinput rdf:resource="http://meerkat.oreillynet.com" /> - - </channel> - - <image rdf:about="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg"> - <title>Meerkat Powered!</title> - <url>http://meerkat.oreillynet.com/icons/meerkat-powered.jpg</url> - <link>http://meerkat.oreillynet.com</link> - </image> - - <item rdf:about="http://c.moreover.com/click/here.pl?r123"> - <title>XML: A Disruptive Technology</title> - <link>http://c.moreover.com/click/here.pl?r123</link> - <dc:description> - XML is placing increasingly heavy loads on the existing technical - infrastructure of the Internet. - </dc:description> - <dc:publisher>The O'Reilly Network</dc:publisher> - <dc:creator>Simon St.Laurent (mailto:simonstl@simonstl.com)</dc:creator> - <dc:rights>Copyright © 2000 O'Reilly & Associates, Inc.</dc:rights> - <dc:subject>XML</dc:subject> - <co:name>XML.com</co:name> - <co:market>NASDAQ</co:market> - <co:symbol>XML</co:symbol> - </item> - - <textinput rdf:about="http://meerkat.oreillynet.com"> - <title>Search Meerkat</title> - <description>Search Meerkat's RSS Database...</description> - <name>s</name> - <link>http://meerkat.oreillynet.com/</link> - <ti:function>search</ti:function> - <ti:inputType>regex</ti:inputType> - </textinput> - -</rdf:RDF> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/RssTest200Sample1.xml b/tests/Zend/Feed/_files/RssTest200Sample1.xml deleted file mode 100644 index 7eedaf8137cfd62be429d03edfa664dd83cb48da..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTest200Sample1.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0"?> -<rss version="2.0"> - <channel> - <title>Liftoff News</title> - <link>http://liftoff.msfc.nasa.gov/</link> - <description>Liftoff to Space Exploration.</description> - <language>en-us</language> - <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate> - <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate> - <docs>http://blogs.law.harvard.edu/tech/rss</docs> - <generator>Weblog Editor 2.0</generator> - <managingEditor>editor@example.com</managingEditor> - <webMaster>webmaster@example.com</webMaster> - <item> - <title>Star City</title> - <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link> - <description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm">Star City</a>.</description> - <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate> - <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid> - </item> - <item> - <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a <a href="http://science.nasa.gov/headlines/y2003/30may_solareclipse.htm">partial eclipse of the Sun</a> on Saturday, May 31st.</description> - <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate> - <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid> - </item> - <item> - <title>The Engine That Does More</title> - <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link> - <description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly. The proposed VASIMR engine would do that.</description> - <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate> - <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid> - </item> - <item> - <title>Astronauts' Dirty Laundry</title> - <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link> - <description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them. Instead, astronauts have other options.</description> - <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate> - <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid> - </item> - </channel> -</rss> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/RssTestCNN.xml b/tests/Zend/Feed/_files/RssTestCNN.xml deleted file mode 100644 index b7992aa0d717b8ff5c196634be9298a24023e5ca..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTestCNN.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<rss version="2.0"> -<channel> -<title>CNN.com</title> -<link>http://www.cnn.com/rssclick/?section=cnn_topstories</link> -<description>CNN.com delivers up-to-the-minute news and information on the latest top stories, weather, entertainment, politics and more.</description> -<language>en-us</language> -<copyright>© 2006 Cable News Network LP, LLLP.</copyright> -<pubDate>Mon, 23 Jan 2006 15:11:09 EST</pubDate> -<ttl>5</ttl> -<image> -<title>CNN.com</title> -<link>http://www.cnn.com/rssclick/?section=cnn_topstories</link> -<url>http://i.cnn.net/cnn/.element/img/1.0/logo/cnn.logo.rss.gif</url> -<width>144</width> -<height>33</height> -<description>CNN.com delivers up-to-the-minute news and information on the latest top stories, weather, entertainment, politics and more.</description> -</image> -<item> -<title>Court ruling could lead to BlackBerry shutdown</title> -<link>http://www.cnn.com/rssclick/money/2006/01/23/technology/rim/index.htm?section=cnn_topstories</link> -<description>BlackBerry maker Research in Motion was dealt a setback today when the U.S. Supreme Court turned down a request to review a major patent infringement ruling against the company. Research In Motion (RIM) had petitioned the Supreme Court to review a federal appeals court ruling that could lead to a shutdown of most U.S. BlackBerry sales and service.</description> -<pubDate>Mon, 23 Jan 2006 15:09:23 EST</pubDate> -</item> -<item> -<title>Ford owners not told how to reduce fire risk</title> -<link>http://www.cnn.com/rssclick/2006/US/01/23/ford.fires/index.html?section=cnn_topstories</link> -<description>The parents of three sisters burned to death in a rear-end crash are asking Ford Motor Co. to install the same gas tank protective devices in regular models as it did for its police cars.</description> -<pubDate>Mon, 23 Jan 2006 12:30:45 EST</pubDate> -</item> -<item> -<title>Ford cutting up to 30,000 jobs</title> -<link>http://www.cnn.com/rssclick/money/2006/01/23/news/companies/ford_closings/index.htm?section=cnn_topstories</link> -<description>Ford will close 14 manufacturing plants in North America and cut up to 30,000 jobs in the coming years to try to stem losses and adjust to a new, significantly lower market share. "If we build it, they'll buy it. That's business as usual and it's wrong," said Ford Chairman and CEO Bill Ford . "Our product plans for too long have been defined by our capacity. That's why we must reduce capacity in North America."</description> -<pubDate>Mon, 23 Jan 2006 11:56:19 EST</pubDate> -</item> -<item> -<title>Bush rejects warrantless wiretaps furor</title> -<link>http://www.cnn.com/rssclick/2006/POLITICS/01/23/bush.ap/index.html?section=cnn_topstories</link> -<description>Read full story for latest details.</description> -<pubDate>Mon, 23 Jan 2006 14:25:26 EST</pubDate> -</item> -<item> -<title>Rescuers dig for survivors in collapsed Nairobi building</title> -<link>http://www.cnn.com/rssclick/2006/WORLD/africa/01/23/kenya.building/index.html?section=cnn_topstories</link> -<description>Rescuers are desperately trying to dig out construction workers trapped under the rubble of a five-story building that collapsed today in Nairobi, Kenya. At least 60 people are injured. It was unclear if any workers had died. Witnesses told news agencies they had seen between four and eight bodies but police have given no official death toll yet. Dozens of rescuers dug into the rubble with their bare hands while the injured were taken to hospitals in cars. </description> -<pubDate>Mon, 23 Jan 2006 15:06:36 EST</pubDate> -</item> -<item> -<title>DNA frees man 24 years into 130-year sentence</title> -<link>http://www.cnn.com/rssclick/2006/LAW/01/23/dna.exoneration.ap/index.html?section=cnn_topstories</link> -<description>Read full story for latest details.</description> -<pubDate>Mon, 23 Jan 2006 14:05:16 EST</pubDate> -</item> -<item> -<title>School nurse crisis putting kids at risk</title> -<link>http://www.cnn.com/rssclick/2006/HEALTH/01/23/btsc.cohen/index.html?section=cnn_topstories</link> -<description>A few months ago, I was interviewing a principal at a Chicago, Illinois, public elementary school, when from outside her office came the sounds of a child coughing. </description> -<pubDate>Mon, 23 Jan 2006 12:54:40 EST</pubDate> -</item> -<item> -<title>Russia: Britain used 'rock' to spy</title> -<link>http://www.cnn.com/rssclick/2006/WORLD/europe/01/23/uk.russia.row/index.html?section=cnn_topstories</link> -<description>British official say they are "concerned and surprised" at allegations by a Russian state TV program that UK diplomats used a transmitter embedded in a fake rock as part of a high-tech spying operation in Moscow, news agencies report.</description> -<pubDate>Mon, 23 Jan 2006 14:21:29 EST</pubDate> -</item> -<item> -<title>Buttafuocos plan TV reunion with Amy Fisher</title> -<link>http://www.cnn.com/rssclick/2006/SHOWBIZ/TV/01/23/people.fisher.buttafuoco.reunion.ap/index.html?section=cnn_topstories</link> -<description>Read full story for latest details.</description> -<pubDate>Mon, 23 Jan 2006 13:31:06 EST</pubDate> -</item> -<item> -<title>Could you love the 'world's worst dog'?</title> -<link>http://www.cnn.com/rssclick/2006/SHOWBIZ/books/01/23/books.marley.me.ap/index.html?section=cnn_topstories</link> -<description>Read full story for latest details.</description> -<pubDate>Mon, 23 Jan 2006 12:35:01 EST</pubDate> -</item> -</channel> -</rss> diff --git a/tests/Zend/Feed/_files/RssTestHarvardLaw.xml b/tests/Zend/Feed/_files/RssTestHarvardLaw.xml deleted file mode 100644 index 842ba27aaea1bc3f2de6598419be42d702fb3a1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTestHarvardLaw.xml +++ /dev/null @@ -1,142 +0,0 @@ -<?xml version="1.0"?> -<!-- RSS generated by UserLand Frontier v9.5 on Mon, 23 Jan 2006 20:08:00 GMT --> -<rss version="2.0" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <channel> - <title>Really Simple Syndication</title> - <link>http://blogs.law.harvard.edu/tech/</link> - <description>RSS Advisory Board announcements and RSS news</description> - <creativeCommons:license>http://creativecommons.org/licenses/by-sa/1.0/</creativeCommons:license> - <language>en-us</language> - <pubDate>Sat, 21 Jan 2006 05:00:00 GMT</pubDate> - <lastBuildDate>Sun, 22 Jan 2006 02:01:58 GMT</lastBuildDate> - <docs>http://backend.userland.com/rss</docs> - <generator>UserLand Frontier v9.5</generator> - <category domain="http://www.weblogs.com/rssUpdates/changes.xml">rssUpdates</category> - <managingEditor>rcade@yahoo.com</managingEditor> - <webMaster>rcade@yahoo.com</webMaster> - <item> - <title>Simple Syndication in Communist China</title> - <link>http://english.peopledaily.com.cn/rss/rss.html</link> - <description>The English language edition of <a href="http://english.peopledaily.com.cn/">People's Daily</a>, the official newspaper of the Communist Party of China, offers <a href="http://english.peopledaily.com.cn/rss/rss.html">18 RSS 2.0 newsfeeds</a>.<br> -<br> -In addition to feeds on current events in news, business, sports, and -other areas, the paper devotes feeds to party leaders such as Chinese -President <a href="http://english.people.com.cn/rss/hujintao.xml">Hu Jintao</a> and Premier <a href="http://english.peopledaily.com.cn/rss/rss.html">Wen Jiabao</a>.<br> -<br> -Outside observers of China often look to <span style="font-style: italic;">People's Daily</span> for clues about the inner workings of the government, as described in <a href="http://en.wikipedia.org/wiki/People%27s_Daily">Wikipedia</a>:<br> -<p style="margin-left: 40px;">Newspaper articles in the <span style="font-style: italic;">People's Daily</span> are often not read for -content, so much as placement. A large number of articles devoted to a -political figure or idea is often taken as a sign that that official is -rising.</p><br><br><div style="margin-left: 40px;">In addition, editorials in the <i>People's Daily</i> are also still regarded as fairly authoritative statements of government policy.<br> -</div></description> - <dc:creator>Rogers Cadenhead</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2005/07/10#a852</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=852&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2005%2F07%2F10%23a852</comments> - </item> - <item> - <title>RSS Takes Flight at NASA</title> - <link>http://www.nasa.gov/rss/</link> - <description>The National Aeronautics and Space Administration makes extensive use -of RSS 2.0 to provide news, photographs, and press releases on upcoming -missions and other space-related topics.<br> -<br> -People looking ahead to the planned July 13 launch of the space shuttle Discovery can subscribe to a <a href="http://www.nasa.gov/rss/rtf_news.rss">Return to Flight RSS feed</a>.<br> -<br> -NASA's RSS information page also includes an interesting demonstration of an RSS viewer created in Macromedia Flash.<br></description> - <dc:creator>Rogers Cadenhead</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2005/07/09#a851</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=851&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2005%2F07%2F09%23a851</comments> - </item> - <item> - <title>RSS Usage Skyrockets in the U.S.</title> - <link>http://blogs.law.harvard.edu/tech/2005/01/04#a821</link> - <description>Six million Americans get news and information from RSS aggregators, according to a <a href="http://www.pewinternet.org/pdfs/PIP_blogging_data.pdf">nationwide telephone survey</a> conducted by the Pew Internet and American Life Project in November.<br> -<br> -The project, an ongoing survey of the 120 million Americans using the -Internet, found that 5 percent follow their favorite sources through -RSS syndication. "This is a first-time measurement from our surveys and -is an indicator that this application is gaining an impressive -foothold."<br> -<br> -The survey also found that 27 percent of those polled are weblog -readers, a 58 percent jump in the 9 months since the preceding poll was -conducted.<br></description> - <dc:creator>Rogers Cadenhead</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2005/01/04#a821</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=821&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2005%2F01%2F04%23a821</comments> - </item> - <item> - <title>Added link to encoding examples in RSS 2.0 spec</title> - <link>http://blogs.law.harvard.edu/tech/2004/06/19#a683</link> - <description><P>We added a link to a page of <A href="http://blogs.law.harvard.edu/tech/encodingDescriptions">encoding examples</A> for descriptions, <A href="http://blogs.law.harvard.edu/tech/rss#hrelementsOfLtitemgt">under</A> Elements of &lt;item>. The change is also <A href="http://blogs.law.harvard.edu/tech/rssChangeNotes#61904Dw">noted</A> on the Change Notes page.</P></description> - <dc:creator>Dave Winer</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/06/19#a683</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=683&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F06%2F19%23a683</comments> - </item> - <item> - <title>Proposed clarification for RSS 2.0 spec (revised)</title> - <link>http://blogs.law.harvard.edu/tech/2004/06/15#a648</link> - <description><P>Here's a revised proposal for a clarification to the RSS 2.0 spec.</P> -<P>Under <A href="http://blogs.law.harvard.edu/tech/rss#hrelementsOfLtitemgt">Elements of &lt;item></A>, replace the lead paragraph with the following.<BR></P> -<BLOCKQUOTE> -<P>A channel may contain any number of &lt;item>s. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed<FONT color=green><B>; see <A style="COLOR: green" href="http://blogs.law.harvard.edu/tech/encodingDescriptions">examples</A></B></FONT>), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.</P></BLOCKQUOTE> -<P><STRONG>Notes</STRONG>: The new text is in green. The word examples links to a <A href="http://blogs.law.harvard.edu/tech/encodingDescriptions">page</A> of examples of encodings. We'd like to make the changes to the spec early next week.&nbsp;&nbsp;If you have concerns about this change, please post a comment below, and we will review them before making the change. Thanks to everyone who has participated in the discussion thus far.</P></description> - <dc:creator>Andrew Grumet</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/06/15#a648</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=648&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F06%2F15%23a648</comments> - </item> - <item> - <title>Proposed clarification for RSS 2.0 spec</title> - <link>http://blogs.law.harvard.edu/tech/2004/06/04#a553</link> - <description><P>Requesting comments on a couple of proposed clarifications to the <A href="http://blogs.law.harvard.edu/tech/rss#hrelementsOfLtitemgt">RSS 2.0 spec</A>.</P> -<P>1. Under Elements of &lt;item>, replace the lead paragraph with the following. The new text is highlighted in green.</P> -<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> -<P>A channel may contain any number of &lt;item>s. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text, and the link and title may be omitted. <B><FONT color=green>Either way, &lt;description> contains entity-encoded HTML</FONT>.</B> All elements of an item are optional, however at least one of title or description must be present.</P></BLOCKQUOTE> -<P>2. Immediately following that section, a link to a <A href="http://blogs.law.harvard.edu/tech/encodingDescriptions">page of examples</A>, authored by Nick Bradbury, author of the FeedDemon aggregator.</P> -<P><STRONG>Notes: </STRONG>We believe aggregators already assume the&nbsp;item-level description contains entity-encoded HTML.&nbsp; We'd like to make the changes to the spec early next week and if there are no deal-stoppers, we will. Please comment below. Off-topic and personal comments will be deleted.</P> -<P><STRONG>Thanks to:</STRONG> Nick Bradbury, Brent Simmons, Greg Reinacker, Jake Savin, Dare Obasanjo, Matt Mullenweg for their help working out this proposed clarification.</P></description> - <dc:creator>Dave Winer</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/06/04#a553</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=553&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F06%2F04%23a553</comments> - </item> - <item> - <title>RSS documentation updates</title> - <link>http://blogs.law.harvard.edu/tech/2004/05/31#a550</link> - <description>If you're not tracking this site's <A href="http://blogs.law.harvard.edu/tech/rssChangeNotes">change notes page</A>, you might have missed a few minor edits to the documentation for RSS 2.0:<BR> -<UL> -<LI>The <A href="http://cyber.law.harvard.edu/blogs/gems/tech/rss2sample.xml">RSS 2.0 sample file</A> has been updated. -<LI>An <A href="http://blogs.law.harvard.edu/tech/rssChangeNotes#53104Dw">encoding issue</A> has been fixed on the <A href="http://blogs.law.harvard.edu/tech/skipHoursDays">skipHours and skipDays</A> page. </LI></UL>Suggestions for further improvements to the documentation are encouraged.<BR><BR></description> - <dc:creator>Rogers Cadenhead</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/05/31#a550</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=550&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F05%2F31%23a550</comments> - </item> - <item> - <title>The role of the advisory board</title> - <link>http://blogs.law.harvard.edu/tech/2004/05/18#a540</link> - <description>There's been some confusion about the role of the advisory board. The purpose of this post to try to clear it up.<BR><BR>1. It's got a very conservative mission, to answer questions about RSS, to help people use it, to promote its use. It's basically a support function. <BR><BR>2. Anyone can extend RSS through namespaces. We suggest that people look first to see if there is a core element that already does what they need to do, and if so, use that instead of inventing a new one. That will keep the work of aggregator developers to a minimum, keep the barriers to entry low, help keep the market competitive. Competition should be based on features, performance and price, not compatibility. Compatibility should be easy.<BR><BR>3. Emphatically, this group is not a standards organization. It does not own RSS, or the spec, it has no more or less authority than any other group of people who wish to promote RSS.</description> - <dc:creator>Dave Winer</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/05/18#a540</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=540&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F05%2F18%23a540</comments> - </item> - <item> - <title>Why are dates RFC 822?</title> - <link>http://blogs.law.harvard.edu/tech/2004/05/16#a534</link> - <description><P>Gene Saunders writes: "Why does RSS 2.0 use RFC 822 instead of the (infinitely more modern) RFC 2822?"</P> -<P>Here's why we went with RFC 822:</P> -<P>1. Any scripting software that was used in Internet applications would already have to deal with RFC 822 dates, since that was the format used in email. For most app developers, I imagined, they already had library routines that dealt with 822 format dates. The script environment I was using certainly did. Over the years I've never heard a complaint that people were unable to process 822 dates. <img src="http://static.userland.com/shortcuts/images/qbullets/sidesmiley.gif"></P> -<P>2. 822 dates are not only machine readable, they are also human readable. One of the <A href="http://davenet.scripting.com/2000/09/02/whatToDoAboutRss#rssIsAboutSimplicity">goals</A> of RSS was to be non-intimidating for non-technical users -- they should be able to look at a file and make sense of what's there, where ever possible. </P> -<P>3. Believe it or not, the decision was made in 1997, seven years ago. RSS is a venerable institution, so its anachronisms should be appreciated&nbsp;as one respects a fine wine or an elder statesman, or a format that spawned an incredible market.</P></description> - <dc:creator>Dave Winer</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/05/16#a534</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=534&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F05%2F16%23a534</comments> - </item> - <item> - <title>Speed Meets Feed in Download Tool</title> - <link>http://blogs.law.harvard.edu/tech/2004/03/15#a519</link> - <description><A href="http://www.wired.com/news/infostructure/0,1377,62651,00.html">Wired</A>: "A demo publishing system launched Friday by a popular programmer and blogger merges two of this season's hottest tech fads -- RSS news syndication and BitTorrent file sharing -- to create a cheap publishing system for what its author calls 'big media objects.' The hybrid system is meant to eliminate both the publisher's need for fat bandwidth, and the consumer's need to wait through a grueling download."</description> - <dc:creator>Dave Winer</dc:creator> - <guid>http://blogs.law.harvard.edu/tech/2004/03/15#a519</guid> - <comments>http://blogs.law.harvard.edu/tech/comments?u=tech&amp;p=519&amp;link=http%3A%2F%2Fblogs.law.harvard.edu%2Ftech%2F2004%2F03%2F15%23a519</comments> - </item> - </channel> - </rss> \ No newline at end of file diff --git a/tests/Zend/Feed/_files/RssTestPlanetPHP.xml b/tests/Zend/Feed/_files/RssTestPlanetPHP.xml deleted file mode 100644 index 762f98772706e23c63783222c7a21a38b65d2507..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTestPlanetPHP.xml +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet - href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css" -?> -<rss version="0.91"><channel><title>Planet PHP</title><link>http://planet-php.net</link><description>People blogging about PHP</description><language>en</language><item><title>eZ components in Gentoo Linux - Sebastian Bergmann</title><link>http://www.sebastian-bergmann.de/blog/archives/565-eZ-components-in-Gentoo-Linux.html</link><pubDate>Mon, 23 Jan 2006 16:40:00 +0000</pubDate><description><![CDATA[ - The <a href="http://www.sebastian-bergmann.de/blog/exit.php?url_id=8307&entry_id=565" title="http://ez.no/products/ez_components" >eZ components</a>, which provide <i>an enterprise ready general purpose <a href="http://www.sebastian-bergmann.de/blog/exit.php?url_id=8308&entry_id=565" title="http://www.php.net/" >PHP</a> platform</i>, are now available through <a href="http://www.sebastian-bergmann.de/blog/exit.php?url_id=8309&entry_id=565" title="http://www.gentoo.org/" >Gentoo Linux</a>'s portage system:<pre>wopr-mobile ~ # emerge -vp ezc-eZcomponents - -These are the packages that I would merge, in order: - -Calculating dependencies ...done! -[ebuild N ] app-admin/php-toolkit-1.0-r2 0 kB -[ebuild N ] dev-lang/php-5.1.2 0 kB [3] -[ebuild N ] dev-php/PEAR-PEAR-1.4.6 0 kB [2] -[ebuild N ] dev-php5/ezc-Base-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Database-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-PhpGenerator-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Configuration-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-ImageAnalysis-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Archive-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Translation-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Cache-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-ConsoleTools-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-PersistentObject-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-ImageConversion-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Mail-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-UserInput-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Debug-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-EventLog-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-Execution-1.0_rc1 0 kB [2] -[ebuild N ] dev-php5/ezc-eZcomponents-1.0_rc1 0 kB [2] - -Total size of downloads: 0 kB -Portage overlays: - [1] /usr/local/overlay/personal - [2] /usr/local/overlay/cvs - [3] /usr/local/overlay/php/testing - [4] /usr/local/overlay/php/experimental - [5] /usr/local/overlay/gentopia - [6] /usr/local/overlay/xgl</pre> - ]]></description></item><item><title>PHP Insecurity - Chris Shiflett</title><link>http://shiflett.org/archive/185</link><pubDate>Mon, 23 Jan 2006 16:15:56 +0000</pubDate><description><![CDATA[<p><a href="http://www.greebo.net/">Andrew van der Stock</a> has written a <a href="http://www.greebo.net/?p=320">strong criticism</a> of PHP's insecurity. Andrew is a seasoned security expert and a major contributor to <a href="http://www.owasp.org/">OWASP</a>, and he states:</p> -<blockquote>After writing PHP forum software for three years now, I've come to the conclusion that it is basically impossible for normal programmers to write secure PHP code. It takes far too much effort.</blockquote> -<p>He <a href="http://www.greebo.net/?p=320">continues</a>, citing specific areas where he thinks PHP is weak and asserting that "PHP must now mature and take on a proper security architecture."</p> -<p>Many of the insecure features he cites (<tt>register_globals</tt>, <tt>magic_quotes_gpc</tt>, and <tt>safe_mode</tt>) are slated to be removed in <a href="http://shiflett.org/archive/135">PHP 6</a>, but his core complaint seems to revolve around the fact that PHP makes too much power too easily accessible, often granting developers more power and flexibility than they realize (e.g., <a href="http://www.php.net/manual/wrappers.php">wrappers</a>).</p> -<p>Aside from minor language features like taint mode, I don't see what other platforms offer to help prevent inexperienced developers from writing insecure code. Anyone care to enlighten me? :-)</p><p style="margin: 0px; padding: 5px 15px 5px 15px; background: #f1f3fc; border: 1px solid #9fa5ea; color: #676DB8"> - Posted Mon, 23 Jan 2006 16:15:56 GMT in <a href="http://shiflett.org/">Chris Shiflett: The PHP Blog</a><br /> - [ -  - <img border="0" src="http://shiflett.org/images/brainbulb.gif" /> - <a href="http://shiflett.org/archive/185#comments">Discuss</a> -  - | -  - <img border="0" src="http://shiflett.org/images/delicious.gif" /> - <a href="http://del.icio.us/post?url=http%3A%2F%2Fshiflett.org%2Farchive%2F185&title=Chris+Shiflett%3A+PHP+Insecurity">Tag</a> -  - | -  - <img border="0" src="http://shiflett.org/images/digg.gif" /> - <a href="http://digg.com/submit?phase=2&url=http%3A%2F%2Fshiflett.org%2Farchive%2F185">Digg</a> -  - | -  - <img border="0" src="http://shiflett.org/images/furl.gif" /> - <a href="http://furl.net/storeIt.jsp?t=Chris+Shiflett%3A+PHP+Insecurity&u=http%3A%2F%2Fshiflett.org%2Farchive%2F185">Furl</a> -  - | -  - <img border="0" src="http://shiflett.org/images/technorati.gif" /> - <a href="http://technorati.com/cosmos/search.html?url=http%3A%2F%2Fshiflett.org%2Farchive%2F185">Cosmos</a> -  - ] - </p>]]></description></item><item><title>Beta release of mobile webmail client (MIMP) - Horde News</title><link>http://janschneider.de/cweb/home/index,channel,25,story,255.html</link><pubDate>Mon, 23 Jan 2006 10:01:16 +0000</pubDate><description><![CDATA[The beta version of Horde's mobile webmail client, MIMP H3 (1.0-BETA), has been released.]]></description></item><item><title>Meet me at php|tek - ThinkPHP /dev/blog - PHP</title><link>http://blog.thinkphp.de/archives/81-Meet-me-at-phptek.html</link><pubDate>Sun, 22 Jan 2006 22:34:00 +0000</pubDate><description><![CDATA[ -<p><a href="http://www.phparch.com/tek/">php|tek</a>, the next conference from the <a href="http://www.phparch.com/">php|arch</a> -guys around Marco Tabini who already organized the php|cruise and php|tropics -conferences, will be from April 26th to 28th at Orlando, Florida. As -you can read on the recently published <a href="http://www.phparch.com/tek/tek_schedule.php">schedule</a> -I'll hold two talks. The first talk will be about PHP on the command -line, showing PHP's strength beyond the web which can be helpful to -build, deploy and scale your web-application and even for building apps -completely independent from anything on the web. My second talk will be -about PHP's reflection API. In that session I'll give an introduction -into the API and show how to use it to build modular, dynamic -applications.</p> -<p>If you're in reachable distance you should take the chance to listen and meet PHP developers from all over the world. (Hint: Till January 31st you can get <a -href="http://www.phparch.com/tek/tek_signup.php">early-bird</a> rates!)</p><p>johannes</p> ]]></description></item><item><title>Quick Lookup - John Cox</title><link>http://wyome.com/index.php?module=articles&func=display&ptid=10&catid=29-31&aid=507</link><pubDate>Sun, 22 Jan 2006 19:23:31 +0000</pubDate><description><![CDATA[ <p><a href="http://aonic.net/~qr/info.php">Quick lookup</a> is a very nice little reference tool for lookups of web development documentation. It installs as a simple bookmark which can be changed to your sidebar for look ups of php / css / javascript / mysql documentation. It has a limited scope of features (which isn't a bad thing in my mind):</p> -<blockquote><p>* Multiple tabs<br /> -* PHP / MySQL / CSS / JS reference (MySQL is 55% complete)<br /> -* Examples<br /> -* Search as you type<br /> -* Fast results<br /> -* Remembers your last tab on your revisit<br /> -* Access keys, [alt + (p, m, j, c)]<br /> -</p></blockquote> -<p>I did a cursory install, and it appears to be pretty fast. I think it might be better as part of the <a href="http://chrispederick.com/work/webdeveloper/">Web Developer Extension</a> for Firefox, but as is, I can see the uses.</p> - ]]></description></item><item><title>mysql_real_escape_string() versus Prepared Statements - Ilia Alshanetsky</title><link>http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html</link><pubDate>Sun, 22 Jan 2006 18:03:59 +0000</pubDate><description><![CDATA[ -<a href="http://shiflett.org/archive/184">Chris</a> has written a compelling piece about how the use of addslashes() for string escaping in MySQL queries can lead to SQL injection through the abuse of multibyte character sets. In his example he relies on addslashes() to convert an invalid multibyte sequence into a valid one, which also has an embedded ' that is not escaped. And in an ironic twist, the function intended to protect against SQL injection is used to actually trigger it. <br/><br/> -The problem demonstrated, actually goes a bit further, which even makes the prescribed escaping mechanism, mysql_real_escape_string() prone to the same kind of issues affecting addslashes(). The main advantage of the mysql_real_escape_string() over addslashes() lies in the fact that it takes character set into account and thus is able to determine how to properly escape the data. For example, if GBK character set is being used, it will not convert an invalid multibyte sequence 0xbf27 (¿’) into 0xbf5c27 (¿\Â’ or in GBK a single valid multibyte character followed by a single quote). To determine the proper escaping methodology mysql_real_escape_string() needs to know the character set used, which is normally retrieved from the database connection cursor. Herein lies the “trick”. In MySQL there are two ways to change the character set, you can do it by changing in MySQL configuration file (my.cnf) by doing:<br/><br/><div class="bb-code-title">CODE:</div><div class="bb-code">[client]<br/> -default-character-set=GBK</div> <br/><br/> -Or you can change on a per-connection basis, which is a common practice done by people without admin level access to the server via the following query:<br/><br/><div class="bb-code-title">CODE:</div><div class="bb-code">SET CHARACTER SET 'GBK'</div><br/><br/> -The problem with the latter, is that while it most certainly modified the charset it didnÂ’t let the escaping facilities know about it. Which means that mysql_real_escape_string() still works on the basis of the default charset, which if set to latin1 (common default) will make the function work in a manner identical to addslashes() for our purposes. Another word, 0xbf27 will be converted to 0xbf5c27 facilitating the SQL injection. Here is a brief proof of concept.<br/><br/><div class="bb-php-title">PHP:</div><div class="bb-php"><code><font color="#000000"><br/><font color="#0000BB"><?php<br/><br/> -$c </font><font color="#007700">= </font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">, </font><font color="#DD0000">"user"</font><font color="#007700">, </font><font color="#DD0000">"pass"</font><font color="#007700">);<br/></font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"database"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/><br/></font><font color="#FF8000">// change our character set<br/></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"SET CHARACTER SET 'gbk'"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/><br/></font><font color="#FF8000">// create demo table<br/></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"CREATE TABLE users (<br/> -    username VARCHAR(32) PRIMARY KEY,<br/> -    password VARCHAR(32)<br/> -) CHARACTER SET 'GBK'"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/></font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#DD0000">"INSERT INTO users VALUES('foo','bar'), ('baz','test')"</font><font color="#007700">, </font><font color="#0000BB">$c</font><font color="#007700">);<br/><br/></font><font color="#FF8000">// now the exploit code<br/></font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'username'</font><font color="#007700">] = </font><font color="#0000BB">chr</font><font color="#007700">(</font><font color="#0000BB">0xbf</font><font color="#007700">) . </font><font color="#0000BB">chr</font><font color="#007700">(</font><font color="#0000BB">0x27</font><font color="#007700">) . </font><font color="#DD0000">' OR username = username /*'</font><font color="#007700">; <br/></font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'password'</font><font color="#007700">] = </font><font color="#DD0000">'anything'</font><font color="#007700">; <br/><br/></font></font></code></div><p><i>Truncated by Planet PHP, read more at <a href="http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html">the original</a> (another 2694 bytes)</i></p>]]></description></item><item><title>The addslashes() Versus mysql_real_escape_string() Debate - Chris Shiflett</title><link>http://shiflett.org/archive/184</link><pubDate>Sun, 22 Jan 2006 04:15:58 +0000</pubDate><description><![CDATA[<p>Last month, I discussed <a href="http://shiflett.org/archive/177">Google's XSS Vulnerability</a> and provided an <a href="http://shiflett.org/archive/178">example that demonstrates it</a>. I was hoping to highlight why character encoding consistency is important, but apparently the <a href="http://www.sitepoint.com/forums/showthread.php?t=337881"><tt>addslashes()</tt> versus <tt>mysql_real_escape_string()</tt> debate</a> continues. <a href="http://shiflett.org/archive/178">Demonstrating</a> Google's XSS vulnerability was pretty easy. Demonstrating an SQL injection attack that is immune to <tt>addslashes()</tt> is a bit more involved, but still pretty straightforward.</p> -<p>In <a href="http://en.wikipedia.org/wiki/GBK">GBK</a>, 0xbf27 is not a valid multi-byte character, but 0xbf5c is. Interpreted as single-byte characters, 0xbf27 is 0xbf (¿) followed by 0x27 ('), and 0xbf5c is 0xbf (¿) followed by 0x5c (\).</p> -<p>How does this help? If I want to attempt an SQL injection attack against a MySQL database, having single quotes escaped with a backslash is a bummer. If you're using <tt>addslashes()</tt>, however, I'm in luck. All I need to do is inject something like 0xbf27, and <tt>addslashes()</tt> modifies this to become 0xbf5c27, a valid multi-byte character followed by a single quote. In other words, I can successfully inject a single quote despite your escaping. That's because 0xbf5c is considered to be a single character, not two. Oops, there goes the backslash.</p> -<p>I'm going to use <a href="http://dev.mysql.com/downloads/mysql/5.0.html">MySQL 5.0</a> and PHP's <a href="http://php.net/mysqli">mysqli</a> extension for this demonstration. If you want to try this yourself, make sure you're using GBK. I just changed <tt>/etc/my.cnf</tt>, but that's because I'm testing locally:</p> -<pre class="code">[client] -default-character-set=GBK</pre> -<p>Create a table called <tt>users</tt>:</p> -<pre class="code">CREATE TABLE users -( - username VARCHAR(32) CHARACTER SET GBK, - password VARCHAR(32) CHARACTER SET GBK, - PRIMARY KEY (username) -); -</pre> -<p>The following script mimics a situation where only <tt>addslashes()</tt> is used to escape the data being used in a query:</p> -<pre class="code"><span style="color: #0000BB"><?php <br/><br/>$mysql </span><span style="color: #007700">= array(); <br/><br/></span><span style="color: #0000BB">$db </span><span style="color: #007700">= </span><span style="color: #0000BB">mysqli_init</span><span style="color: #007700">(); <br/></span><span style="color: #0000BB">$db</span><span style="color: #007700">-></span><span style="color: #0000BB">real_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">, </span><span style="color: #DD0000">'myuser'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mypass'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mydb'</span><span style="color: #007700">); <br/><br/></span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">] = </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0xbf</span><span style="color: #007700">) . <br/>                     </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">0x27</span><span style="color: #007700">) . <br/>                     </span><span style="color: #DD0000">' OR username = username /*'</span><span style="color: #007700">; <br/></span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'password'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'guess'</span><span style="color: #007700">; <br/><br/></span><span style="color: #0000BB">$mysql</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">] = </span><span style="color: #0000BB">addslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">]); <br/></span><span style="color: #0000BB">$mysql</span><span style="color: #007700">[</span><span style="color: #DD0000">'password'</span><span style="color: #007700">] = </span><span style="color: #0000BB">addslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color</body>"/></pre><p><i>Truncated by Planet PHP, read more at <a href="http://shiflett.org/archive/184">the original</a> (another 4165 bytes)</i></p>]]></description></item><item><title>PHP Conferences - Jason E. Sweat</title><link>http://blog.casey-sweat.us/?p=69</link><pubDate>Sun, 22 Jan 2006 04:04:14 +0000</pubDate><description><![CDATA[If you have never been to a PHP Conference, you owe it to yourself to make 2006 a year to attend one. There are of course the obvious benefits of attending the presentations and being able to see these presentations first hand as well as being able to interact with the presenters, ask questions, etc. A more subtle benefit is the networking which happens at these conferences. People whom you recognize from email addresses on mailing lists, pseudonyms on forums or names on the covers of PHP books are actually living breathing people (and usually fine, upstanding people at that). PHP conferences are a great opportunity to interact with both the presenters, conference organizers and the other attendees, who likely share many common interests with you, chiefly a passion for PHP and web development.]]></description></item><item><title>Back from Norway - Tobias Schlitt</title><link>http://www.schlitt.info/applications/blog/index.php?/archives/407-Back-from-Norway.html</link><pubDate>Sun, 22 Jan 2006 00:30:57 +0000</pubDate><description><![CDATA[ -<p>Norway is a somewhat strange country. When I got there - 2 weeks ago to work with Amos, Derick, Fred and Ray on the <a href="http://www.schlitt.info/applications/blog/exit.php?url_id=2247&entry_id=407" title="http://ez.no/products/ez_components" >eZ components</a> - it had the expected amount of snow. A few days later, there was nothing anymore. We had positive celsius values and the weather was really crappy... until Monday. Since then it has been snowing all the time and yesterday we left when it looked like this:</p> - -<p><div style="text-align: center;"><img src="http://schlitt.info/applications/gallery/d/6723-2/pict1285.jpg" width="150" height="113" alt="pict1285.jpg" /></div></p> - -<p>Nice to watch, but not real fun to walk onto. :) Anyway, it's been another great stay in Skien, where the eZ headquarter is and I'm pretty much looking forward to <a href="http://www.schlitt.info/applications/blog/exit.php?url_id=2248&entry_id=407" title="http://ez.no/company/events/ez_publish_conference_2006" >our summer conference</a>, where we plan to have the complete eZ team there and lots of people from the PHP world. Thanks for the great time, folks!</p> - - ]]></description></item><item><title>Solar 0.10.0 Released - Paul M. Jones</title><link>http://paul-m-jones.com/blog/?p=192</link><pubDate>Sat, 21 Jan 2006 21:44:43 +0000</pubDate><description><![CDATA[The good news is that I've rolled the 0.10.0 release for Solar; the bad news is that it has a ton of changes, and that the release after this will also have large number of changes. Read on for change notes, especially regarding the new MVC architecture.]]></description></item></channel></rss> diff --git a/tests/Zend/Feed/_files/RssTestSlashdot.xml b/tests/Zend/Feed/_files/RssTestSlashdot.xml deleted file mode 100644 index 2ae85d9ae1809038b1e60f8ee7e75a326a5d3fc8..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/RssTestSlashdot.xml +++ /dev/null @@ -1,178 +0,0 @@ -<?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/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"> - <channel rdf:about="http://slashdot.org/"> - <title>Slashdot</title> - <link>http://slashdot.org/</link> - <description>News for nerds, stuff that matters</description> - <dc:language>en-us</dc:language> - <dc:rights>Copyright 1997-2005, OSTG - Open Source Technology Group, Inc. All Rights Reserved.</dc:rights> - <dc:date>2006-01-23T20:11:00+00:00</dc:date> - <dc:publisher>OSTG</dc:publisher> - <dc:creator>pater@slashdot.org</dc:creator> - <dc:subject>Technology</dc:subject> - <syn:updatePeriod>hourly</syn:updatePeriod> - <syn:updateFrequency>1</syn:updateFrequency> - <syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase> - <items> - <rdf:Seq> - <rdf:li rdf:resource="http://slashdot.org/article.pl?sid=06/01/23/1517205&from=rss" /> - <rdf:li rdf:resource="http://books.slashdot.org/article.pl?sid=06/01/23/1411250&from=rss" /> - <rdf:li rdf:resource="http://yro.slashdot.org/article.pl?sid=06/01/23/1744258&from=rss" /> - <rdf:li rdf:resource="http://hardware.slashdot.org/article.pl?sid=06/01/23/1544235&from=rss" /> - <rdf:li rdf:resource="http://slashdot.org/article.pl?sid=06/01/19/175253&from=rss" /> - <rdf:li rdf:resource="http://it.slashdot.org/article.pl?sid=06/01/23/152211&from=rss" /> - <rdf:li rdf:resource="http://yro.slashdot.org/article.pl?sid=06/01/23/1450249&from=rss" /> - <rdf:li rdf:resource="http://apple.slashdot.org/article.pl?sid=06/01/23/1333220&from=rss" /> - <rdf:li rdf:resource="http://it.slashdot.org/article.pl?sid=06/01/23/0340241&from=rss" /> - <rdf:li rdf:resource="http://games.slashdot.org/article.pl?sid=06/01/23/1244201&from=rss" /> - </rdf:Seq> - </items> - <image rdf:resource="http://images.slashdot.org/topics/topicslashdot.gif" /> - <textinput rdf:resource="http://slashdot.org/search.pl" /> - </channel> - <image rdf:about="http://images.slashdot.org/topics/topicslashdot.gif"> - <title>Slashdot</title> - <url>http://images.slashdot.org/topics/topicslashdot.gif</url> - <link>http://slashdot.org/</link> - </image> - <item rdf:about="http://slashdot.org/article.pl?sid=06/01/23/1517205&from=rss"> - <title>Interview with Mark Spencer of Asterisk</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3264</link> - <description>comforteagle writes "OSDir has published an interview with Mark Spencer of Asterisk and Gaim about why and how he got started coding up the software platform PBX system and how it has become much more than -just- another phone system. He also shares his insights for the opportunities within the telecom industry for open source."<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3264"/></description> - <dc:creator>ScuttleMonkey</dc:creator> - <dc:date>2006-01-23T19:47:00+00:00</dc:date> - <dc:subject>communications</dc:subject> - <slash:department>ripe-for-open-source</slash:department> - <slash:section>mainpage</slash:section> - <slash:comments>15</slash:comments> - <slash:hit_parade>15,13,11,6,2,1,1</slash:hit_parade> - <feedburner:origLink>http://slashdot.org/article.pl?sid=06/01/23/1517205&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://books.slashdot.org/article.pl?sid=06/01/23/1411250&from=rss"> - <title>The Adobe Photoshop Elements Crafts Book</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3263</link> - <description>Sdurham writes "Adobe Photoshop and its many siblings have long been a staple of artists, photographers, and programmers interested in doing serious image manipulation. Increasingly, Photoshop's younger sister Photoshop Elements comes prepackaged with digital cameras. Yet many of the users of these cameras lack the time or patience to tackle the steep learning curve of the Photoshop family and are left asking "How do I do ... ?". Elizabeth Bulger's The Adobe Photoshop Elements Crafts Book attempts to bridge the gap between Photoshop skill level and personal creativity by stepping the reader through 14 different craft projects. In doing so, Bulger tries to provide the basic Photoshop Elements skills necessary for readers to pursue their own projects after finishing the book." Read the rest of Sdurham's review.<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3263"/></description> - <dc:creator>samzenpus</dc:creator> - <dc:date>2006-01-23T18:54:00+00:00</dc:date> - <dc:subject>books</dc:subject> - <slash:department>update-your-prom-pictures</slash:department> - <slash:section>books</slash:section> - <slash:comments>18</slash:comments> - <slash:hit_parade>18,15,9,5,3,1,0</slash:hit_parade> - <feedburner:origLink>http://books.slashdot.org/article.pl?sid=06/01/23/1411250&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://yro.slashdot.org/article.pl?sid=06/01/23/1744258&from=rss"> - <title>Supreme Court spurns RIM</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3262</link> - <description>l2718 writes "NTP has just won the latest round in its court battle against Research in Motion (makers of the Blackberry). Today's Order List from the US Supreme Court includes a denial of certiorary for RIM's appeal. This follows the Circuit Court of Appeals' denial of review en banc we have covered previously. As sometimes happens, the court nevertheless accepted amicus curiae briefs from several groups, including Intel and the Canadian government." The potential impact of this may mean the shutdown of Blackberry's network. I hope the crackberry addicts have lots of methadone onhand. -<p><a href="http://rss.slashdot.org/~c/Slashdot/slashdot?a=fYMCju"><img src="http://rss.slashdot.org/~c/Slashdot/slashdot?i=fYMCju" border="0"></img></a></p><img src="http://rss.slashdot.org/Slashdot/slashdot?g=3262"/></description> - <dc:creator>Hemos</dc:creator> - <dc:date>2006-01-23T18:22:00+00:00</dc:date> - <dc:subject>patents</dc:subject> - <slash:department>good-bye-black-berry</slash:department> - <slash:section>yro</slash:section> - <slash:comments>138</slash:comments> - <slash:hit_parade>138,131,116,73,15,9,5</slash:hit_parade> - <feedburner:origLink>http://yro.slashdot.org/article.pl?sid=06/01/23/1744258&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://hardware.slashdot.org/article.pl?sid=06/01/23/1544235&from=rss"> - <title>Adult Entertainment Antes Up In DRM War</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3261</link> - <description>At the recent adult entertainment awards, host Greg Fitzsimmons highlighted the deep relationship between the internet and pornography stating "'The Internet was completely funded by porn,' he said [...] And if it wasn't for the Internet, he added, 'you guys would be completely out of business.' The audience, packed with porn actors and adult entertainment moguls like Jenna Jameson and Larry Flynt, roared with laughter." Now it appears that the adult entertainment industry has chosen to ante up in the DRM battle as well. Some companies have chosen to take sides, like Digital Playground who will be supporting Sony's Blu-Ray. Others, like Vivid Entertainment, seem to think that the answer is diversity and will be supporting both Blu-Ray and HD-DVD.<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3261"/></description> - <dc:creator>ScuttleMonkey</dc:creator> - <dc:date>2006-01-23T17:37:00+00:00</dc:date> - <dc:subject>media</dc:subject> - <slash:department>can't-we-all-just-get-along</slash:department> - <slash:section>hardware</slash:section> - <slash:comments>152</slash:comments> - <slash:hit_parade>152,146,124,84,34,17,12</slash:hit_parade> - <feedburner:origLink>http://hardware.slashdot.org/article.pl?sid=06/01/23/1544235&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://slashdot.org/article.pl?sid=06/01/19/175253&from=rss"> - <title>Slashdot Index Code Update</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3259</link> - <description>For years now Slashdot has posted what we call "Sectional Content". That is to say, stories that we think are good, but since we try to keep the Slashdot Main Page to around 15 stories per day, some stuff just gets put into the sections. This content is mostly lost to readers who simply don't know it exists. Today we're deploying new code to help you find that content (and alternatively, to disable it).<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3259"/></description> - <dc:creator>CmdrTaco</dc:creator> - <dc:date>2006-01-23T17:00:00+00:00</dc:date> - <dc:subject>slashdot</dc:subject> - <slash:department>zomg-you-got-some-ajax-in-our-ui</slash:department> - <slash:section>mainpage</slash:section> - <slash:comments>247</slash:comments> - <slash:hit_parade>247,231,192,142,41,21,14</slash:hit_parade> - <feedburner:origLink>http://slashdot.org/article.pl?sid=06/01/19/175253&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://it.slashdot.org/article.pl?sid=06/01/23/152211&from=rss"> - <title>IE7 Leaked</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3260</link> - <description>lju writes "IE7 has been leaked according to pcpro. From the article: '...last Friday it was revealed that a build of the new browser - version 5299 - along with numerous screenshots, was available online.' " -<p><a href="http://rss.slashdot.org/~c/Slashdot/slashdot?a=jVTbOh"><img src="http://rss.slashdot.org/~c/Slashdot/slashdot?i=jVTbOh" border="0"></img></a></p><img src="http://rss.slashdot.org/Slashdot/slashdot?g=3260"/></description> - <dc:creator>CmdrTaco</dc:creator> - <dc:date>2006-01-23T16:41:00+00:00</dc:date> - <dc:subject>microsoft</dc:subject> - <slash:department>hate-when-that-happens</slash:department> - <slash:section>it</slash:section> - <slash:comments>265</slash:comments> - <slash:hit_parade>265,257,202,137,52,31,19</slash:hit_parade> - <feedburner:origLink>http://it.slashdot.org/article.pl?sid=06/01/23/152211&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://yro.slashdot.org/article.pl?sid=06/01/23/1450249&from=rss"> - <title>The Future of e-Commerce and e-Information?</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3257</link> - <description>An anonymous reader writes "The Washington Post has an interesting article on what they label 'The Coming Tug of War Over the Internet. From the article: 'Do you prefer to search for information online with Google or Yahoo? What about bargain shopping -- do you go to Amazon or eBay? Many of us make these kinds of decisions several times a day, based on who knows what -- maybe you don't like bidding, or maybe Google's clean white search page suits you better than Yahoo's colorful clutter. But the nation's largest telephone companies have a new business plan, and if it comes to pass you may one day discover that Yahoo suddenly responds much faster to your inquiries, overriding your affinity for Google. Or that Amazon's Web site seems sluggish compared with eBay's.'" Seems like the idea of the 2-tier internet is really catching on with the market-droids.<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3257"/></description> - <dc:creator>ScuttleMonkey</dc:creator> - <dc:date>2006-01-23T15:46:00+00:00</dc:date> - <dc:subject>biz</dc:subject> - <slash:department>bad-for-the-internet-good-for-business</slash:department> - <slash:section>yro</slash:section> - <slash:comments>159</slash:comments> - <slash:hit_parade>159,157,140,90,25,16,10</slash:hit_parade> - <feedburner:origLink>http://yro.slashdot.org/article.pl?sid=06/01/23/1450249&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://apple.slashdot.org/article.pl?sid=06/01/23/1333220&from=rss"> - <title>MacWorld MacBook Only a Prototype?</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3256</link> - <description>mahju writes "Hard Mac is reporting that Apple's, unoffical, response in Paris to the the lack of information on battery life, is that the MacBook Pro that were demoed at Mac World SF are only prototypes and the final versions are still under development. " -<p><a href="http://rss.slashdot.org/~c/Slashdot/slashdot?a=qEOB5Q"><img src="http://rss.slashdot.org/~c/Slashdot/slashdot?i=qEOB5Q" border="0"></img></a></p><img src="http://rss.slashdot.org/Slashdot/slashdot?g=3256"/></description> - <dc:creator>CmdrTaco</dc:creator> - <dc:date>2006-01-23T14:12:00+00:00</dc:date> - <dc:subject>intel</dc:subject> - <slash:department>well-thats-not-surprising</slash:department> - <slash:section>apple</slash:section> - <slash:comments>160</slash:comments> - <slash:hit_parade>160,150,136,102,35,21,14</slash:hit_parade> - <feedburner:origLink>http://apple.slashdot.org/article.pl?sid=06/01/23/1333220&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://it.slashdot.org/article.pl?sid=06/01/23/0340241&from=rss"> - <title>Has Microsoft 'Solved' Spam?</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3254</link> - <description>MsWillow writes to tell us the Seattle PI is running a story looking back at Bill Gates promise to have the spam problem "solved" in two years. Well, it looks like time is up, and the verdict is -- an emphatic "maybe". From the article: "Microsoft says it sees things differently. To "solve" the problem for consumers in the short run doesn't require eliminating spam entirely, said Ryan Hamlin, the general manager who oversees the company's anti-spam programs. Rather, he said, the idea is to contain it to the point that its impact on in-boxes is minor. In that way, Hamlin said, Gates' prediction has come true for people using the right tactics and advanced filtering technology."<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3254"/></description> - <dc:creator>ScuttleMonkey</dc:creator> - <dc:date>2006-01-23T13:37:00+00:00</dc:date> - <dc:subject>spam</dc:subject> - <slash:department>depends-on-your-definition-of-solved</slash:department> - <slash:section>it</slash:section> - <slash:comments>283</slash:comments> - <slash:hit_parade>283,277,240,152,57,27,15</slash:hit_parade> - <feedburner:origLink>http://it.slashdot.org/article.pl?sid=06/01/23/0340241&from=rss</feedburner:origLink> - </item> - <item rdf:about="http://games.slashdot.org/article.pl?sid=06/01/23/1244201&from=rss"> - <title>World of Warcraft AQ Gates Open!</title> - <link>http://rss.slashdot.org/Slashdot/slashdot?m=3255</link> - <description>Tayman writes "Wow...who didn't see this one coming? The players on the World of Warcraft Medivh server opened the gates to AQ. What happened next? The server crashed repeatedly. Why create content the servers can't handle? The very first time I read about this patch, I knew the servers would crash. The more people who open the gates, the more angry customers Blizzard will have in my opinion. With 5million+ subscribers, you would think Blizzard would have the best servers/connection money can buy. Although, I'm sure it's more complicated than simply plugging in a few ram chips and faster processors though. Most of the people involved in the raid are having a great time though. Could this be the most epic battle ever introduced to the mmorpg market? All signs point to yes. Let's see how long the mobs will respawn. Hopefully, the people of the Medivh server haven't seen anything yet. Either way, I would hate to be a network admin for Blizzard atm. ^_^ Here are some pics of the event. Thanks go out to all of those who took these pics. World of Warcraft AQ Pics Check out MMORPG Veteran to keep up with the events as they unfold." Update: 01/23 13:44 GMT by Z : Additionally, brandor wrote in with a link to some video of the event.<img src="http://rss.slashdot.org/Slashdot/slashdot?g=3255"/></description> - <dc:creator>Hemos</dc:creator> - <dc:date>2006-01-23T13:33:00+00:00</dc:date> - <dc:subject>rpg</dc:subject> - <slash:department>of-course-it-will-blow-up</slash:department> - <slash:section>games</slash:section> - <slash:comments>330</slash:comments> - <slash:hit_parade>330,313,258,158,46,27,20</slash:hit_parade> - <feedburner:origLink>http://games.slashdot.org/article.pl?sid=06/01/23/1244201&from=rss</feedburner:origLink> - </item> - <textinput rdf:about="http://slashdot.org/search.pl"> - <title>Search Slashdot</title> - <description>Search Slashdot stories</description> - <name>query</name> - <link>http://slashdot.org/search.pl</link> - </textinput> -</rdf:RDF> - diff --git a/tests/Zend/Feed/_files/TestAtomFeed.xml b/tests/Zend/Feed/_files/TestAtomFeed.xml deleted file mode 100644 index 69afce7a60e42dae78670dadc0b4061c282c4836..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/TestAtomFeed.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<feed xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/" version="1.0"> - <title>Atom Example</title> - <tagline>This is a simple Atom Feed made by XML_Feed_Writer.</tagline> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="./TestAtomFeed.xml" /> - <link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="./TestAtomFeed.xml" /> - <link rel="self" type="application/atom+xml" href="./TestAtomFeed.xml" /> - <opensearch:totalResults>4</opensearch:totalResults> - <opensearch:startIndex>3</opensearch:startIndex> - <opensearch:itemsPerPage>2</opensearch:itemsPerPage> - <modified>2005-04-25T00:00:00+02:00</modified> - <entry> - <id>1</id> - <link rel="edit" href="./TestAtomFeed.xml/1/1" /> - <title>The Item Title</title> - <issued>2004-09-25T16:03:00+02:00</issued> - <modified>2005-12-25T16:03:00+01:00</modified> - <author> - <name>David Coallier</name> - </author> - <summary>Testing something before releasing</summary> - </entry> - <entry> - <id>2</id> - <link rel="edit" href="./TestAtomFeed.xml/2/1" /> - <title>Second item added to the builder/feeded..</title> - <issued>2004-01-04T00:00:00+01:00</issued> - <modified>1970-01-01T01:00:00+01:00</modified> - <author> - <name>David Coallier</name> - </author> - <summary>Jaws project, visit the website for infos...</summary> - </entry> -</feed> diff --git a/tests/Zend/Feed/_files/TestAtomFeedEntryOnly.xml b/tests/Zend/Feed/_files/TestAtomFeedEntryOnly.xml deleted file mode 100644 index 9088137da779c8ecd549858f08f7a2d8d66028aa..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/TestAtomFeedEntryOnly.xml +++ /dev/null @@ -1 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?><atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:bugzilla='http://www.bugzilla.orgs'><atom:id>1</atom:id><atom:title type='text'>Bug</atom:title><bugzilla:bugId>1</bugzilla:bugId><bugzilla:productName>Buggy</bugzilla:productName><bugzilla:component></bugzilla:component><bugzilla:description>Long time debugging</bugzilla:description><bugzilla:creationTime>2005-09-15</bugzilla:creationTime><bugzilla:updateTime>2005-09-18</bugzilla:updateTime><bugzilla:status>RESOLVED</bugzilla:status><bugzilla:severity>normal</bugzilla:severity><bugzilla:priority>P2</bugzilla:priority><bugzilla:resolution>FIXED</bugzilla:resolution><bugzilla:assignee>example@example.com</bugzilla:assignee><bugzilla:bugComments><bugzilla:comment date='2005-09-15'>The bug has been fixed.</bugzilla:comment></bugzilla:bugComments></atom:entry> diff --git a/tests/Zend/Feed/_files/TestAtomFeedNamespaced.xml b/tests/Zend/Feed/_files/TestAtomFeedNamespaced.xml deleted file mode 100644 index 02d0ee25441972394348a62f64e774639b64361e..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/TestAtomFeedNamespaced.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/" version="1.0"> - <title>Atom Example</title> - <tagline>This is a simple Atom Feed made by XML_Feed_Writer.</tagline> - <atom:link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="./TestAtomFeedNamespaced.xml" /> - <atom:link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="./TestAtomFeedNamespaced.xml" /> - <atom:link rel="self" type="application/atom+xml" href="./TestAtomFeedNamespaced.xml" /> - <opensearch:totalResults>4</opensearch:totalResults> - <opensearch:startIndex>3</opensearch:startIndex> - <opensearch:itemsPerPage>2</opensearch:itemsPerPage> - <modified>2005-04-25T00:00:00+02:00</modified> - <atom:entry> - <atom:id>1</atom:id> - <atom:link rel="edit" href="./TestAtomFeedNamespaced.xml/1/1" /> - <title>The Item Title</title> - <issued>2004-09-25T16:03:00+02:00</issued> - <modified>2005-12-25T16:03:00+01:00</modified> - <author> - <name>David Coallier</name> - </author> - <summary>Testing something before releasing</summary> - </atom:entry> - <atom:entry> - <atom:id>2</atom:id> - <atom:link rel="edit" href="./TestAtomFeedNamespaced.xml/2/1" /> - <title>Second item added to the builder/feeded..</title> - <issued>2004-01-04T00:00:00+01:00</issued> - <modified>1970-01-01T01:00:00+01:00</modified> - <author> - <name>David Coallier</name> - </author> - <summary>Jaws project, visit the website for infos...</summary> - </atom:entry> -</atom:feed> diff --git a/tests/Zend/Feed/_files/TestFeedEntryRssContentEncoded.xml b/tests/Zend/Feed/_files/TestFeedEntryRssContentEncoded.xml deleted file mode 100644 index baa70a73b9c6331e92c171ce42f5cae89a992389..0000000000000000000000000000000000000000 --- a/tests/Zend/Feed/_files/TestFeedEntryRssContentEncoded.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- generator="wordpress/2.3.1" --> -<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"> - <channel> - <title>Zend Framework IT</title> - <link>http://www.zend-framework.it</link> - <description>Just another Zend Framework (Italian) weblog.</description> - <pubDate>Sun, 03 Feb 2008 21:07:35 +0000</pubDate> - <generator>http://wordpress.org/?v=2.3.1</generator> - <language>en</language> - <item> - <title>Zend_Service_Technorati promosso in Core</title> - <link>http://www.zend-framework.it/2008/02/03/zend_service_technorati-promosso-in-core/</link> - <comments>http://www.zend-framework.it/2008/02/03/zend_service_technorati-promosso-in-core/#comments</comments> - <pubDate>Sun, 03 Feb 2008 21:06:15 +0000</pubDate> - <dc:creator>weppos</dc:creator> - <category><![CDATA[Aggiornamenti]]></category> - <category><![CDATA[API]]></category> - <category><![CDATA[Technorati]]></category> - <category><![CDATA[Zend_Service_Technorati]]></category> - <guid isPermaLink="false">http://www.zend-framework.it/2008/02/03/zend_service_technorati-promosso-in-core/</guid> - <description><![CDATA[Il componente Zend_Service_Technorati è stato ufficialmente promosso in core e sarà disponibile nella prossima release Zend Framework 1.5.]]></description> - <content:encoded><![CDATA[<p>Il commit <a href="http://framework.zend.com/fisheye/changelog/Zend_Framework/?cs=7757">r7757</a> ha ufficialmente decretato la promozione nella core library di un componente al quale sono molto affezionato: <strong>Zend_Service_Technorati</strong>.<br /> -Non solo si tratta della prima libreria completamente proposta e sviluppata dal sottoscritto, ma è anche un lavoro che mi ha visto occupato per diversi giorni nel tentativo di risolvere i vari problemi di inconsistenza delle API di Technorati, come dimostra il ticket <a href="http://framework.zend.com/issues/browse/ZF-2334">#ZF-2334</a>. <a href="http://www.zend-framework.it/2008/02/03/zend_service_technorati-promosso-in-core/#more-30" class="more-link">(more…)</a></p> -]]></content:encoded> - <wfw:commentRss>http://www.zend-framework.it/2008/02/03/zend_service_technorati-promosso-in-core/feed/</wfw:commentRss> - </item> - <item> - <title>Proposta per la struttura predefinita di un nuovo progetto Zend Framework</title> - <link>http://www.zend-framework.it/2008/02/02/proposta-per-la-struttura-predefinita-di-un-nuovo-progetto-zend-framework/</link> - <comments>http://www.zend-framework.it/2008/02/02/proposta-per-la-struttura-predefinita-di-un-nuovo-progetto-zend-framework/#comments</comments> - <pubDate>Sat, 02 Feb 2008 14:21:15 +0000</pubDate> - <dc:creator>weppos</dc:creator> - <category><![CDATA[Aggiornamenti]]></category> - <category><![CDATA[Zend_Build]]></category> - <guid isPermaLink="false">http://www.zend-framework.it/2008/02/02/proposta-per-la-struttura-predefinita-di-un-nuovo-progetto-zend-framework/</guid> - <description><![CDATA[In fase di discussione una proposta per definire una struttura di cartelle predefinita per ogni nuovo progetto Zend Framework.]]></description> - <!-- <content:encoded></content:encoded> --> - <wfw:commentRss>http://www.zend-framework.it/2008/02/02/proposta-per-la-struttura-predefinita-di-un-nuovo-progetto-zend-framework/feed/</wfw:commentRss> - </item> - <item> - <title>Installare Zend Framework via PEAR</title> - <link>http://www.zend-framework.it/2008/01/29/installare-zend-framework-via-pear/</link> - <comments>http://www.zend-framework.it/2008/01/29/installare-zend-framework-via-pear/#comments</comments> - <pubDate>Tue, 29 Jan 2008 08:42:37 +0000</pubDate> - <dc:creator>weppos</dc:creator> - <category><![CDATA[Tutorial]]></category> - <category><![CDATA[PEAR]]></category> - <category><![CDATA[php]]></category> - <guid isPermaLink="false">http://www.zend-framework.it/2008/01/29/installare-zend-framework-via-pear/</guid> - <description><![CDATA[Come installare Zend Framework via PEAR, utilizzando il progetto Zend Framework PEAR Repository disponibile su Google Code.]]></description> - <content:encoded><![CDATA[<h2>Introduzione a PEAR</h2> -<p>Chiunque programmi in PHP avrà sentito parlare, prima o poi, di <a href="http://pear.php.net/">PEAR</a>.<br /> -PEAR è un enorme <strong>repository di librerie PHP</strong>. Vi si trovano applicazioni complete, librerie complete ma, ahimè, anche molti componenti abbandonati sul nascere.</p> -<p>PEAR offre un eccellente sistema di packaging che consente di installare facilmente una libreria parte del repository ufficiale o una qualsiasi libreria su un altro repository che sia compatibile con gli standard definiti.<br /> -Per chi programma in altri linguaggi, questo sistema è molto simile al concetto di <a href="http://rubygems.org/">GEM in Ruby</a> o ai moduli di PERL. <a href="http://www.zend-framework.it/2008/01/29/installare-zend-framework-via-pear/#more-28" class="more-link">(more…)</a></p> -]]></content:encoded> - <wfw:commentRss>http://www.zend-framework.it/2008/01/29/installare-zend-framework-via-pear/feed/</wfw:commentRss> - </item> - </channel> -</rss> diff --git a/tests/Zend/File/AllTests.php b/tests/Zend/File/AllTests.php deleted file mode 100644 index 11a60c541cb2a68f6e7ce9c80a4c15540ac7416b..0000000000000000000000000000000000000000 --- a/tests/Zend/File/AllTests.php +++ /dev/null @@ -1,60 +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_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10656 2008-08-05 02:16:02Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_File_AllTests::main'); -} - -require_once 'Zend/File/Transfer/AllTests.php'; - -/** - * @category Zend - * @package Zend_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_File_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_File'); - - $suite->addTest(Zend_File_Transfer_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_File_AllTests::main') { - Zend_File_AllTests::main(); -} diff --git a/tests/Zend/File/Transfer/Adapter/AbstractTest.php b/tests/Zend/File/Transfer/Adapter/AbstractTest.php deleted file mode 100644 index 1a585283c6e1a93d3c26966478751c4b748ce083..0000000000000000000000000000000000000000 --- a/tests/Zend/File/Transfer/Adapter/AbstractTest.php +++ /dev/null @@ -1,670 +0,0 @@ -<?php -// Call Zend_File_Transfer_Adapter_AbstractTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_File_Transfer_Adapter_AbstractTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -require_once 'Zend/File/Transfer/Adapter/Abstract.php'; -require_once 'Zend/Filter/BaseName.php'; -require_once 'Zend/Filter/StringToLower.php'; -require_once 'Zend/Loader/PluginLoader.php'; -require_once 'Zend/Validate/File/Count.php'; -require_once 'Zend/Validate/File/Extension.php'; - -/** - * Test class for Zend_File_Transfer_Adapter_Abstract - */ -class Zend_File_Transfer_Adapter_AbstractTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_File_Transfer_Adapter_AbstractTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->adapter = new Zend_File_Transfer_Adapter_AbstractTest_MockAdapter(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testAdapterShouldImplementValidatorInterface() - { - // Commented out: The implementation is actually not instancing - // Zend_Validate_Interface. This was a failure in the initial implementation. - // But it allows to set validators to use within it. - // $this->assertTrue($this->adapter instanceof Zend_Validate_Interface); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testAdapterShouldThrowExceptionWhenRetrievingPluginLoaderOfInvalidType() - { - $this->adapter->getPluginLoader('bogus'); - } - - public function testAdapterShouldHavePluginLoaderForValidators() - { - $loader = $this->adapter->getPluginLoader('validate'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - } - - public function testAdapterShouldAllowAddingCustomPluginLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->adapter->setPluginLoader($loader, 'filter'); - $this->assertSame($loader, $this->adapter->getPluginLoader('filter')); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testAddingInvalidPluginLoaderTypeToAdapterShouldRaiseException() - { - $loader = new Zend_Loader_PluginLoader(); - $this->adapter->setPluginLoader($loader, 'bogus'); - } - - public function testAdapterShouldProxyAddingPluginLoaderPrefixPath() - { - $loader = $this->adapter->getPluginLoader('validate'); - $this->adapter->addPrefixPath('Foo_Valid', 'Foo/Valid/', 'validate'); - $paths = $loader->getPaths('Foo_Valid'); - $this->assertTrue(is_array($paths)); - } - - public function testPassingNoTypeWhenAddingPrefixPathToAdapterShouldGeneratePathsForAllTypes() - { - $this->adapter->addPrefixPath('Foo', 'Foo'); - $validateLoader = $this->adapter->getPluginLoader('validate'); - $filterLoader = $this->adapter->getPluginLoader('filter'); - $paths = $validateLoader->getPaths('Foo_Validate'); - $this->assertTrue(is_array($paths)); - $paths = $filterLoader->getPaths('Foo_Filter'); - $this->assertTrue(is_array($paths)); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testPassingInvalidTypeWhenAddingPrefixPathToAdapterShouldThrowException() - { - $this->adapter->addPrefixPath('Foo', 'Foo', 'bogus'); - } - - public function testAdapterShouldProxyAddingMultiplePluginLoaderPrefixPaths() - { - $validatorLoader = $this->adapter->getPluginLoader('validate'); - $filterLoader = $this->adapter->getPluginLoader('filter'); - $this->adapter->addPrefixPaths(array( - 'validate' => array('prefix' => 'Foo_Valid', 'path' => 'Foo/Valid/'), - 'filter' => array( - 'Foo_Filter' => 'Foo/Filter/', - 'Baz_Filter' => array( - 'Baz/Filter/', - 'My/Baz/Filter/', - ), - ), - array('type' => 'filter', 'prefix' => 'Bar_Filter', 'path' => 'Bar/Filter/'), - )); - $paths = $validatorLoader->getPaths('Foo_Valid'); - $this->assertTrue(is_array($paths)); - $paths = $filterLoader->getPaths('Foo_Filter'); - $this->assertTrue(is_array($paths)); - $paths = $filterLoader->getPaths('Bar_Filter'); - $this->assertTrue(is_array($paths)); - $paths = $filterLoader->getPaths('Baz_Filter'); - $this->assertTrue(is_array($paths)); - $this->assertEquals(2, count($paths)); - } - - public function testValidatorPluginLoaderShouldRegisterPathsForBaseAndFileValidatorsByDefault() - { - $loader = $this->adapter->getPluginLoader('validate'); - $paths = $loader->getPaths('Zend_Validate'); - $this->assertTrue(is_array($paths)); - $paths = $loader->getPaths('Zend_Validate_File'); - $this->assertTrue(is_array($paths)); - } - - public function testAdapterShouldAllowAddingValidatorInstance() - { - $validator = new Zend_Validate_File_Count(1, 1); - $this->adapter->addValidator($validator); - $test = $this->adapter->getValidator('Zend_Validate_File_Count'); - $this->assertSame($validator, $test); - } - - public function testAdapterShouldAllowAddingValidatorViaPluginLoader() - { - $this->adapter->addValidator('Count'); - $test = $this->adapter->getValidator('Count'); - $this->assertTrue($test instanceof Zend_Validate_File_Count); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testAdapterhShouldRaiseExceptionWhenAddingInvalidValidatorType() - { - $this->adapter->addValidator(new Zend_Filter_BaseName); - } - - public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader() - { - $validators = array( - 'count' => array('min' => 1, 'max' => 1), - 'Exists' => 'C:\temp', - array('validator' => 'Upload', 'options' => array(realpath(__FILE__))), - new Zend_Validate_File_Extension('jpg'), - ); - $this->adapter->addValidators($validators); - $test = $this->adapter->getValidators(); - $this->assertTrue(is_array($test)); - $this->assertEquals(4, count($test), var_export($test, 1)); - $count = array_shift($test); - $this->assertTrue($count instanceof Zend_Validate_File_Count); - $exists = array_shift($test); - $this->assertTrue($exists instanceof Zend_Validate_File_Exists); - $size = array_shift($test); - $this->assertTrue($size instanceof Zend_Validate_File_Upload); - $ext = array_shift($test); - $this->assertTrue($ext instanceof Zend_Validate_File_Extension); - $orig = array_pop($validators); - $this->assertSame($orig, $ext); - } - - public function testGetValidatorShouldReturnNullWhenNoMatchingIdentifierExists() - { - $this->assertNull($this->adapter->getValidator('Alpha')); - } - - public function testAdapterShouldAllowPullingValidatorsByFile() - { - $this->adapter->addValidator('Alpha', false, false, 'foo'); - $validators = $this->adapter->getValidators('foo'); - $this->assertEquals(1, count($validators)); - $validator = array_shift($validators); - $this->assertTrue($validator instanceof Zend_Validate_Alpha); - } - - public function testCallingSetValidatorsOnAdapterShouldOverwriteExistingValidators() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $validators = array( - new Zend_Validate_File_Count(1), - new Zend_Validate_File_Extension('jpg'), - ); - $this->adapter->setValidators($validators); - $test = $this->adapter->getValidators(); - $this->assertSame($validators, array_values($test)); - } - - public function testAdapterShouldAllowRetrievingValidatorInstancesByClassName() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $ext = $this->adapter->getValidator('Zend_Validate_File_Extension'); - $this->assertTrue($ext instanceof Zend_Validate_File_Extension); - } - - public function testAdapterShouldAllowRetrievingValidatorInstancesByPluginName() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $count = $this->adapter->getValidator('Count'); - $this->assertTrue($count instanceof Zend_Validate_File_Count); - } - - public function testAdapterShouldAllowRetrievingAllValidatorsAtOnce() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $validators = $this->adapter->getValidators(); - $this->assertTrue(is_array($validators)); - $this->assertEquals(4, count($validators)); - foreach ($validators as $validator) { - $this->assertTrue($validator instanceof Zend_Validate_Interface); - } - } - - public function testAdapterShouldAllowRemovingValidatorInstancesByClassName() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $this->assertTrue($this->adapter->hasValidator('Zend_Validate_File_Extension')); - $this->adapter->removeValidator('Zend_Validate_File_Extension'); - $this->assertFalse($this->adapter->hasValidator('Zend_Validate_File_Extension')); - } - - public function testAdapterShouldAllowRemovingValidatorInstancesByPluginName() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $this->assertTrue($this->adapter->hasValidator('Count')); - $this->adapter->removeValidator('Count'); - $this->assertFalse($this->adapter->hasValidator('Count')); - } - - public function testRemovingNonexistentValidatorShouldDoNothing() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $validators = $this->adapter->getValidators(); - $this->assertFalse($this->adapter->hasValidator('Alpha')); - $this->adapter->removeValidator('Alpha'); - $this->assertFalse($this->adapter->hasValidator('Alpha')); - $test = $this->adapter->getValidators(); - $this->assertSame($validators, $test); - } - - public function testAdapterShouldAllowRemovingAllValidatorsAtOnce() - { - $this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader(); - $this->adapter->clearValidators(); - $validators = $this->adapter->getValidators(); - $this->assertTrue(is_array($validators)); - $this->assertEquals(0, count($validators)); - } - - public function testValidationShouldReturnTrueForValidTransfer() - { - $this->adapter->addValidator('Count', false, array(1, 3), 'foo'); - $this->assertTrue($this->adapter->isValid('foo')); - } - - public function testValidationShouldReturnTrueForValidTransferOfMultipleFiles() - { - $this->assertTrue($this->adapter->isValid(null)); - } - - public function testValidationShouldReturnFalseForInvalidTransfer() - { - $this->adapter->addValidator('Extension', false, 'png', 'foo'); - $this->assertFalse($this->adapter->isValid('foo')); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testValidationShouldThrowExceptionForNonexistentFile() - { - $this->adapter->isValid('bogus'); - } - - public function testErrorMessagesShouldBeEmptyByDefault() - { - $messages = $this->adapter->getMessages(); - $this->assertTrue(is_array($messages)); - $this->assertEquals(0, count($messages)); - } - - public function testErrorMessagesShouldBePopulatedAfterInvalidTransfer() - { - $this->testValidationShouldReturnFalseForInvalidTransfer(); - $messages = $this->adapter->getMessages(); - $this->assertTrue(is_array($messages)); - $this->assertFalse(empty($messages)); - } - - public function testErrorCodesShouldBeNullByDefault() - { - $errors = $this->adapter->getErrors(); - $this->assertTrue(is_array($errors)); - $this->assertEquals(0, count($errors)); - } - - public function testErrorCodesShouldBePopulatedAfterInvalidTransfer() - { - $this->testValidationShouldReturnFalseForInvalidTransfer(); - $errors = $this->adapter->getErrors(); - $this->assertTrue(is_array($errors)); - $this->assertFalse(empty($errors)); - } - - public function testAdapterShouldHavePluginLoaderForFilters() - { - $loader = $this->adapter->getPluginLoader('filter'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - } - - public function testFilterPluginLoaderShouldRegisterPathsForBaseAndFileFiltersByDefault() - { - $loader = $this->adapter->getPluginLoader('filter'); - $paths = $loader->getPaths('Zend_Filter'); - $this->assertTrue(is_array($paths)); - $paths = $loader->getPaths('Zend_Filter_File'); - $this->assertTrue(is_array($paths)); - } - - public function testAdapterShouldAllowAddingFilterInstance() - { - $filter = new Zend_Filter_StringToLower(1, 1); - $this->adapter->addFilter($filter); - $test = $this->adapter->getFilter('Zend_Filter_StringToLower'); - $this->assertSame($filter, $test); - } - - public function testAdapterShouldAllowAddingFilterViaPluginLoader() - { - $this->adapter->addFilter('StringToUpper'); - $test = $this->adapter->getFilter('StringToUpper'); - $this->assertTrue($test instanceof Zend_Filter_StringToUpper); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testAdapterhShouldRaiseExceptionWhenAddingInvalidFilterType() - { - $this->adapter->addFilter(new Zend_Validate_File_Extension('jpg')); - } - - public function testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader() - { - $filters = array( - 'Word_SeparatorToCamelCase' => array('separator' => ' '), - array('filter' => 'Alpha', 'options' => array(true)), - new Zend_Filter_BaseName(), - ); - $this->adapter->addFilters($filters); - $test = $this->adapter->getFilters(); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test), var_export($test, 1)); - $count = array_shift($test); - $this->assertTrue($count instanceof Zend_Filter_Word_SeparatorToCamelCase); - $size = array_shift($test); - $this->assertTrue($size instanceof Zend_Filter_Alpha); - $ext = array_shift($test); - $orig = array_pop($filters); - $this->assertSame($orig, $ext); - } - - public function testGetFilterShouldReturnNullWhenNoMatchingIdentifierExists() - { - $this->assertNull($this->adapter->getFilter('Alpha')); - } - - public function testAdapterShouldAllowPullingFiltersByFile() - { - $this->adapter->addFilter('Alpha', false, 'foo'); - $filters = $this->adapter->getFilters('foo'); - $this->assertEquals(1, count($filters)); - $filter = array_shift($filters); - $this->assertTrue($filter instanceof Zend_Filter_Alpha); - } - - public function testCallingSetFiltersOnAdapterShouldOverwriteExistingFilters() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $filters = array( - new Zend_Filter_StringToUpper(), - new Zend_Filter_Alpha(), - ); - $this->adapter->setFilters($filters); - $test = $this->adapter->getFilters(); - $this->assertSame($filters, array_values($test)); - } - - public function testAdapterShouldAllowRetrievingFilterInstancesByClassName() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $ext = $this->adapter->getFilter('Zend_Filter_BaseName'); - $this->assertTrue($ext instanceof Zend_Filter_BaseName); - } - - public function testAdapterShouldAllowRetrievingFilterInstancesByPluginName() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $count = $this->adapter->getFilter('Alpha'); - $this->assertTrue($count instanceof Zend_Filter_Alpha); - } - - public function testAdapterShouldAllowRetrievingAllFiltersAtOnce() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $filters = $this->adapter->getFilters(); - $this->assertTrue(is_array($filters)); - $this->assertEquals(3, count($filters)); - foreach ($filters as $filter) { - $this->assertTrue($filter instanceof Zend_Filter_Interface); - } - } - - public function testAdapterShouldAllowRemovingFilterInstancesByClassName() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $this->assertTrue($this->adapter->hasFilter('Zend_Filter_BaseName')); - $this->adapter->removeFilter('Zend_Filter_BaseName'); - $this->assertFalse($this->adapter->hasFilter('Zend_Filter_BaseName')); - } - - public function testAdapterShouldAllowRemovingFilterInstancesByPluginName() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $this->assertTrue($this->adapter->hasFilter('Alpha')); - $this->adapter->removeFilter('Alpha'); - $this->assertFalse($this->adapter->hasFilter('Alpha')); - } - - public function testRemovingNonexistentFilterShouldDoNothing() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $filters = $this->adapter->getFilters(); - $this->assertFalse($this->adapter->hasFilter('Int')); - $this->adapter->removeFilter('Int'); - $this->assertFalse($this->adapter->hasFilter('Int')); - $test = $this->adapter->getFilters(); - $this->assertSame($filters, $test); - } - - public function testAdapterShouldAllowRemovingAllFiltersAtOnce() - { - $this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader(); - $this->adapter->clearFilters(); - $filters = $this->adapter->getFilters(); - $this->assertTrue(is_array($filters)); - $this->assertEquals(0, count($filters)); - } - - public function testDestinationShouldDefaultToSystemTempDirectory() - { - $tmpdir = sys_get_temp_dir(); - $tmpdir = rtrim($tmpdir, "/\\"); - $destinations = $this->adapter->getDestination(); - foreach ($destinations as $file => $destination) { - $this->assertEquals($tmpdir, $destination); - } - $this->assertEquals($tmpdir, $this->adapter->getDestination('foo')); - } - - public function testTransferDestinationShouldBeMutable() - { - $this->testDestinationShouldDefaultToSystemTempDirectory(); - $directory = dirname(__FILE__); - $this->adapter->setDestination($directory); - $destinations = $this->adapter->getDestination(); - $this->assertTrue(is_array($destinations)); - foreach ($destinations as $file => $destination) { - $this->assertEquals($directory, $destination); - } - - $newdirectory = dirname(__FILE__) - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '_files'; - $this->adapter->setDestination($newdirectory, 'foo'); - $this->assertEquals($newdirectory, $this->adapter->getDestination('foo')); - $this->assertEquals($directory, $this->adapter->getDestination('bar')); - } - - public function testAdapterShouldAllowRetrievingDestinationsForAnArrayOfSpecifiedFiles() - { - $this->testTransferDestinationShouldBeMutable(); - $destinations = $this->adapter->getDestination(array('bar', 'baz')); - $this->assertTrue(is_array($destinations)); - foreach ($destinations as $file => $destination) { - $this->assertTrue(in_array($file, array('bar', 'baz'))); - $this->assertEquals('/var/www/upload', $destination); - } - } - - public function testSettingAndRetrievingOptions() - { - $this->assertEquals(array('ignoreNoFile' => false), $this->adapter->getOptions()); - - $this->adapter->setOptions(array('ignoreNoFile' => true)); - $this->assertEquals(array('ignoreNoFile' => true), $this->adapter->getOptions()); - } - - public function testGetAllAdditionalFileInfos() - { - $files = $this->adapter->getFileInfo(); - $this->assertEquals(3, count($files)); - $this->assertEquals('baz.text', $files['baz']['name']); - } - - public function testGetAdditionalFileInfosForSingleFile() - { - $files = $this->adapter->getFileInfo('baz'); - $this->assertEquals(1, count($files)); - $this->assertEquals('baz.text', $files['baz']['name']); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testGetAdditionalFileInfosForUnknownFile() - { - $files = $this->adapter->getFileInfo('unknown'); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testGetUnknownOption() - { - $this->adapter->setOptions(array('unknownOption' => 'unknown')); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testGetFileIsNotImplemented() - { - $this->adapter->getFile(); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testAddFileIsNotImplemented() - { - $this->adapter->addFile('foo'); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testGetTypeIsNotImplemented() - { - $this->adapter->getType(); - } - - /** - * @expectedException Zend_File_Transfer_Exception - */ - public function testAddTypeIsNotImplemented() - { - $this->adapter->addType('foo'); - } - - public function testAdapterShouldAllowRetrievingFileName() - { - $path = dirname(__FILE__) - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '_files'; - $this->adapter->setDestination($path); - $this->assertEquals($path . DIRECTORY_SEPARATOR . 'foo.jpg', $this->adapter->getFileName('foo')); - } -} - -class Zend_File_Transfer_Adapter_AbstractTest_MockAdapter extends Zend_File_Transfer_Adapter_Abstract -{ - public $received = false; - - public function __construct() - { - $this->_files = array( - 'foo' => array( - 'name' => 'foo.jpg', - 'type' => 'image/jpeg', - 'size' => 126976, - 'tmp_name' => '/tmp/489127ba5c89c', - ), - 'bar' => array( - 'name' => 'bar.png', - 'type' => 'image/png', - 'size' => 91136, - 'tmp_name' => '/tmp/489128284b51f', - ), - 'baz' => array( - 'name' => 'baz.text', - 'type' => 'text/plain', - 'size' => 1172, - 'tmp_name' => '/tmp/4891286cceff3', - ), - ); - } - - public function send($options = null) - { - return; - } - - public function receive($options = null) - { - $this->received = true; - return; - } - - public function isSent($file = null) - { - return false; - } - - public function isReceived($file = null) - { - return $this->received; - } - - public function getProgress() - { - return; - } -} - -// Call Zend_File_Transfer_Adapter_AbstractTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_File_Transfer_Adapter_AbstractTest::main") { - Zend_File_Transfer_Adapter_AbstractTest::main(); -} diff --git a/tests/Zend/File/Transfer/Adapter/AllTests.php b/tests/Zend/File/Transfer/Adapter/AllTests.php deleted file mode 100644 index bff212713153a59822817ff55ad0d8914d039ff0..0000000000000000000000000000000000000000 --- a/tests/Zend/File/Transfer/Adapter/AllTests.php +++ /dev/null @@ -1,60 +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_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10656 2008-08-05 02:16:02Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_File_Transfer_Adapter_AllTests::main'); -} - -require_once 'Zend/File/Transfer/Adapter/AbstractTest.php'; - -/** - * @category Zend - * @package Zend_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_File_Transfer_Adapter_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_File_Transfer_Adapter'); - - $suite->addTestSuite('Zend_File_Transfer_Adapter_AbstractTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_File_Transfer_Adapter_AllTests::main') { - Zend_File_Transfer_Adapter_AllTests::main(); -} diff --git a/tests/Zend/File/Transfer/AllTests.php b/tests/Zend/File/Transfer/AllTests.php deleted file mode 100644 index ec5d8b6ed58c4104839ca0ee0768910149cfe9ba..0000000000000000000000000000000000000000 --- a/tests/Zend/File/Transfer/AllTests.php +++ /dev/null @@ -1,60 +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_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10656 2008-08-05 02:16:02Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_File_Transfer_AllTests::main'); -} - -require_once 'Zend/File/Transfer/Adapter/AllTests.php'; - -/** - * @category Zend - * @package Zend_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_File_Transfer_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_File_Transfer'); - - $suite->addTest(Zend_File_Transfer_Adapter_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_File_Transfer_AllTests::main') { - Zend_File_Transfer_AllTests::main(); -} diff --git a/tests/Zend/Filter/AllTests.php b/tests/Zend/Filter/AllTests.php deleted file mode 100644 index 3325ae25f6cfc7fd89d3e44863be464d0e971795..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/AllTests.php +++ /dev/null @@ -1,186 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10637 2008-08-04 16:20:40Z ralph $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Filter_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_AlnumTest - */ -require_once 'Zend/Filter/AlnumTest.php'; - -/** - * @see Zend_Filter_AlphaTest - */ -require_once 'Zend/Filter/AlphaTest.php'; - -/** - * @see Zend_Filter_BaseNameTest - */ -require_once 'Zend/Filter/BaseNameTest.php'; - -/** - * @see Zend_Filter_DigitsTest - */ -require_once 'Zend/Filter/DigitsTest.php'; - -/** - * @see Zend_Filter_DirTest - */ -require_once 'Zend/Filter/DirTest.php'; - -/** - * @see Zend_Filter_HtmlEntitiesTest - */ -require_once 'Zend/Filter/HtmlEntitiesTest.php'; - -/** - * @see Zend_Filter_InflectorTest - */ -require_once 'Zend/Filter/InflectorTest.php'; - -/** - * @see Zend_Filter_IntTest - */ -require_once 'Zend/Filter/IntTest.php'; - -/** - * @see Zend_Filter_PregReplaceTest - */ -require_once 'Zend/Filter/PregReplaceTest.php'; - -/** - * @see Zend_Filter_RealPathTest - */ -require_once 'Zend/Filter/RealPathTest.php'; - -/** - * @see Zend_Filter_StringToLowerTest - */ -require_once 'Zend/Filter/StringToLowerTest.php'; - -/** - * @see Zend_Filter_StringToUpperTest - */ -require_once 'Zend/Filter/StringToUpperTest.php'; - -/** - * @see Zend_Filter_StringTrimTest - */ -require_once 'Zend/Filter/StringTrimTest.php'; - -/** - * @see Zend_Filter_StripNewlinesTest - */ -require_once 'Zend/Filter/StripNewlinesTest.php'; - -/** - * @see Zend_Filter_StripTagsTest - */ -require_once 'Zend/Filter/StripTagsTest.php'; - -/** - * @see Zend_Filter_InputTest - */ -require_once 'Zend/Filter/InputTest.php'; - -/** - * Word filter tests - */ -require_once 'Zend/Filter/Word/CamelCaseToDashTest.php'; -require_once 'Zend/Filter/Word/CamelCaseToSeparatorTest.php'; -require_once 'Zend/Filter/Word/CamelCaseToUnderscoreTest.php'; -require_once 'Zend/Filter/Word/SeparatorToCamelCaseTest.php'; -require_once 'Zend/Filter/Word/DashToCamelCaseTest.php'; -require_once 'Zend/Filter/Word/UnderscoreToCamelCaseTest.php'; -require_once 'Zend/Filter/Word/DashToUnderscoreTest.php'; -require_once 'Zend/Filter/Word/UnderscoreToDashTest.php'; - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Filter'); - - $suite->addTestSuite('Zend_Filter_AlnumTest'); - $suite->addTestSuite('Zend_Filter_AlphaTest'); - $suite->addTestSuite('Zend_Filter_BaseNameTest'); - $suite->addTestSuite('Zend_Filter_DigitsTest'); - $suite->addTestSuite('Zend_Filter_DirTest'); - $suite->addTestSuite('Zend_Filter_HtmlEntitiesTest'); - $suite->addTestSuite('Zend_Filter_InflectorTest'); - $suite->addTestSuite('Zend_Filter_IntTest'); - $suite->addTestSuite('Zend_Filter_PregReplaceTest'); - $suite->addTestSuite('Zend_Filter_RealPathTest'); - $suite->addTestSuite('Zend_Filter_StringToLowerTest'); - $suite->addTestSuite('Zend_Filter_StringToUpperTest'); - $suite->addTestSuite('Zend_Filter_StringTrimTest'); - $suite->addTestSuite('Zend_Filter_StripNewlinesTest'); - $suite->addTestSuite('Zend_Filter_StripTagsTest'); - $suite->addTestSuite('Zend_Filter_InputTest'); - $suite->addTestSuite('Zend_Filter_Word_CamelCaseToDashTest'); - $suite->addTestSuite('Zend_Filter_Word_CamelCaseToSeparatorTest'); - $suite->addTestSuite('Zend_Filter_Word_CamelCaseToUnderscoreTest'); - $suite->addTestSuite('Zend_Filter_Word_SeparatorToCamelCaseTest'); - $suite->addTestSuite('Zend_Filter_Word_DashToCamelCaseTest'); - $suite->addTestSuite('Zend_Filter_Word_UnderscoreToCamelCaseTest'); - $suite->addTestSuite('Zend_Filter_Word_DashToUnderscoreTest'); - $suite->addTestSuite('Zend_Filter_Word_UnderscoreToDashTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Filter_AllTests::main') { - Zend_Filter_AllTests::main(); -} diff --git a/tests/Zend/Filter/AlnumTest.php b/tests/Zend/Filter/AlnumTest.php deleted file mode 100644 index a9cd33c8f4f816b834246239b5c66112bcb2c281..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/AlnumTest.php +++ /dev/null @@ -1,189 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AlnumTest.php 9268 2008-04-21 07:35:12Z yoshida@zend.co.jp $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Alnum - */ -require_once 'Zend/Filter/Alnum.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_AlnumTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_Alnum object - * - * @var Zend_Filter_Alnum - */ - protected $_filter; - - /** - * Is PCRE is compiled with UTF-8 and Unicode support - * - * @var mixed - **/ - protected static $_unicodeEnabled; - - /** - * Locale in browser. - * - * @var Zend_Locale object - */ - protected $_locale; - - /** - * The Alphabet means english alphabet. - * - * @var boolean - */ - protected static $_meansEnglishAlphabet; - - /** - * Creates a new Zend_Filter_Alnum object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_Alnum(); - if (null === self::$_unicodeEnabled) { - self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale(Zend_Locale::BROWSER); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), - array('ja') - ); - } - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative a-zA-Z match - $valuesExpected = array( - 'abc123' => 'abc123', - 'abc 123' => 'abc123', - 'abcxyz' => 'abcxyz', - 'AZ@#4.3' => 'AZ43', - '' => '' - ); - } if (self::$_meansEnglishAlphabet) { - //The Alphabet means english alphabet. - /** - * The first element contains multibyte alphabets and digits. - * But , Zend_Filter_Alnum is expected to return only singlebyte alphabets and digits. - * - * The second contains multibyte or singebyte space. - * The third contains various multibyte or singebyte characters. - */ - $valuesExpected = array( - 'aABb3ï¼”5ï¼–' => 'aB35', - 'zï¼— ï¼¹8 xï¼™' => 'z8x', - ',s1.2r3#:q,' => 's12rq', - ); - } else { - //The Alphabet means each language's alphabet. - $valuesExpected = array( - 'abc123' => 'abc123', - 'abc 123' => 'abc123', - 'abcxyz' => 'abcxyz', - 'Äe2t3nÄ›' => 'Äe2t3nÄ›', - 'grz5e4gżółka' => 'grz5e4gżółka', - 'Be3l5gië' => 'Be3l5gië', - '' => '' - ); - } - foreach ($valuesExpected as $input => $output) { - $this->assertEquals( - $output, - $result = $this->_filter->filter($input), - "Expected '$input' to filter to '$output', but received '$result' instead" - ); - } - } - - /** - * Ensures that the allowWhiteSpace option works as expected - * - * @return void - */ - public function testAllowWhiteSpace() - { - $this->_filter->allowWhiteSpace = true; - - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative a-zA-Z match - $valuesExpected = array( - 'abc123' => 'abc123', - 'abc 123' => 'abc 123', - 'abcxyz' => 'abcxyz', - 'AZ@#4.3' => 'AZ43', - '' => '', - "\n" => "\n", - " \t " => " \t " - ); - } if (self::$_meansEnglishAlphabet) { - //The Alphabet means english alphabet. - $valuesExpected = array( - 'a B ï¼”5' => 'a B 5', - 'z3 x' => 'z3x' - ); - } else { - //The Alphabet means each language's alphabet. - $valuesExpected = array( - 'abc123' => 'abc123', - 'abc 123' => 'abc 123', - 'abcxyz' => 'abcxyz', - 'Äe2 t3nÄ›' => 'Äe2 t3nÄ›', - 'gr z5e4gżółka' => 'gr z5e4gżółka', - 'Be3l5 gië' => 'Be3l5 gië', - '' => '', - ); - } - foreach ($valuesExpected as $input => $output) { - $this->assertEquals( - $output, - $result = $this->_filter->filter($input), - "Expected '$input' to filter to '$output', but received '$result' instead" - ); - } - } -} \ No newline at end of file diff --git a/tests/Zend/Filter/AlphaTest.php b/tests/Zend/Filter/AlphaTest.php deleted file mode 100644 index a4b15f148794ff776b3babf5b4c08aa754a185d6..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/AlphaTest.php +++ /dev/null @@ -1,195 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AlphaTest.php 9268 2008-04-21 07:35:12Z yoshida@zend.co.jp $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Alpha - */ -require_once 'Zend/Filter/Alpha.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_AlphaTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_Alpha object - * - * @var Zend_Filter_Alpha - */ - protected $_filter; - - /** - * Is PCRE is compiled with UTF-8 and Unicode support - * - * @var mixed - **/ - protected static $_unicodeEnabled; - - /** - * Locale in browser. - * - * @var Zend_Locale object - */ - protected $_locale; - - /** - * The Alphabet means english alphabet. - * - * @var boolean - */ - protected static $_meansEnglishAlphabet; - - /** - * Creates a new Zend_Filter_Alpha object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_Alpha(); - if (null === self::$_unicodeEnabled) { - self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale(Zend_Locale::BROWSER); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), - array('ja') - ); - } - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative a-zA-Z match - $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc', - 'abcxyz' => 'abcxyz', - '' => '' - ); - } else if (self::$_meansEnglishAlphabet) { - //The Alphabet means english alphabet. - /** - * The first element contains multibyte alphabets. - * But , Zend_Filter_Alpha is expected to return only singlebyte alphabets. - * The second contains multibyte or singlebyte space. - * The third contains multibyte or singlebyte digits. - * The forth contains various multibyte or singlebyte characters. - * The last contains only singlebyte alphabets. - */ - $valuesExpected = array( - 'aABbc' => 'aBc', - 'z Y x' => 'zx', - 'ï¼·1v3U4t' => 'vt', - ',sй.rλ:qν_p' => 'srqp', - 'onml' => 'onml' - ); - } else { - //The Alphabet means each language's alphabet. - $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc', - 'abcxyz' => 'abcxyz', - 'ÄetnÄ›' => 'ÄetnÄ›', - 'لعربية' => 'لعربية', - 'grzegżółka' => 'grzegżółka', - 'België' => 'België', - '' => '' - ); - } - - foreach ($valuesExpected as $input => $output) { - $this->assertEquals( - $output, - $result = $this->_filter->filter($input), - "Expected '$input' to filter to '$output', but received '$result' instead" - ); - } - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testAllowWhiteSpace() - { - $this->_filter->allowWhiteSpace = true; - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative a-zA-Z match - $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc ', - 'abcxyz' => 'abcxyz', - '' => '', - "\n" => "\n", - " \t " => " \t " - ); - } if (self::$_meansEnglishAlphabet) { - //The Alphabet means english alphabet. - $valuesExpected = array( - 'a B' => 'a B', - 'zY x' => 'zx' - ); - } else { - //The Alphabet means each language's alphabet. - $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc ', - 'abcxyz' => 'abcxyz', - 'ÄetnÄ›' => 'ÄetnÄ›', - 'لعربية' => 'لعربية', - 'grzegżółka' => 'grzegżółka', - 'België' => 'België', - '' => '', - "\n" => "\n", - " \t " => " \t " - ); - } - - foreach ($valuesExpected as $input => $output) { - $this->assertEquals( - $output, - $result = $this->_filter->filter($input), - "Expected '$input' to filter to '$output', but received '$result' instead" - ); - } - } -} diff --git a/tests/Zend/Filter/BaseNameTest.php b/tests/Zend/Filter/BaseNameTest.php deleted file mode 100644 index 9a7f15c07ac34161849158d066804bc12efaf5f3..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/BaseNameTest.php +++ /dev/null @@ -1,77 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BaseNameTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_BaseName - */ -require_once 'Zend/Filter/BaseName.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_BaseNameTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_BaseName object - * - * @var Zend_Filter_BaseName - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_BaseName object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_BaseName(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - '/path/to/filename' => 'filename', - '/path/to/filename.ext' => 'filename.ext' - ); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } -} diff --git a/tests/Zend/Filter/DigitsTest.php b/tests/Zend/Filter/DigitsTest.php deleted file mode 100644 index fa04d45f1a5967a7ae02e9bfc214f83d512d5a06..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/DigitsTest.php +++ /dev/null @@ -1,116 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DigitsTest.php 9267 2008-04-21 06:59:08Z yoshida@zend.co.jp $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Digits - */ -require_once 'Zend/Filter/Digits.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_DigitsTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_Digits object extended for checking whether Unicode PCRE is enabled - * - * @var Zend_Filter_Digits - */ - protected $_filter; - - /** - * Is PCRE is compiled with UTF-8 and Unicode support - * - * @var mixed - **/ - protected static $_unicodeEnabled; - - /** - * Creates a new Zend_Filter_Digits object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_Digits(); - if (null === self::$_unicodeEnabled) { - self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - if (self::$_unicodeEnabled && extension_loaded('mbstring')) { - // Filter for the value with mbstring - /** - * The first element of $valuesExpected contains multibyte digit characters. - * But , Zend_Filter_Digits is expected to return only singlebyte digits. - * - * The second contains multibyte or singebyte space, and also alphabet. - * The third contains various multibyte characters. - * The last contains only singlebyte digits. - */ - $valuesExpected = array( - '1ï¼™2å…«3四8' => '123', - 'ï¼£ 4.5B 6' => '456', - '9壱8ï¼ 7.6,5#4' => '987654', - '789' => '789' - ); - } else { - // POSIX named classes are not supported, use alternative 0-9 match - // Or filter for the value without mbstring - $valuesExpected = array( - 'abc123' => '123', - 'abc 123' => '123', - 'abcxyz' => '', - 'AZ@#4.3' => '43', - '1.23' => '123', - '0x9f' => '09' - ); - } - - foreach ($valuesExpected as $input => $output) { - $this->assertEquals( - $output, - $result = $this->_filter->filter($input), - "Expected '$input' to filter to '$output', but received '$result' instead" - ); - } - } -} \ No newline at end of file diff --git a/tests/Zend/Filter/DirTest.php b/tests/Zend/Filter/DirTest.php deleted file mode 100644 index 5ab3bddf53c0d59a02a80688bb77be32295018bc..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/DirTest.php +++ /dev/null @@ -1,78 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DirTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Dir - */ -require_once 'Zend/Filter/Dir.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_DirTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_Dir object - * - * @var Zend_Filter_Dir - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_Dir object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_Dir(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'filename' => '.', - '/path/to/filename' => '/path/to', - '/path/to/filename.ext' => '/path/to' - ); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } -} diff --git a/tests/Zend/Filter/File/RenameTest.php b/tests/Zend/Filter/File/RenameTest.php deleted file mode 100644 index 1d94c4b282945893d34d22463481e7a3ecf7ab43..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/File/RenameTest.php +++ /dev/null @@ -1,257 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Filter_File_Rename - */ -require_once 'Zend/Filter/File/Rename.php'; - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_File_RenameTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * Original testfile - * - * @var string - */ - protected $_origFile; - - /** - * Testfile - * - * @var string - */ - protected $_oldFile; - - /** - * Testfile - * - * @var string - */ - protected $_newFile; - - /** - * Testdirectory - * - * @var string - */ - protected $_newDir; - - /** - * Testfile in Testdirectory - * - * @var string - */ - protected $_newDirFile; - - /** - * Sets the path to test files - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR - . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR; - $this->_origFile = $this->_filesPath . 'original.file'; - $this->_oldFile = $this->_filesPath . 'testfile.txt'; - $this->_newFile = $this->_filesPath . 'newfile.xml'; - $this->_newDir = $this->_filesPath . DIRECTORY_SEPARATOR . '_testDir2'; - $this->_newDirFile = $this->_newDir . DIRECTORY_SEPARATOR . 'testfile.txt'; - } - - /** - * Sets the path to test files - * - * @return void - */ - public function setUp() - { - if (file_exists($this->_origFile)) { - unlink($this->_origFile); - } - - if (file_exists($this->_newFile)) { - unlink($this->_newFile); - } - - if (file_exists($this->_newDirFile)) { - unlink($this->_newDirFile); - } - - copy($this->_oldFile, $this->_origFile); - } - - /** - * Sets the path to test files - * - * @return void - */ - public function tearDown() - { - if (!file_exists($this->_oldFile)) { - copy($this->_origFile, $this->_oldFile); - } - - if (file_exists($this->_origFile)) { - unlink($this->_origFile); - } - - if (file_exists($this->_newFile)) { - unlink($this->_newFile); - } - - if (file_exists($this->_newDirFile)) { - unlink($this->_newDirFile); - } - } - - /** - * Test single parameter filter - * - * @return void - */ - public function testConstructSingle() - { - $filter = new Zend_Filter_File_Rename($this->_oldFile, $this->_newFile); - - $this->assertEquals(array($this->_oldFile => $this->_newFile), $filter->getFile()); - $this->assertEquals($this->_newFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single array parameter filter - * - * @return void - */ - public function testConstructSingleArray() - { - $filter = new Zend_Filter_File_Rename(array($this->_oldFile => $this->_newFile)); - - $this->assertEquals(array($this->_oldFile => $this->_newFile), $filter->getFile()); - $this->assertEquals($this->_newFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single array parameter filter - * - * @return void - */ - public function testConstructDoubleArray() - { - $filter = new Zend_Filter_File_Rename(array($this->_oldFile), array($this->_newFile)); - - $this->assertEquals(array($this->_oldFile => $this->_newFile), $filter->getFile()); - $this->assertEquals($this->_newFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single array parameter filter - * - * @return void - */ - public function testConstructTruncated() - { - $filter = new Zend_Filter_File_Rename($this->_newFile); - - $this->assertEquals(array($this->_newFile), $filter->getFile()); - $this->assertEquals($this->_newFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single parameter filter by using directory only - * - * @return void - */ - public function testConstructSingleDirectory() - { - $filter = new Zend_Filter_File_Rename($this->_oldFile, $this->_newDir); - - $this->assertEquals(array($this->_oldFile => $this->_newDir), $filter->getFile()); - $this->assertEquals($this->_newDirFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single array parameter filter by using directory only - * - * @return void - */ - public function testConstructSingleArrayDirectory() - { - $filter = new Zend_Filter_File_Rename(array($this->_oldFile => $this->_newDir)); - - $this->assertEquals(array($this->_oldFile => $this->_newDir), $filter->getFile()); - $this->assertEquals($this->_newDirFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single array parameter filter by using directory only - * - * @return void - */ - public function testConstructDoubleArrayDirectory() - { - $filter = new Zend_Filter_File_Rename(array($this->_oldFile), array($this->_newDir)); - - $this->assertEquals(array($this->_oldFile => $this->_newDir), $filter->getFile()); - $this->assertEquals($this->_newDirFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } - - /** - * Test single array parameter filter by using directory only - * - * @return void - */ - public function testConstructTruncatedDirectory() - { - $filter = new Zend_Filter_File_Rename($this->_newDir); - - $this->assertEquals(array($this->_newDir), $filter->getFile()); - $this->assertEquals($this->_newDirFile, $filter->filter($this->_oldFile)); - $this->assertEquals('falsefile', $filter->filter('falsefile')); - } -} diff --git a/tests/Zend/Filter/HtmlEntitiesTest.php b/tests/Zend/Filter/HtmlEntitiesTest.php deleted file mode 100644 index afd48eafe5aa516c5b272915d7be92661b716ab0..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/HtmlEntitiesTest.php +++ /dev/null @@ -1,134 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HtmlEntitiesTest.php 11786 2008-10-09 17:45:03Z andries $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_HtmlEntities - */ -require_once 'Zend/Filter/HtmlEntities.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_HtmlEntitiesTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_HtmlEntities object - * - * @var Zend_Filter_HtmlEntities - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_HtmlEntities object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_HtmlEntities(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'string' => 'string', - '<' => '<', - '>' => '>', - '\'' => '\'', - '"' => '"', - '&' => '&' - ); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } - - /** - * Ensures that getQuoteStyle() returns expected default value - * - * @return void - */ - public function testGetQuoteStyle() - { - $this->assertEquals(ENT_COMPAT, $this->_filter->getQuoteStyle()); - } - - /** - * Ensures that setQuoteStyle() follows expected behavior - * - * @return void - */ - public function testSetQuoteStyle() - { - $this->_filter->setQuoteStyle(ENT_QUOTES); - $this->assertEquals(ENT_QUOTES, $this->_filter->getQuoteStyle()); - } - - /** - * Ensures that getCharSet() returns expected default value - * - * @return void - */ - public function testGetCharSet() - { - $this->assertEquals('ISO-8859-1', $this->_filter->getCharSet()); - } - - /** - * Ensures that setCharSet() follows expected behavior - * - * @return void - */ - public function testSetCharSet() - { - $this->_filter->setCharSet('UTF-8'); - $this->assertEquals('UTF-8', $this->_filter->getCharSet()); - } - - /** - * Ensure that fluent interfaces are supported - * - * @group ZF-3172 - */ - public function testFluentInterface() - { - $instance = $this->_filter->setCharSet('UTF-8')->setQuoteStyle(ENT_QUOTES); - $this->assertTrue($instance instanceof Zend_Filter_HtmlEntities); - } -} diff --git a/tests/Zend/Filter/InflectorTest.php b/tests/Zend/Filter/InflectorTest.php deleted file mode 100644 index d968d3f406f4d60bacc0e88ae9317f3c5da2d635..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/InflectorTest.php +++ /dev/null @@ -1,492 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: InflectorTest.php 9045 2008-03-25 15:57:29Z ralph $ - */ - - -// Call Zend_Filter_InflectorTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Filter_InflectorTest::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Inflector - */ -require_once 'Zend/Filter/Inflector.php'; - -/** - * @see Zend_Config - */ -require_once 'Zend/Config.php'; - - -/** - * Test class for Zend_Filter_Inflector. - * - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_InflectorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite('Zend_Filter_InflectorTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->inflector = new Zend_Filter_Inflector(); - $this->loader = $this->inflector->getPluginLoader(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - $this->loader->clearPaths(); - } - - public function testGetPluginLoaderReturnsLoaderByDefault() - { - $loader = $this->inflector->getPluginLoader(); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader_Interface); - $paths = $loader->getPaths(); - $this->assertEquals(1, count($paths)); - $this->assertTrue(array_key_exists('Zend_Filter_', $paths)); - } - - public function testSetPluginLoaderAllowsSettingAlternatePluginLoader() - { - $defaultLoader = $this->inflector->getPluginLoader(); - $loader = new Zend_Loader_PluginLoader(); - $this->inflector->setPluginLoader($loader); - $receivedLoader = $this->inflector->getPluginLoader(); - $this->assertNotSame($defaultLoader, $receivedLoader); - $this->assertSame($loader, $receivedLoader); - } - - public function testAddFilterPrefixPathAddsPathsToPluginLoader() - { - $this->inflector->addFilterPrefixPath('Foo_Bar', 'Zend/View/'); - $loader = $this->inflector->getPluginLoader(); - $paths = $loader->getPaths(); - $this->assertTrue(array_key_exists('Foo_Bar_', $paths)); - } - - public function testTargetAccessorsWork() - { - $this->inflector->setTarget('foo/:bar/:baz'); - $this->assertEquals('foo/:bar/:baz', $this->inflector->getTarget()); - } - - public function testTargetInitiallyNull() - { - $this->assertNull($this->inflector->getTarget()); - } - - public function testPassingTargetToConstructorSetsTarget() - { - $inflector = new Zend_Filter_Inflector('foo/:bar/:baz'); - $this->assertEquals('foo/:bar/:baz', $inflector->getTarget()); - } - - public function testSetTargetByReferenceWorks() - { - $target = 'foo/:bar/:baz'; - $this->inflector->setTargetReference($target); - $this->assertEquals('foo/:bar/:baz', $this->inflector->getTarget()); - $target .= '/:bat'; - $this->assertEquals('foo/:bar/:baz/:bat', $this->inflector->getTarget()); - } - - public function testSetFilterRuleWithStringRuleCreatesRuleEntryAndFilterObject() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->setFilterRule('controller', 'PregReplace'); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals(1, count($rules)); - $filter = $rules[0]; - $this->assertTrue($filter instanceof Zend_Filter_Interface); - } - - public function testSetFilterRuleWithFilterObjectCreatesRuleEntryWithFilterObject() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $filter = new Zend_Filter_PregReplace(); - $this->inflector->setFilterRule('controller', $filter); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals(1, count($rules)); - $received = $rules[0]; - $this->assertTrue($received instanceof Zend_Filter_Interface); - $this->assertSame($filter, $received); - } - - public function testSetFilterRuleWithArrayOfRulesCreatesRuleEntries() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->setFilterRule('controller', array('PregReplace', 'Alpha')); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals(2, count($rules)); - $this->assertTrue($rules[0] instanceof Zend_Filter_Interface); - $this->assertTrue($rules[1] instanceof Zend_Filter_Interface); - } - - public function testAddFilterRuleAppendsRuleEntries() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->setFilterRule('controller', 'PregReplace'); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals(1, count($rules)); - $this->inflector->addFilterRule('controller', 'Alpha'); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals(2, count($rules)); - } - - public function testSetStaticRuleCreatesScalarRuleEntry() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->setStaticRule('controller', 'foobar'); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals('foobar', $rules); - } - - public function testSetStaticRuleMultipleTimesOverwritesEntry() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->setStaticRule('controller', 'foobar'); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals('foobar', $rules); - $this->inflector->setStaticRule('controller', 'bazbat'); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals('bazbat', $rules); - } - - public function testSetStaticRuleReferenceAllowsUpdatingRuleByReference() - { - $rule = 'foobar'; - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->setStaticRuleReference('controller', $rule); - $rules = $this->inflector->getRules('controller'); - $this->assertEquals('foobar', $rules); - $rule .= '/baz'; - $rules = $this->inflector->getRules('controller'); - $this->assertEquals('foobar/baz', $rules); - } - - public function testAddRulesCreatesAppropriateRuleEntries() - { - $rules = $this->inflector->getRules(); - $this->assertEquals(0, count($rules)); - $this->inflector->addRules(array( - ':controller' => array('PregReplace', 'Alpha'), - 'suffix' => 'phtml', - )); - $rules = $this->inflector->getRules(); - $this->assertEquals(2, count($rules)); - $this->assertEquals(2, count($rules['controller'])); - $this->assertEquals('phtml', $rules['suffix']); - } - - public function testSetRulesCreatesAppropriateRuleEntries() - { - $this->inflector->setStaticRule('some-rules', 'some-value'); - $rules = $this->inflector->getRules(); - $this->assertEquals(1, count($rules)); - $this->inflector->setRules(array( - ':controller' => array('PregReplace', 'Alpha'), - 'suffix' => 'phtml', - )); - $rules = $this->inflector->getRules(); - $this->assertEquals(2, count($rules)); - $this->assertEquals(2, count($rules['controller'])); - $this->assertEquals('phtml', $rules['suffix']); - } - - public function testGetRule() - { - $this->inflector->setFilterRule(':controller', array('Alpha', 'StringToLower')); - $this->assertTrue($this->inflector->getRule('controller', 1) instanceof Zend_Filter_StringToLower); - $this->assertFalse($this->inflector->getRule('controller', 2)); - } - - public function testFilterTransformsStringAccordingToRules() - { - $this->inflector->setTarget(':controller/:action.:suffix') - ->addRules(array( - ':controller' => array('Word_CamelCaseToDash'), - ':action' => array('Word_CamelCaseToDash'), - 'suffix' => 'phtml' - )); - $filtered = $this->inflector->filter(array( - 'controller' => 'FooBar', - 'action' => 'bazBat' - )); - $this->assertEquals('Foo-Bar/baz-Bat.phtml', $filtered); - } - - public function testTargetReplacementIdentiferAccessorsWork() - { - $this->assertEquals(':', $this->inflector->getTargetReplacementIdentifier()); - $this->inflector->setTargetReplacementIdentifier('?='); - $this->assertEquals('?=', $this->inflector->getTargetReplacementIdentifier()); - } - - public function testTargetReplacementIdentiferWorksWhenInflected() - { - $this->inflector = new Zend_Filter_Inflector( - '?=##controller/?=##action.?=##suffix', - array( - ':controller' => array('Word_CamelCaseToDash'), - ':action' => array('Word_CamelCaseToDash'), - 'suffix' => 'phtml' - ), - null, - '?=##' - ); - - $filtered = $this->inflector->filter(array( - 'controller' => 'FooBar', - 'action' => 'bazBat' - )); - - $this->assertEquals('Foo-Bar/baz-Bat.phtml', $filtered); - } - - public function testThrowTargetExceptionsAccessorsWork() - { - $this->assertEquals(':', $this->inflector->getTargetReplacementIdentifier()); - $this->inflector->setTargetReplacementIdentifier('?='); - $this->assertEquals('?=', $this->inflector->getTargetReplacementIdentifier()); - } - - public function testThrowTargetExceptionsOnAccessorsWork() - { - $this->assertTrue($this->inflector->isThrowTargetExceptionsOn()); - $this->inflector->setThrowTargetExceptionsOn(false); - $this->assertFalse($this->inflector->isThrowTargetExceptionsOn()); - } - - public function testTargetExceptionThrownWhenTargetSourceNotSatisfied() - { - $this->inflector = new Zend_Filter_Inflector( - '?=##controller/?=##action.?=##suffix', - array( - ':controller' => array('Word_CamelCaseToDash'), - ':action' => array('Word_CamelCaseToDash'), - 'suffix' => 'phtml' - ), - true, - '?=##' - ); - - try { - $filtered = $this->inflector->filter(array('controller' => 'FooBar')); - $this->fail('Exception was not thrown when it was suppose to be.'); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Filter_Exception); - } - } - - public function testTargetExceptionNotThrownOnIdentifierNotFollowedByCharacter() - { - $this->inflector = new Zend_Filter_Inflector( - 'e:\path\to\:controller\:action.:suffix', - array( - ':controller' => array('Word_CamelCaseToDash', 'StringToLower'), - ':action' => array('Word_CamelCaseToDash'), - 'suffix' => 'phtml' - ), - true, - ':' - ); - - try { - $filtered = $this->inflector->filter(array('controller' => 'FooBar', 'action' => 'MooToo')); - $this->assertEquals($filtered, 'e:\path\to\foo-bar\Moo-Too.phtml'); - } catch (Exception $e) { - $this->fail($e->getMessage()); - } - } - - public function getOptions() - { - $options = array( - 'target' => '$controller/$action.$suffix', - 'filterPrefixPath' => array( - 'Zend_View_Filter' => 'Zend/View/Filter/', - 'Foo_Filter' => 'foo/filters/' - ), - 'throwTargetExceptionsOn' => true, - 'targetReplacementIdentifier' => '$', - 'rules' => array( - ':controller' => array( - 'rule1' => 'Word_CamelCaseToUnderscore', - 'rule2' => 'StringToLower', - ), - ':action' => array( - 'rule1' => 'Word_CamelCaseToDash', - 'rule2' => 'StringToUpper', - ), - 'suffix' => 'php' - ), - ); - return $options; - } - - public function getConfig() - { - $options = $this->getOptions(); - return new Zend_Config($options); - } - - protected function _testOptions($inflector) - { - $options = $this->getOptions(); - $loader = $inflector->getPluginLoader(); - $this->assertEquals($options['target'], $inflector->getTarget()); - - $viewFilterPath = $loader->getPaths('Zend_View_Filter'); - $this->assertEquals($options['filterPrefixPath']['Zend_View_Filter'], $viewFilterPath[0]); - $fooFilterPath = $loader->getPaths('Foo_Filter'); - $this->assertEquals($options['filterPrefixPath']['Foo_Filter'], $fooFilterPath[0]); - - $this->assertTrue($inflector->isThrowTargetExceptionsOn()); - - $this->assertEquals($options['targetReplacementIdentifier'], $inflector->getTargetReplacementIdentifier()); - - $rules = $inflector->getRules(); - foreach (array_values($options['rules'][':controller']) as $key => $rule) { - $class = get_class($rules['controller'][$key]); - $this->assertContains($rule, $class); - } - foreach (array_values($options['rules'][':action']) as $key => $rule) { - $class = get_class($rules['action'][$key]); - $this->assertContains($rule, $class); - } - $this->assertEquals($options['rules']['suffix'], $rules['suffix']); - } - - public function testPassingConfigObjectToConstructorSetsStateAndRules() - { - $config = $this->getConfig(); - $inflector = new Zend_Filter_Inflector($config); - $this->_testOptions($inflector); - } - - public function testSetConfigSetsStateAndRules() - { - $config = $this->getConfig(); - $inflector = new Zend_Filter_Inflector(); - $inflector->setConfig($config); - $this->_testOptions($inflector); - } - - /** - * Added str_replace('\\', '\\\\', ..) to all processedParts values to disable backreferences - * - * @issue ZF-2538 Zend_Filter_Inflector::filter() fails with all numeric folder on Windows - */ - public function testCheckInflectorWithPregBackreferenceLikeParts() - { - - $this->inflector = new Zend_Filter_Inflector( - ':moduleDir' . DIRECTORY_SEPARATOR . ':controller' . DIRECTORY_SEPARATOR . ':action.:suffix', - array( - ':controller' => array('Word_CamelCaseToDash', 'StringToLower'), - ':action' => array('Word_CamelCaseToDash'), - 'suffix' => 'phtml' - ), - true, - ':' - ); - - $this->inflector->setStaticRule('moduleDir', 'C:\htdocs\public\cache\00\01\42\app\modules'); - - try { - $filtered = $this->inflector->filter(array( - 'controller' => 'FooBar', - 'action' => 'MooToo' - )); - $this->assertEquals($filtered, 'C:\htdocs\public\cache\00\01\42\app\modules' . DIRECTORY_SEPARATOR . 'foo-bar' . DIRECTORY_SEPARATOR . 'Moo-Too.phtml'); - } catch (Exception $e) { - $this->fail($e->getMessage()); - } - } - - /** - * @issue ZF-2522 - */ - public function testTestForFalseInConstructorParams() - { - $inflector = new Zend_Filter_Inflector('something', array(), false, false); - $this->assertFalse($inflector->isThrowTargetExceptionsOn()); - $this->assertEquals($inflector->getTargetReplacementIdentifier(), ':'); - $inflector = new Zend_Filter_Inflector('something', array(), false, '#'); - $this->assertEquals($inflector->getTargetReplacementIdentifier(), '#'); - } - - /** - * @issue ZF-2964 - */ - public function testNoInflectableTarget() - { - $inflector = new Zend_Filter_Inflector('abc'); - $inflector->addRules(array(':foo' => array())); - $this->assertEquals($inflector->filter(array('fo' => 'bar')), 'abc'); - } - -} - -// Call Zend_Filter_InflectorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == 'Zend_Filter_InflectorTest::main') { - Zend_Filter_InflectorTest::main(); -} diff --git a/tests/Zend/Filter/InputTest.php b/tests/Zend/Filter/InputTest.php deleted file mode 100644 index 4324e6ad35aef80101c48e4c7eb199486a5473ea..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/InputTest.php +++ /dev/null @@ -1,1561 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: InputTest.php 11754 2008-10-08 19:38:31Z andries $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Input - */ -require_once 'Zend/Filter/Input.php'; - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_InputTest extends PHPUnit_Framework_TestCase -{ - - public function testFilterDeclareSingle() - { - $data = array( - 'month' => '6abc ' - ); - $filters = array( - 'month' => 'digits' - ); - $input = new Zend_Filter_Input($filters, null, $data); - - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $month = $input->month; - $this->assertEquals('6', $month); - } - - public function testFilterDeclareByObject() - { - $data = array( - 'month' => '6abc ' - ); - Zend_Loader::loadClass('Zend_Filter_Digits'); - $filters = array( - 'month' => array(new Zend_Filter_Digits()) - ); - $input = new Zend_Filter_Input($filters, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $month = $input->month; - $this->assertEquals('6', $month); - } - - public function testFilterDeclareByArray() - { - $data = array( - 'month' => '_6_' - ); - $filters = array( - 'month' => array( - array('StringTrim', '_') - ) - ); - $input = new Zend_Filter_Input($filters, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $month = $input->month; - $this->assertEquals('6', $month); - } - - public function testFilterDeclareByChain() - { - $data = array( - 'field1' => ' ABC ' - ); - $filters = array( - 'field1' => array('StringTrim', 'StringToLower') - ); - $input = new Zend_Filter_Input($filters, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('abc', $input->field1); - } - - public function testFilterWildcardRule() - { - $data = array( - 'field1' => ' 12abc ', - 'field2' => ' 24abc ' - ); - $filters = array( - '*' => 'stringTrim', - 'field1' => 'digits' - ); - $input = new Zend_Filter_Input($filters, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('12', $input->field1); - $this->assertEquals('24abc', $input->field2); - } - - public function testFilterMultiValue() - { - $data = array( - 'field1' => array('FOO', 'BAR', 'BaZ') - ); - $filters = array( - 'field1' => 'StringToLower' - ); - $input = new Zend_Filter_Input($filters, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $f1 = $input->field1; - $this->assertType('array', $f1); - $this->assertEquals(array('foo', 'bar', 'baz'), $f1); - } - - public function testValidatorSingle() - { - $data = array( - 'month' => '6' - ); - $validators = array( - 'month' => 'digits' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $month = $input->month; - $this->assertEquals('6', $month); - } - - public function testValidatorSingleInvalid() - { - $data = array( - 'month' => '6abc ' - ); - $validators = array( - 'month' => 'digits' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertType('array', $messages['month']); - $this->assertEquals("'6abc ' contains not only digit characters", current($messages['month'])); - - $errors = $input->getErrors(); - $this->assertType('array', $errors); - $this->assertEquals(array('month'), array_keys($errors)); - $this->assertType('array', $errors['month']); - $this->assertEquals("notDigits", $errors['month'][0]); - } - - public function testValidatorDeclareByObject() - { - $data = array( - 'month' => '6' - ); - Zend_Loader::loadClass('Zend_Validate_Digits'); - $validators = array( - 'month' => array( - new Zend_Validate_Digits() - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $month = $input->month; - $this->assertEquals('6', $month); - } - - public function testValidatorDeclareByArray() - { - $data = array( - 'month' => '6', - 'month2' => 13 - ); - $validators = array( - 'month' => array( - 'digits', - array('Between', 1, 12) - ), - 'month2' => array( - 'digits', - array('Between', 1, 12) - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $month = $input->month; - $this->assertEquals('6', $month); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month2'), array_keys($messages)); - $this->assertEquals("'13' is not between '1' and '12', inclusively", current($messages['month2'])); - } - - public function testValidatorChain() - { - $data = array( - 'field1' => '50', - 'field2' => 'abc123', - 'field3' => 150, - ); - Zend_Loader::loadClass('Zend_Validate_Between'); - $btw = new Zend_Validate_Between(1, 100); - $validators = array( - 'field1' => array('digits', $btw), - 'field2' => array('digits', $btw), - 'field3' => array('digits', $btw) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field2', 'field3'), array_keys($messages)); - $this->assertType('array', $messages['field2']); - $this->assertType('array', $messages['field3']); - $this->assertEquals("'abc123' contains not only digit characters", - current($messages['field2'])); - $this->assertEquals("'150' is not between '1' and '100', inclusively", - current($messages['field3'])); - } - - public function testValidatorInvalidFieldInMultipleRules() - { - $data = array( - 'field2' => 'abc123', - ); - Zend_Loader::loadClass('Zend_Validate_Between'); - $validators = array( - 'field2a' => array( - 'digits', - 'fields' => 'field2' - ), - 'field2b' => array( - new Zend_Validate_Between(1, 100), - 'fields' => 'field2' - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field2a', 'field2b'), array_keys($messages)); - $this->assertType('array', $messages['field2a']); - $this->assertType('array', $messages['field2b']); - $this->assertEquals("'abc123' contains not only digit characters", - current($messages['field2a'])); - $this->assertEquals("'abc123' is not between '1' and '100', inclusively", - current($messages['field2b'])); - } - - public function testValidatorWildcardRule() - { - $data = array( - 'field1' => '123abc', - 'field2' => '246abc' - ); - $validators = array( - '*' => 'alnum', - 'field1' => 'digits' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertNull($input->field1); - $this->assertEquals('246abc', $input->field2); - } - - public function testValidatorMultiValue() - { - $data = array( - 'field1' => array('abc', 'def', 'ghi'), - 'field2' => array('abc', '123') - ); - $validators = array( - 'field1' => 'alpha', - 'field2' => 'alpha' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field2'), array_keys($messages)); - $this->assertEquals("'123' has not only alphabetic characters", - current($messages['field2'])); - } - - public function testValidatorMultiField() - { - $data = array( - 'password1' => 'EREIAMJH', - 'password2' => 'EREIAMJH', - 'password3' => 'VESPER' - ); - $validators = array( - 'rule1' => array( - 'StringEquals', - 'fields' => array('password1', 'password2') - ), - 'rule2' => array( - 'StringEquals', - 'fields' => array('password1', 'password3') - ) - ); - $options = array( - Zend_Filter_Input::INPUT_NAMESPACE => 'TestNamespace' - ); - - $ip = get_include_path(); - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $newIp = $dir . PATH_SEPARATOR . $ip; - set_include_path($newIp); - - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - set_include_path($ip); - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('rule2'), array_keys($messages)); - $this->assertEquals("Not all strings in the argument are equal", - current($messages['rule2'])); - } - - public function testValidatorBreakChain() - { - $data = array( - 'field1' => '150', - 'field2' => '150' - ); - - Zend_Loader::loadClass('Zend_Validate_Between'); - - $btw1 = new Zend_Validate_Between(1, 100); - - $btw2 = new Zend_Validate_Between(1, 125); - $messageUserDefined = 'Something other than the default message'; - $btw2->setMessage($messageUserDefined, Zend_Validate_Between::NOT_BETWEEN); - - $validators = array( - 'field1' => array($btw1, $btw2), - 'field2' => array($btw1, $btw2, Zend_Filter_Input::BREAK_CHAIN => true) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field1', 'field2'), array_keys($messages)); - $this->assertEquals( - $messageUserDefined, - current($messages['field1']), - 'Expected message to break 2 validators, the message of the latter overwriting that of the former' - ); - $this->assertEquals( - "'150' is not between '1' and '100', inclusively", - current($messages['field2']), - 'Expected rule for field2 to break the validation chain at the first validator' - ); - } - - public function testValidatorAllowEmpty() - { - $data = array( - 'field1' => '', - 'field2' => '' - ); - $validators = array( - 'field1' => array( - 'alpha', - Zend_Filter_Input::ALLOW_EMPTY => false - ), - 'field2' => array( - 'alpha', - Zend_Filter_Input::ALLOW_EMPTY => true - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertNull($input->field1); - $this->assertNotNull($input->field2); - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field1'), array_keys($messages)); - $this->assertEquals("'' is an empty string", current($messages['field1'])); - } - - public function testValidatorAllowEmptyNoValidatorChain() - { - Zend_Loader::loadClass('Zend_Filter_StringTrim'); - Zend_Loader::loadClass('Zend_Filter_StripTags'); - Zend_Loader::loadClass('Zend_Validate_EmailAddress'); - - $data = array( - 'nick' => '', - 'email' => 'someemail@server.com' - ); - - $filters = array( - '*' => new Zend_Filter_StringTrim(), - 'nick' => new Zend_Filter_StripTags() - ); - - $validators = array( - 'email' => array( - new Zend_Validate_EmailAddress(), - Zend_Filter_Input::ALLOW_EMPTY => true - ), - /* - * This is the case we're testing - when presense is required, - * but there are no validators besides disallowing empty values. - */ - 'nick' => array( - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED, - Zend_Filter_Input::ALLOW_EMPTY => false - ) - ); - - $input = new Zend_Filter_Input($filters, $validators, $data); - - if ($input->hasInvalid()) { - $input->getMessages(); - } - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('nick'), array_keys($messages)); - $this->assertEquals(1, count($messages['nick'])); - } - - public function testValidatorAllowEmptySetNotEmptyMessage() - { - $data = array( - 'field1' => '', - ); - $validators = array( - 'field1Rule' => array( - Zend_Filter_Input::ALLOW_EMPTY => false, - 'fields' => 'field1' - ) - ); - - $options = array( - Zend_Filter_Input::NOT_EMPTY_MESSAGE => "You cannot give an empty value for field '%field%', according to rule '%rule%'" - ); - - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $this->assertNull($input->field1); - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field1Rule'), array_keys($messages)); - $this->assertType('array', $messages['field1Rule']); - $this->assertEquals("You cannot give an empty value for field 'field1', according to rule 'field1Rule'", current($messages['field1Rule'])); - } - - public function testValidatorDefault() - { - $validators = array( - 'field1' => array('presence' => 'required', 'allowEmpty' => false), - 'field2' => array('presence' => 'optional', 'allowEmpty' => false), - 'field3' => array('presence' => 'required', 'allowEmpty' => true), - 'field4' => array('presence' => 'optional', 'allowEmpty' => true), - 'field5' => array('presence' => 'required', 'allowEmpty' => false, 'default' => 'field5default'), - 'field6' => array('presence' => 'optional', 'allowEmpty' => false, 'default' => 'field6default'), - 'field7' => array('presence' => 'required', 'allowEmpty' => true, 'default' => 'field7default'), - 'field8' => array('presence' => 'optional', 'allowEmpty' => true, 'default' => array('field8default', 'field8default2')), - ); - $data = array(); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $missing = $input->getMissing(); - $this->assertType('array', $missing); - // make sure field5 and field7 are not counted as missing - $this->assertEquals(array('field1', 'field3'), array_keys($missing)); - - $this->assertNull($input->field1); - $this->assertNull($input->field2); - $this->assertNull($input->field3); - $this->assertNull($input->field4); - $this->assertEquals('field5default', $input->field5, 'Expected field5 to be non-null'); - $this->assertEquals('field6default', $input->field6, 'Expected field6 to be non-null'); - $this->assertEquals('field7default', $input->field7, 'Expected field7 to be non-null'); - $this->assertEquals('field8default', $input->field8, 'Expected field8 to be non-null'); - } - - public function testValidatorDefaultDoesNotOverwriteData() - { - $validators = array( - 'field1' => array('presence' => 'required', 'allowEmpty' => false, 'default' => 'abcd'), - 'field2' => array('presence' => 'optional', 'allowEmpty' => false, 'default' => 'abcd'), - 'field3' => array('presence' => 'required', 'allowEmpty' => true, 'default' => 'abcd'), - 'field4' => array('presence' => 'optional', 'allowEmpty' => true, 'default' => 'abcd'), - ); - $data = array( - 'field1' => 'ABCD', - 'field2' => 'ABCD', - 'field3' => 'ABCD', - 'field4' => 'ABCD' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('ABCD', $input->field1); - $this->assertEquals('ABCD', $input->field2); - $this->assertEquals('ABCD', $input->field3); - $this->assertEquals('ABCD', $input->field4); - } - - public function testValidatorNotAllowEmpty() - { - $filters = array( - 'field1' => 'Digits', - 'field2' => 'Alnum' - ); - - $validators = array( - 'field1' => array('Digits'), - 'field2' => array('Alnum'), - 'field3' => array('Alnum', 'presence' => 'required') - ); - $data = array( - 'field1' => 'asd1', // Valid data - 'field2' => '$' // Invalid data - ); - $input = new Zend_Filter_Input($filters, $validators, $data); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field2', 'field3'), array_keys($messages)); - $this->assertType('array', $messages['field2']); - $this->assertEquals("'' is an empty string", current($messages['field2'])); - } - - public function testValidatorMessagesSingle() - { - $data = array('month' => '13abc'); - $digitsMesg = 'Month should consist of digits'; - $validators = array( - 'month' => array( - 'digits', - 'messages' => $digitsMesg - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertEquals(1, count($messages['month'])); - $this->assertEquals($digitsMesg, current($messages['month'])); - } - - public function testValidatorMessagesMultiple() - { - $data = array('month' => '13abc'); - $digitsMesg = 'Month should consist of digits'; - $betweenMesg = 'Month should be between 1 and 12'; - Zend_Loader::loadClass('Zend_Validate_Between'); - $validators = array( - 'month' => array( - 'digits', - new Zend_Validate_Between(1, 12), - 'messages' => array( - $digitsMesg, - $betweenMesg - ) - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertEquals(2, count($messages['month'])); - // $this->assertEquals($digitsMesg, $messages['month'][0]); - // $this->assertEquals($betweenMesg, $messages['month'][1]); - } - - public function testValidatorMessagesIntIndex() - { - $data = array('month' => '13abc'); - $betweenMesg = 'Month should be between 1 and 12'; - Zend_Loader::loadClass('Zend_Validate_Between'); - $validators = array( - 'month' => array( - 'digits', - new Zend_Validate_Between(1, 12), - 'messages' => array( - 1 => $betweenMesg - ) - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertEquals(2, count($messages['month'])); - $this->assertEquals("'13abc' contains not only digit characters", current($messages['month'])); - /** - * @todo $this->assertEquals($betweenMesg, next($messages['month'])); - */ - } - - public function testValidatorMessagesSingleWithKeys() - { - $data = array('month' => '13abc'); - $digitsMesg = 'Month should consist of digits'; - $validators = array( - 'month' => array( - 'digits', - 'messages' => array('notDigits' => $digitsMesg) - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertEquals(1, count($messages['month'])); - // $this->assertEquals($digitsMesg, $messages['month'][0]); - } - - public function testValidatorMessagesMultipleWithKeys() - { - $data = array('month' => '13abc'); - $digitsMesg = 'Month should consist of digits'; - $betweenMesg = 'Month should be between 1 and 12'; - Zend_Loader::loadClass('Zend_Validate_Between'); - $validators = array( - 'month' => array( - 'digits', - new Zend_Validate_Between(1, 12), - 'messages' => array( - array('notDigits' => $digitsMesg), - array('notBetween' => $betweenMesg) - ) - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertEquals(2, count($messages['month'])); - // $this->assertEquals($digitsMesg, $messages['month'][0]); - // $this->assertEquals($betweenMesg, $messages['month'][1]); - } - - public function testValidatorMessagesMixedWithKeys() - { - $data = array('month' => '13abc'); - $digitsMesg = 'Month should consist of digits'; - $betweenMesg = 'Month should be between 1 and 12'; - Zend_Loader::loadClass('Zend_Validate_Between'); - $validators = array( - 'month' => array( - 'digits', - new Zend_Validate_Between(1, 12), - 'messages' => array( - $digitsMesg, - array('notBetween' => $betweenMesg) - ) - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('month'), array_keys($messages)); - $this->assertEquals(2, count($messages['month'])); - // $this->assertEquals($digitsMesg, $messages['month'][0]); - // $this->assertEquals($betweenMesg, $messages['month'][1]); - } - - public function testValidatorHasMissing() - { - $data = array(); - $validators = array( - 'month' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - } - - public function testValidatorFieldOptional() - { - $data = array(); - $validators = array( - 'month' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - } - - public function testValidatorGetMissing() - { - $data = array(); - $validators = array( - 'month' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED - ) - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $missing = $input->getMissing(); - $this->assertType('array', $missing); - $this->assertEquals(array('month'), array_keys($missing)); - $this->assertEquals("Field 'month' is required by rule 'month', but the field is missing", $missing['month'][0]); - } - - public function testValidatorSetMissingMessage() - { - $data = array(); - $validators = array( - 'monthRule' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED, - 'fields' => 'month' - ) - ); - $options = array( - Zend_Filter_Input::MISSING_MESSAGE => 'I looked for %field% but I did not find it; it is required by rule %rule%' - ); - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $missing = $input->getMissing(); - $this->assertType('array', $missing); - $this->assertEquals(array('monthRule'), array_keys($missing)); - $this->assertEquals("I looked for month but I did not find it; it is required by rule monthRule", $missing['monthRule'][0]); - } - - public function testValidatorHasUnknown() - { - $data = array( - 'unknown' => 'xxx' - ); - $validators = array( - 'month' => 'digits' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expecting hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expecting hasInvalid() to return false'); - $this->assertTrue($input->hasUnknown(), 'Expecting hasUnknown() to return true'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - } - - public function testValidatorGetUnknown() - { - $data = array( - 'unknown' => 'xxx' - ); - $validators = array( - 'month' => 'digits' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertTrue($input->hasUnknown(), 'Expected hasUnknown() to retrun true'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $unknown = $input->getUnknown(); - $this->assertType('array', $unknown); - $this->assertThat($unknown, $this->arrayHasKey('unknown')); - } - - public function testValidatorGetInvalid() - { - $data = array( - 'month' => '6abc ' - ); - $validators = array( - 'month' => 'digits', - 'field2' => array('digits', 'presence' => 'required') - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $invalid = $input->getInvalid(); - $missing = $input->getMissing(); - - $this->assertType('array', $messages); - $this->assertEquals(array('month', 'field2'), array_keys($messages)); - $this->assertType('array', $invalid); - $this->assertEquals(array('month'), array_keys($invalid)); - $this->assertType('array', $missing); - $this->assertEquals(array('field2'), array_keys($missing)); - $this->assertEquals(array_merge($invalid, $missing), $messages); - } - - public function testValidatorIsValid() - { - $data = array( - 'field1' => 'abc123', - 'field2' => 'abcdef' - ); - $validators = array( - 'field1' => 'alpha', - 'field2' => 'alpha' - ); - $input = new Zend_Filter_Input(null, $validators, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertFalse($input->isValid()); - $this->assertFalse($input->isValid('field1')); - $this->assertTrue($input->isValid('field2')); - - $input->setData(array('field2' => 'abcdef')); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertTrue($input->isValid()); - $this->assertFalse($input->isValid('field1')); - $this->assertTrue($input->isValid('field2')); - } - - public function testAddNamespace() - { - $data = array( - 'field1' => 'abc', - 'field2' => '123', - 'field3' => '123' - ); - $validators = array( - 'field1' => 'MyDigits', - 'field2' => 'MyDigits', - 'field3' => 'digits' - ); - $options = array( - Zend_Filter_Input::INPUT_NAMESPACE => 'TestNamespace' - ); - - $ip = get_include_path(); - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $newIp = $dir . PATH_SEPARATOR . $ip; - set_include_path($newIp); - - $input = new Zend_Filter_Input(null, $validators, $data); - $input->addNamespace('TestNamespace'); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - set_include_path($ip); - - $this->assertEquals('123', (string) $input->field2); - $this->assertEquals('123', (string) $input->field3); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertThat($messages, $this->arrayHasKey('field1')); - $this->assertEquals("'abc' contains not only digit characters", current($messages['field1'])); - } - - public function testGetPluginLoader() - { - $input = new Zend_Filter_Input(null, null); - - $loader = $input->getPluginLoader(Zend_Filter_Input::VALIDATE); - $this->assertType('Zend_Loader_PluginLoader', $loader, - 'Expected object of type Zend_Loader_PluginLoader, got ' , get_class($loader)); - - try { - $loader = $input->getPluginLoader('foo'); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals('Invalid type "foo" provided to getPluginLoader()', - $e->getMessage()); - } - - } - - public function testSetPluginLoader() - { - $input = new Zend_Filter_Input(null, null); - - $loader = new Zend_Loader_PluginLoader(); - - $input->setPluginLoader($loader, Zend_Filter_Input::VALIDATE); - } - - public function testSetPluginLoaderInvalidType() - { - $input = new Zend_Filter_Input(null, null); - - $loader = new Zend_Loader_PluginLoader(); - - try { - $input->setPluginLoader($loader, 'foo'); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals('Invalid type "foo" provided to setPluginLoader()', - $e->getMessage()); - } - } - - public function testNamespaceExceptionClassNotFound() - { - $data = array( - 'field1' => 'abc' - ); - $validators = array( - 'field1' => 'MyDigits' - ); - // Do not add namespace on purpose, so MyDigits will not be found - $input = new Zend_Filter_Input(null, $validators, $data); - try { - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Loader_PluginLoader_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertContains("Plugin by name MyDigits was not found in the registry", - $e->getMessage()); - } - } - - public function testNamespaceExceptionInvalidClass() - { - $data = array( - 'field1' => 'abc' - ); - // Zend_Validate_Exception exists, but does not implement the needed interface - $validators = array( - 'field1' => 'Exception' - ); - - $input = new Zend_Filter_Input(null, $validators, $data); - - try { - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals("Class based on basename 'Exception' must implement the 'Zend_Validate_Interface' interface", - $e->getMessage()); - } - } - - public function testSetDefaultEscapeFilter() - { - $data = array( - 'field1' => ' ab&c ' - ); - $options = array( - Zend_Filter_Input::ESCAPE_FILTER => 'StringTrim' - ); - $input = new Zend_Filter_Input(null, null, $data); - $input->setDefaultEscapeFilter('StringTrim'); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('ab&c', $input->field1); - } - - public function testSetDefaultEscapeFilterExceptionWrongClassType() - { - $input = new Zend_Filter_Input(null, null); - try { - $input->setDefaultEscapeFilter(new StdClass()); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals("Escape filter specified does not implement Zend_Filter_Interface", $e->getMessage()); - } - } - - public function testOptionAllowEmpty() - { - $data = array( - 'field1' => '' - ); - $validators = array( - 'field1' => 'alpha' - ); - $options = array( - Zend_Filter_Input::ALLOW_EMPTY => true - ); - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertNotNull($input->field1); - $this->assertEquals('', $input->field1); - } - - public function testOptionBreakChain() - { - $data = array( - 'field1' => '150' - ); - Zend_Loader::loadClass('Zend_Validate_Between'); - $btw1 = new Zend_Validate_Between(1, 100); - $btw2 = new Zend_Validate_Between(1, 125); - $validators = array( - 'field1' => array($btw1, $btw2), - ); - $options = array( - Zend_Filter_Input::BREAK_CHAIN => true - ); - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false'); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertEquals(array('field1'), array_keys($messages)); - $this->assertEquals(1, count($messages['field1']), 'Expected rule for field1 to break 1 validator'); - $this->assertEquals("'150' is not between '1' and '100', inclusively", - current($messages['field1'])); - } - - public function testOptionEscapeFilter() - { - $data = array( - 'field1' => ' ab&c ' - ); - $options = array( - Zend_Filter_Input::ESCAPE_FILTER => 'StringTrim' - ); - $input = new Zend_Filter_Input(null, null, $data, $options); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('ab&c', $input->field1); - } - - public function testOptionNamespace() - { - $data = array( - 'field1' => 'abc', - 'field2' => '123', - 'field3' => '123' - ); - $validators = array( - 'field1' => 'MyDigits', - 'field2' => 'MyDigits', - 'field3' => 'digits' - ); - $options = array( - Zend_Filter_Input::INPUT_NAMESPACE => 'TestNamespace' - ); - - $ip = get_include_path(); - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $newIp = $dir . PATH_SEPARATOR . $ip; - set_include_path($newIp); - - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - set_include_path($ip); - - $this->assertEquals('123', (string) $input->field2); - $this->assertEquals('123', (string) $input->field3); - - $messages = $input->getMessages(); - $this->assertType('array', $messages); - $this->assertThat($messages, $this->arrayHasKey('field1')); - $this->assertEquals("'abc' contains not only digit characters", current($messages['field1'])); - } - - public function testOptionPresence() - { - $data = array( - 'field1' => '123' - // field2 is missing deliberately - ); - $validators = array( - 'field1' => 'Digits', - 'field2' => 'Digits' - ); - $options = array( - Zend_Filter_Input::PRESENCE => true - ); - $input = new Zend_Filter_Input(null, $validators, $data, $options); - - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $missing = $input->getMissing(); - $this->assertType('array', $missing); - $this->assertEquals(array('field2'), array_keys($missing)); - $this->assertEquals("Field 'field2' is required by rule 'field2', but the field is missing", $missing['field2'][0]); - } - - public function testOptionExceptionUnknown() - { - $options = array( - 'unknown' => 'xxx' - ); - try { - $input = new Zend_Filter_Input(null, null, null, $options); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals("Unknown option 'unknown'", $e->getMessage()); - } - } - - public function testGetEscaped() - { - $data = array( - 'field1' => 'ab&c' - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('ab&c', $input->getEscaped('field1')); - $this->assertNull($input->getEscaped('field2')); - } - - public function testGetEscapedAllFields() - { - $data = array( - 'field1' => 'ab&c' - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals(array('field1' => 'ab&c'), $input->getEscaped()); - } - - public function testMagicGetEscaped() - { - $data = array( - 'field1' => 'ab&c' - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('ab&c', $input->field1); - $this->assertNull($input->field2); - } - - public function testGetEscapedMultiValue() - { - $data = array( - 'multiSelect' => array('C&H', 'B&O', 'AT&T') - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $multi = $input->getEscaped('multiSelect'); - $this->assertType('array', $multi); - $this->assertEquals(3, count($multi)); - $this->assertEquals(array('C&H', 'B&O', 'AT&T'), $multi); - } - - public function testGetUnescaped() - { - $data = array( - 'field1' => 'ab&c' - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals('ab&c', $input->getUnescaped('field1')); - $this->assertNull($input->getUnescaped('field2')); - } - - public function testGetUnescapedAllFields() - { - $data = array( - 'field1' => 'ab&c' - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertEquals(array('field1' => 'ab&c'), $input->getUnescaped()); - } - - public function testMagicIsset() - { - $data = array( - 'field1' => 'ab&c' - ); - $input = new Zend_Filter_Input(null, null, $data); - - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - - $this->assertTrue(isset($input->field1)); - $this->assertFalse(isset($input->field2)); - } - - public function testProcess() - { - $data = array( - 'field1' => 'ab&c', - 'field2' => '123abc' - ); - $filters = array( - '*' => 'StringTrim', - 'field2' => 'digits' - ); - $validators = array( - 'field1' => array(Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), - 'field2' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED - ) - ); - $input = new Zend_Filter_Input($filters, $validators, $data); - try { - $input->process(); - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - } catch (Zend_Exception $e) { - $this->fail('Received Zend_Exception where none was expected'); - } - } - - public function testProcessUnknownThrowsNoException() - { - $data = array( - 'field1' => 'ab&c', - 'field2' => '123abc', - 'field3' => 'unknown' - ); - $filters = array( - '*' => 'StringTrim', - 'field2' => 'digits' - ); - $validators = array( - 'field1' => array(Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), - 'field2' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED - ) - ); - $input = new Zend_Filter_Input($filters, $validators, $data); - try { - $input->process(); - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertTrue($input->hasUnknown(), 'Expected hasUnknown() to retrun true'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - } catch (Zend_Exception $e) { - $this->fail('Received Zend_Exception where none was expected'); - } - } - - public function testProcessInvalidThrowsException() - { - $data = array( - 'field1' => 'ab&c', - 'field2' => 'abc' // invalid because no digits - ); - $filters = array( - '*' => 'StringTrim', - 'field2' => 'digits' - ); - $validators = array( - 'field1' => array(Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), - 'field2' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED - ) - ); - $input = new Zend_Filter_Input($filters, $validators, $data); - try { - $input->process(); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals("Input has invalid fields", $e->getMessage()); - $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false'); - $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - } - } - - public function testProcessMissingThrowsException() - { - $data = array( - 'field1' => 'ab&c' - // field2 is missing on purpose for this test - ); - $filters = array( - '*' => 'StringTrim', - 'field2' => 'digits' - ); - $validators = array( - 'field1' => array( - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL - ), - 'field2' => array( - 'digits', - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED - ) - ); - $input = new Zend_Filter_Input($filters, $validators, $data); - try { - $input->process(); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected object of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals("Input has missing fields", $e->getMessage()); - $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true'); - $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false'); - $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false'); - $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true'); - } - } - -} diff --git a/tests/Zend/Filter/IntTest.php b/tests/Zend/Filter/IntTest.php deleted file mode 100644 index b1bd5c9c0f35ddd36a1244d51db3549ad2c23fc1..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/IntTest.php +++ /dev/null @@ -1,82 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IntTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_Int - */ -require_once 'Zend/Filter/Int.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_IntTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_Int object - * - * @var Zend_Filter_Int - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_Int object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_Int(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'string' => 0, - '1' => 1, - '-1' => -1, - '1.1' => 1, - '-1.1' => -1, - '0.9' => 0, - '-0.9' => 0 - ); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } -} diff --git a/tests/Zend/Filter/PregReplaceTest.php b/tests/Zend/Filter/PregReplaceTest.php deleted file mode 100644 index bc4344afd526de3156ed0cb1e9f0db128d64a451..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/PregReplaceTest.php +++ /dev/null @@ -1,138 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PregReplaceTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -// Call Zend_Filter_PregReplaceTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Filter_PregReplaceTest::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_PregReplace - */ -require_once 'Zend/Filter/PregReplace.php'; - - -/** - * Test class for Zend_Filter_PregReplace. - * - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_PregReplaceTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite('Zend_Filter_PregReplaceTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->filter = new Zend_Filter_PregReplace(); - } - - public function testPassingMatchPatternToConstructorSetsMatchPattern() - { - $pattern = '#^controller/(?P<action>[a-z_-]+)#'; - $filter = new Zend_Filter_PregReplace($pattern); - $this->assertEquals($pattern, $filter->getMatchPattern()); - } - - public function testPassingReplacementToConstructorSetsReplacement() - { - $replace = 'foo/bar'; - $filter = new Zend_Filter_PregReplace(null, $replace); - $this->assertEquals($replace, $filter->getReplacement()); - } - - public function testIsUnicodeSupportEnabledReturnsSaneValue() - { - $enabled = (@preg_match('/\pL/u', 'a')) ? true : false; - $this->assertEquals($enabled, $this->filter->isUnicodeSupportEnabled()); - } - - public function testMatchPatternInitiallyNull() - { - $this->assertNull($this->filter->getMatchPattern()); - } - - public function testMatchPatternAccessorsWork() - { - $pattern = '#^controller/(?P<action>[a-z_-]+)#'; - $this->filter->setMatchPattern($pattern); - $this->assertEquals($pattern, $this->filter->getMatchPattern()); - } - - public function testReplacementInitiallyEmpty() - { - $replacement = $this->filter->getReplacement(); - $this->assertTrue(empty($replacement)); - } - - public function testReplacementAccessorsWork() - { - $replacement = 'foo/bar'; - $this->filter->setReplacement($replacement); - $this->assertEquals($replacement, $this->filter->getReplacement()); - } - - public function testFilterPerformsRegexReplacement() - { - $string = 'controller/action'; - $this->filter->setMatchPattern('#^controller/(?P<action>[a-z_-]+)#') - ->setReplacement('foo/bar'); - $filtered = $this->filter->filter($string); - $this->assertNotEquals($string, $filtered); - $this->assertEquals('foo/bar', $filtered); - } - - public function testFilterThrowsExceptionWhenNoMatchPatternPresent() - { - $string = 'controller/action'; - $this->filter->setReplacement('foo/bar'); - try { - $filtered = $this->filter->filter($string); - $this->fail('Replacement should fail when no match pattern present'); - } catch (Exception $e) { - } - } -} - -// Call Zend_Filter_PregReplaceTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == 'Zend_Filter_PregReplaceTest::main') { - Zend_Filter_PregReplaceTest::main(); -} diff --git a/tests/Zend/Filter/RealPathTest.php b/tests/Zend/Filter/RealPathTest.php deleted file mode 100644 index 2b5d8d4a6b7c63ed77fe434467c0ab945b501fb1..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/RealPathTest.php +++ /dev/null @@ -1,104 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RealPathTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_RealPath - */ -require_once 'Zend/Filter/RealPath.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_RealPathTest extends PHPUnit_Framework_TestCase -{ - /** - * Path to test files - * - * @var string - */ - protected $_filesPath; - - /** - * Sets the path to test files - * - * @return void - */ - public function __construct() - { - $this->_filesPath = dirname(__FILE__) . '/_files'; - } - - /** - * Zend_Filter_Basename object - * - * @var Zend_Filter_Basename - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_Basename object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_RealPath(); - } - - /** - * Ensures expected behavior for existing file - * - * @return void - */ - public function testFileExists() - { - $filename = 'file.1'; - $this->assertContains($filename, $this->_filter->filter("$this->_filesPath/$filename")); - } - - /** - * Ensures expected behavior for nonexistent file - * - * @return void - */ - public function testFileNonexistent() - { - $path = '/path/to/nonexistent'; - if (false !== strpos(PHP_OS, 'BSD')) { - $this->assertEquals($path, $this->_filter->filter($path)); - } else { - $this->assertEquals(false, $this->_filter->filter($path)); - } - } -} diff --git a/tests/Zend/Filter/StringToLowerTest.php b/tests/Zend/Filter/StringToLowerTest.php deleted file mode 100644 index 2593912dfe71d2dfb071b4b3ba3b1f520c04193d..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/StringToLowerTest.php +++ /dev/null @@ -1,104 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringToLowerTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_StringToLower - */ -require_once 'Zend/Filter/StringToLower.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StringToLowerTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_StringToLower object - * - * @var Zend_Filter_StringToLower - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_StringToLower object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_StringToLower(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'string' => 'string', - 'aBc1@3' => 'abc1@3', - 'A b C' => 'a b c' - ); - - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } - - /** - * Ensures that the filter follows expected behavior with - * specified encoding - * - * @return void - */ - public function testWithEncoding() - { - $valuesExpected = array( - 'Ü' => 'ü', - 'Ñ' => 'ñ', - 'ÜÑ123' => 'üñ123' - ); - - try { - $this->_filter->setEncoding('UTF-8'); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } catch (Zend_Filter_Exception $e) { - $this->assertContains('mbstring is required', $e->getMessage()); - } - - } -} diff --git a/tests/Zend/Filter/StringToUpperTest.php b/tests/Zend/Filter/StringToUpperTest.php deleted file mode 100644 index 7e13b8c97672c5f6860df9b6462d1e2decd11477..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/StringToUpperTest.php +++ /dev/null @@ -1,104 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringToUpperTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_StringToUpper - */ -require_once 'Zend/Filter/StringToUpper.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StringToUpperTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_StringToLower object - * - * @var Zend_Filter_StringToLower - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_StringToUpper object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_StringToUpper(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'STRING' => 'STRING', - 'ABC1@3' => 'ABC1@3', - 'A b C' => 'A B C' - ); - - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } - - /** - * Ensures that the filter follows expected behavior with - * specified encoding - * - * @return void - */ - public function testWithEncoding() - { - $valuesExpected = array( - 'ü' => 'Ü', - 'ñ' => 'Ñ', - 'üñ123' => 'ÜÑ123' - ); - - try { - $this->_filter->setEncoding('UTF-8'); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } catch (Zend_Filter_Exception $e) { - $this->assertContains('mbstring is required', $e->getMessage()); - } - - } -} diff --git a/tests/Zend/Filter/StringTrimTest.php b/tests/Zend/Filter/StringTrimTest.php deleted file mode 100644 index 932583af2067d47e5feafa978c4168cef51151b1..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/StringTrimTest.php +++ /dev/null @@ -1,110 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringTrimTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_StringTrim - */ -require_once 'Zend/Filter/StringTrim.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StringTrimTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_StringTrim object - * - * @var Zend_Filter_StringTrim - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_StringTrim object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_StringTrim(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'string' => 'string', - ' str ' => 'str', - "\ns\t" => 's' - ); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } - - /** - * Ensures that getCharList() returns expected default value - * - * @return void - */ - public function testGetCharList() - { - $this->assertEquals(null, $this->_filter->getCharList()); - } - - /** - * Ensures that setCharList() follows expected behavior - * - * @return void - */ - public function testSetCharList() - { - $this->_filter->setCharList('&'); - $this->assertEquals('&', $this->_filter->getCharList()); - } - - /** - * Ensures expected behavior under custom character list - * - * @return void - */ - public function testCharList() - { - $this->_filter->setCharList('&'); - $this->assertEquals('a&b', $this->_filter->filter('&&a&b&&')); - } -} diff --git a/tests/Zend/Filter/StripNewlinesTest.php b/tests/Zend/Filter/StripNewlinesTest.php deleted file mode 100644 index c24eca6eacc4f07c69a6b66d190a06f26a6d8a1b..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/StripNewlinesTest.php +++ /dev/null @@ -1,80 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_StripNewlines - */ -require_once 'Zend/Filter/StripNewlines.php'; - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StripNewlinesTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_StripNewlines object - * - * @var Zend_Filter_StripNewlines - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_StripNewlines object for each test method - * - * @return void - */ - public function setUp () - { - $this->_filter = new Zend_Filter_StripNewlines(); - } - - /** - * Ensures that the filter follows expected behavior - * - * @return void - */ - public function testBasic () - { - $valuesExpected = array( - '' => '', - "\n" => '', - "\r" => '', - "\r\n" => '', - '\n' => '\n', - '\r' => '\r', - '\r\n' => '\r\n', - "Some text\nthat we have\r\nstuff in" => 'Some textthat we havestuff in' - ); - foreach ($valuesExpected as $input => $output) { - $this->assertEquals($output, $this->_filter->filter($input)); - } - } -} diff --git a/tests/Zend/Filter/StripTagsTest.php b/tests/Zend/Filter/StripTagsTest.php deleted file mode 100644 index 43aef5ee35ad8c180daf5e61630c1c040eb3324b..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/StripTagsTest.php +++ /dev/null @@ -1,492 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StripTagsTest.php 10752 2008-08-07 13:20:50Z alexander $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Filter_StripTags - */ -require_once 'Zend/Filter/StripTags.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StripTagsTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter_StripTags object - * - * @var Zend_Filter_StripTags - */ - protected $_filter; - - /** - * Creates a new Zend_Filter_StripTags object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter_StripTags(); - } - - /** - * Ensures that getTagsAllowed() returns expected default value - * - * @return void - */ - public function testGetTagsAllowed() - { - $this->assertEquals(array(), $this->_filter->getTagsAllowed()); - } - - /** - * Ensures that setTagsAllowed() follows expected behavior when provided a single tag - * - * @return void - */ - public function testSetTagsAllowedString() - { - $this->_filter->setTagsAllowed('b'); - $this->assertEquals(array('b' => array()), $this->_filter->getTagsAllowed()); - } - - /** - * Ensures that setTagsAllowed() follows expected behavior when provided an array of tags - * - * @return void - */ - public function testSetTagsAllowedArray() - { - $tagsAllowed = array( - 'b', - 'a' => 'href', - 'div' => array('id', 'class') - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $tagsAllowedExpected = array( - 'b' => array(), - 'a' => array('href' => null), - 'div' => array('id' => null, 'class' => null) - ); - $this->assertEquals($tagsAllowedExpected, $this->_filter->getTagsAllowed()); - } - - /** - * Ensures that getAttributesAllowed() returns expected default value - * - * @return void - */ - public function testGetAttributesAllowed() - { - $this->assertEquals(array(), $this->_filter->getAttributesAllowed()); - } - - /** - * Ensures that setAttributesAllowed() follows expected behavior when provided a single attribute - * - * @return void - */ - public function testSetAttributesAllowedString() - { - $this->_filter->setAttributesAllowed('class'); - $this->assertEquals(array('class' => null), $this->_filter->getAttributesAllowed()); - } - - /** - * Ensures that setAttributesAllowed() follows expected behavior when provided an array of attributes - * - * @return void - */ - public function testSetAttributesAllowedArray() - { - $attributesAllowed = array( - 'clAss', - 4 => 'inT', - 'ok' => 'String', - null - ); - $this->_filter->setAttributesAllowed($attributesAllowed); - $attributesAllowedExpected = array( - 'class' => null, - 'int' => null, - 'string' => null - ); - $this->assertEquals($attributesAllowedExpected, $this->_filter->getAttributesAllowed()); - } - - /** - * Ensures that a single unclosed tag is stripped in its entirety - * - * @return void - */ - public function testFilterTagUnclosed1() - { - $input = '<a href="http://example.com" Some Text'; - $expected = ''; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that a single tag is stripped - * - * @return void - */ - public function testFilterTag1() - { - $input = '<a href="example.com">foo</a>'; - $expected = 'foo'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that singly nested tags are stripped - * - * @return void - */ - public function testFilterTagNest1() - { - $input = '<a href="example.com"><b>foo</b></a>'; - $expected = 'foo'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that two successive tags are stripped - * - * @return void - */ - public function testFilterTag2() - { - $input = '<a href="example.com">foo</a><b>bar</b>'; - $expected = 'foobar'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that an allowed tag is returned as lowercase and with backward-compatible XHTML ending, where supplied - * - * @return void - */ - public function testFilterTagAllowedBackwardCompatible() - { - $input = '<BR><Br><bR><br/><br /><br / ></br></bR>'; - $expected = '<br><br><br><br /><br /><br></br></br>'; - $this->_filter->setTagsAllowed('br'); - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that any greater-than symbols '>' are removed from text preceding a tag - * - * @return void - */ - public function testFilterTagPrefixGt() - { - $input = '2 > 1 === true<br/>'; - $expected = '2 1 === true'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that any greater-than symbols '>' are removed from text having no tags - * - * @return void - */ - public function testFilterGt() - { - $input = '2 > 1 === true ==> $object->property'; - $expected = '2 1 === true == $object-property'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that any greater-than symbols '>' are removed from text wrapping a tag - * - * @return void - */ - public function testFilterTagWrappedGt() - { - $input = '2 > 1 === true <==> $object->property'; - $expected = '2 1 === true $object-property'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that an attribute for an allowed tag is stripped - * - * @return void - */ - public function testFilterTagAllowedAttribute() - { - $tagsAllowed = 'img'; - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<IMG alt="foo" />'; - $expected = '<img />'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that an allowed tag with an allowed attribute is filtered as expected - * - * @return void - */ - public function testFilterTagAllowedAttributeAllowed() - { - $tagsAllowed = array( - 'img' => 'alt' - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<IMG ALT="FOO" />'; - $expected = '<img alt="FOO" />'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures expected behavior when a greater-than symbol '>' appears in an allowed attribute's value - * - * Currently this is not unsupported; these symbols should be escaped when used in an attribute value. - * - * @return void - */ - public function testFilterTagAllowedAttributeAllowedGt() - { - $tagsAllowed = array( - 'img' => 'alt' - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<img alt="$object->property" />'; - $expected = '<img>property" /'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures expected behavior when an escaped greater-than symbol '>' appears in an allowed attribute's value - * - * @return void - */ - public function testFilterTagAllowedAttributeAllowedGtEscaped() - { - $tagsAllowed = array( - 'img' => 'alt' - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<img alt="$object->property" />'; - $expected = '<img alt="$object->property" />'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that an unterminated attribute value does not affect other attributes but causes the corresponding - * attribute to be removed in its entirety. - * - * @return void - */ - public function testFilterTagAllowedAttributeAllowedValueUnclosed() - { - $tagsAllowed = array( - 'img' => array('alt', 'height', 'src', 'width') - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<img src="image.png" alt="square height="100" width="100" />'; - $expected = '<img src="image.png" height="100" width="100" />'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that an allowed attribute having no value is removed (XHTML disallows attributes with no values) - * - * @return void - */ - public function testFilterTagAllowedAttributeAllowedValueMissing() - { - $tagsAllowed = array( - 'input' => array('checked', 'name', 'type') - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<input name="foo" type="checkbox" checked />'; - $expected = '<input name="foo" type="checkbox" />'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that the filter works properly for the data reported on fw-general on 2007-05-26 - * - * @see http://www.nabble.com/question-about-tag-filter-p10813688s16154.html - * @return void - */ - public function testFilter20070526() - { - $tagsAllowed = array( - 'object' => array('width', 'height'), - 'param' => array('name', 'value'), - 'embed' => array('src', 'type', 'wmode', 'width', 'height'), - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<object width="425" height="350"><param name="movie" value="http://www.example.com/path/to/movie">' - . '</param><param name="wmode" value="transparent"></param><embed ' - . 'src="http://www.example.com/path/to/movie" type="application/x-shockwave-flash" ' - . 'wmode="transparent" width="425" height="350"></embed></object>'; - $expected = '<object width="425" height="350"><param name="movie" value="http://www.example.com/path/to/movie">' - . '</param><param name="wmode" value="transparent"></param><embed ' - . 'src="http://www.example.com/path/to/movie" type="application/x-shockwave-flash" ' - . 'wmode="transparent" width="425" height="350"></embed></object>'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that a comment is stripped - * - * @return void - */ - public function testFilterComment() - { - $input = '<!-- a comment -->'; - $expected = ''; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that a comment wrapped with other strings is stripped - * - * @return void - */ - public function testFilterCommentWrapped() - { - $input = 'foo<!-- a comment -->bar'; - $expected = 'foobar'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that a comment is not removed when comments are allowed - * - * @return void - */ - public function testFilterCommentAllowed() - { - $input = '<!-- a comment -->'; - $expected = '<!-- a comment -->'; - $this->_filter->commentsAllowed = true; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that a comment containing tags is untouched when comments are allowed - * - * @return void - */ - public function testFilterCommentAllowedContainsTags() - { - $input = '<!-- a comment <br /> <h1>SuperLarge</h1> -->'; - $expected = '<!-- a comment <br /> <h1>SuperLarge</h1> -->'; - $this->_filter->commentsAllowed = true; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures expected behavior when comments are allowed and a comment contains tags and linebreaks - * - * @return void - */ - public function testFilterCommentsAllowedContainsTagsLinebreaks() - { - $input = "<br> test <p> text </p> with <!-- comments --> and <!-- hidd\n\nen <br> -->"; - $expected = " test text with <!-- comments --> and <!-- hidd\n\nen <br> -->"; - $this->_filter->commentsAllowed = true; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures expected behavior when comments are allowed but nested - * - * @return void - */ - public function testFilterCommentsAllowedNested() - { - $input = '<a> <!-- <b> <!-- <c> --> <d> --> <e>'; - $expected = ' <!-- <b> <!-- <c> --> -- '; - $this->_filter->commentsAllowed = true; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that space is allowed between the double-hyphen '--' and the ending delimiter '>' - * - * @see http://www.w3.org/TR/1999/REC-html401-19991224/intro/sgmltut.html#h-3.2.4 - * @return void - */ - public function testFilterCommentsAllowedDelimiterEndingWhiteSpace() - { - $input = '<a> <!-- <b> -- > <c>'; - $expected = ' <!-- <b> -- > '; - $this->_filter->commentsAllowed = true; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that a closing angle bracket in an allowed attribute does not break the parser - * - * @return void - * @link http://framework.zend.com/issues/browse/ZF-3278 - */ - public function testClosingAngleBracketInAllowedAttributeValue() - { - $tagsAllowed = array( - 'a' => 'href' - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<a href="Some > Text">'; - $expected = '<a href="Some > Text">'; - $this->assertEquals($expected, $this->_filter->filter($input)); - } - - /** - * Ensures that an allowed attribute's value may end with an equals sign '=' - * - * @return void - * @link http://framework.zend.com/issues/browse/ZF-3293 - */ - public function testAllowedAttributeValueMayEndWithEquals() - { - $this->markTestSkipped(); - return; - /* - $tagsAllowed = array( - 'element' => 'attribute' - ); - $this->_filter->setTagsAllowed($tagsAllowed); - $input = '<element attribute="a=">contents</element>'; - $this->assertEquals($input, $this->_filter->filter($input)); - */ - } -} diff --git a/tests/Zend/Filter/Word/CamelCaseToDashTest.php b/tests/Zend/Filter/Word/CamelCaseToDashTest.php deleted file mode 100644 index 72ee8b8587452d919402e476d0686f830297ed25..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/CamelCaseToDashTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -// Call Zend_Filter_CamelCaseToDashTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_CamelCaseToDashTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/CamelCaseToDash.php'; - -/** - * Test class for Zend_Filter_Word_CamelCaseToDash. - */ -class Zend_Filter_Word_CamelCaseToDashTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_CamelCaseToDashTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithDashes() - { - $string = 'CamelCasedWords'; - $filter = new Zend_Filter_Word_CamelCaseToDash(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('Camel-Cased-Words', $filtered); - } -} - -// Call Zend_Filter_Word_CamelCaseToDashTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_CamelCaseToDashTest::main") { - Zend_Filter_Word_CamelCaseToDashTest::main(); -} diff --git a/tests/Zend/Filter/Word/CamelCaseToSeparatorTest.php b/tests/Zend/Filter/Word/CamelCaseToSeparatorTest.php deleted file mode 100644 index 1ca3751f68f80be93f11e90b2605aa68ff1b0f4d..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/CamelCaseToSeparatorTest.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -// Call Zend_Filter_CamelCaseToSeparatorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_CamelCaseToSeparatorTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/CamelCaseToSeparator.php'; - -/** - * Test class for Zend_Filter_Word_CamelCaseToSeparator. - */ -class Zend_Filter_Word_CamelCaseToSeparatorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_CamelCaseToSeparatorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithSpacesByDefault() - { - $string = 'CamelCasedWords'; - $filter = new Zend_Filter_Word_CamelCaseToSeparator(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('Camel Cased Words', $filtered); - } - - public function testFilterSeparatesCamelCasedWordsWithProvidedSeparator() - { - $string = 'CamelCasedWords'; - $filter = new Zend_Filter_Word_CamelCaseToSeparator(':-#'); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('Camel:-#Cased:-#Words', $filtered); - } -} - -// Call Zend_Filter_Word_CamelCaseToSeparatorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_CamelCaseToSeparatorTest::main") { - Zend_Filter_Word_CamelCaseToSeparatorTest::main(); -} diff --git a/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php b/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php deleted file mode 100644 index 5f7f2068eb938bf221f9f79bfd302505cf1189b9..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -// Call Zend_Filter_CamelCaseToUnderscoreTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_CamelCaseToUnderscoreTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/CamelCaseToUnderscore.php'; - -/** - * Test class for Zend_Filter_Word_CamelCaseToUnderscore. - */ -class Zend_Filter_Word_CamelCaseToUnderscoreTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_CamelCaseToUnderscoreTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithUnderscores() - { - $string = 'CamelCasedWords'; - $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('Camel_Cased_Words', $filtered); - } -} - -// Call Zend_Filter_Word_CamelCaseToUnderscoreTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_CamelCaseToUnderscoreTest::main") { - Zend_Filter_Word_CamelCaseToUnderscoreTest::main(); -} diff --git a/tests/Zend/Filter/Word/DashToCamelCaseTest.php b/tests/Zend/Filter/Word/DashToCamelCaseTest.php deleted file mode 100644 index e60c04c224a8cecd03e22033e9d4aa5d06d47bd3..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/DashToCamelCaseTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -// Call Zend_Filter_DashToCamelCaseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_DashToCamelCaseTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/DashToCamelCase.php'; - -/** - * Test class for Zend_Filter_Word_DashToCamelCase. - */ -class Zend_Filter_Word_DashToCamelCaseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_DashToCamelCaseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithDashes() - { - $string = 'camel-cased-words'; - $filter = new Zend_Filter_Word_DashToCamelCase(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('CamelCasedWords', $filtered); - } -} - -// Call Zend_Filter_Word_DashToCamelCaseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_DashToCamelCaseTest::main") { - Zend_Filter_Word_DashToCamelCaseTest::main(); -} diff --git a/tests/Zend/Filter/Word/DashToSeparatorTest.php b/tests/Zend/Filter/Word/DashToSeparatorTest.php deleted file mode 100644 index 194a518fc2c5c5b2404fab5be5b81ced582eb3f0..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/DashToSeparatorTest.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -// Call Zend_Filter_DashToSeparatorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_DashToSeparatorTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/DashToSeparator.php'; - -/** - * Test class for Zend_Filter_Word_DashToSeparator. - */ -class Zend_Filter_Word_DashToSeparatorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_DashToSeparatorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesDashedWordsWithDefaultSpaces() - { - $string = 'dash-separated-words'; - $filter = new Zend_Filter_Word_DashToSeparator(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash separated words', $filtered); - } - - public function testFilterSeparatesDashedWordsWithSomeString() - { - $string = 'dash-separated-words'; - $filter = new Zend_Filter_Word_DashToSeparator(':-:'); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash:-:separated:-:words', $filtered); - } - -} - -// Call Zend_Filter_Word_DashToSeparatorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_DashToSeparatorTest::main") { - Zend_Filter_Word_DashToSeparatorTest::main(); -} diff --git a/tests/Zend/Filter/Word/DashToUnderscoreTest.php b/tests/Zend/Filter/Word/DashToUnderscoreTest.php deleted file mode 100644 index 56b0fc37bac581189dc8ae1fa8cf6a51c3d27a34..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/DashToUnderscoreTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -// Call Zend_Filter_DashToUnderscoreTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_DashToUnderscoreTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/DashToUnderscore.php'; - -/** - * Test class for Zend_Filter_Word_DashToUnderscore. - */ -class Zend_Filter_Word_DashToUnderscoreTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_DashToUnderscoreTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithDashes() - { - $string = 'dash-separated-words'; - $filter = new Zend_Filter_Word_DashToUnderscore(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash_separated_words', $filtered); - } -} - -// Call Zend_Filter_Word_DashToUnderscoreTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_DashToUnderscoreTest::main") { - Zend_Filter_Word_DashToUnderscoreTest::main(); -} diff --git a/tests/Zend/Filter/Word/SeparatorToCamelCaseTest.php b/tests/Zend/Filter/Word/SeparatorToCamelCaseTest.php deleted file mode 100644 index 087ee08efe0e4d61494513971e970114a85bab59..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/SeparatorToCamelCaseTest.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -// Call Zend_Filter_SeparatorToCamelCaseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_SeparatorToCamelCaseTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/SeparatorToCamelCase.php'; - -/** - * Test class for Zend_Filter_Word_SeparatorToCamelCase. - */ -class Zend_Filter_Word_SeparatorToCamelCaseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_SeparatorToCamelCaseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithSpacesByDefault() - { - $string = 'camel cased words'; - $filter = new Zend_Filter_Word_SeparatorToCamelCase(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('CamelCasedWords', $filtered); - } - - public function testFilterSeparatesCamelCasedWordsWithProvidedSeparator() - { - $string = 'camel:-:cased:-:Words'; - $filter = new Zend_Filter_Word_SeparatorToCamelCase(':-:'); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('CamelCasedWords', $filtered); - } -} - -// Call Zend_Filter_Word_SeparatorToCamelCaseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_SeparatorToCamelCaseTest::main") { - Zend_Filter_Word_SeparatorToCamelCaseTest::main(); -} diff --git a/tests/Zend/Filter/Word/SeparatorToDashTest.php b/tests/Zend/Filter/Word/SeparatorToDashTest.php deleted file mode 100644 index 3f2698dc991b316e01ddac576298e965c83a3f1a..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/SeparatorToDashTest.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -// Call Zend_Filter_SeparatorToDashTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_SeparatorToDashTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/SeparatorToDash.php'; - -/** - * Test class for Zend_Filter_Word_SeparatorToDash. - */ -class Zend_Filter_Word_SeparatorToDashTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_SeparatorToDashTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesDashedWordsWithDefaultSpaces() - { - $string = 'dash separated words'; - $filter = new Zend_Filter_Word_SeparatorToDash(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash-separated-words', $filtered); - } - - public function testFilterSeparatesDashedWordsWithSomeString() - { - $string = 'dash=separated=words'; - $filter = new Zend_Filter_Word_SeparatorToDash('='); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash-separated-words', $filtered); - } - -} - -// Call Zend_Filter_Word_SeparatorToDashTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_SeparatorToDashTest::main") { - Zend_Filter_Word_SeparatorToDashTest::main(); -} diff --git a/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php b/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php deleted file mode 100644 index cdaf84afadefaa71cd6354353e13b32e0f8e444b..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -// Call Zend_Filter_SeparatorToSeparatorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_SeparatorToSeparatorTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/SeparatorToSeparator.php'; - -/** - * Test class for Zend_Filter_Word_SeparatorToSeparator. - */ -class Zend_Filter_Word_SeparatorToSeparatorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_SeparatorToSeparatorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesWordsByDefault() - { - $string = 'dash separated words'; - $filter = new Zend_Filter_Word_SeparatorToSeparator(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash-separated-words', $filtered); - } - - public function testFilterSeparatesWordsWithSearchSpecified() - { - $string = 'dash=separated=words'; - $filter = new Zend_Filter_Word_SeparatorToSeparator('='); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash-separated-words', $filtered); - } - - public function testFilterSeparatesWordsWithSearchAndReplacementSpecified() - { - $string = 'dash=separated=words'; - $filter = new Zend_Filter_Word_SeparatorToSeparator('=', '?'); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('dash?separated?words', $filtered); - } - -} - -// Call Zend_Filter_Word_SeparatorToSeparatorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_SeparatorToSeparatorTest::main") { - Zend_Filter_Word_SeparatorToSeparatorTest::main(); -} diff --git a/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php b/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php deleted file mode 100644 index fa457204e6c6bd5bb373c73c9f1abf2df7036d37..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -// Call Zend_Filter_Word_UnderscoreToCamelCaseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_UnderscoreToCamelCaseTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/UnderscoreToCamelCase.php'; - -/** - * Test class for Zend_Filter_Word_UnderscoreToCamelCase. - */ -class Zend_Filter_Word_UnderscoreToCamelCaseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_UnderscoreToCamelCaseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithDashes() - { - $string = 'camel_cased_words'; - $filter = new Zend_Filter_Word_UnderscoreToCamelCase(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('CamelCasedWords', $filtered); - } -} - -// Call Zend_Filter_Word_UnderscoreToCamelCaseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_UnderscoreToCamelCaseTest::main") { - Zend_Filter_Word_UnderscoreToCamelCaseTest::main(); -} diff --git a/tests/Zend/Filter/Word/UnderscoreToDashTest.php b/tests/Zend/Filter/Word/UnderscoreToDashTest.php deleted file mode 100644 index 4d3f0df241fd4727ac777306c12bd613aa5c8b01..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/UnderscoreToDashTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -// Call Zend_Filter_Word_UnderscoreToDashTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_UnderscoreToDashTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/UnderscoreToDash.php'; - -/** - * Test class for Zend_Filter_Word_UnderscoreToDash. - */ -class Zend_Filter_Word_UnderscoreToDashTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_UnderscoreToDashTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithDashes() - { - $string = 'underscore_separated_words'; - $filter = new Zend_Filter_Word_UnderscoreToDash(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('underscore-separated-words', $filtered); - } -} - -// Call Zend_Filter_Word_UnderscoreToDashTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_UnderscoreToDashTest::main") { - Zend_Filter_Word_UnderscoreToDashTest::main(); -} diff --git a/tests/Zend/Filter/Word/UnderscoreToPathSeparatorTest.php b/tests/Zend/Filter/Word/UnderscoreToPathSeparatorTest.php deleted file mode 100644 index 1c790bb231fc2c0874dad2fa2c5333ec43141c2b..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/UnderscoreToPathSeparatorTest.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -// Call Zend_Filter_Word_UnderscoreToPathSeparatorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_UnderscoreToPathSeparatorTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/UnderscoreToPathSeparator.php'; - -/** - * Test class for Zend_Filter_Word_UnderscoreToPathSeparator. - */ -class Zend_Filter_Word_UnderscoreToPathSeparatorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_UnderscoreToPathSeparatorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsWithPathSeparators() - { - $string = 'underscore_separated_words'; - $filter = new Zend_Filter_Word_UnderscoreToPathSeparator(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $expected = 'underscore' - . DIRECTORY_SEPARATOR . 'separated' - . DIRECTORY_SEPARATOR . 'words'; - $this->assertEquals($expected, $filtered); - } -} - -// Call Zend_Filter_Word_UnderscoreToPathSeparatorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_UnderscoreToPathSeparatorTest::main") { - Zend_Filter_Word_UnderscoreToPathSeparatorTest::main(); -} diff --git a/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php b/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php deleted file mode 100644 index 99becf9d924b9f719d4eb88f85ba45f12825b303..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -// Call Zend_Filter_Word_UnderscoreToSeparatorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_Filter_Word_UnderscoreToSeparatorTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Filter/Word/UnderscoreToSeparator.php'; - -/** - * Test class for Zend_Filter_Word_UnderscoreToSeparator. - */ -class Zend_Filter_Word_UnderscoreToSeparatorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Filter_Word_UnderscoreToSeparatorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testFilterSeparatesCamelCasedWordsDefaultSeparator() - { - $string = 'underscore_separated_words'; - $filter = new Zend_Filter_Word_UnderscoreToSeparator(); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('underscore separated words', $filtered); - } - - public function testFilterSeparatesCamelCasedWordsProvidedSeparator() - { - $string = 'underscore_separated_words'; - $filter = new Zend_Filter_Word_UnderscoreToSeparator(':=:'); - $filtered = $filter->filter($string); - - $this->assertNotEquals($string, $filtered); - $this->assertEquals('underscore:=:separated:=:words', $filtered); - } - -} - -// Call Zend_Filter_Word_UnderscoreToSeparatorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Filter_Word_UnderscoreToSeparatorTest::main") { - Zend_Filter_Word_UnderscoreToSeparatorTest::main(); -} diff --git a/tests/Zend/Filter/_files/TestNamespace/MyDigits.php b/tests/Zend/Filter/_files/TestNamespace/MyDigits.php deleted file mode 100644 index 4688f64d373120cb413402b8fbc75db889004a4c..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/_files/TestNamespace/MyDigits.php +++ /dev/null @@ -1,40 +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_Filter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Validate_Digits - */ -require_once 'Zend/Validate/Digits.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class TestNamespace_MyDigits extends Zend_Validate_Digits -{ -} diff --git a/tests/Zend/Filter/_files/TestNamespace/StringEquals.php b/tests/Zend/Filter/_files/TestNamespace/StringEquals.php deleted file mode 100644 index 72cfae81956f56bbe1f53aba943ab7dc07b33f67..0000000000000000000000000000000000000000 --- a/tests/Zend/Filter/_files/TestNamespace/StringEquals.php +++ /dev/null @@ -1,76 +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_Filter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - - -/** - * @see Zend_Validate_Abstract - */ -require_once 'Zend/Validate/Abstract.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class TestNamespace_StringEquals extends Zend_Validate_Abstract -{ - - const NOT_EQUALS = 'stringNotEquals'; - - /** - * Array with message templates - * - * @var array - */ - protected $_messageTemplates = array( - self::NOT_EQUALS => 'Not all strings in the argument are equal' - ); - - /** - * Defined by Zend_Validate_Interface - * - * Returns true if and only if all the elements of the array argument - * are equal to one another with string comparison. - * - * @param array $value Value to validate - * @return boolean - */ - public function isValid($value) - { - $this->_setValue($value); - - $initial = (string) current((array) $value); - foreach ((array) $value as $element) { - if ((string) $element !== $initial) { - $this->_error(); - return false; - } - } - - return true; - } - -} diff --git a/tests/Zend/Filter/_files/file.1 b/tests/Zend/Filter/_files/file.1 deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/Zend/Filter/_files/testfile.txt b/tests/Zend/Filter/_files/testfile.txt deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/Zend/FilterTest.php b/tests/Zend/FilterTest.php deleted file mode 100644 index 0d7437cf915c66233749c26d04dd0c8bc8edc1f4..0000000000000000000000000000000000000000 --- a/tests/Zend/FilterTest.php +++ /dev/null @@ -1,149 +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_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FilterTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * @see Zend_Filter - */ -require_once 'Zend/Filter.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_FilterTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Filter object - * - * @var Zend_Filter - */ - protected $_filter; - - /** - * Creates a new Zend_Filter object for each test method - * - * @return void - */ - public function setUp() - { - $this->_filter = new Zend_Filter(); - } - - /** - * Ensures expected return value from empty filter chain - * - * @return void - */ - public function testEmpty() - { - $value = 'something'; - $this->assertEquals($value, $this->_filter->filter($value)); - } - - /** - * Ensures that filters are executed in the expected order (FIFO) - * - * @return void - */ - public function testFilterOrder() - { - $this->_filter->addFilter(new Zend_FilterTest_LowerCase()) - ->addFilter(new Zend_FilterTest_StripUpperCase()); - $value = 'AbC'; - $valueExpected = 'abc'; - $this->assertEquals($valueExpected, $this->_filter->filter($value)); - } - - /** - * Ensures that we can call the static method get() - * to instantiate a named validator by its class basename - * and it returns the result of filter() with the input. - */ - public function testStaticFactory() - { - $filteredValue = Zend_Filter::get('1a2b3c4d', 'Digits'); - $this->assertEquals('1234', $filteredValue); - } - - /** - * Ensures that a validator with constructor arguments can be called - * with the static method get(). - */ - public function testStaticFactoryWithConstructorArguments() - { - // Test HtmlEntities with one ctor argument. - $filteredValue = Zend_Filter::get('"O\'Reilly"', 'HtmlEntities', array(ENT_COMPAT)); - $this->assertEquals('"O\'Reilly"', $filteredValue); - - // Test HtmlEntities with a different ctor argument, - // and make sure it gives the correct response - // so we know it passed the arg to the ctor. - $filteredValue = Zend_Filter::get('"O\'Reilly"', 'HtmlEntities', array(ENT_QUOTES)); - $this->assertEquals('"O'Reilly"', $filteredValue); - } - - /** - * Ensures that if we specify a validator class basename that doesn't - * exist in the namespace, get() throws an exception. - */ - public function testStaticFactoryClassNotFound() - { - try { - $this->assertTrue(Zend_Filter::get('1234', 'UnknownFilter')); - $this->fail('Expected to catch Zend_Filter_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Filter_Exception', $e, - 'Expected exception of type Zend_Filter_Exception, got '.get_class($e)); - $this->assertEquals("Filter class not found from basename 'UnknownFilter'", $e->getMessage()); - } - } - -} - - -class Zend_FilterTest_LowerCase implements Zend_Filter_Interface -{ - public function filter($value) - { - return strtolower($value); - } -} - - -class Zend_FilterTest_StripUpperCase implements Zend_Filter_Interface -{ - public function filter($value) - { - return preg_replace('/[A-Z]/', '', $value); - } -} diff --git a/tests/Zend/Form/AllTests.php b/tests/Zend/Form/AllTests.php deleted file mode 100644 index d42b3eeb0a123f6ce9ab47a1afac5311c88c6124..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/AllTests.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -// error_reporting(E_ALL); - -require_once 'Zend/Form/Decorator/AllTests.php'; -require_once 'Zend/Form/DisplayGroupTest.php'; -require_once 'Zend/Form/ElementTest.php'; -require_once 'Zend/Form/Element/AllTests.php'; -require_once 'Zend/Form/FormTest.php'; - -class Zend_Form_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Form'); - - $suite->addTest(Zend_Form_Decorator_AllTests::suite()); - $suite->addTestSuite('Zend_Form_DisplayGroupTest'); - $suite->addTestSuite('Zend_Form_ElementTest'); - $suite->addTest(Zend_Form_Element_AllTests::suite()); - $suite->addTestSuite('Zend_Form_FormTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_AllTests::main') { - Zend_Form_AllTests::main(); -} diff --git a/tests/Zend/Form/Decorator/AbstractTest.php b/tests/Zend/Form/Decorator/AbstractTest.php deleted file mode 100644 index 84e6eee98ab6160dbca5ce57ee7e5bbc52910a96..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/AbstractTest.php +++ /dev/null @@ -1,174 +0,0 @@ -<?php -// Call Zend_Form_Decorator_AbstractTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_AbstractTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/Errors.php'; - -require_once 'Zend/Config.php'; -require_once 'Zend/Form.php'; -require_once 'Zend/Form/DisplayGroup.php'; -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Loader/PluginLoader.php'; - -/** - * Test class for Zend_Form_Decorator_Abstract - * - * Uses Zend_Form_Decorator_Errors as a concrete implementation - */ -class Zend_Form_Decorator_AbstractTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_AbstractTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Errors(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getOptions() - { - $options = array( - 'foo' => 'fooval', - 'bar' => 'barval', - 'baz' => 'bazval' - ); - return $options; - } - - public function testCanSetOptions() - { - $options = $this->getOptions(); - $this->decorator->setOptions($options); - $this->assertEquals($options, $this->decorator->getOptions()); - } - - public function testCanSetOptionsFromConfigObject() - { - $config = new Zend_Config($this->getOptions()); - $this->decorator->setConfig($config); - $this->assertEquals($config->toArray(), $this->decorator->getOptions()); - } - - public function testSetElementAllowsFormElements() - { - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element); - $this->assertSame($element, $this->decorator->getElement()); - } - - public function testSetElementAllowsForms() - { - $form = new Zend_Form(); - $this->decorator->setElement($form); - $this->assertSame($form, $this->decorator->getElement()); - } - - public function testSetElementAllowsDisplayGroups() - { - $loader = new Zend_Loader_PluginLoader(array('Zend_Form_Decorator' => 'Zend/Form/Decorator')); - $group = new Zend_Form_DisplayGroup('foo', $loader); - $this->decorator->setElement($group); - $this->assertSame($group, $this->decorator->getElement()); - } - - public function testSetElementThrowsExceptionWithInvalidElementTypes() - { - $config = new Zend_Config(array()); - try { - $this->decorator->setElement($config); - $this->fail('Invalid element type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid element', $e->getMessage()); - } - } - - public function testPlacementDefaultsToAppend() - { - $this->assertEquals(Zend_Form_Decorator_Abstract::APPEND, $this->decorator->getPlacement()); - } - - public function testCanSetPlacementViaPlacementOption() - { - $this->testPlacementDefaultsToAppend(); - $this->decorator->setOptions(array('placement' => 'PREPEND')); - $this->assertEquals(Zend_Form_Decorator_Abstract::PREPEND, $this->decorator->getPlacement()); - } - - public function testSeparatorDefaultsToPhpEol() - { - $this->assertEquals(PHP_EOL, $this->decorator->getSeparator()); - } - - public function testCanSetSeparatorViaSeparatorOption() - { - $this->testSeparatorDefaultsToPhpEol(); - $this->decorator->setOptions(array('separator' => '<br />')); - $this->assertEquals('<br />', $this->decorator->getSeparator()); - } - - public function testCanSetIndividualOptions() - { - $this->assertNull($this->decorator->getOption('foo')); - $this->decorator->setOption('foo', 'bar'); - $this->assertEquals('bar', $this->decorator->getOption('foo')); - } - - public function testCanRemoveIndividualOptions() - { - $this->assertNull($this->decorator->getOption('foo')); - $this->decorator->setOption('foo', 'bar'); - $this->assertEquals('bar', $this->decorator->getOption('foo')); - $this->decorator->removeOption('foo'); - $this->assertNull($this->decorator->getOption('foo')); - } - - public function testCanClearAllOptions() - { - $this->assertNull($this->decorator->getOption('foo')); - $this->assertNull($this->decorator->getOption('bar')); - $this->assertNull($this->decorator->getOption('baz')); - $options = array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat'); - $this->decorator->setOptions($options); - $received = $this->decorator->getOptions(); - $this->assertEquals($options, $received); - $this->decorator->clearOptions(); - $this->assertEquals(array(), $this->decorator->getOptions()); - } -} - -// Call Zend_Form_Decorator_AbstractTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_AbstractTest::main") { - Zend_Form_Decorator_AbstractTest::main(); -} diff --git a/tests/Zend/Form/Decorator/AllTests.php b/tests/Zend/Form/Decorator/AllTests.php deleted file mode 100644 index acb8485e42b039ad36e333d86d3e5da458f53a3c..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/AllTests.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_Decorator_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -// error_reporting(E_ALL); - -require_once 'Zend/Form/Decorator/AbstractTest.php'; -require_once 'Zend/Form/Decorator/CallbackTest.php'; -require_once 'Zend/Form/Decorator/DescriptionTest.php'; -require_once 'Zend/Form/Decorator/ErrorsTest.php'; -require_once 'Zend/Form/Decorator/FieldsetTest.php'; -require_once 'Zend/Form/Decorator/FileTest.php'; -require_once 'Zend/Form/Decorator/FormTest.php'; -require_once 'Zend/Form/Decorator/HtmlTagTest.php'; -require_once 'Zend/Form/Decorator/ImageTest.php'; -require_once 'Zend/Form/Decorator/LabelTest.php'; -require_once 'Zend/Form/Decorator/ViewHelperTest.php'; -require_once 'Zend/Form/Decorator/ViewScriptTest.php'; - -class Zend_Form_Decorator_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Form_Decorator'); - - $suite->addTestSuite('Zend_Form_Decorator_AbstractTest'); - $suite->addTestSuite('Zend_Form_Decorator_CallbackTest'); - $suite->addTestSuite('Zend_Form_Decorator_DescriptionTest'); - $suite->addTestSuite('Zend_Form_Decorator_ErrorsTest'); - $suite->addTestSuite('Zend_Form_Decorator_FieldsetTest'); - $suite->addTestSuite('Zend_Form_Decorator_FileTest'); - $suite->addTestSuite('Zend_Form_Decorator_FormTest'); - $suite->addTestSuite('Zend_Form_Decorator_HtmlTagTest'); - $suite->addTestSuite('Zend_Form_Decorator_ImageTest'); - $suite->addTestSuite('Zend_Form_Decorator_LabelTest'); - $suite->addTestSuite('Zend_Form_Decorator_ViewHelperTest'); - $suite->addTestSuite('Zend_Form_Decorator_ViewScriptTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_Decorator_AllTests::main') { - Zend_Form_Decorator_AllTests::main(); -} diff --git a/tests/Zend/Form/Decorator/CallbackTest.php b/tests/Zend/Form/Decorator/CallbackTest.php deleted file mode 100644 index 379ce72c7fd0979fa47ec897b12eda2b733eb717..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/CallbackTest.php +++ /dev/null @@ -1,201 +0,0 @@ -<?php -// Call Zend_Form_Decorator_CallbackTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_CallbackTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/Callback.php'; - -require_once 'Zend/Form/Element.php'; - -/** - * Test class for Zend_Form_Decorator_Callback - */ -class Zend_Form_Decorator_CallbackTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_CallbackTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Callback(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testCanSetCallback() - { - $callback = 'Zend_Form_Decorator_CallbackTest_TestCallback'; - $this->decorator->setCallback($callback); - $this->assertSame($callback, $this->decorator->getCallback()); - - $callback = array('Zend_Form_Decorator_CallbackTest_TestCallbackClass', 'direct'); - $this->decorator->setCallback($callback); - $this->assertSame($callback, $this->decorator->getCallback()); - } - - public function testCanSetCallbackViaOptions() - { - $callback = 'Zend_Form_Decorator_CallbackTest_TestCallback'; - $this->decorator->setOptions(array('callback' => $callback)); - $this->assertSame($callback, $this->decorator->getCallback()); - } - - public function testInvalidCallbackRaisesException() - { - try { - $this->decorator->setCallback(true); - $this->fail('Only string or array callbacks should be allowed'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid', $e->getMessage()); - } - - try { - $o = new stdClass; - $this->decorator->setCallback($o); - $this->fail('Only string or array callbacks should be allowed'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid', $e->getMessage()); - } - - try { - $this->decorator->setCallback(array('foo', 'bar', 'baz')); - $this->fail('Only arrays of two elements should be allowed as callbacks'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid', $e->getMessage()); - } - - try { - $this->decorator->setCallback(array('foo')); - $this->fail('Only arrays of two elements should be allowed as callbacks'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid', $e->getMessage()); - } - } - - public function testRenderCallsFunctionCallback() - { - $callback = 'Zend_Form_Decorator_CallbackTest_TestCallback'; - $element = new Zend_Form_Element('foobar'); - $element->setLabel('Label Me'); - - $this->decorator->setOptions(array('callback' => $callback)) - ->setElement($element); - - $content = $this->decorator->render('foo bar'); - $this->assertContains('foo bar', $content); - $this->assertContains($element->getName(), $content); - $this->assertContains($element->getLabel(), $content); - } - - public function testRenderCallsMethodCallback() - { - $callback = array('Zend_Form_Decorator_CallbackTest_TestCallbackClass', 'direct'); - $element = new Zend_Form_Element('foobar'); - $element->setLabel('Label Me'); - - $this->decorator->setOptions(array('callback' => $callback)) - ->setElement($element); - - $content = $this->decorator->render('foo bar'); - $this->assertContains('foo bar', $content); - $this->assertContains($element->getName(), $content); - $this->assertContains($element->getLabel(), $content); - $this->assertContains('Item ', $content); - } - - public function testRenderCanPrepend() - { - $callback = 'Zend_Form_Decorator_CallbackTest_TestCallback'; - $element = new Zend_Form_Element('foobar'); - $element->setLabel('Label Me'); - - $this->decorator->setOptions(array('callback' => $callback, 'placement' => 'prepend')) - ->setElement($element); - - $content = $this->decorator->render('foo bar'); - $this->assertContains('foo bar', $content); - $this->assertContains($element->getName(), $content); - $this->assertContains($element->getLabel(), $content); - $this->assertRegexp('/foo bar$/s', $content); - } - - public function testRenderCanReplaceContent() - { - $callback = 'Zend_Form_Decorator_CallbackTest_TestCallback'; - $element = new Zend_Form_Element('foobar'); - $element->setLabel('Label Me'); - - $this->decorator->setOptions(array('callback' => $callback, 'placement' => false)) - ->setElement($element); - - $content = $this->decorator->render('foo bar'); - $this->assertNotContains('foo bar', $content, $content); - $this->assertContains($element->getName(), $content); - $this->assertContains($element->getLabel(), $content); - } -} - -function Zend_Form_Decorator_CallbackTest_TestCallback($content, $element, array $options) -{ - $name = $element->getName(); - $label = ''; - if (method_exists($element, 'getLabel')) { - $label = $element->getLabel(); - } - $html =<<<EOH -$label: $name - -EOH; - return $html; -} - -class Zend_Form_Decorator_CallbackTest_TestCallbackClass -{ - public static function direct($content, $element, array $options) - { - $name = $element->getName(); - $label = ''; - if (method_exists($element, 'getLabel')) { - $label = $element->getLabel(); - } - $html =<<<EOH -Item "$label": $name - -EOH; - return $html; - } -} - -// Call Zend_Form_Decorator_CallbackTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_CallbackTest::main") { - Zend_Form_Decorator_CallbackTest::main(); -} diff --git a/tests/Zend/Form/Decorator/DescriptionTest.php b/tests/Zend/Form/Decorator/DescriptionTest.php deleted file mode 100644 index 90f3df1f0ea2bbd0bfd865231c97a03b6b336e58..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/DescriptionTest.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php -// Call Zend_Form_Decorator_DescriptionTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_DescriptionTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/Description.php'; - -require_once 'Zend/Form/Element.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_Description - */ -class Zend_Form_Decorator_DescriptionTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_DescriptionTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (isset($this->html)) { - unset($this->html); - } - - $this->element = new Zend_Form_Element('foo'); - $this->element->setDescription('a test description') - ->setView($this->getView()); - $this->decorator = new Zend_Form_Decorator_Description(); - $this->decorator->setElement($this->element); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testRendersDescriptionInParagraphTagsByDefault() - { - $html = $this->decorator->render(''); - $this->assertContains('<p', $html, $html); - $this->assertContains('</p>', $html); - $this->assertContains($this->element->getDescription(), $html); - $this->html = $html; - } - - public function testParagraphTagsContainHintClassByDefault() - { - $this->testRendersDescriptionInParagraphTagsByDefault(); - $this->assertRegexp('/<p[^>]*?class="hint"/', $this->html); - } - - public function testCanSpecifyAlternateTag() - { - $this->decorator->setTag('quote'); - $html = $this->decorator->render(''); - $this->assertContains('<quote', $html, $html); - $this->assertContains('</quote>', $html); - $this->assertContains($this->element->getDescription(), $html); - $this->html = $html; - } - - public function testCanSpecifyAlternateTagViaOption() - { - $this->decorator->setOption('tag', 'quote'); - $html = $this->decorator->render(''); - $this->assertContains('<quote', $html, $html); - $this->assertContains('</quote>', $html); - $this->assertContains($this->element->getDescription(), $html); - $this->html = $html; - } - - public function testAlternateTagContainsHintClass() - { - $this->testCanSpecifyAlternateTag(); - $this->assertRegexp('/<quote[^>]*?class="hint"/', $this->html); - } - - public function testCanSpecifyAlternateClass() - { - $this->decorator->setOption('class', 'haha'); - $html = $this->decorator->render(''); - $this->assertRegexp('/<p[^>]*?class="haha"/', $html); - } - - public function testRenderingEscapesDescriptionByDefault() - { - $description = '<span>some spanned text</span>'; - $this->element->setDescription($description); - $html = $this->decorator->render(''); - $this->assertNotContains($description, $html); - $this->assertContains('<', $html); - $this->assertContains('>', $html); - $this->assertContains('some spanned text', $html); - } - - public function testCanDisableEscapingDescription() - { - $description = '<span>some spanned text</span>'; - $this->element->setDescription($description); - $this->decorator->setEscape(false); - $html = $this->decorator->render(''); - $this->assertContains($description, $html); - $this->assertNotContains('<', $html); - $this->assertNotContains('>', $html); - } - - public function testCanSetEscapeFlagViaOption() - { - $description = '<span>some spanned text</span>'; - $this->element->setDescription($description); - $this->decorator->setOption('escape', false); - $html = $this->decorator->render(''); - $this->assertContains($description, $html); - $this->assertNotContains('<', $html); - $this->assertNotContains('>', $html); - } - - public function testDescriptionIsTranslatedWhenTranslationAvailable() - { - require_once 'Zend/Translate.php'; - $translations = array('description' => 'This is the description'); - $translate = new Zend_Translate('array', $translations); - $this->element->setDescription('description') - ->setTranslator($translate); - $html = $this->decorator->render(''); - $this->assertContains($translations['description'], $html); - } -} - -// Call Zend_Form_Decorator_DescriptionTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_DescriptionTest::main") { - Zend_Form_Decorator_DescriptionTest::main(); -} diff --git a/tests/Zend/Form/Decorator/ErrorsTest.php b/tests/Zend/Form/Decorator/ErrorsTest.php deleted file mode 100644 index e4b1ff8c680bfa308597c8f6952b6d1154517a2a..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/ErrorsTest.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php -// Call Zend_Form_Decorator_ErrorsTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_ErrorsTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/Errors.php'; - -require_once 'Zend/Form/Element.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_Errors - */ -class Zend_Form_Decorator_ErrorsTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_ErrorsTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Errors(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testRenderReturnsInitialContentIfNoViewPresentInElement() - { - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element); - $content = 'test content'; - $this->assertSame($content, $this->decorator->render($content)); - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function setupElement() - { - $element = new Zend_Form_Element('foo'); - $element->addValidator('Alnum') - ->addValidator('Alpha') - ->setView($this->getView()); - $element->isValid('abc-123'); - $this->element = $element; - $this->decorator->setElement($element); - } - - public function testRenderRendersAllErrorMessages() - { - $this->setupElement(); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertContains($content, $test); - foreach ($this->element->getMessages() as $message) { - $this->assertContains($message, $test); - } - } - - public function testRenderAppendsMessagesToContentByDefault() - { - $this->setupElement(); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertRegexp('#' . $content . '.*?<ul#s', $test, $test); - } - - public function testRenderPrependsMessagesToContentWhenRequested() - { - $this->decorator->setOptions(array('placement' => 'PREPEND')); - $this->setupElement(); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertRegexp('#</ul>.*?' . $content . '#s', $test); - } - - public function testRenderSeparatesContentAndErrorsWithPhpEolByDefault() - { - $this->setupElement(); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertContains($content . PHP_EOL . '<ul', $test); - } - - public function testRenderSeparatesContentAndErrorsWithCustomSeparatorWhenRequested() - { - $this->decorator->setOptions(array('separator' => '<br />')); - $this->setupElement(); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertContains($content . $this->decorator->getSeparator() . '<ul', $test, $test); - } -} - -// Call Zend_Form_Decorator_ErrorsTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_ErrorsTest::main") { - Zend_Form_Decorator_ErrorsTest::main(); -} diff --git a/tests/Zend/Form/Decorator/FieldsetTest.php b/tests/Zend/Form/Decorator/FieldsetTest.php deleted file mode 100644 index 76fbc1dda59196b2a4cec741dbeda89b95e802f5..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/FieldsetTest.php +++ /dev/null @@ -1,185 +0,0 @@ -<?php -// Call Zend_Form_Decorator_FieldsetTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_FieldsetTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/Fieldset.php'; - -require_once 'Zend/Form.php'; -require_once 'Zend/Form/Element.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_Fieldset - */ -class Zend_Form_Decorator_FieldsetTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_FieldsetTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Fieldset(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testPlacementInitiallyNull() - { - $this->assertNull($this->decorator->getPlacement()); - } - - public function testRenderReturnsOriginalContentWhenNoViewPresentInElement() - { - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element); - $content = 'test content'; - $this->assertSame($content, $this->decorator->render($content)); - } - - public function testLegendInitiallyNull() - { - $this->assertNull($this->decorator->getLegend()); - } - - public function testUsesLegendOptionWhenSetAndNoLegendInElement() - { - $this->testLegendInitiallyNull(); - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element) - ->setOption('legend', 'this is a legend'); - $this->assertEquals('this is a legend', $this->decorator->getLegend()); - } - - public function testUsesElementLegendWhenPresent() - { - $this->testLegendInitiallyNull(); - $element = new Zend_Form(); - $element->setLegend('this is a legend'); - $this->decorator->setElement($element); - $this->assertEquals('this is a legend', $this->decorator->getLegend()); - } - - public function testCanSetLegend() - { - $this->testLegendInitiallyNull(); - $this->decorator->setLegend('this is a legend'); - $this->assertEquals('this is a legend', $this->decorator->getLegend()); - } - - /** - * @see ZF-2981 - */ - public function testActionAndMethodAttributesShouldNotBePresentInFieldsetTag() - { - $form = new Zend_Form(); - $form->setAction('/foo/bar') - ->setMethod('post') - ->setView($this->getView()); - $this->decorator->setElement($form); - $test = $this->decorator->render('content'); - $this->assertContains('<fieldset', $test, $test); - $this->assertNotContains('action="', $test); - $this->assertNotContains('method="', $test); - } - - /**#@+ - * @see ZF-3731 - */ - public function testIdShouldBePrefixedWithFieldset() - { - $form = new Zend_Form(); - $form->setAction('/foo/bar') - ->setMethod('post') - ->setName('foobar') - ->setView($this->getView()); - $this->decorator->setElement($form); - $test = $this->decorator->render('content'); - $this->assertContains('id="fieldset-foobar"', $test); - } - - public function testElementWithNoIdShouldNotCreateFieldsetId() - { - $form = new Zend_Form(); - $form->setAction('/foo/bar') - ->setMethod('post') - ->setView($this->getView()); - $this->decorator->setElement($form); - $test = $this->decorator->render('content'); - $this->assertNotContains('id="', $test); - } - /**#@-*/ - - /** - * @see ZF-3728 - */ - public function testEnctypeAttributeShouldNotBePresentInFieldsetTag() - { - $form = new Zend_Form(); - $form->setAction('/foo/bar') - ->setMethod('post') - ->setAttrib('enctype', 'dojo/method') - ->setView($this->getView()); - $this->decorator->setElement($form); - $test = $this->decorator->render('content'); - $this->assertContains('<fieldset', $test, $test); - $this->assertNotContains('enctype="', $test); - } - - /** - * @see ZF-3499 - */ - public function testHelperAttributeShouldNotBePresentInFieldsetTag() - { - $form = new Zend_Form(); - $form->setAction('/foo/bar') - ->setMethod('post') - ->setAttrib('helper', 'form') - ->setView($this->getView()); - $this->decorator->setElement($form); - $test = $this->decorator->render('content'); - $this->assertContains('<fieldset', $test, $test); - $this->assertNotContains('helper="', $test); - } -} - -// Call Zend_Form_Decorator_FieldsetTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_FieldsetTest::main") { - Zend_Form_Decorator_FieldsetTest::main(); -} diff --git a/tests/Zend/Form/Decorator/FileTest.php b/tests/Zend/Form/Decorator/FileTest.php deleted file mode 100644 index f9a331cb60e790be147c9a38495e26bddcbd5eb9..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/FileTest.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php -// Call Zend_Form_Decorator_FileTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_FileTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/File.php'; - -require_once 'Zend/Form/Element/File.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_Errors - */ -class Zend_Form_Decorator_FileTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_FileTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_File(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testRenderReturnsInitialContentIfNoViewPresentInElement() - { - $element = new Zend_Form_Element_File('foo'); - $this->decorator->setElement($element); - $content = 'test content'; - $this->assertSame($content, $this->decorator->render($content)); - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function setupSingleElement() - { - $element = new Zend_Form_Element_File('foo'); - $element->addValidator('Count', 1) - ->setView($this->getView()); - $this->element = $element; - $this->decorator->setElement($element); - } - - public function setupMultiElement() - { - $element = new Zend_Form_Element_File('foo'); - $element->addValidator('Count', 1) - ->setMultiFile(2) - ->setView($this->getView()); - $this->element = $element; - $this->decorator->setElement($element); - } - - public function testRenderSingleFiles() - { - $this->setupSingleElement(); - $test = $this->decorator->render(null); - $this->assertRegexp('#foo#s', $test); - } - - public function testRenderMultiFiles() - { - $this->setupMultiElement(); - $test = $this->decorator->render(null); - $this->assertRegexp('#foo\[\]#s', $test); - } - - public function setupElementWithMaxFileSize() - { - $element = new Zend_Form_Element_File('foo'); - $element->addValidator('Count', 1) - ->setView($this->getView()) - ->setMaxFileSize(3000); - $this->element = $element; - $this->decorator->setElement($element); - } - - public function testRenderMaxFileSize() - { - $this->setupElementWithMaxFileSize(); - $test = $this->decorator->render(null); - $this->assertRegexp('#MAX_FILE_SIZE#s', $test); - $this->assertRegexp('#3000#s', $test); - } -} - -// Call Zend_Form_Decorator_FileTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_FileTest::main") { - Zend_Form_Decorator_FileTest::main(); -} diff --git a/tests/Zend/Form/Decorator/FormTest.php b/tests/Zend/Form/Decorator/FormTest.php deleted file mode 100644 index 538c30a0fddc9136ae5ab5b31b0e0e61a7a7461f..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/FormTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php -// Call Zend_Form_Decorator_FormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_FormTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Decorator/Form.php'; -require_once 'Zend/Form.php'; - - -/** - * Test class for Zend_Form_Decorator_Form - */ -class Zend_Form_Decorator_FormTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_FormTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Form(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testHelperIsFormByDefault() - { - $this->assertEquals('form', $this->decorator->getHelper()); - } - - public function testCanSetHelperWithOption() - { - $this->testHelperIsFormByDefault(); - $this->decorator->setOption('helper', 'formForm'); - $this->assertEquals('formForm', $this->decorator->getHelper()); - - require_once 'Zend/Form/DisplayGroup.php'; - require_once 'Zend/Loader/PluginLoader.php'; - $attribs = array( - 'enctype' => 'ascii', - 'charset' => 'us-ascii' - ); - $loader = new Zend_Loader_PluginLoader(array('Zend_Form_Decorator' => 'Zend/Form/Decorator/')); - $displayGroup = new Zend_Form_DisplayGroup('foo', $loader, array('attribs' => $attribs)); - $this->decorator->setElement($displayGroup); - $options = $this->decorator->getOptions(); - $this->assertTrue(isset($options['enctype'])); - $this->assertEquals($attribs['enctype'], $options['enctype']); - $this->assertTrue(isset($options['charset'])); - $this->assertEquals($attribs['charset'], $options['charset']); - } - - /** - * @see ZF-3643 - */ - public function testShouldPreferFormIdAttributeOverFormName() - { - $form = new Zend_Form(); - $form->setMethod('post') - ->setAction('/foo/bar') - ->setName('foobar') - ->setAttrib('id', 'bazbat') - ->setView($this->getView()); - $html = $form->render(); - $this->assertContains('id="bazbat"', $html, $html); - } - - public function testEmptyFormNameShouldNotRenderEmptyFormId() - { - $form = new Zend_Form(); - $form->setMethod('post') - ->setAction('/foo/bar') - ->setView($this->getView()); - $html = $form->render(); - $this->assertNotContains('id=""', $html, $html); - } -} - -// Call Zend_Form_Decorator_FormTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_FormTest::main") { - Zend_Form_Decorator_FormTest::main(); -} diff --git a/tests/Zend/Form/Decorator/HtmlTagTest.php b/tests/Zend/Form/Decorator/HtmlTagTest.php deleted file mode 100644 index d9e5b5fe080090bf9648a095215ccee65537ca2f..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/HtmlTagTest.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -// Call Zend_Form_Decorator_HtmlTagTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_HtmlTagTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/HtmlTag.php'; - -require_once 'Zend/Form/Element.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_HtmlTag - */ -class Zend_Form_Decorator_HtmlTagTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_HtmlTagTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_HtmlTag(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testNormalizeTagStripsNonAlphanumericCharactersAndLowersCase() - { - $tag = 'ab1-cd0EFG'; - $received = $this->decorator->normalizeTag($tag); - $this->assertEquals('ab1cd0efg', $received); - } - - public function testRendersOptionsAsHtmlAttribsByDefault() - { - $element = new Zend_Form_Element('foo'); - $options = array('tag' => 'div', 'class' => 'foobar', 'id' => 'foo'); - $this->decorator->setElement($element) - ->setOptions($options); - $html = $this->decorator->render(''); - foreach ($options as $key => $value) { - if ('tag' == $key) { - $this->assertContains('<' . $value, $html); - $this->assertContains('</' . $value . '>', $html); - } else { - $this->assertContains($key . '="' . $value . '"', $html); - } - } - } - - public function testDoesNotRenderAttribsWhenNoAttribsOptionSet() - { - $element = new Zend_Form_Element('foo'); - $options = array('tag' => 'div', 'class' => 'foobar', 'id' => 'foo', 'noAttribs' => true); - $this->decorator->setElement($element) - ->setOptions($options); - $html = $this->decorator->render(''); - foreach ($options as $key => $value) { - if ('tag' == $key) { - $this->assertContains('<' . $value, $html); - $this->assertContains('</' . $value . '>', $html); - } else { - $this->assertNotContains($key . '="' . (string) $value . '"', $html); - } - } - } - - public function testCanRenderOnlyOpeningTag() - { - $element = new Zend_Form_Element('foo'); - $options = array('tag' => 'div', 'class' => 'foobar', 'id' => 'foo', 'openOnly' => true); - $this->decorator->setElement($element) - ->setOptions($options); - $html = $this->decorator->render(''); - foreach ($options as $key => $value) { - if ('tag' == $key) { - $this->assertContains('<' . $value, $html); - $this->assertNotContains('</' . $value . '>', $html); - } elseif ('openOnly' == $key) { - $this->assertNotContains($key, $html); - } else { - $this->assertContains($key . '="' . (string) $value . '"', $html); - } - } - } - - public function testCanRenderOnlyClosingTag() - { - $element = new Zend_Form_Element('foo'); - $options = array('tag' => 'div', 'class' => 'foobar', 'id' => 'foo', 'closeOnly' => true); - $this->decorator->setElement($element) - ->setOptions($options); - $html = $this->decorator->render(''); - foreach ($options as $key => $value) { - if ('tag' == $key) { - $this->assertNotContains('<' . $value, $html); - $this->assertContains('</' . $value . '>', $html); - } else { - $this->assertNotContains($key . '="' . (string) $value . '"', $html); - } - } - } - - public function testArrayAttributesAreRenderedAsSpaceSeparatedLists() - { - $element = new Zend_Form_Element('foo'); - $options = array('tag' => 'div', 'class' => array('foobar', 'bazbat'), 'id' => 'foo'); - $this->decorator->setElement($element) - ->setOptions($options); - $html = $this->decorator->render(''); - $this->assertContains('class="foobar bazbat"', $html); - } - - public function testAppendPlacementWithCloseOnlyRendersClosingTagFollowingContent() - { - $options = array( - 'closeOnly' => true, - 'tag' => 'div', - 'placement' => 'append' - ); - $this->decorator->setOptions($options); - $html = $this->decorator->render('content'); - $this->assertRegexp('#(content).*?(</div>)#', $html, $html); - } - - public function testAppendPlacementWithOpenOnlyRendersOpeningTagFollowingContent() - { - $options = array( - 'openOnly' => true, - 'tag' => 'div', - 'placement' => 'append' - ); - $this->decorator->setOptions($options); - $html = $this->decorator->render('content'); - $this->assertRegexp('#(content).*?(<div>)#', $html, $html); - } - - public function testPrependPlacementWithCloseOnlyRendersClosingTagBeforeContent() - { - $options = array( - 'closeOnly' => true, - 'tag' => 'div', - 'placement' => 'prepend' - ); - $this->decorator->setOptions($options); - $html = $this->decorator->render('content'); - $this->assertRegexp('#(</div>).*?(content)#', $html, $html); - } - - public function testPrependPlacementWithOpenOnlyRendersOpeningTagBeforeContent() - { - $options = array( - 'openOnly' => true, - 'tag' => 'div', - 'placement' => 'prepend' - ); - $this->decorator->setOptions($options); - $html = $this->decorator->render('content'); - $this->assertRegexp('#(<div>).*?(content)#', $html, $html); - } - - public function testTagIsInitiallyDiv() - { - $this->assertEquals('div', $this->decorator->getTag()); - } - - public function testCanSetTag() - { - $this->testTagIsInitiallyDiv(); - $this->decorator->setTag('dl'); - $this->assertEquals('dl', $this->decorator->getTag()); - } - - public function testCanSetTagViaOption() - { - $this->decorator->setOption('tag', 'dl'); - $this->assertEquals('dl', $this->decorator->getTag()); - } -} - -// Call Zend_Form_Decorator_HtmlTagTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_HtmlTagTest::main") { - Zend_Form_Decorator_HtmlTagTest::main(); -} diff --git a/tests/Zend/Form/Decorator/ImageTest.php b/tests/Zend/Form/Decorator/ImageTest.php deleted file mode 100644 index 26e7e732899bd74b432898c1be57454be8076710..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/ImageTest.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php -// Call Zend_Form_Decorator_ImageTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_ImageTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/Image.php'; - -require_once 'Zend/Form.php'; -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Form/Element/Image.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_Image - */ -class Zend_Form_Decorator_ImageTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_ImageTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Image(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testPlacementInitiallyAppends() - { - $this->assertEquals(Zend_Form_Decorator_Abstract::APPEND, $this->decorator->getPlacement()); - } - - public function testRenderReturnsOriginalContentWhenNoViewPresentInElement() - { - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element); - $content = 'test content'; - $this->assertSame($content, $this->decorator->render($content)); - } - - public function testTagInitiallyNull() - { - $this->assertNull($this->decorator->getTag()); - } - - public function testCanSetTag() - { - $this->testTagInitiallyNull(); - $this->decorator->setTag('div'); - $this->assertEquals('div', $this->decorator->getTag()); - } - - public function testCanSetTagViaOptions() - { - $this->testTagInitiallyNull(); - $this->decorator->setOption('tag', 'div'); - $this->assertEquals('div', $this->decorator->getTag()); - } - - public function testRendersXhtmlImageTag() - { - $element = new Zend_Form_Element_Image('foo'); - $element->setImage('foobar') - ->setView($this->getView()); - $this->decorator->setElement($element); - - $image = $this->decorator->render(''); - $this->assertContains('<input', $image, $image); - $this->assertContains('src="foobar"', $image); - $this->assertContains('name="foo"', $image); - $this->assertContains('type="image"', $image); - } - - public function testCanRenderImageWithinAdditionalTag() - { - $element = new Zend_Form_Element_Image('foo'); - $element->setValue('foobar') - ->setView($this->getView()); - $this->decorator->setElement($element) - ->setOption('tag', 'div'); - - $image = $this->decorator->render(''); - $this->assertRegexp('#<div>.*?<input[^>]*>.*?</div>#s', $image, $image); - } - - public function testCanPrependImageToContent() - { - $element = new Zend_Form_Element_Image('foo'); - $element->setValue('foobar') - ->setView($this->getView()); - $this->decorator->setElement($element) - ->setOption('placement', 'prepend'); - - $image = $this->decorator->render('content'); - $this->assertRegexp('#<input[^>]*>.*?(content)#s', $image, $image); - } - - /** - * @see ZF-2714 - */ - public function testImageElementAttributesPassedWithDecoratorOptionsToViewHelper() - { - $element = new Zend_Form_Element_Image('foo'); - $element->setValue('foobar') - ->setAttrib('onClick', 'foo()') - ->setAttrib('id', 'foo-element') - ->setView($this->getView()); - $this->decorator->setElement($element) - ->setOption('class', 'imageclass'); - - $image = $this->decorator->render(''); - $this->assertContains('class="imageclass"', $image); - $this->assertContains('onClick="foo()"', $image); - $this->assertContains('id="foo-element"', $image); - } -} - -// Call Zend_Form_Decorator_ImageTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_ImageTest::main") { - Zend_Form_Decorator_ImageTest::main(); -} diff --git a/tests/Zend/Form/Decorator/LabelTest.php b/tests/Zend/Form/Decorator/LabelTest.php deleted file mode 100644 index 7315512cc15e2780494fedf8ab61099454b9c06c..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/LabelTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php -// Call Zend_Form_Decorator_LabelTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_LabelTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Decorator/Label.php'; - -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Form/Element/Text.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_Label - */ -class Zend_Form_Decorator_LabelTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_LabelTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_Label(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testUsesPrependPlacementByDefault() - { - $this->assertEquals(Zend_Form_Decorator_Abstract::PREPEND, $this->decorator->getPlacement()); - } - - public function testRenderReturnsOriginalContentWhenNoViewPresentInElement() - { - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element); - $content = 'test content'; - $this->assertSame($content, $this->decorator->render($content)); - } - - public function testRenderReturnsOriginalContentWhenNoLabelPresentInElement() - { - $element = new Zend_Form_Element('foo'); - $this->decorator->setElement($element); - $content = 'test content'; - $this->assertSame($content, $this->decorator->render($content)); - } - - public function testRenderUsesElementIdIfSet() - { - $element = new Zend_Form_Element('foo'); - $element->setAttrib('id', 'foobar') - ->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertContains('for="foobar"', $test); - } - - public function testRenderAddsOptionalClassForNonRequiredElements() - { - $element = new Zend_Form_Element('foo'); - $element->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertRegexp('/<label[^>]*?class="[^"]*optional/', $test, $test); - - $element->class = "bar"; - $this->decorator->setOption('class', 'foo'); - $test = $this->decorator->render($content); - $this->assertNotRegexp('/<label[^>]*?class="[^"]*bar/', $test, $test); - $this->assertRegexp('/<label[^>]*?class="[^"]*foo/', $test, $test); - $this->assertRegexp('/<label[^>]*?class="[^"]*optional/', $test, $test); - } - - public function testRenderAddsRequiredClassForRequiredElements() - { - $element = new Zend_Form_Element('foo'); - $element->setRequired(true) - ->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertRegexp('/<label[^>]*?class="[^"]*required/', $test, $test); - - $element->class = "bar"; - $this->decorator->setOption('class', 'foo'); - $test = $this->decorator->render($content); - $this->assertNotRegexp('/<label[^>]*?class="[^"]*bar/', $test, $test); - $this->assertRegexp('/<label[^>]*?class="[^"]*foo/', $test, $test); - $this->assertRegexp('/<label[^>]*?class="[^"]*required/', $test, $test); - } - - public function testRenderAppendsRequiredClassToClassProvidedInRequiredElement() - { - $element = new Zend_Form_Element('foo'); - $element->setRequired(true) - ->setView($this->getView()) - ->setLabel('My Label') - ->setAttrib('class', 'bazbat'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertRegexp('/<label[^>]*?class="[^"]*required/', $test, $test); - $this->assertNotRegexp('/<label[^>]*?class="[^"]*bazbat/', $test, $test); - } - - public function testRenderUtilizesOptionalSuffixesAndPrefixesWhenRequested() - { - $element = new Zend_Form_Element('foo'); - $element->setAttribs(array( - 'optionalPrefix' => '-opt-prefix-', - 'optionalSuffix' => '-opt-suffix-', - 'requiredPrefix' => '-req-prefix-', - 'requiredSuffix' => '-req-suffix-', - )) - ->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertNotContains('-req-prefix-', $test, $test); - $this->assertNotContains('-req-suffix-', $test, $test); - $this->assertContains('-opt-prefix-', $test, $test); - $this->assertContains('-opt-suffix-', $test, $test); - $this->assertRegexp('/-opt-prefix-[^-]*?My Label[^-]*-opt-suffix-/s', $test, $test); - } - - public function testRenderUtilizesRequiredSuffixesAndPrefixesWhenRequested() - { - $element = new Zend_Form_Element('foo'); - $element->setAttribs(array( - 'optionalPrefix' => '-opt-prefix-', - 'optionalSuffix' => '-opt-suffix-', - 'requiredPrefix' => '-req-prefix-', - 'requiredSuffix' => '-req-suffix-', - )) - ->setRequired(true) - ->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertNotContains('-opt-prefix-', $test, $test); - $this->assertNotContains('-opt-suffix-', $test, $test); - $this->assertContains('-req-prefix-', $test, $test); - $this->assertContains('-req-suffix-', $test, $test); - $this->assertRegexp('/-req-prefix-[^-]*?My Label[^-]*-req-suffix-/s', $test, $test); - } - - /** - * @see ZF-3538 - */ - public function testRenderShouldNotUtilizeElementClass() - { - $element = new Zend_Form_Element('foo'); - $element->setView($this->getView()) - ->setLabel('My Label') - ->setAttrib('class', 'foobar'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertNotRegexp('#<label[^>]*(class="[^"]*foobar)[^"]*"#', $test, $test); - } - - public function testRenderRendersLabel() - { - $element = new Zend_Form_Element('foo'); - $element->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertContains($content, $test); - $this->assertContains($element->getLabel(), $test); - $this->assertContains('<label for=', $test); - $this->assertContains('</label>', $test); - } - - public function testRenderAppendsOnRequest() - { - $element = new Zend_Form_Element('foo'); - $element->setView($this->getView()) - ->setLabel('My Label'); - $this->decorator->setElement($element) - ->setOptions(array('placement' => 'APPEND')); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertRegexp('#' . $content . '.*?<label#s', $test); - } - - public function testCanChooseNotToEscapeLabel() - { - $element = new Zend_Form_Element('foo'); - $element->setView($this->getView()) - ->setLabel('<b>My Label</b>'); - $this->decorator->setElement($element) - ->setOptions(array('escape' => false)); - $test = $this->decorator->render(''); - $this->assertContains($element->getLabel(), $test); - } - - public function testRetrievingLabelRetrievesLabelWithTranslationAndPrefixAndSuffix() - { - require_once 'Zend/Translate.php'; - $translate = new Zend_Translate('array', array('My Label' => 'Translation'), 'en'); - $translate->setLocale('en'); - - $element = new Zend_Form_Element('foo'); - $element->setView($this->getView()) - ->setLabel('My Label') - ->setTranslator($translate); - $this->decorator->setElement($element) - ->setOptions(array( - 'optionalPrefix' => '> ', - 'optionalSuffix' => ':', - 'requiredPrefix' => '! ', - 'requiredSuffix' => '*:', - )); - $label = $this->decorator->getLabel(); - $this->assertEquals('> Translation:', $label); - - $element->setRequired(true); - $label = $this->decorator->getLabel(); - $this->assertEquals('! Translation*:', $label); - } - - public function testSettingTagToEmptyValueShouldDisableTag() - { - $element = new Zend_Form_Element_Text('foo', array('label' => 'Foo')); - $this->decorator->setElement($element) - ->setTag(''); - $content = $this->decorator->render(''); - $this->assertTrue(empty($content), $content); - } -} - -// Call Zend_Form_Decorator_LabelTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_LabelTest::main") { - Zend_Form_Decorator_LabelTest::main(); -} diff --git a/tests/Zend/Form/Decorator/ViewHelperTest.php b/tests/Zend/Form/Decorator/ViewHelperTest.php deleted file mode 100644 index 14dce57fcdced7787b1d53ad1f39891f049f5b7d..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/ViewHelperTest.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php -// Call Zend_Form_Decorator_ViewHelperTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_ViewHelperTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Decorator/ViewHelper.php'; - -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Form/Element/Text.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_ViewHelper - */ -class Zend_Form_Decorator_ViewHelperTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_ViewHelperTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_ViewHelper(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function getElement() - { - $element = new Zend_Form_Element_Text('foo'); - $this->decorator->setElement($element); - return $element; - } - - public function testGetHelperWillUseElementHelperAttributeInAbsenceOfHelper() - { - $element = new Zend_Form_Element('foo'); - $element->helper = 'formTextarea'; - $this->decorator->setElement($element); - $this->assertEquals('formTextarea', $this->decorator->getHelper()); - } - - public function testGetHelperWillUseElementTypeInAbsenceOfHelper() - { - $element = new Zend_Form_Decorator_ViewHelperTest_Textarea('foo'); - $this->decorator->setElement($element); - $this->assertEquals('formTextarea', $this->decorator->getHelper()); - } - - public function testGetHelperWillUseHelperProvidedInOptions() - { - $this->decorator->setOptions(array('helper' => 'formSubmit')); - $this->assertEquals('formSubmit', $this->decorator->getHelper()); - } - - public function testGetHelperReturnsNullByDefault() - { - $this->assertNull($this->decorator->getHelper()); - } - - public function testCanSetHelper() - { - $this->decorator->setHelper('formSubmit'); - $this->assertEquals('formSubmit', $this->decorator->getHelper()); - } - - public function testAppendsBracketsIfElementIsAnArray() - { - $element = $this->getElement(); - $element->setIsArray(true); - $name = $this->decorator->getName(); - $expect = $element->getName() . '[]'; - $this->assertEquals($expect, $name); - } - - public function testRenderThrowsExceptionIfNoViewSetInElement() - { - $element = $this->getElement(); - $content = 'test content'; - try { - $test = $this->decorator->render($content); - $this->fail('Render should raise exception without view'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('ViewHelper decorator cannot render', $e->getMessage()); - } - } - - public function testRenderRendersElementWithSpecifiedHelper() - { - $element = $this->getElement(); - $element->setView($this->getView()); - $content = 'test content'; - $test = $this->decorator->render($content); - $this->assertContains($content, $test); - $this->assertRegexp('#<input.*?name="foo"#s', $test); - } - - public function testMultiOptionsPassedToViewHelperAreTranslated() - { - require_once 'Zend/Form/Element/Select.php'; - require_once 'Zend/Translate.php'; - $element = new Zend_Form_Element_Select('foo'); - $options = array( - 'foo' => 'This Foo Will Not Be Displayed', - 'bar' => 'This Bar Will Not Be Displayed', - 'baz' => 'This Baz Will Not Be Displayed', - ); - $element->setMultiOptions($options); - - $translations = array( - 'This Foo Will Not Be Displayed' => 'This is the Foo Value', - 'This Bar Will Not Be Displayed' => 'This is the Bar Value', - 'This Baz Will Not Be Displayed' => 'This is the Baz Value', - ); - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $element->setTranslator($translate); - $test = $element->render($this->getView()); - foreach ($options as $key => $value) { - $this->assertNotContains($value, $test); - $this->assertContains($translations[$value], $test); - } - } -} - -class Zend_Form_Decorator_ViewHelperTest_Textarea extends Zend_Form_Element -{ - public function __construct($name, $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } elseif ($options instanceof Zend_Config) { - $this->setConfig($options); - } - $this->helper = null; - } -} - -// Call Zend_Form_Decorator_ViewHelperTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_ViewHelperTest::main") { - Zend_Form_Decorator_ViewHelperTest::main(); -} diff --git a/tests/Zend/Form/Decorator/ViewScriptTest.php b/tests/Zend/Form/Decorator/ViewScriptTest.php deleted file mode 100644 index 10f820ffad3cca04b0220edc8d0f4e908a1064a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Decorator/ViewScriptTest.php +++ /dev/null @@ -1,168 +0,0 @@ -<?php -// Call Zend_Form_Decorator_ViewScriptTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Decorator_ViewScriptTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Decorator/ViewScript.php'; - -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Form/Element/Text.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Decorator_ViewScript - */ -class Zend_Form_Decorator_ViewScriptTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Decorator_ViewScriptTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->decorator = new Zend_Form_Decorator_ViewScript(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - $view->addScriptPath(dirname(__FILE__) . '/../_files/views/'); - return $view; - } - - public function getElement() - { - $element = new Zend_Form_Element_Text('foo'); - $element->setView($this->getView()); - $this->decorator->setElement($element); - return $element; - } - - public function testRenderRaisesExceptionIfNoViewScriptRegistered() - { - $this->getElement(); - try { - $this->decorator->render(''); - } catch (Zend_Form_Exception $e) { - $this->assertContains('script', $e->getMessage()); - } - } - - public function testViewScriptNullByDefault() - { - $this->assertNull($this->decorator->getViewScript()); - } - - public function testCanSetViewScript() - { - $this->testViewScriptNullByDefault(); - $this->decorator->setViewScript('decorator.phtml'); - $this->assertEquals('decorator.phtml', $this->decorator->getViewScript()); - } - - public function testCanSetViewScriptViaOption() - { - $this->testViewScriptNullByDefault(); - $this->decorator->setOption('viewScript', 'decorator.phtml'); - $this->assertEquals('decorator.phtml', $this->decorator->getViewScript()); - } - - public function testCanSetViewScriptViaElementAttribute() - { - $this->testViewScriptNullByDefault(); - $this->getElement()->setAttrib('viewScript', 'decorator.phtml'); - $this->assertEquals('decorator.phtml', $this->decorator->getViewScript()); - } - - public function testRenderingRendersViewScript() - { - $this->testCanSetViewScriptViaElementAttribute(); - $test = $this->decorator->render(''); - $this->assertContains('This is content from the view script', $test); - } - - public function testOptionsArePassedToPartialAsVariables() - { - $this->decorator->setOptions(array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - 'bat' => 'Bat Value', - 'viewScript' => 'decorator.phtml', - )); - $this->getElement(); - $test = $this->decorator->render(''); - foreach ($this->decorator->getOptions() as $key => $value) { - $this->assertContains("$key: $value", $test); - } - } - - public function testCanReplaceContentBySpecifyingFalsePlacement() - { - $this->decorator->setViewScript('replacingDecorator.phtml') - ->setOption('placement', false) - ->setElement($this->getElement()); - $test = $this->decorator->render('content to decorate'); - $this->assertNotContains('content to decorate', $test, $test); - $this->assertContains('This is content from the view script', $test); - } - - public function testContentCanBeRenderedWithinViewScript() - { - $this->decorator->setViewScript('contentWrappingDecorator.phtml') - ->setOption('placement', false) - ->setElement($this->getElement()); - - $test = $this->decorator->render('content to decorate'); - $this->assertContains('content to decorate', $test, $test); - $this->assertContains('This text prefixes the content', $test); - $this->assertContains('This text appends the content', $test); - } - - public function testDecoratorCanControlPlacementFromWithinViewScript() - { - $this->decorator->setViewScript('decoratorCausesReplacement.phtml') - ->setElement($this->getElement()); - - $test = $this->decorator->render('content to decorate'); - $this->assertContains('content to decorate', $test, $test); - - $count = substr_count($test, 'content to decorate'); - $this->assertEquals(1, $count); - - $this->assertContains('This text prefixes the content', $test); - $this->assertContains('This text appends the content', $test); - } -} - -// Call Zend_Form_Decorator_ViewScriptTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_ViewScriptTest::main") { - Zend_Form_Decorator_ViewScriptTest::main(); -} diff --git a/tests/Zend/Form/DisplayGroupTest.php b/tests/Zend/Form/DisplayGroupTest.php deleted file mode 100644 index 823f0cfd80243de8640edbb456e5110530c89047..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/DisplayGroupTest.php +++ /dev/null @@ -1,762 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_DisplayGroupTest::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Form/DisplayGroup.php'; - -require_once 'Zend/Config.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Form.php'; -require_once 'Zend/Form/Decorator/Form.php'; -require_once 'Zend/Form/Decorator/HtmlTag.php'; -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Form/Element/Text.php'; -require_once 'Zend/Loader/PluginLoader.php'; -require_once 'Zend/Translate.php'; -require_once 'Zend/View.php'; - -class Zend_Form_DisplayGroupTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite('Zend_Form_DisplayGroupTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - Zend_Form::setDefaultTranslator(null); - - if (isset($this->error)) { - unset($this->error); - } - - Zend_Controller_Action_HelperBroker::resetHelpers(); - $this->loader = new Zend_Loader_PluginLoader( - array('Zend_Form_Decorator' => 'Zend/Form/Decorator') - ); - $this->group = new Zend_Form_DisplayGroup( - 'test', - $this->loader - ); - } - - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $libPath = dirname(__FILE__) . '/../../../library'; - $view->addHelperPath($libPath . '/Zend/View/Helper'); - return $view; - } - - // General - public function testConstructorRequiresNameAndPluginLoader() - { - $this->assertEquals('test', $this->group->getName()); - $this->assertSame($this->loader, $this->group->getPluginLoader()); - } - - public function testSetNameNormalizesValueToContainOnlyValidVariableCharacters() - { - $this->group->setName('f%\o^&*)o\(%$b#@!.a}{;-,r'); - $this->assertEquals('foobar', $this->group->getName()); - - try { - $this->group->setName('%\^&*)\(%$#@!.}{;-,'); - $this->fail('Empty names should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid name provided', $e->getMessage()); - } - } - - public function testZeroIsAValidGroupName() - { - try { - $this->group->setName(0); - $this->assertSame('0', $this->group->getName()); - } catch (Zend_Form_Exception $e) { - $this->fail('Should allow zero as group name'); - } - } - - public function testOrderNullByDefault() - { - $this->assertNull($this->group->getOrder()); - } - - public function testCanSetOrder() - { - $this->testOrderNullByDefault(); - $this->group->setOrder(50); - $this->assertEquals(50, $this->group->getOrder()); - } - - public function testDescriptionInitiallyNull() - { - $this->assertNull($this->group->getDescription()); - } - - public function testCanSetDescription() - { - $this->testDescriptionInitiallyNull(); - $description = "this is a description"; - $this->group->setDescription($description); - $this->assertEquals($description, $this->group->getDescription()); - } - - // Elements - - public function testPassingInvalidElementsToAddElementsThrowsException() - { - $elements = array('foo' => true); - try { - $this->group->addElements($elements); - $this->fail('Invalid elements should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('must be Zend_Form_Elements only', $e->getMessage()); - } - } - - public function testCanAddElements() - { - $foo = new Zend_Form_Element('foo'); - $this->group->addElement($foo); - $element = $this->group->getElement('foo'); - $this->assertSame($foo, $element); - } - - public function testCanAddMultipleElements() - { - $foo = new Zend_Form_Element('foo'); - $bar = new Zend_Form_Element('bar'); - $this->group->addElements(array($foo, $bar)); - $elements = $this->group->getElements(); - $this->assertEquals(array('foo' => $foo, 'bar' => $bar), $elements); - } - - public function testSetElementsOverWritesExistingElements() - { - $this->testCanAddMultipleElements(); - $baz = new Zend_Form_Element('baz'); - $this->group->setElements(array($baz)); - $elements = $this->group->getElements(); - $this->assertEquals(array('baz' => $baz), $elements); - } - - public function testCanRemoveSingleElements() - { - $this->testCanAddMultipleElements(); - $this->group->removeElement('bar'); - $this->assertNull($this->group->getElement('bar')); - } - - public function testRemoveElementReturnsFalseIfElementNotRegistered() - { - $this->assertFalse($this->group->removeElement('bar')); - } - - public function testCanRemoveAllElements() - { - $this->testCanAddMultipleElements(); - $this->group->clearElements(); - $elements = $this->group->getElements(); - $this->assertTrue(is_array($elements)); - $this->assertTrue(empty($elements)); - } - - // Plugin loader - - public function testCanSetPluginLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->group->setPluginLoader($loader); - $this->assertSame($loader, $this->group->getPluginLoader()); - } - - // Decorators - - public function testDefaultDecoratorsRegistered() - { - $this->_checkZf2794(); - - $decorator = $this->group->getDecorator('FormElements'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_FormElements); - $decorator = $this->group->getDecorator('Fieldset'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Fieldset); - } - - public function testCanDisableRegisteringDefaultDecoratorsDuringInitialization() - { - $group = new Zend_Form_DisplayGroup( - 'test', - $this->loader, - array('disableLoadDefaultDecorators' => true) - ); - $decorators = $group->getDecorators(); - $this->assertEquals(array(), $decorators); - } - - public function testAddingInvalidDecoratorThrowsException() - { - try { - $this->group->addDecorator(123); - $this->fail('Invalid decorator should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid decorator', $e->getMessage()); - } - } - - public function testCanAddSingleDecoratorAsString() - { - $this->_checkZf2794(); - - $this->group->clearDecorators(); - $this->assertFalse($this->group->getDecorator('form')); - - $this->group->addDecorator('viewHelper'); - $decorator = $this->group->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - } - - public function testCanNotRetrieveSingleDecoratorRegisteredAsStringUsingClassName() - { - $this->assertFalse($this->group->getDecorator('Zend_Form_Decorator_FormElements')); - } - - public function testCanAddSingleDecoratorAsDecoratorObject() - { - $this->group->clearDecorators(); - $this->assertFalse($this->group->getDecorator('form')); - - $decorator = new Zend_Form_Decorator_ViewHelper; - $this->group->addDecorator($decorator); - $test = $this->group->getDecorator('Zend_Form_Decorator_ViewHelper'); - $this->assertSame($decorator, $test); - } - - public function testCanRetrieveSingleDecoratorRegisteredAsDecoratorObjectUsingShortName() - { - $this->_checkZf2794(); - - $this->group->clearDecorators(); - $this->assertFalse($this->group->getDecorator('form')); - - $decorator = new Zend_Form_Decorator_Form; - $this->group->addDecorator($decorator); - $test = $this->group->getDecorator('form'); - $this->assertSame($decorator, $test); - } - - public function testCanAddMultipleDecorators() - { - $this->_checkZf2794(); - - $this->group->clearDecorators(); - $this->assertFalse($this->group->getDecorator('form')); - - $testDecorator = new Zend_Form_Decorator_HtmlTag; - $this->group->addDecorators(array( - 'ViewHelper', - $testDecorator - )); - - $viewHelper = $this->group->getDecorator('viewHelper'); - $this->assertTrue($viewHelper instanceof Zend_Form_Decorator_ViewHelper); - $decorator = $this->group->getDecorator('HtmlTag'); - $this->assertSame($testDecorator, $decorator); - } - - public function testCanRemoveDecorator() - { - $this->_checkZf2794(); - - $this->testDefaultDecoratorsRegistered(); - $this->group->removeDecorator('form'); - $this->assertFalse($this->group->getDecorator('form')); - } - - /** - * @see ZF-3069 - */ - public function testRemovingNamedDecoratorsShouldWork() - { - $this->_checkZf2794(); - $this->group->setDecorators(array( - 'FormElements', - array(array('div' => 'HtmlTag'), array('tag' => 'div')), - array(array('div2' => 'HtmlTag'), array('tag' => 'div')), - )); - $decorators = $this->group->getDecorators(); - $this->assertTrue(array_key_exists('div', $decorators)); - $this->assertTrue(array_key_exists('div2', $decorators)); - $this->group->removeDecorator('div'); - $decorators = $this->group->getDecorators(); - $this->assertFalse(array_key_exists('div', $decorators)); - $this->assertTrue(array_key_exists('div2', $decorators)); - } - - - public function testCanClearAllDecorators() - { - $this->_checkZf2794(); - - $this->testCanAddMultipleDecorators(); - $this->group->clearDecorators(); - $this->assertFalse($this->group->getDecorator('viewHelper')); - $this->assertFalse($this->group->getDecorator('HtmlTag')); - } - - public function testCanAddDecoratorAliasesToAllowMultipleDecoratorsOfSameType() - { - $this->_checkZf2794(); - - $this->group->setDecorators(array( - array('HtmlTag', array('tag' => 'fieldset')), - array('decorator' => array('FooBar' => 'HtmlTag'), 'options' => array('tag' => 'dd')), - )); - $decorator = $this->group->getDecorator('FooBar'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_HtmlTag); - $this->assertEquals('dd', $decorator->getOption('tag')); - - $decorator = $this->group->getDecorator('HtmlTag'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_HtmlTag); - $this->assertEquals('fieldset', $decorator->getOption('tag')); - } - - /** - * @see ZF-3494 - */ - public function testGetViewShouldNotReturnNullWhenViewRendererIsActive() - { - require_once 'Zend/Controller/Action/HelperBroker.php'; - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); - $viewRenderer->initView(); - $view = $this->group->getView(); - $this->assertSame($viewRenderer->view, $view); - } - - public function testRetrievingNamedDecoratorShouldNotReorderDecorators() - { - $this->group->setDecorators(array( - 'FormElements', - array(array('dl' => 'HtmlTag'), array('tag' => 'dl')), - array(array('div' => 'HtmlTag'), array('tag' => 'div')), - array(array('fieldset' => 'HtmlTag'), array('tag' => 'fieldset')), - )); - - $decorator = $this->group->getDecorator('div'); - $decorators = $this->group->getDecorators(); - $i = 0; - $order = array(); - - foreach (array_keys($decorators) as $name) { - $order[$name] = $i; - ++$i; - } - $this->assertEquals(2, $order['div'], var_export($order, 1)); - } - - public function testRenderingRendersAllElementsWithinFieldsetByDefault() - { - $foo = new Zend_Form_Element_Text('foo'); - $bar = new Zend_Form_Element_Text('bar'); - - $this->group->addElements(array($foo, $bar)); - $html = $this->group->render($this->getView()); - $this->assertRegexp('#^<dt> </dt><dd><fieldset.*?</fieldset></dd>$#s', $html, $html); - $this->assertContains('<input', $html, $html); - $this->assertContains('"foo"', $html); - $this->assertContains('"bar"', $html); - } - - public function testToStringProxiesToRender() - { - $foo = new Zend_Form_Element_Text('foo'); - $bar = new Zend_Form_Element_Text('bar'); - - $this->group->addElements(array($foo, $bar)) - ->setView($this->getView()); - $html = $this->group->__toString(); - $this->assertRegexp('#^<dt> </dt><dd><fieldset.*?</fieldset></dd>$#s', $html, $html); - $this->assertContains('<input', $html); - $this->assertContains('"foo"', $html); - $this->assertContains('"bar"', $html); - } - - public function raiseDecoratorException($content, $element, $options) - { - throw new Exception('Raising exception in decorator callback'); - } - - public function handleDecoratorErrors($errno, $errstr, $errfile = '', $errline = 0, array $errcontext = array()) - { - $this->error = $errstr; - } - - public function testToStringRaisesErrorWhenExceptionCaught() - { - $this->group->setDecorators(array( - array( - 'decorator' => 'Callback', - 'options' => array('callback' => array($this, 'raiseDecoratorException')) - ), - )); - $origErrorHandler = set_error_handler(array($this, 'handleDecoratorErrors'), E_USER_WARNING); - - $text = $this->group->__toString(); - - restore_error_handler(); - - $this->assertTrue(empty($text)); - $this->assertTrue(isset($this->error)); - $this->assertEquals('Raising exception in decorator callback', $this->error); - } - - public function testNoTranslatorByDefault() - { - $this->assertNull($this->group->getTranslator()); - } - - public function testGetTranslatorRetrievesGlobalDefaultWhenAvailable() - { - $this->testNoTranslatorByDefault(); - $translator = new Zend_Translate('array', array('foo' => 'bar')); - Zend_Form::setDefaultTranslator($translator); - $received = $this->group->getTranslator(); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testTranslatorAccessorsWorks() - { - $translator = new Zend_Translate('array', array('foo' => 'bar')); - $this->group->setTranslator($translator); - $received = $this->group->getTranslator($translator); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testCanDisableTranslation() - { - $this->testGetTranslatorRetrievesGlobalDefaultWhenAvailable(); - $this->group->setDisableTranslator(true); - $this->assertNull($this->group->getTranslator()); - } - - // Iteration - - public function setupIteratorElements() - { - $foo = new Zend_Form_Element('foo'); - $bar = new Zend_Form_Element('bar'); - $baz = new Zend_Form_Element('baz'); - $this->group->addElements(array($foo, $bar, $baz)); - } - - public function testDisplayGroupIsIterableAndIteratesElements() - { - $this->setupIteratorElements(); - $expected = array('foo', 'bar', 'baz'); - $received = array(); - foreach ($this->group as $key => $element) { - $received[] = $key; - $this->assertTrue($element instanceof Zend_Form_Element); - } - $this->assertSame($expected, $received); - } - - public function testDisplayGroupIteratesElementsInExpectedOrder() - { - $this->setupIteratorElements(); - $test = new Zend_Form_Element('checkorder', array('order' => 1)); - $this->group->addElement($test); - $expected = array('foo', 'checkorder', 'bar', 'baz'); - $received = array(); - foreach ($this->group as $key => $element) { - $received[] = $key; - } - $this->assertSame($expected, $received); - } - - public function testDisplayGroupIteratesElementsInExpectedOrderWhenFirstElementHasNoOrderSpecified() - { - $a = new Zend_Form_Element('a',array('label'=>'a')); - $b = new Zend_Form_Element('b',array('label'=>'b', 'order' => 0)); - $c = new Zend_Form_Element('c',array('label'=>'c', 'order' => 1)); - $this->group->addElement($a) - ->addElement($b) - ->addElement($c) - ->setView($this->getView()); - $test = $this->group->render(); - $this->assertContains('name="a"', $test); - if (!preg_match_all('/(<input[^>]+>)/', $test, $matches)) { - $this->fail('Expected markup not found'); - } - $order = array(); - foreach ($matches[1] as $element) { - if (preg_match('/name="(a|b|c)"/', $element, $m)) { - $order[] = $m[1]; - } - } - $this->assertSame(array('b', 'c', 'a'), $order); - } - - public function testRemovingElementsShouldNotRaiseExceptionsDuringIteration() - { - $this->setupIteratorElements(); - $bar = $this->group->getElement('bar'); - $this->group->removeElement('bar'); - - try { - foreach ($this->group as $item) { - } - } catch (Exception $e) { - $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage()); - } - } - - // Countable - - public function testCanCountDisplayGroup() - { - $this->setupIteratorElements(); - $this->assertEquals(3, count($this->group)); - } - - // Configuration - - public function getOptions() - { - $options = array( - 'name' => 'foo', - 'legend' => 'Display Group', - 'order' => 20, - 'class' => 'foobar' - ); - return $options; - } - - public function testCanSetObjectStateViaSetOptions() - { - $this->group->setOptions($this->getOptions()); - $this->assertEquals('foo', $this->group->getName()); - $this->assertEquals('Display Group', $this->group->getLegend()); - $this->assertEquals(20, $this->group->getOrder()); - $this->assertEquals('foobar', $this->group->getAttrib('class')); - } - - public function testSetOptionsOmitsAccessorsRequiringObjectsOrMultipleParams() - { - $options = $this->getOptions(); - $config = new Zend_Config($options); - $options['config'] = $config; - $options['options'] = $config->toArray(); - $options['pluginLoader'] = true; - $options['view'] = true; - $options['translator'] = true; - $options['attrib'] = true; - $this->group->setOptions($options); - } - - public function testSetOptionsSetsArrayOfStringDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array('label', 'form'); - $this->group->setOptions($options); - $this->assertFalse($this->group->getDecorator('group')); - - $decorator = $this->group->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $decorator = $this->group->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - } - - public function testSetOptionsSetsArrayOfArrayDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array( - array('label', array('id' => 'mylabel')), - array('form', array('id' => 'form')), - ); - $this->group->setOptions($options); - $this->assertFalse($this->group->getDecorator('group')); - - $decorator = $this->group->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $options = $decorator->getOptions(); - $this->assertEquals('mylabel', $options['id']); - - $decorator = $this->group->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - $options = $decorator->getOptions(); - $this->assertEquals('form', $options['id']); - } - - public function testSetOptionsSetsArrayOfAssocArrayDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array( - array( - 'options' => array('id' => 'mylabel'), - 'decorator' => 'label', - ), - array( - 'options' => array('id' => 'form'), - 'decorator' => 'form', - ), - ); - $this->group->setOptions($options); - $this->assertFalse($this->group->getDecorator('group')); - - $decorator = $this->group->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $options = $decorator->getOptions(); - $this->assertEquals('mylabel', $options['id']); - - $decorator = $this->group->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - $options = $decorator->getOptions(); - $this->assertEquals('form', $options['id']); - } - - public function testCanSetObjectStateViaSetConfig() - { - $config = new Zend_Config($this->getOptions()); - $this->group->setConfig($config); - $this->assertEquals('foo', $this->group->getName()); - $this->assertEquals('Display Group', $this->group->getLegend()); - $this->assertEquals(20, $this->group->getOrder()); - $this->assertEquals('foobar', $this->group->getAttrib('class')); - } - - public function testPassingConfigObjectToConstructorSetsObjectState() - { - $config = new Zend_Config($this->getOptions()); - $group = new Zend_Form_DisplayGroup('foo', $this->loader, $config); - $this->assertEquals('foo', $group->getName()); - $this->assertEquals('Display Group', $group->getLegend()); - $this->assertEquals(20, $group->getOrder()); - $this->assertEquals('foobar', $group->getAttrib('class')); - } - - public function testGetAttribReturnsNullForUndefinedAttribs() - { - $this->assertNull($this->group->getAttrib('bogus')); - } - - public function testCanAddMultipleAttribsSimultaneously() - { - $attribs = array( - 'foo' => 'fooval', - 'bar' => 'barval', - 'baz' => 'bazval' - ); - $this->group->addAttribs($attribs); - $this->assertEquals($attribs, $this->group->getAttribs()); - } - - public function testSetAttribsOverwritesPreviouslySetAttribs() - { - $this->testCanAddMultipleAttribsSimultaneously(); - $attribs = array( - 'foo' => 'valfoo', - 'bat' => 'batval' - ); - $this->group->setAttribs($attribs); - $this->assertEquals($attribs, $this->group->getAttribs()); - } - - public function testCanRemoveSingleAttrib() - { - $this->testCanAddMultipleAttribsSimultaneously(); - $this->group->removeAttrib('bar'); - $this->assertNull($this->group->getAttrib('bar')); - } - - public function testCanClearAllAttribs() - { - $this->testCanAddMultipleAttribsSimultaneously(); - $this->group->clearAttribs(); - $this->assertEquals(array(), $this->group->getAttribs()); - } - - // Extension - - public function testInitCalledBeforeLoadDecorators() - { - $group = new Zend_Form_DisplayGroupTest_DisplayGroup( - 'test', - $this->loader - ); - $decorators = $group->getDecorators(); - $this->assertTrue(empty($decorators)); - } - - /** - * @group ZF-3217 - */ - public function testGroupShouldOverloadToRenderDecorators() - { - $foo = new Zend_Form_Element_Text('foo'); - $bar = new Zend_Form_Element_Text('bar'); - $this->group->addElements(array($foo, $bar)); - - $this->group->setView($this->getView()); - $html = $this->group->renderFormElements(); - foreach ($this->group->getElements() as $element) { - $this->assertContains('id="' . $element->getFullyQualifiedName() . '"', $html, 'Received: ' . $html); - } - $this->assertNotContains('<dl', $html); - $this->assertNotContains('<form', $html); - - $html = $this->group->renderFieldset('this is the content'); - $this->assertContains('<fieldset', $html); - $this->assertContains('</fieldset>', $html); - $this->assertContains('this is the content', $html); - } - - /** - * @group ZF-3217 - * @expectedException Zend_Form_Exception - */ - public function testOverloadingToInvalidMethodsShouldThrowAnException() - { - $html = $this->group->bogusMethodCall(); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -class Zend_Form_DisplayGroupTest_DisplayGroup extends Zend_Form_DisplayGroup -{ - public function init() - { - $this->setDisableLoadDefaultDecorators(true); - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_DisplayGroupTest::main') { - Zend_Form_DisplayGroupTest::main(); -} diff --git a/tests/Zend/Form/Element/AllTests.php b/tests/Zend/Form/Element/AllTests.php deleted file mode 100644 index 65bfe61ce09a81ee267211397eb473640bb640b5..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/AllTests.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_Element_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -// error_reporting(E_ALL); - -require_once 'Zend/Form/Element/ButtonTest.php'; -require_once 'Zend/Form/Element/CaptchaTest.php'; -require_once 'Zend/Form/Element/CheckboxTest.php'; -require_once 'Zend/Form/Element/FileTest.php'; -require_once 'Zend/Form/Element/HashTest.php'; -require_once 'Zend/Form/Element/HiddenTest.php'; -require_once 'Zend/Form/Element/ImageTest.php'; -require_once 'Zend/Form/Element/MultiCheckboxTest.php'; -require_once 'Zend/Form/Element/MultiselectTest.php'; -require_once 'Zend/Form/Element/PasswordTest.php'; -require_once 'Zend/Form/Element/RadioTest.php'; -require_once 'Zend/Form/Element/ResetTest.php'; -require_once 'Zend/Form/Element/SelectTest.php'; -require_once 'Zend/Form/Element/SubmitTest.php'; -require_once 'Zend/Form/Element/TextareaTest.php'; -require_once 'Zend/Form/Element/TextTest.php'; - -class Zend_Form_Element_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Form_Element'); - - $suite->addTestSuite('Zend_Form_Element_ButtonTest'); - $suite->addTestSuite('Zend_Form_Element_CaptchaTest'); - $suite->addTestSuite('Zend_Form_Element_CheckboxTest'); - $suite->addTestSuite('Zend_Form_Element_FileTest'); - $suite->addTestSuite('Zend_Form_Element_HashTest'); - $suite->addTestSuite('Zend_Form_Element_HiddenTest'); - $suite->addTestSuite('Zend_Form_Element_ImageTest'); - $suite->addTestSuite('Zend_Form_Element_MultiCheckboxTest'); - $suite->addTestSuite('Zend_Form_Element_MultiselectTest'); - $suite->addTestSuite('Zend_Form_Element_PasswordTest'); - $suite->addTestSuite('Zend_Form_Element_RadioTest'); - $suite->addTestSuite('Zend_Form_Element_ResetTest'); - $suite->addTestSuite('Zend_Form_Element_SelectTest'); - $suite->addTestSuite('Zend_Form_Element_SubmitTest'); - $suite->addTestSuite('Zend_Form_Element_TextareaTest'); - $suite->addTestSuite('Zend_Form_Element_TextTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_Element_AllTests::main') { - Zend_Form_Element_AllTests::main(); -} diff --git a/tests/Zend/Form/Element/ButtonTest.php b/tests/Zend/Form/Element/ButtonTest.php deleted file mode 100644 index 48a56e931f1f109d14ac07322ff55fdb8926cf08..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/ButtonTest.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php -// Call Zend_Form_Element_ButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_ButtonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Button.php'; -require_once 'Zend/Translate.php'; - -/** - * Test class for Zend_Form_Element_Button - */ -class Zend_Form_Element_ButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_ButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Button('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper/'); - return $view; - } - - public function testButtonElementSubclassesSubmitElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Submit); - } - - public function testButtonElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testButtonElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testHelperAttributeSetToFormButtonByDefault() - { - $this->assertEquals('formButton', $this->element->getAttrib('helper')); - } - - public function testButtonElementUsesButtonHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formButton', $helper); - } - - public function testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered() - { - $translations = include dirname(__FILE__) . '/../_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $this->element->setTranslator($translate) - ->setLabel('submit'); - $test = $this->element->getLabel(); - $this->assertEquals($translations['submit'], $test); - } - - public function testTranslatedLabelIsRendered() - { - $this->_checkZf2794(); - - $this->testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered(); - $this->element->setView($this->getView()); - $decorator = $this->element->getDecorator('ViewHelper'); - $decorator->setElement($this->element); - $html = $decorator->render(''); - $this->assertRegexp('/<(input|button)[^>]*?value="Submit Button"/', $html, $html); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_ButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_ButtonTest::main") { - Zend_Form_Element_ButtonTest::main(); -} diff --git a/tests/Zend/Form/Element/CaptchaTest.php b/tests/Zend/Form/Element/CaptchaTest.php deleted file mode 100644 index 68fe6ebf04a2c9946997cc7be0e8333e0d3e85d3..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/CaptchaTest.php +++ /dev/null @@ -1,192 +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_Form - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CaptchaTest.php 11031 2008-08-25 02:03:27Z matthew $ - */ - -// Call Zend_Form_Element_CaptchaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_CaptchaTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Form_Element_Captcha */ -require_once 'Zend/Form/Element/Captcha.php'; - -/** Zend_Captcha_Dumb */ -require_once 'Zend/Captcha/Dumb.php'; - -/** - * @category Zend - * @package Zend_Form - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Form_Element_CaptchaTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - // require_once 'PHPUnit/TextUI/TestRunner.php'; - - $suite = new PHPUnit_Framework_TestSuite('Zend_Form_Element_CaptchaTest'); - PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->element = new Zend_Form_Element_Captcha( - 'foo', - array( - 'captcha' => 'Dumb', - 'captchaOptions' => array( - 'sessionClass' => 'Zend_Form_Element_CaptchaTest_SessionContainer', - ), - ) - ); - } - - public function getCaptcha() - { - $captcha = new Zend_Captcha_Dumb(array( - 'sessionClass' => 'Zend_Form_Element_CaptchaTest_SessionContainer', - )); - return $captcha; - } - - /** - * @expectedException Zend_Form_Exception - */ - public function testConstructionShouldRequireCaptchaDetails() - { - $this->element = new Zend_Form_Element_Captcha('foo'); - } - - public function testShouldAllowSettingCaptcha() - { - $captcha = $this->getCaptcha(); - $this->assertNotSame($this->element->getCaptcha(), $captcha); - $this->element->setCaptcha($captcha); - $this->assertSame($captcha, $this->element->getCaptcha()); - } - - public function testShouldAllowAddingCaptchaPrefixPath() - { - $this->element->addPrefixPath('My_Captcha', 'My/Captcha/', 'captcha'); - $loader = $this->element->getPluginLoader('captcha'); - $paths = $loader->getPaths('My_Captcha'); - $this->assertTrue(is_array($paths)); - } - - public function testAddingNullPrefixPathShouldAddCaptchaPrefixPath() - { - $this->element->addPrefixPath('My', 'My'); - $loader = $this->element->getPluginLoader('captcha'); - $paths = $loader->getPaths('My_Captcha'); - $this->assertTrue(is_array($paths)); - } - - /** - * @see ZF-4038 - * @group ZF-4038 - */ - public function testCaptchaShouldRenderFullyQualifiedElementName() - { - require_once 'Zend/Form.php'; - require_once 'Zend/View.php'; - $form = new Zend_Form(); - $form->addElement($this->element) - ->setElementsBelongTo('bar'); - $html = $form->render(new Zend_View); - $this->assertContains('name="bar[foo', $html, $html); - $this->assertContains('id="bar-foo-', $html, $html); - $this->form = $form; - } - - /** - * @see ZF-4038 - * @group ZF-4038 - */ - public function testCaptchaShouldValidateUsingFullyQualifiedElementName() - { - $this->testCaptchaShouldRenderFullyQualifiedElementName(); - $word = $this->element->getCaptcha()->getWord(); - $id = $this->element->getCaptcha()->getId(); - $data = array( - 'bar' => array( - 'foo' => array( - 'id' => $id, - 'input' => $word, - ) - ) - ); - $valid = $this->form->isValid($data); - $this->assertTrue($valid, var_export($this->form->getMessages(), 1)); - } - -} - -class Zend_Form_Element_CaptchaTest_SessionContainer -{ - protected static $_word; - - public function __get($name) - { - if ('word' == $name) { - return self::$_word; - } - - return null; - } - - public function __set($name, $value) - { - if ('word' == $name) { - self::$_word = $value; - } else { - $this->$name = $value; - } - } - - public function __isset($name) - { - if (('word' == $name) && (null !== self::$_word)) { - return true; - } - - return false; - } - - public function __call($method, $args) - { - switch ($method) { - case 'setExpirationHops': - case 'setExpirationSeconds': - $this->$method = array_shift($args); - break; - default: - } - } -} - -// Call Zend_Form_Element_CaptchaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_CaptchaTest::main") { - Zend_Form_Element_CaptchaTest::main(); -} diff --git a/tests/Zend/Form/Element/CheckboxTest.php b/tests/Zend/Form/Element/CheckboxTest.php deleted file mode 100644 index b83cf9f012d26752048a67ee242cea65e21c213d..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/CheckboxTest.php +++ /dev/null @@ -1,236 +0,0 @@ -<?php -// Call Zend_Form_Element_CheckboxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_CheckboxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Checkbox.php'; - -/** - * Test class for Zend_Form_Element_Checkbox - */ -class Zend_Form_Element_CheckboxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_CheckboxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Checkbox('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - return new Zend_View(); - } - - public function testCheckboxElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testCheckboxElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testCheckboxElementUsesCheckboxHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formCheckbox', $helper); - } - - public function testCheckedFlagIsFalseByDefault() - { - $this->assertFalse($this->element->checked); - } - - public function testCheckedAttributeNotRenderedByDefault() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $html = $this->element->render($view); - $this->assertNotContains('checked="checked"', $html); - } - - public function testCheckedAttributeRenderedWhenCheckedFlagTrue() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $this->element->checked = true; - $html = $this->element->render($view); - $this->assertContains('checked="checked"', $html); - } - - public function testCheckedValueDefaultsToOne() - { - $this->assertEquals(1, $this->element->getCheckedValue()); - } - - public function testUncheckedValueDefaultsToZero() - { - $this->assertEquals(0, $this->element->getUncheckedValue()); - } - - public function testCanSetCheckedValue() - { - $this->testCheckedValueDefaultsToOne(); - $this->element->setCheckedValue('foo'); - $this->assertEquals('foo', $this->element->getCheckedValue()); - } - - public function testCanSetUncheckedValue() - { - $this->testUncheckedValueDefaultsToZero(); - $this->element->setUncheckedValue('foo'); - $this->assertEquals('foo', $this->element->getUncheckedValue()); - } - - public function testValueInitiallyUncheckedValue() - { - $this->assertEquals($this->element->getUncheckedValue(), $this->element->getValue()); - } - - public function testSettingValueToCheckedValueSetsWithEquivalentValue() - { - $this->testValueInitiallyUncheckedValue(); - $this->element->setValue($this->element->getCheckedValue()); - $this->assertEquals($this->element->getCheckedValue(), $this->element->getValue()); - } - - public function testSettingValueToAnythingOtherThanCheckedValueSetsAsUncheckedValue() - { - $this->testSettingValueToCheckedValueSetsWithEquivalentValue(); - $this->element->setValue('bogus'); - $this->assertEquals($this->element->getUncheckedValue(), $this->element->getValue()); - } - - public function testSettingCheckedFlagToTrueSetsValueToCheckedValue() - { - $this->testValueInitiallyUncheckedValue(); - $this->element->setChecked(true); - $this->assertEquals($this->element->getCheckedValue(), $this->element->getValue()); - } - - public function testSettingCheckedFlagToFalseSetsValueToUncheckedValue() - { - $this->testSettingCheckedFlagToTrueSetsValueToCheckedValue(); - $this->element->setChecked(false); - $this->assertEquals($this->element->getUncheckedValue(), $this->element->getValue()); - } - - public function testSettingValueToCheckedValueMarksElementAsChecked() - { - $this->testValueInitiallyUncheckedValue(); - $this->element->setValue($this->element->getCheckedValue()); - $this->assertTrue($this->element->checked); - } - - public function testSettingValueToUncheckedValueMarksElementAsNotChecked() - { - $this->testSettingValueToCheckedValueMarksElementAsChecked(); - $this->element->setValue($this->element->getUncheckedValue()); - $this->assertFalse($this->element->checked); - } - - public function testSetOptionsSetsInitialValueAccordingToCheckedAndUncheckedValues() - { - $options = array( - 'checkedValue' => 'foo', - 'uncheckedValue' => 'bar', - ); - - $element = new Zend_Form_Element_Checkbox('test', $options); - $this->assertEquals($options['uncheckedValue'], $element->getValue()); - } - - public function testSetOptionsSetsInitialValueAccordingToSubmittedValues() - { - $options = array( - 'test1' => array( - 'value' => 'foo', - 'checkedValue' => 'foo', - 'uncheckedValue' => 'bar', - ), - 'test2' => array( - 'value' => 'bar', - 'checkedValue' => 'foo', - 'uncheckedValue' => 'bar', - ), - ); - - foreach ($options as $current) { - $element = new Zend_Form_Element_Checkbox('test', $current); - $this->assertEquals($current['value'], $element->getValue()); - $this->assertEquals($current['checkedValue'], $element->getCheckedValue()); - $this->assertEquals($current['uncheckedValue'], $element->getUncheckedValue()); - } - } - - public function testCheckedValueAlwaysRenderedAsCheckboxValue() - { - $this->element->setValue($this->element->getUncheckedValue()); - $html = $this->element->render($this->getView()); - if (!preg_match_all('/(<input[^>]+>)/', $html, $matches)) { - $this->fail('Unexpected generated HTML: ' . $html); - } - $this->assertEquals(2, count($matches[1])); - foreach ($matches[1] as $element) { - if (strstr($element, 'hidden')) { - $this->assertContains($this->element->getUncheckedValue(), $element); - } else { - $this->assertContains($this->element->getCheckedValue(), $element); - } - } - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_CheckboxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_CheckboxTest::main") { - Zend_Form_Element_CheckboxTest::main(); -} diff --git a/tests/Zend/Form/Element/FileTest.php b/tests/Zend/Form/Element/FileTest.php deleted file mode 100644 index dc919adb3be9f39288a233e305fb1f67afbdeadb..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/FileTest.php +++ /dev/null @@ -1,301 +0,0 @@ -<?php -// Call Zend_Form_Element_FileTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_FileTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/File.php'; -require_once 'Zend/File/Transfer/Adapter/Abstract.php'; -require_once 'Zend/Validate/File/Upload.php'; -require_once 'Zend/Form/SubForm.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Element_File - */ -class Zend_Form_Element_FileTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_FileTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_File('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testElementShouldProxyToParentForDecoratorPluginLoader() - { - $loader = $this->element->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Form_Decorator'); - $this->assertTrue(is_array($paths)); - - $loader = new Zend_Loader_PluginLoader; - $this->element->setPluginLoader($loader, 'decorator'); - $test = $this->element->getPluginLoader('decorator'); - $this->assertSame($loader, $test); - } - - public function testElementShouldProxyToParentWhenSettingDecoratorPrefixPaths() - { - $this->element->addPrefixPath('Foo_Decorator', 'Foo/Decorator/', 'decorator'); - $loader = $this->element->getPluginLoader('decorator'); - $paths = $loader->getPaths('Foo_Decorator'); - $this->assertTrue(is_array($paths)); - } - - public function testElementShouldAddToAllPluginLoadersWhenAddingNullPrefixPath() - { - $this->element->addPrefixPath('Foo', 'Foo'); - foreach (array('validate', 'filter', 'decorator', 'transfer_adapter') as $type) { - $loader = $this->element->getPluginLoader($type); - $string = str_replace('_', ' ', $type); - $string = ucwords($string); - $string = str_replace(' ', '_', $string); - $prefix = 'Foo_' . $string; - $paths = $loader->getPaths($prefix); - $this->assertTrue(is_array($paths), "Failed asserting paths found for prefix $prefix"); - } - } - - public function testElementShouldUseHttpTransferAdapterByDefault() - { - $adapter = $this->element->getTransferAdapter(); - $this->assertTrue($adapter instanceof Zend_File_Transfer_Adapter_Http); - } - - public function testElementShouldAllowSpecifyingAdapterUsingConcreteInstance() - { - $adapter = new Zend_Form_Element_FileTest_MockAdapter(); - $this->element->setTransferAdapter($adapter); - $test = $this->element->getTransferAdapter(); - $this->assertSame($adapter, $test); - } - - /** - * @expectedException Zend_Form_Element_Exception - */ - public function testElementShouldThrowExceptionWhenAddingAdapterOfInvalidType() - { - $this->element->setTransferAdapter(new stdClass); - } - - public function testShouldRegisterPluginLoaderWithFileTransferAdapterPathByDefault() - { - $loader = $this->element->getPluginLoader('transfer_adapter'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader_Interface); - $paths = $loader->getPaths('Zend_File_Transfer_Adapter'); - $this->assertTrue(is_array($paths)); - } - - public function testElementShouldAllowSpecifyingAdapterUsingPluginLoader() - { - $this->element->addPrefixPath('Zend_Form_Element_FileTest_Adapter', dirname(__FILE__) . '/_files/TransferAdapter', 'transfer_adapter'); - $this->element->setTransferAdapter('Foo'); - $test = $this->element->getTransferAdapter(); - $this->assertTrue($test instanceof Zend_Form_Element_FileTest_Adapter_Foo); - } - - public function testValidatorAccessAndMutationShouldProxyToAdapter() - { - $this->testElementShouldAllowSpecifyingAdapterUsingConcreteInstance(); - $this->element->addValidator('Count', false, 1) - ->addValidators(array( - 'Extension' => 'jpg', - new Zend_Validate_File_Upload(), - )); - $validators = $this->element->getValidators(); - $test = $this->element->getTransferAdapter()->getValidators(); - $this->assertEquals($validators, $test); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test)); - - $validator = $this->element->getValidator('count'); - $test = $this->element->getTransferAdapter()->getValidator('count'); - $this->assertNotNull($validator); - $this->assertSame($validator, $test); - - $this->element->removeValidator('Extension'); - $this->assertFalse($this->element->getTransferAdapter()->hasValidator('Extension')); - - $this->element->setValidators(array( - 'Upload', - array('validator' => 'Extension', 'options' => 'jpg'), - array('validator' => 'Count', 'options' => 1), - )); - $validators = $this->element->getValidators(); - $test = $this->element->getTransferAdapter()->getValidators(); - $this->assertSame($validators, $test); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test), var_export($test, 1)); - - $this->element->clearValidators(); - $validators = $this->element->getValidators(); - $this->assertTrue(is_array($validators)); - $this->assertEquals(0, count($validators)); - $test = $this->element->getTransferAdapter()->getValidators(); - $this->assertSame($validators, $test); - } - - public function testValidationShouldProxyToAdapter() - { - $this->markTestIncomplete('Unsure how to accurately test'); - - $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter); - $this->element->addValidator('Regex', '/([a-z0-9]{13})$/i'); - $this->assertTrue($this->element->isValid('foo.jpg')); - } - - public function testDestinationMutatorsShouldProxyToTransferAdapter() - { - $this->element->setDestination(dirname(__FILE__)); - $this->assertEquals(dirname(__FILE__), $this->element->getDestination()); - $this->assertEquals(dirname(__FILE__), $this->element->getTransferAdapter()->getDestination('foo')); - } - - public function testSettingMultipleFiles() - { - $this->element->setMultiFile(3); - $this->assertEquals(3, $this->element->getMultiFile()); - } - - public function testFileInSubSubSubform() - { - $form = new Zend_Form(); - $element = new Zend_Form_Element_File('file1'); - $element2 = new Zend_Form_Element_File('file2'); - - $subform0 = new Zend_Form_SubForm(); - $subform0->addElement($element); - $subform0->addElement($element2); - $subform1 = new Zend_Form_SubForm(); - $subform1->addSubform($subform0, 'subform0'); - $subform2 = new Zend_Form_SubForm(); - $subform2->addSubform($subform1, 'subform1'); - $subform3 = new Zend_Form_SubForm(); - $subform3->addSubform($subform2, 'subform2'); - $form->addSubform($subform3, 'subform3'); - - $form->setView(new Zend_View()); - $output = (string) $form; - $this->assertContains('name="file1"', $output); - $this->assertContains('name="file2"', $output); - } - - public function testMultiFileInSubSubSubform() - { - $form = new Zend_Form(); - $element = new Zend_Form_Element_File('file'); - $element->setMultiFile(2); - - $subform0 = new Zend_Form_SubForm(); - $subform0->addElement($element); - $subform1 = new Zend_Form_SubForm(); - $subform1->addSubform($subform0, 'subform0'); - $subform2 = new Zend_Form_SubForm(); - $subform2->addSubform($subform1, 'subform1'); - $subform3 = new Zend_Form_SubForm(); - $subform3->addSubform($subform2, 'subform2'); - $form->addSubform($subform3, 'subform3'); - - $form->setView(new Zend_View()); - $output = (string) $form; - $this->assertContains('name="file[]"', $output); - $this->assertEquals(2, substr_count($output, 'file[]')); - } - - public function testSettingMaxFileSize() - { - $this->assertEquals(0, $this->element->getMaxFileSize()); - $this->element->setMaxFileSize(3000); - $this->assertEquals(3000, $this->element->getMaxFileSize()); - } -} - -class Zend_Form_Element_FileTest_MockAdapter extends Zend_File_Transfer_Adapter_Abstract -{ - public $received = false; - - public function __construct() - { - $this->_files = array( - 'foo' => array( - 'name' => 'foo.jpg', - 'type' => 'image/jpeg', - 'size' => 126976, - 'tmp_name' => '/tmp/489127ba5c89c', - 'validators' => array(), - ), - 'bar' => array( - 'name' => 'bar.png', - 'type' => 'image/png', - 'size' => 91136, - 'tmp_name' => '/tmp/489128284b51f', - 'validators' => array(), - ), - 'baz' => array( - 'name' => 'baz.text', - 'type' => 'text/plain', - 'size' => 1172, - 'tmp_name' => '/tmp/4891286cceff3', - 'validators' => array(), - ), - ); - } - - public function send($options = null) - { - return; - } - - public function receive($options = null) - { - $this->received = true; - return; - } - - public function isSent($file = null) - { - return false; - } - - public function isReceived($file = null) - { - return $this->received; - } - - public function getProgress() - { - return; - } -} - -// Call Zend_Form_Element_FileTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_FileTest::main") { - Zend_Form_Element_FileTest::main(); -} diff --git a/tests/Zend/Form/Element/HashTest.php b/tests/Zend/Form/Element/HashTest.php deleted file mode 100644 index ea8771f0757a8c64c65290311b0946eb02acf191..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/HashTest.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -// Call Zend_Form_Element_HashTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_HashTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Hash.php'; - -/** - * Test class for Zend_Form_Element_Hash - */ -class Zend_Form_Element_HashTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_HashTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (isset($this->hash)) { - unset($this->hash); - } - - $session = new Zend_Form_Element_HashTest_SessionContainer(); - $session->hash = null; - - $this->element = new Zend_Form_Element_Hash('foo', array( - 'session' => $session, - )); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testHashElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testHashElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testSaltPopulatedByDefault() - { - $salt = $this->element->getSalt(); - $this->assertFalse(empty($salt)); - } - - public function testCanSetSalt() - { - $salt = $this->element->getSalt(); - $this->element->setSalt('foobar'); - $this->assertNotEquals($salt, $this->element->getSalt()); - $this->assertEquals('foobar', $this->element->getSalt()); - } - - public function testTimeoutPopulatedByDefault() - { - $ttl = $this->element->getTimeout(); - $this->assertFalse(empty($ttl)); - $this->assertTrue(is_int($ttl)); - } - - public function testCanSetTimeout() - { - $ttl = $this->element->getTimeout(); - $this->element->setTimeout(3600); - $this->assertNotEquals($ttl, $this->element->getTimeout()); - $this->assertEquals(3600, $this->element->getTimeout()); - } - - public function testGetHashReturnsHashValue() - { - $hash = $this->element->getHash(); - $this->assertFalse(empty($hash)); - $this->assertTrue(is_string($hash)); - $this->hash = $hash; - } - - public function testGetHashSetsElementValueToHash() - { - $this->testGetHashReturnsHashValue(); - $this->assertEquals($this->hash, $this->element->getValue()); - } - - public function testHashIsMd5() - { - $this->testGetHashReturnsHashValue(); - $this->assertEquals(32, strlen($this->hash)); - $this->assertRegexp('/^[a-f0-9]{32}$/', $this->hash); - } - - public function testLabelIsNull() - { - $this->assertNull($this->element->getLabel()); - } - - public function testSessionNameContainsSaltAndName() - { - $sessionName = $this->element->getSessionName(); - $this->assertContains($this->element->getSalt(), $sessionName); - $this->assertContains($this->element->getName(), $sessionName); - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testValidatorTokenReceivesSessionHashWhenPresent() - { - $this->_checkZf2794(); - - $session = $this->element->getSession(); - $session->hash = $this->element->getHash(); - $element = new Zend_Form_Element_Hash('foo', array('session' => $session)); - $validator = $element->getValidator('Identical'); - $this->assertEquals($session->hash, $validator->getToken()); - } - - public function testRenderInitializesSessionHashToken() - { - $session = $this->element->getSession(); - $this->assertNull($session->hash); - $html = $this->element->render($this->getView()); - - $this->assertEquals($this->element->getHash(), $session->hash); - $this->assertEquals(1, $session->setExpirationHops); - $this->assertEquals($this->element->getTimeout(), $session->setExpirationSeconds); - } - - public function testHashTokenIsRendered() - { - $html = $this->element->render($this->getView()); - $this->assertContains($this->element->getHash(), $html); - } - - public function testHiddenInputRenderedByDefault() - { - $html = $this->element->render($this->getView()); - $this->assertRegexp('/<input[^>]*?type="hidden"/', $html, $html); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -class Zend_Form_Element_HashTest_SessionContainer -{ - protected static $_hash; - - public function __get($name) - { - if ('hash' == $name) { - return self::$_hash; - } - - return null; - } - - public function __set($name, $value) - { - if ('hash' == $name) { - self::$_hash = $value; - } else { - $this->$name = $value; - } - } - - public function __isset($name) - { - if (('hash' == $name) && (null !== self::$_hash)) { - return true; - } - - return false; - } - - public function __call($method, $args) - { - switch ($method) { - case 'setExpirationHops': - case 'setExpirationSeconds': - $this->$method = array_shift($args); - break; - default: - } - } -} - -// Call Zend_Form_Element_HashTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_HashTest::main") { - Zend_Form_Element_HashTest::main(); -} diff --git a/tests/Zend/Form/Element/HiddenTest.php b/tests/Zend/Form/Element/HiddenTest.php deleted file mode 100644 index 0b0ca1f43ffd2ca385fbbb2c4bef512516661594..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/HiddenTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -// Call Zend_Form_Element_HiddenTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_HiddenTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Element/Hidden.php'; - -/** - * Test class for Zend_Form_Element_Hidden - */ -class Zend_Form_Element_HiddenTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_HiddenTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Hidden('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testHiddenElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testHiddenElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testHiddenElementUsesHiddenHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formHidden', $helper); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_HiddenTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_HiddenTest::main") { - Zend_Form_Element_HiddenTest::main(); -} diff --git a/tests/Zend/Form/Element/ImageTest.php b/tests/Zend/Form/Element/ImageTest.php deleted file mode 100644 index 8a925cac6449113b39f14e37beec28cf5ec85fe3..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/ImageTest.php +++ /dev/null @@ -1,155 +0,0 @@ -<?php -// Call Zend_Form_Element_ImageTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_ImageTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Image.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Element_Image - */ -class Zend_Form_Element_ImageTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_ImageTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Image('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testImageElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testImageElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testImageElementUsesImageDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('Image'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Image); - } - - /** - * ZF-2717 - */ - public function testImageShouldSetHelperPropertyToFormImageByDefault() - { - $this->assertEquals('formImage', $this->element->helper); - } - - public function testImageSourceValueNullByDefault() - { - $this->assertNull($this->element->getImage()); - $this->assertNull($this->element->src); - } - - public function testCanSetImageSourceViaAccessors() - { - $this->element->setImage('foo.gif'); - $this->assertEquals('foo.gif', $this->element->getImage()); - $this->assertEquals('foo.gif', $this->element->src); - } - - public function testImageSourceUsedWhenRenderingImage() - { - $this->testCanSetImageSourceViaAccessors(); - $html = $this->element->render(new Zend_View()); - $this->assertContains('src="foo.gif"', $html); - } - - public function testHelperAttributeNotRenderedWhenRenderingImage() - { - $this->testCanSetImageSourceViaAccessors(); - $html = $this->element->render(new Zend_View()); - $this->assertNotContains('helper="', $html); - } - - public function testValueEmptyWhenRenderingImageByDefault() - { - $this->testCanSetImageSourceViaAccessors(); - $html = $this->element->render(new Zend_View()); - if (!strstr($html, 'value="')) { - return; - } - $this->assertContains('value=""', $html); - } - - public function testLabelUsedAsAltAttribute() - { - $this->element->setLabel('Foo Bar'); - $html = $this->element->render(new Zend_View()); - $this->assertRegexp('#<input[^>]*alt="Foo Bar"#', $html); - } - - public function testImageValueRenderedAsElementValue() - { - $this->element->setImageValue('foo') - ->setImage('foo.gif'); - $html = $this->element->render(new Zend_View()); - $this->assertRegexp('#<input[^>]*value="foo"#', $html, $html); - } - - public function testIsCheckedReturnsSetValueMatchesImageValue() - { - $this->assertFalse($this->element->isChecked()); - $this->element->setImageValue('foo'); - $this->assertFalse($this->element->isChecked()); - $this->element->setValue('foo'); - $this->assertTrue($this->element->isChecked()); - $this->element->setValue('bar'); - $this->assertFalse($this->element->isChecked()); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_ImageTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_ImageTest::main") { - Zend_Form_Element_ImageTest::main(); -} diff --git a/tests/Zend/Form/Element/MultiCheckboxTest.php b/tests/Zend/Form/Element/MultiCheckboxTest.php deleted file mode 100644 index 90535033f66622d022c429485494337d201f68b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/MultiCheckboxTest.php +++ /dev/null @@ -1,243 +0,0 @@ -<?php -// Call Zend_Form_Element_MultiCheckboxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_MultiCheckboxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/MultiCheckbox.php'; - -/** - * Test class for Zend_Form_Element_MultiCheckbox - */ -class Zend_Form_Element_MultiCheckboxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_MultiCheckboxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_MultiCheckbox('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testMultiCheckboxElementSubclassesMultiElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Multi); - } - - public function testMultiCheckboxElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testMultiCheckboxElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testMultiCheckboxElementIsAnArrayByDefault() - { - $this->assertTrue($this->element->isArray()); - } - - public function testHelperAttributeSetToFormMultiCheckboxByDefault() - { - $this->assertEquals('formMultiCheckbox', $this->element->getAttrib('helper')); - } - - public function testMultiCheckboxElementUsesMultiCheckboxHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formMultiCheckbox', $helper); - } - - public function testCanDisableIndividualMultiCheckboxOptions() - { - $this->element->setMultiOptions(array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz', - 'bat' => 'Bat', - 'test' => 'Test', - )) - ->setAttrib('disable', array('baz', 'test')); - $html = $this->element->render($this->getView()); - foreach (array('baz', 'test') as $test) { - if (!preg_match('/(<input[^>]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { - $this->fail('Unable to find matching disabled option for ' . $test); - } - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $m[1]); - } - foreach (array('foo', 'bar', 'bat') as $test) { - if (!preg_match('/(<input[^>]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { - $this->fail('Unable to find matching option for ' . $test); - } - $this->assertNotRegexp('/<input[^>]*?(disabled="disabled")/', $m[1], var_export($m, 1)); - } - } - - public function testSpecifiedSeparatorIsUsedWhenRendering() - { - $this->element->setMultiOptions(array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz', - 'bat' => 'Bat', - 'test' => 'Test', - )) - ->setSeparator('--FooBarFunSep--'); - $html = $this->element->render($this->getView()); - $this->assertContains($this->element->getSeparator(), $html); - $count = substr_count($html, $this->element->getSeparator()); - $this->assertEquals(4, $count); - } - - /** - * @see ZF-2830 - */ - public function testRenderingMulticheckboxCreatesCorrectArrayNotation() - { - $this->element->addMultiOption(1, 'A'); - $this->element->addMultiOption(2, 'B'); - $html = $this->element->render($this->getView()); - $this->assertContains('name="foo[]"', $html, $html); - $count = substr_count($html, 'name="foo[]"'); - $this->assertEquals(2, $count); - } - - /** - * @see ZF-2828 - */ - public function testCanPopulateCheckboxOptionsFromPostedData() - { - $form = new Zend_Form(array( - 'elements' => array( - '100_1' => array('MultiCheckbox', array( - 'multiOptions' => array( - '100_1_1' => 'Agriculture', - '100_1_2' => 'Automotive', - '100_1_12' => 'Chemical', - '100_1_13' => 'Communications', - ), - 'required' => true, - )), - ), - )); - $data = array( - '100_1' => array( - '100_1_1', - '100_1_2', - '100_1_12', - '100_1_13' - ), - ); - $form->populate($data); - $html = $form->render($this->getView()); - foreach ($form->getElement('100_1')->getMultiOptions() as $key => $value) { - if (!preg_match('#(<input[^>]*' . $key . '[^>]*>)#', $html, $m)) { - $this->fail('Missing input for a given multi option: ' . $html); - } - $this->assertContains('checked="checked"', $m[1]); - } - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } - - /**#+ - * @see ZF-3286 - */ - public function testShouldRegisterInArrayValidatorByDefault() - { - $this->assertTrue($this->element->registerInArrayValidator()); - } - - public function testShouldAllowSpecifyingWhetherOrNotToUseInArrayValidator() - { - $this->testShouldRegisterInArrayValidatorByDefault(); - $this->element->setRegisterInArrayValidator(false); - $this->assertFalse($this->element->registerInArrayValidator()); - $this->element->setRegisterInArrayValidator(true); - $this->assertTrue($this->element->registerInArrayValidator()); - } - - public function testInArrayValidatorShouldBeRegisteredAfterValidation() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->assertFalse($this->element->getValidator('InArray')); - $this->element->isValid('test'); - $validator = $this->element->getValidator('InArray'); - $this->assertTrue($validator instanceof Zend_Validate_InArray); - } - - public function testShouldNotValidateIfValueIsNotInArray() - { - $options = array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - ); - $this->element->setMultiOptions($options); - $this->assertFalse($this->element->getValidator('InArray')); - $this->assertFalse($this->element->isValid('test')); - } - /**#@-*/ -} - -// Call Zend_Form_Element_MultiCheckboxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_MultiCheckboxTest::main") { - Zend_Form_Element_MultiCheckboxTest::main(); -} diff --git a/tests/Zend/Form/Element/MultiselectTest.php b/tests/Zend/Form/Element/MultiselectTest.php deleted file mode 100644 index 1275ac38392286b8972bad2a4143268dc77d0050..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/MultiselectTest.php +++ /dev/null @@ -1,279 +0,0 @@ -<?php -// Call Zend_Form_Element_MultiselectTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_MultiselectTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Multiselect.php'; -require_once 'Zend/Translate.php'; - -/** - * Test class for Zend_Form_Element_Multiselect - */ -class Zend_Form_Element_MultiselectTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_MultiselectTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Multiselect('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper/'); - return $view; - } - - public function testMultiselectElementInstanceOfMultiElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Multi); - } - - public function testMultiselectElementInstanceOfXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testMultiselectElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testMultiselectElementIsAnArrayByDefault() - { - $this->assertTrue($this->element->isArray()); - } - - public function testMultiselectElementUsesSelectHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formSelect', $helper); - } - - public function testMultipleOptionSetByDefault() - { - $this->assertNotNull($this->element->multiple); - $this->assertEquals('multiple', $this->element->multiple); - } - - public function testHasDefaultSeparator() - { - $this->assertEquals('<br />', $this->element->getSeparator()); - } - - public function testCanSetSeparator() - { - $this->testHasDefaultSeparator(); - $this->element->setSeparator("\n"); - $this->assertEquals("\n", $this->element->getSeparator()); - } - - public function testMultiOptionsEmptyByDefault() - { - $options = $this->element->getMultiOptions(); - $this->assertTrue(is_array($options)); - $this->assertTrue(empty($options)); - } - - public function testCanSetMultiOptions() - { - $this->testMultiOptionsEmptyByDefault(); - $this->element->addMultiOption('foo', 'foovalue'); - $this->assertEquals('foovalue', $this->element->getMultiOption('foo')); - $this->element->setMultiOptions(array('bar' => 'barvalue', 'baz' => 'bazvalue')); - $this->assertEquals(array('bar' => 'barvalue', 'baz' => 'bazvalue'), $this->element->getMultiOptions()); - $this->element->addMultiOptions(array('bat' => 'batvalue', 'foo' => 'foovalue')); - $this->assertEquals(array('bar' => 'barvalue', 'baz' => 'bazvalue', 'bat' => 'batvalue', 'foo' => 'foovalue'), $this->element->getMultiOptions()); - $this->element->addMultiOption('test', 'testvalue'); - $this->assertEquals(array('bar' => 'barvalue', 'baz' => 'bazvalue', 'bat' => 'batvalue', 'foo' => 'foovalue', 'test' => 'testvalue'), $this->element->getMultiOptions()); - } - - /** - * @see ZF-2824 - */ - public function testCanSetMultiOptionsUsingAssocArraysWithKeyValueKeys() - { - $options = array( - array( - 'value' => '1', - 'key' => 'aa', - ), - array ( - 'key' => '2', - 'value' => 'xxxx', - ), - array ( - 'value' => '444', - 'key' => 'ssss', - ), - ); - $this->element->addMultiOptions($options); - $this->assertEquals($options[0]['value'], $this->element->getMultiOption('aa')); - $this->assertEquals($options[1]['value'], $this->element->getMultiOption(2)); - $this->assertEquals($options[2]['value'], $this->element->getMultiOption('ssss')); - } - - /** - * @see ZF-2824 - */ - public function testCanSetMultiOptionsUsingConfigWithKeyValueKeys() - { - require_once 'Zend/Config/Xml.php'; - $config = new Zend_Config_Xml(dirname(__FILE__) . '/../_files/config/multiOptions.xml', 'testing'); - $this->element->setMultiOptions($config->options->toArray()); - $this->assertEquals($config->options->first->value, $this->element->getMultiOption('aa')); - $this->assertEquals($config->options->second->value, $this->element->getMultiOption(2)); - $this->assertEquals($config->options->third->value, $this->element->getMultiOption('ssss')); - - require_once 'Zend/Config/Ini.php'; - $config = new Zend_Config_Ini(dirname(__FILE__) . '/../_files/config/multiOptions.ini', 'testing'); - $this->element->setMultiOptions($config->options->toArray()); - $this->assertEquals($config->options->first->value, $this->element->getMultiOption('aa')); - $this->assertEquals($config->options->second->value, $this->element->getMultiOption(2)); - $this->assertEquals($config->options->third->value, $this->element->getMultiOption('ssss')); - - } - - public function testCanRemoveMultiOption() - { - $this->testMultiOptionsEmptyByDefault(); - $this->element->addMultiOption('foo', 'foovalue'); - $this->assertEquals('foovalue', $this->element->getMultiOption('foo')); - $this->element->removeMultiOption('foo'); - $this->assertNull($this->element->getMultiOption('foo')); - } - - public function testOptionsAreRenderedInFinalMarkup() - { - $options = array( - 'foovalue' => 'Foo', - 'barvalue' => 'Bar' - ); - $this->element->addMultiOptions($options); - $html = $this->element->render($this->getView()); - foreach ($options as $value => $label) { - $this->assertRegexp('/<option.*value="' . $value . '"[^>]*>' . $label . '/s', $html, $html); - } - } - - public function testTranslatedOptionsAreRenderedInFinalMarkupWhenTranslatorPresent() - { - $translations = array( - 'ThisShouldNotShow' => 'Foo Value', - 'ThisShouldNeverShow' => 'Bar Value' - ); - require_once 'Zend/Translate.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $options = array( - 'foovalue' => 'ThisShouldNotShow', - 'barvalue' => 'ThisShouldNeverShow' - ); - - $this->element->setTranslator($translate) - ->addMultiOptions($options); - - $html = $this->element->render($this->getView()); - foreach ($options as $value => $label) { - $this->assertNotContains($label, $html, $html); - $this->assertRegexp('/<option.*value="' . $value . '"[^>]*>' . $translations[$label] . '/s', $html, $html); - } - } - - public function testOptionLabelsAreTranslatedWhenTranslateAdapterIsPresent() - { - $translations = include dirname(__FILE__) . '/../_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $options = array( - 'foovalue' => 'Foo', - 'barvalue' => 'Bar' - ); - $this->element->addMultiOptions($options) - ->setTranslator($translate); - $test = $this->element->getMultiOption('barvalue'); - $this->assertEquals($translations[$options['barvalue']], $test); - - $test = $this->element->getMultiOptions(); - foreach ($test as $key => $value) { - $this->assertEquals($translations[$options[$key]], $value); - } - } - - public function testOptionLabelsAreUntouchedIfTranslatonDoesNotExistInnTranslateAdapter() - { - $translations = include dirname(__FILE__) . '/../_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $options = array( - 'foovalue' => 'Foo', - 'barvalue' => 'Bar', - 'testing' => 'Test Value', - ); - $this->element->addMultiOptions($options) - ->setTranslator($translate); - $test = $this->element->getMultiOption('testing'); - $this->assertEquals($options['testing'], $test); - } - - public function testMultiselectIsArrayByDefault() - { - $this->assertTrue($this->element->isArray()); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_MultiselectTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_MultiselectTest::main") { - Zend_Form_Element_MultiselectTest::main(); -} diff --git a/tests/Zend/Form/Element/PasswordTest.php b/tests/Zend/Form/Element/PasswordTest.php deleted file mode 100644 index 70c692feae3c09151911e12792bf823fa2095bc0..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/PasswordTest.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php -// Call Zend_Form_Element_PasswordTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_PasswordTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Element/Password.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Form_Element_Password - */ -class Zend_Form_Element_PasswordTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_PasswordTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->errors = array(); - $this->element = new Zend_Form_Element_Password('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testPasswordElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testPasswordElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testHelperAttributeSetToFormPasswordByDefault() - { - $this->assertEquals('formPassword', $this->element->getAttrib('helper')); - } - - public function testPasswordElementUsesPasswordHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formPassword', $helper); - } - - public function testPasswordValueMaskedByGetMessages() - { - $this->element->addValidators(array( - 'Alpha', - 'Alnum' - )); - $value = 'abc-123'; - $expect = '*******'; - $this->assertFalse($this->element->isValid($value)); - foreach ($this->element->getMessages() as $message) { - $this->assertNotContains($value, $message); - $this->assertContains($expect, $message, $message); - } - } - - public function handleErrors($errno, $errmsg, $errfile, $errline, $errcontext) - { - if (!isset($this->errors)) { - $this->errors = array(); - } - $this->errors[] = $errmsg; - } - - /** - * ZF-2656 - */ - public function testGetMessagesReturnsEmptyArrayWhenNoMessagesRegistered() - { - set_error_handler(array($this, 'handleErrors')); - $messages = $this->element->getMessages(); - restore_error_handler(); - $this->assertSame(array(), $messages); - $this->assertTrue(empty($this->errors)); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } - - public function testRenderPasswordAttributeShouldDefaultToFalse() - { - $this->assertFalse($this->element->renderPassword()); - } - - public function testShouldAllowSettingRenderPasswordFlag() - { - $this->testRenderPasswordAttributeShouldDefaultToFalse(); - $this->element->setRenderPassword(true); - $this->assertTrue($this->element->renderPassword()); - $this->element->setRenderPassword(false); - $this->assertFalse($this->element->renderPassword()); - } - - public function testShouldPassRenderPasswordAttributeToViewHelper() - { - $this->element->setValue('foobar') - ->setView(new Zend_View()); - $test = $this->element->render(); - $this->assertContains('value=""', $test); - - $this->element->setRenderPassword(true); - $test = $this->element->render(); - $this->assertContains('value="foobar"', $test); - } -} - -// Call Zend_Form_Element_PasswordTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_PasswordTest::main") { - Zend_Form_Element_PasswordTest::main(); -} diff --git a/tests/Zend/Form/Element/RadioTest.php b/tests/Zend/Form/Element/RadioTest.php deleted file mode 100644 index f0a8b0d2b078ddd72e205f973adba3e6ccb5c823..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/RadioTest.php +++ /dev/null @@ -1,163 +0,0 @@ -<?php -// Call Zend_Form_Element_RadioTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_RadioTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Radio.php'; - -/** - * Test class for Zend_Form_Element_Radio - */ -class Zend_Form_Element_RadioTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_RadioTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Radio('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testRadioElementSubclassesMultiElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Multi); - } - - public function testRadioElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testRadioElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testRadioElementIsNotAnArrayByDefault() - { - $this->assertFalse($this->element->isArray()); - } - - public function testHelperAttributeSetToFormRadioByDefault() - { - $this->assertEquals('formRadio', $this->element->getAttrib('helper')); - } - - public function testRadioElementUsesRadioHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formRadio', $helper); - } - - public function testCanDisableIndividualRadioOptions() - { - $this->element->setMultiOptions(array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz', - 'bat' => 'Bat', - 'test' => 'Test', - )) - ->setAttrib('disable', array('baz', 'test')); - $html = $this->element->render($this->getView()); - foreach (array('baz', 'test') as $test) { - if (!preg_match('/(<input[^>]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { - $this->fail('Unable to find matching disabled option for ' . $test); - } - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $m[1]); - } - foreach (array('foo', 'bar', 'bat') as $test) { - if (!preg_match('/(<input[^>]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { - $this->fail('Unable to find matching option for ' . $test); - } - $this->assertNotRegexp('/<input[^>]*?(disabled="disabled")/', $m[1], var_export($m, 1)); - } - } - - public function testSpecifiedSeparatorIsUsedWhenRendering() - { - $this->element->setMultiOptions(array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz', - 'bat' => 'Bat', - 'test' => 'Test', - )) - ->setSeparator('--FooBarFunSep--'); - $html = $this->element->render($this->getView()); - $this->assertContains($this->element->getSeparator(), $html); - $count = substr_count($html, $this->element->getSeparator()); - $this->assertEquals(4, $count); - } - - public function testRadioElementRendersDtDdWrapper() - { - $this->element->setMultiOptions(array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz', - 'bat' => 'Bat', - 'test' => 'Test', - )); - $html = $this->element->render($this->getView()); - $this->assertRegexp('#<dt> </dt>.*?<dd#s', $html, $html); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_RadioTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_RadioTest::main") { - Zend_Form_Element_RadioTest::main(); -} diff --git a/tests/Zend/Form/Element/ResetTest.php b/tests/Zend/Form/Element/ResetTest.php deleted file mode 100644 index e931b891d5a89ab83a40d6c094acb2fbb214f558..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/ResetTest.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php -// Call Zend_Form_Element_ResetTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_ResetTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Element/Reset.php'; - -/** - * Test class for Zend_Form_Element_Reset - */ -class Zend_Form_Element_ResetTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_ResetTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Reset('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testResetElementSubclassesSubmitElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Submit); - } - - public function testResetElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testResetElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testResetElementUsesResetHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formReset', $helper); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_ResetTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_ResetTest::main") { - Zend_Form_Element_ResetTest::main(); -} diff --git a/tests/Zend/Form/Element/SelectTest.php b/tests/Zend/Form/Element/SelectTest.php deleted file mode 100644 index 7309e09be54087593c0b8ec58cacc74b8f6f158c..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/SelectTest.php +++ /dev/null @@ -1,173 +0,0 @@ -<?php -// Call Zend_Form_Element_SelectTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_SelectTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Form/Element/Select.php'; - -/** - * Test class for Zend_Form_Element_Select - */ -class Zend_Form_Element_SelectTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_SelectTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Select('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); - return $view; - } - - public function testSelectElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testSelectElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testSelectElementIsNotAnArrayByDefault() - { - $this->assertFalse($this->element->isArray()); - } - - public function testSelectElementUsesSelectHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formSelect', $helper); - } - - public function testCanDisableIndividualSelectOptions() - { - $this->element->setMultiOptions(array( - 'foo' => 'foo', - 'bar' => array( - 'baz' => 'Baz', - 'bat' => 'Bat' - ), - 'test' => 'Test', - )) - ->setAttrib('disable', array('baz', 'test')); - $html = $this->element->render($this->getView()); - $this->assertNotRegexp('/<select[^>]*?(disabled="disabled")/', $html, $html); - foreach (array('baz', 'test') as $test) { - if (!preg_match('/(<option[^>]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { - $this->fail('Unable to find matching disabled option for ' . $test); - } - $this->assertRegexp('/<option[^>]*?(disabled="disabled")/', $m[1]); - } - foreach (array('foo', 'bat') as $test) { - if (!preg_match('/(<option[^>]*?(value="' . $test . '")[^>]*>)/', $html, $m)) { - $this->fail('Unable to find matching option for ' . $test); - } - $this->assertNotRegexp('/<option[^>]*?(disabled="disabled")/', $m[1], var_export($m, 1)); - } - } - - /** - * No explicit assertions; just checking for error conditions - * - * @see ZF-2847 - */ - public function testTranslationShouldNotRaiseWarningsWithNestedGroups() - { - require_once 'Zend/Translate.php'; - require_once 'Zend/View.php'; - $translate = new Zend_Translate('array', array('Select Test', 'Select Test Translated'), 'en'); - $this->element - ->setLabel('Select Test') - ->setMultiOptions(array( - 'Group 1' => array( - '1-1' => 'Hi 1-1', - '1-2' => 'Hi 1-2', - ), - 'Group 2' => array( - '2-1' => 'Hi 2-1', - '2-2' => 'Hi 2-2', - ), - )) - ->setTranslator($translate) - ->setView(new Zend_View()); - $html = $this->element->render(); - } - - /** - * @see ZF-3953 - * @group ZF-3953 - */ - public function testUsingZeroAsValueShouldSelectAppropriateOption() - { - $this->element->setMultiOptions(array( - array('key' => '1', 'value' => 'Yes'), - array('key' => '0', 'value' => 'No'), - array('key' => 'somewhat', 'value' => 'Somewhat'), - )); - $this->element->setValue(0); - $html = $this->element->render($this->getView()); - - if (!preg_match('#(<option[^>]*(?:value="somewhat")[^>]*>)#s', $html, $matches)) { - $this->fail('Could not find option: ' . $html); - } - $this->assertNotContains('selected', $matches[1]); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_SelectTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_SelectTest::main") { - Zend_Form_Element_SelectTest::main(); -} diff --git a/tests/Zend/Form/Element/SubmitTest.php b/tests/Zend/Form/Element/SubmitTest.php deleted file mode 100644 index c2ca346030aef35acdc0549e43314283c55feb73..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/SubmitTest.php +++ /dev/null @@ -1,170 +0,0 @@ -<?php -// Call Zend_Form_Element_SubmitTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_SubmitTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Element/Submit.php'; -require_once 'Zend/Translate.php'; - -/** - * Test class for Zend_Form_Element_Submit - */ -class Zend_Form_Element_SubmitTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_SubmitTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Submit('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function getView() - { - require_once 'Zend/View.php'; - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper/'); - return $view; - } - - public function testSubmitElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testSubmitElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testSubmitElementUsesViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - } - - public function testSubmitElementSpecifiesFormSubmitAsDefaultHelper() - { - $this->assertEquals('formSubmit', $this->element->helper); - } - - public function testGetLabelReturnsNameIfNoValuePresent() - { - $this->assertEquals($this->element->getName(), $this->element->getLabel()); - } - - public function testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered() - { - $translations = include dirname(__FILE__) . '/../_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $this->element->setTranslator($translate) - ->setLabel('submit'); - $test = $this->element->getLabel(); - $this->assertEquals($translations['submit'], $test); - } - - public function testTranslatedLabelIsRendered() - { - $this->_checkZf2794(); - - $this->testGetLabelReturnsTranslatedLabelIfTranslatorIsRegistered(); - $this->element->setView($this->getView()); - $decorator = $this->element->getDecorator('ViewHelper'); - $decorator->setElement($this->element); - $html = $decorator->render(''); - $this->assertRegexp('/<(input|button)[^>]*?value="Submit Button"/', $html); - } - - public function testConstructorSetsLabelToNameIfNoLabelProvided() - { - $submit = new Zend_Form_Element_Submit('foo'); - $this->assertEquals('foo', $submit->getName()); - $this->assertEquals('foo', $submit->getLabel()); - } - - public function testCanPassLabelAsParameterToConstructor() - { - $submit = new Zend_Form_Element_Submit('foo', 'Label'); - $this->assertEquals('Label', $submit->getLabel()); - } - - public function testLabelIsTranslatedWhenTranslationAvailable() - { - require_once 'Zend/Translate.php'; - $translations = array('Label' => 'This is the Submit Label'); - $translate = new Zend_Translate('array', $translations); - $submit = new Zend_Form_Element_Submit('foo', 'Label'); - $submit->setTranslator($translate); - $this->assertEquals($translations['Label'], $submit->getLabel()); - } - - public function testIsCheckedReturnsFalseWhenNoValuePresent() - { - $this->assertFalse($this->element->isChecked()); - } - - public function testIsCheckedReturnsFalseWhenValuePresentButDoesNotMatchLabel() - { - $this->assertFalse($this->element->isChecked()); - $this->element->setValue('bar'); - $this->assertFalse($this->element->isChecked()); - } - - public function testIsCheckedReturnsTrueWhenValuePresentAndMatchesLabel() - { - $this->testIsCheckedReturnsFalseWhenNoValuePresent(); - $this->element->setValue('foo'); - $this->assertTrue($this->element->isChecked()); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_SubmitTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_SubmitTest::main") { - Zend_Form_Element_SubmitTest::main(); -} diff --git a/tests/Zend/Form/Element/TextTest.php b/tests/Zend/Form/Element/TextTest.php deleted file mode 100644 index 8c531b3c4d74550d2ba463461f883e8707c7857e..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/TextTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -// Call Zend_Form_Element_TextTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_TextTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Element/Text.php'; - -/** - * Test class for Zend_Form_Element_Text - */ -class Zend_Form_Element_TextTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_TextTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Text('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testTextElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testTextElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testTextElementUsesTextHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formText', $helper); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_TextTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_TextTest::main") { - Zend_Form_Element_TextTest::main(); -} diff --git a/tests/Zend/Form/Element/TextareaTest.php b/tests/Zend/Form/Element/TextareaTest.php deleted file mode 100644 index 7557fb91a4278126222982d7094e86feabb82b92..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/TextareaTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -// Call Zend_Form_Element_TextareaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_TextareaTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Form/Element/Textarea.php'; - -/** - * Test class for Zend_Form_Element_Textarea - */ -class Zend_Form_Element_TextareaTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_TextareaTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->element = new Zend_Form_Element_Textarea('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testTextareaElementSubclassesXhtmlElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml); - } - - public function testTextareaElementInstanceOfBaseElement() - { - $this->assertTrue($this->element instanceof Zend_Form_Element); - } - - public function testTextareaElementUsesTextareaHelperInViewHelperDecoratorByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator->setElement($this->element); - $helper = $decorator->getHelper(); - $this->assertEquals('formTextarea', $helper); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -// Call Zend_Form_Element_TextareaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_TextareaTest::main") { - Zend_Form_Element_TextareaTest::main(); -} diff --git a/tests/Zend/Form/Element/_files/TransferAdapter/Foo.php b/tests/Zend/Form/Element/_files/TransferAdapter/Foo.php deleted file mode 100644 index 2da0ccd6cc7a58aa4329e2f1abf3fafa62a0f251..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/Element/_files/TransferAdapter/Foo.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -class Zend_Form_Element_FileTest_Adapter_Foo extends Zend_File_Transfer_Adapter_Abstract -{ - public $received = false; - - public function send($options = null) - { - return; - } - - public function receive($options = null) - { - $this->received = true; - return; - } - - public function isSent($file = null) - { - return false; - } - - public function isReceived($file = null) - { - return $this->received; - } - - public function getProgress() - { - return; - } -} diff --git a/tests/Zend/Form/ElementTest.php b/tests/Zend/Form/ElementTest.php deleted file mode 100644 index 6edaca535081229d78e34a487141229e7bed3818..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/ElementTest.php +++ /dev/null @@ -1,1947 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_ElementTest::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -// error_reporting(E_ALL); - -require_once 'Zend/Form/Element.php'; - -require_once 'Zend/Config.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Form.php'; -require_once 'Zend/Form/Decorator/Abstract.php'; -require_once 'Zend/Form/Decorator/HtmlTag.php'; -require_once 'Zend/Loader/PluginLoader.php'; -require_once 'Zend/Translate.php'; -require_once 'Zend/Validate/NotEmpty.php'; -require_once 'Zend/Validate/EmailAddress.php'; -require_once 'Zend/View.php'; - -class Zend_Form_ElementTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite('Zend_Form_ElementTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - Zend_Form::setDefaultTranslator(null); - - if (isset($this->error)) { - unset($this->error); - } - - $this->element = new Zend_Form_Element('foo'); - Zend_Controller_Action_HelperBroker::resetHelpers(); - } - - public function tearDown() - { - } - - public function getView() - { - $view = new Zend_View(); - $libPath = dirname(__FILE__) . '/../../../library'; - $view->addHelperPath($libPath . '/Zend/View/Helper'); - return $view; - } - - public function testConstructorRequiresMinimallyElementName() - { - try { - $element = new Zend_Form_Element(1); - $this->fail('Zend_Form_Element constructor should not accept integer argument'); - } catch (Zend_Form_Exception $e) { - } - try { - $element = new Zend_Form_Element(true); - $this->fail('Zend_Form_Element constructor should not accept boolean argument'); - } catch (Zend_Form_Exception $e) { - } - - try { - $element = new Zend_Form_Element('foo'); - } catch (Exception $e) { - $this->fail('Zend_Form_Element constructor should accept String values'); - } - - $config = array('foo' => 'bar'); - try { - $element = new Zend_Form_Element($config); - $this->fail('Zend_Form_Element constructor requires array with name element'); - } catch (Zend_Form_Exception $e) { - } - - $config = array('name' => 'bar'); - try { - $element = new Zend_Form_Element($config); - } catch (Zend_Form_Exception $e) { - $this->fail('Zend_Form_Element constructor should accept array with name element'); - } - - $config = new Zend_Config(array('foo' => 'bar')); - try { - $element = new Zend_Form_Element($config); - $this->fail('Zend_Form_Element constructor requires Zend_Config object with name element'); - } catch (Zend_Form_Exception $e) { - } - - $config = new Zend_Config(array('name' => 'bar')); - try { - $element = new Zend_Form_Element($config); - } catch (Zend_Form_Exception $e) { - $this->fail('Zend_Form_Element constructor should accept Zend_Config with name element'); - } - } - - public function testNoTranslatorByDefault() - { - $this->assertNull($this->element->getTranslator()); - } - - public function testGetTranslatorRetrievesGlobalDefaultWhenAvailable() - { - $this->testNoTranslatorByDefault(); - $translator = new Zend_Translate('array', array('foo' => 'bar')); - Zend_Form::setDefaultTranslator($translator); - $received = $this->element->getTranslator(); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testTranslatorAccessorsWork() - { - $translator = new Zend_Translate('array', array('foo' => 'bar')); - $this->element->setTranslator($translator); - $received = $this->element->getTranslator($translator); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testCanDisableTranslation() - { - $this->testGetTranslatorRetrievesGlobalDefaultWhenAvailable(); - $this->element->setDisableTranslator(true); - $this->assertNull($this->element->getTranslator()); - } - - public function testSetNameNormalizesValueToContainOnlyValidVariableCharacters() - { - $this->element->setName('f%\o^&*)o\(%$b#@!.a}{;-,r'); - $this->assertEquals('foobar', $this->element->getName()); - - try { - $this->element->setName('%\^&*)\(%$#@!.}{;-,'); - $this->fail('Empty names should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid name provided', $e->getMessage()); - } - } - - public function testZeroIsAllowedAsElementName() - { - try { - $this->element->setName(0); - $this->assertSame('0', $this->element->getName()); - } catch (Zend_Form_Exception $e) { - $this->fail('Should allow zero as element name'); - } - } - - /** - * @see ZF-2851 - */ - public function testSetNameShouldNotAllowEmptyString() - { - foreach (array('', ' ', ' ') as $name) { - try { - $this->element->setName($name); - $this->fail('setName() should not allow empty string'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid name', $e->getMessage()); - } - } - } - - public function testElementValueInitiallyNull() - { - $this->assertNull($this->element->getValue()); - } - - public function testValueAccessorsWork() - { - $this->element->setValue('bar'); - $this->assertContains('bar', $this->element->getValue()); - } - - public function testGetValueFiltersValue() - { - $this->element->setValue('This 0 is 1 a-2-TEST') - ->addFilter('alnum') - ->addFilter('stringToUpper'); - $test = $this->element->getValue(); - $this->assertEquals('THIS0IS1A2TEST', $test); - } - - public function checkFilterValues($item, $key) - { - $this->assertRegexp('/^[A-Z]+$/', $item); - } - - public function testRetrievingArrayValueFiltersAllArrayValues() - { - $this->element->setValue(array( - 'foo', - array( - 'bar', - 'baz' - ), - 'bat' - )) - ->setIsArray(true) - ->addFilter('StringToUpper'); - $test = $this->element->getValue(); - $this->assertTrue(is_array($test)); - array_walk_recursive($test, array($this, 'checkFilterValues')); - } - - public function testRetrievingArrayValueDoesNotFilterAllValuesWhenNotIsArray() - { - $values = array( - 'foo', - array( - 'bar', - 'baz' - ), - 'bat' - ); - $this->element->setValue($values) - ->addFilter(new Zend_Form_ElementTest_ArrayFilter()); - $test = $this->element->getValue(); - $this->assertTrue(is_array($test)); - require_once 'Zend/Json.php'; - $test = Zend_Json::encode($test); - $this->assertNotContains('foo', $test); - foreach (array('bar', 'baz', 'bat') as $value) { - $this->assertContains($value, $test); - } - } - - public function testGetUnfilteredValueRetrievesOriginalValue() - { - $this->element->setValue('bar'); - $this->assertSame('bar', $this->element->getUnfilteredValue()); - } - - public function testLabelInitiallyNull() - { - $this->assertNull($this->element->getLabel()); - } - - public function testLabelAccessorsWork() - { - $this->element->setLabel('FooBar'); - $this->assertEquals('FooBar', $this->element->getLabel()); - } - - public function testOrderNullByDefault() - { - $this->assertNull($this->element->getOrder()); - } - - public function testCanSetOrder() - { - $this->testOrderNullByDefault(); - $this->element->setOrder(50); - $this->assertEquals(50, $this->element->getOrder()); - } - - public function testRequiredFlagFalseByDefault() - { - $this->assertFalse($this->element->isRequired()); - } - - public function testRequiredAcccessorsWork() - { - $this->assertFalse($this->element->isRequired()); - $this->element->setRequired(true); - $this->assertTrue($this->element->isRequired()); - } - - public function testIsValidInsertsNotEmptyValidatorWhenElementIsRequiredByDefault() - { - $this->_checkZf2794(); - - $this->element->setRequired(true); - $this->assertFalse($this->element->isValid('')); - $validator = $this->element->getValidator('NotEmpty'); - $this->assertTrue($validator instanceof Zend_Validate_NotEmpty); - $this->assertTrue($validator->zfBreakChainOnFailure); - } - - /** - * @see ZF-2862 - */ - public function testBreakChainOnFailureFlagsForExistingValidatorsRemainSetWhenNotEmptyValidatorAutoInserted() - { - $this->_checkZf2794(); - - $username = new Zend_Form_Element('username'); - $username->addValidator('stringLength', true, array(5, 20)) - ->addValidator('regex', true, array('/^[a-zA-Z0-9_]*$/')) - ->addFilter('StringToLower') - ->setRequired(true); - $form = new Zend_Form(array('elements' => array($username))); - $form->isValid(array('username' => '#')); - - $validator = $username->getValidator('stringLength'); - $this->assertTrue($validator->zfBreakChainOnFailure); - $validator = $username->getValidator('regex'); - $this->assertTrue($validator->zfBreakChainOnFailure); - } - - public function testAutoInsertNotEmptyValidatorFlagTrueByDefault() - { - $this->assertTrue($this->element->autoInsertNotEmptyValidator()); - } - - public function testCanSetAutoInsertNotEmptyValidatorFlag() - { - $this->testAutoInsertNotEmptyValidatorFlagTrueByDefault(); - $this->element->setAutoInsertNotEmptyValidator(false); - $this->assertFalse($this->element->autoInsertNotEmptyValidator()); - $this->element->setAutoInsertNotEmptyValidator(true); - $this->assertTrue($this->element->autoInsertNotEmptyValidator()); - } - - public function testIsValidDoesNotInsertNotEmptyValidatorWhenElementIsRequiredButAutoInsertNotEmptyValidatorFlagIsFalse() - { - $this->element->setAutoInsertNotEmptyValidator(false) - ->setRequired(true); - $this->assertTrue($this->element->isValid('')); - } - - public function testDescriptionInitiallyNull() - { - $this->assertNull($this->element->getDescription()); - } - - public function testCanSetDescription() - { - $this->testDescriptionInitiallyNull(); - $this->element->setDescription('element hint'); - $this->assertEquals('element hint', $this->element->getDescription()); - } - - public function testElementIsNotArrayByDefault() - { - $this->assertFalse($this->element->isArray()); - } - - public function testCanSetArrayFlag() - { - $this->testElementIsNotArrayByDefault(); - $this->element->setIsArray(true); - $this->assertTrue($this->element->isArray()); - $this->element->setIsArray(false); - $this->assertFalse($this->element->isArray()); - } - - public function testElementBelongsToNullByDefault() - { - $this->assertNull($this->element->getBelongsTo()); - } - - public function testCanSetArrayElementBelongsTo() - { - $this->testElementBelongsToNullByDefault(); - $this->element->setBelongsTo('foo'); - $this->assertEquals('foo', $this->element->getBelongsTo()); - } - - public function testArrayElementBelongsToNormalizedToValidVariableCharactersOnly() - { - $this->testElementBelongsToNullByDefault(); - $this->element->setBelongsTo('f%\o^&*)o\(%$b#@!.a}{;-,r'); - $this->assertEquals('foobar', $this->element->getBelongsTo()); - } - - public function testGetTypeReturnsCurrentElementClass() - { - $this->assertEquals('Zend_Form_Element', $this->element->getType()); - } - - public function testCanUseAccessorsToSetIndidualAttribs() - { - $this->element->setAttrib('foo', 'bar') - ->setAttrib('bar', 'baz') - ->setAttrib('baz', 'bat'); - - $this->assertEquals('bar', $this->element->getAttrib('foo')); - $this->assertEquals('baz', $this->element->getAttrib('bar')); - $this->assertEquals('bat', $this->element->getAttrib('baz')); - } - - public function testGetUndefinedAttribShouldReturnNull() - { - $this->assertNull($this->element->getAttrib('bogus')); - } - - public function testSetAttribThrowsExceptionsForKeysWithLeadingUnderscores() - { - try { - $this->element->setAttrib('_foo', 'bar'); - $this->fail('setAttrib() should throw an exception for invalid keys'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid attribute', $e->getMessage()); - } - } - - public function testPassingNullValueToSetAttribUnsetsAttrib() - { - $this->element->setAttrib('foo', 'bar'); - $this->assertEquals('bar', $this->element->getAttrib('foo')); - $this->element->setAttrib('foo', null); - $this->assertFalse(isset($this->element->foo)); - } - - public function testSetAttribsSetsMultipleAttribs() - { - $this->element->setAttribs(array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat' - )); - - $this->assertEquals('bar', $this->element->getAttrib('foo')); - $this->assertEquals('baz', $this->element->getAttrib('bar')); - $this->assertEquals('bat', $this->element->getAttrib('baz')); - } - - public function testGetAttribsRetrievesAllAttributes() - { - $attribs = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat' - ); - $this->element->setAttribs($attribs); - - $attribs['helper'] = 'formText'; - - $received = $this->element->getAttribs(); - $this->assertEquals($attribs, $received); - } - - public function testPassingNullValuesToSetAttribsUnsetsAttribs() - { - $this->testSetAttribsSetsMultipleAttribs(); - $this->element->setAttribs(array('foo' => null)); - $this->assertNull($this->element->foo); - } - - public function testRetrievingOverloadedValuesThrowsExceptionWithInvalidKey() - { - try { - $name = $this->element->_name; - $this->fail('Overloading should not return protected or private members'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Cannot retrieve value for protected/private', $e->getMessage()); - } - } - - public function testCanSetAndRetrieveAttribsViaOverloading() - { - $this->element->foo = 'bar'; - $this->assertEquals('bar', $this->element->foo); - } - - public function testGetPluginLoaderRetrievesDefaultValidatorPluginLoader() - { - $loader = $this->element->getPluginLoader('validate'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - $paths = $loader->getPaths('Zend_Validate'); - $this->assertTrue(is_array($paths), var_export($loader, 1)); - $this->assertTrue(0 < count($paths)); - $this->assertContains('Validate', $paths[0]); - } - - public function testGetPluginLoaderRetrievesDefaultFilterPluginLoader() - { - $loader = $this->element->getPluginLoader('filter'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - $paths = $loader->getPaths('Zend_Filter'); - $this->assertTrue(is_array($paths)); - $this->assertTrue(0 < count($paths)); - $this->assertContains('Filter', $paths[0]); - } - - public function testGetPluginLoaderRetrievesDefaultDecoratorPluginLoader() - { - $loader = $this->element->getPluginLoader('decorator'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - $paths = $loader->getPaths('Zend_Form_Decorator'); - $this->assertTrue(is_array($paths)); - $this->assertTrue(0 < count($paths)); - $this->assertContains('Decorator', $paths[0]); - } - - public function testCanSetCustomValidatorPluginLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->element->setPluginLoader($loader, 'validate'); - $test = $this->element->getPluginLoader('validate'); - $this->assertSame($loader, $test); - } - - public function testPassingInvalidTypeToSetPluginLoaderThrowsException() - { - $loader = new Zend_Loader_PluginLoader(); - try { - $this->element->setPluginLoader($loader, 'foo'); - $this->fail('Invalid loader type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid type', $e->getMessage()); - } - } - - public function testPassingInvalidTypeToGetPluginLoaderThrowsException() - { - try { - $this->element->getPluginLoader('foo'); - $this->fail('Invalid loader type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid type', $e->getMessage()); - } - } - - public function testCanSetCustomFilterPluginLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->element->setPluginLoader($loader, 'filter'); - $test = $this->element->getPluginLoader('filter'); - $this->assertSame($loader, $test); - } - - public function testCanSetCustomDecoratorPluginLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->element->setPluginLoader($loader, 'decorator'); - $test = $this->element->getPluginLoader('decorator'); - $this->assertSame($loader, $test); - } - - public function testPassingInvalidLoaderTypeToAddPrefixPathThrowsException() - { - try { - $this->element->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'foo'); - $this->fail('Invalid loader type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid type', $e->getMessage()); - } - } - - public function testCanAddValidatorPluginLoaderPrefixPath() - { - $loader = $this->element->getPluginLoader('validate'); - $this->element->addPrefixPath('Zend_Form', 'Zend/Form/', 'validate'); - $paths = $loader->getPaths('Zend_Form'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Form', $paths[0]); - } - - public function testAddingValidatorPluginLoaderPrefixPathDoesNotAffectOtherLoaders() - { - $validateLoader = $this->element->getPluginLoader('validate'); - $filterLoader = $this->element->getPluginLoader('filter'); - $decoratorLoader = $this->element->getPluginLoader('decorator'); - $this->element->addPrefixPath('Zend_Form', 'Zend/Form/', 'validate'); - $this->assertFalse($filterLoader->getPaths('Zend_Form')); - $this->assertFalse($decoratorLoader->getPaths('Zend_Form')); - } - - public function testCanAddFilterPluginLoaderPrefixPath() - { - $loader = $this->element->getPluginLoader('validate'); - $this->element->addPrefixPath('Zend_Form', 'Zend/Form/', 'validate'); - $paths = $loader->getPaths('Zend_Form'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Form', $paths[0]); - } - - public function testAddingFilterPluginLoaderPrefixPathDoesNotAffectOtherLoaders() - { - $filterLoader = $this->element->getPluginLoader('filter'); - $validateLoader = $this->element->getPluginLoader('validate'); - $decoratorLoader = $this->element->getPluginLoader('decorator'); - $this->element->addPrefixPath('Zend_Form', 'Zend/Form/', 'filter'); - $this->assertFalse($validateLoader->getPaths('Zend_Form')); - $this->assertFalse($decoratorLoader->getPaths('Zend_Form')); - } - - public function testCanAddDecoratorPluginLoaderPrefixPath() - { - $loader = $this->element->getPluginLoader('decorator'); - $this->element->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testAddingDecoratorrPluginLoaderPrefixPathDoesNotAffectOtherLoaders() - { - $decoratorLoader = $this->element->getPluginLoader('decorator'); - $filterLoader = $this->element->getPluginLoader('filter'); - $validateLoader = $this->element->getPluginLoader('validate'); - $this->element->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $this->assertFalse($validateLoader->getPaths('Zend_Foo')); - $this->assertFalse($filterLoader->getPaths('Zend_Foo')); - } - - public function testCanAddAllPluginLoaderPrefixPathsSimultaneously() - { - $validatorLoader = new Zend_Loader_PluginLoader(); - $filterLoader = new Zend_Loader_PluginLoader(); - $decoratorLoader = new Zend_Loader_PluginLoader(); - $this->element->setPluginLoader($validatorLoader, 'validate') - ->setPluginLoader($filterLoader, 'filter') - ->setPluginLoader($decoratorLoader, 'decorator') - ->addPrefixPath('Zend', 'Zend/'); - - $paths = $filterLoader->getPaths('Zend_Filter'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Filter', $paths[0]); - - $paths = $validatorLoader->getPaths('Zend_Validate'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Validate', $paths[0]); - - $paths = $decoratorLoader->getPaths('Zend_Decorator'); - $this->assertTrue(is_array($paths), var_export($paths, 1)); - $this->assertContains('Decorator', $paths[0]); - } - - public function testPassingInvalidValidatorToAddValidatorThrowsException() - { - try { - $this->element->addValidator(123); - $this->fail('Invalid validator should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid validator', $e->getMessage()); - } - } - - public function testCanAddSingleValidatorAsString() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getValidator('digits')); - - $this->element->addValidator('digits'); - $validator = $this->element->getValidator('digits'); - $this->assertTrue($validator instanceof Zend_Validate_Digits, var_export($validator, 1)); - $this->assertFalse($validator->zfBreakChainOnFailure); - } - - public function testCanNotRetrieveSingleValidatorRegisteredAsStringUsingClassName() - { - $this->assertFalse($this->element->getValidator('digits')); - - $this->element->addValidator('digits'); - $this->assertFalse($this->element->getValidator('Zend_Validate_Digits')); - } - - public function testCanAddSingleValidatorAsValidatorObject() - { - $this->assertFalse($this->element->getValidator('Zend_Validate_Digits')); - - require_once 'Zend/Validate/Digits.php'; - $validator = new Zend_Validate_Digits(); - $this->element->addValidator($validator); - $test = $this->element->getValidator('Zend_Validate_Digits'); - $this->assertSame($validator, $test); - $this->assertFalse($validator->zfBreakChainOnFailure); - } - - public function testOptionsAreCastToArrayWhenAddingValidator() - { - $this->_checkZf2794(); - - try { - $this->element->addValidator('Alnum', false, true); - } catch (Exception $e) { - $this->fail('Should be able to add non-array validator options'); - } - $validator = $this->element->getValidator('Alnum'); - $this->assertTrue($validator instanceof Zend_Validate_Alnum); - $this->assertTrue($validator->allowWhiteSpace); - } - - public function testCanRetrieveSingleValidatorRegisteredAsValidatorObjectUsingShortName() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getValidator('digits')); - - require_once 'Zend/Validate/Digits.php'; - $validator = new Zend_Validate_Digits(); - $this->element->addValidator($validator); - $test = $this->element->getValidator('digits'); - $this->assertSame($validator, $test); - $this->assertFalse($validator->zfBreakChainOnFailure); - } - - public function testRetrievingNamedValidatorShouldNotReorderValidators() - { - $this->element->addValidators(array( - 'NotEmpty', - 'Alnum', - 'Digits', - )); - - $validator = $this->element->getValidator('Alnum'); - $validators = $this->element->getValidators(); - $i = 0; - $order = array(); - - foreach (array_keys($validators) as $name) { - $order[$name] = $i; - ++$i; - } - $this->assertEquals(1, $order['Zend_Validate_Alnum'], var_export($order, 1)); - } - - - public function testCanAddMultipleValidators() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getValidator('Zend_Validate_Digits')); - $this->assertFalse($this->element->getValidator('Zend_Validate_Alnum')); - $this->element->addValidators(array('digits', 'alnum')); - $digits = $this->element->getValidator('digits'); - $this->assertTrue($digits instanceof Zend_Validate_Digits); - $alnum = $this->element->getValidator('alnum'); - $this->assertTrue($alnum instanceof Zend_Validate_Alnum); - } - - public function testRemovingUnregisteredValidatorReturnsObjectInstance() - { - $this->assertSame($this->element, $this->element->removeValidator('bogus')); - } - - public function testPassingMessagesOptionToAddValidatorSetsValidatorMessages() - { - $messageTemplates = array( - Zend_Validate_Digits::NOT_DIGITS => 'Value should only contain digits', - Zend_Validate_Digits::STRING_EMPTY => 'Value needs some digits', - ); - $this->element->setAllowEmpty(false) - ->addValidator('digits', false, array('messages' => $messageTemplates)); - - $this->element->isValid(''); - $messages = $this->element->getMessages(); - $found = false; - foreach ($messages as $key => $message) { - if ($key == Zend_Validate_Digits::STRING_EMPTY) { - $found = true; - break; - } - } - $this->assertTrue($found, 'Empty string message not found: ' . var_export($messages, 1)); - $this->assertEquals($messageTemplates[Zend_Validate_Digits::STRING_EMPTY], $message); - - $this->element->isValid('abc'); - $messages = $this->element->getMessages(); - $found = false; - foreach ($messages as $key => $message) { - if ($key == Zend_Validate_Digits::NOT_DIGITS) { - $found = true; - break; - } - } - $this->assertTrue($found, 'Not digits message not found'); - $this->assertEquals($messageTemplates[Zend_Validate_Digits::NOT_DIGITS], $message); - } - - public function testCanPassSingleMessageToValidatorToSetValidatorMessages() - { - $this->_checkZf2794(); - - $message = 'My custom empty message'; - $this->element->setRequired(true) - ->addValidator('notEmpty', false, array('messages' => $message)); - - $this->element->isValid(''); - $messages = $this->element->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals($message, current($messages)); - } - - public function testMessagesAreTranslatedForCurrentLocale() - { - $localeFile = dirname(__FILE__) . '/_files/locale/array.php'; - $translations = include($localeFile); - $translator = new Zend_Translate('array', $translations, 'en'); - $translator->setLocale('en'); - - $this->element->setAllowEmpty(false) - ->setTranslator($translator) - ->addValidator('digits'); - - $this->element->isValid(''); - $messages = $this->element->getMessages(); - $found = false; - foreach ($messages as $key => $message) { - if ($key == 'stringEmpty') { - $found = true; - break; - } - } - $this->assertTrue($found, 'String Empty message not found: ' . var_export($messages, 1)); - $this->assertEquals($translations['stringEmpty'], $message); - - $this->element->isValid('abc'); - $messages = $this->element->getMessages(); - $found = false; - foreach ($messages as $key => $message) { - if ($key == 'notDigits') { - $found = true; - break; - } - } - $this->assertTrue($found, 'Not Digits message not found'); - $this->assertEquals($translations['notDigits'], $message); - } - - /**#@+ - * @see ZF-2988 - */ - public function testSettingErrorMessageShouldOverrideValidationErrorMessages() - { - $this->element->addValidator('Alpha'); - $this->element->addErrorMessage('Invalid value entered'); - $this->assertFalse($this->element->isValid(123)); - $messages = $this->element->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('Invalid value entered', array_shift($messages)); - } - - public function testCustomErrorMessagesShouldBeManagedInAStack() - { - $this->element->addValidator('Alpha'); - $this->element->addErrorMessage('Invalid value entered'); - $this->element->addErrorMessage('Really, it is not valid'); - $messages = $this->element->getErrorMessages(); - $this->assertEquals(2, count($messages)); - - $this->assertFalse($this->element->isValid(123)); - $messages = $this->element->getMessages(); - $this->assertEquals(2, count($messages)); - $this->assertEquals('Invalid value entered', array_shift($messages)); - $this->assertEquals('Really, it is not valid', array_shift($messages)); - } - - public function testShouldAllowSettingMultipleErrorMessagesAtOnce() - { - $set1 = array('foo', 'bar', 'baz'); - $this->element->addErrorMessages($set1); - $this->assertSame($set1, $this->element->getErrorMessages()); - } - - public function testSetErrorMessagesShouldOverwriteMessages() - { - $set1 = array('foo', 'bar', 'baz'); - $set2 = array('bat', 'cat'); - $this->element->addErrorMessages($set1); - $this->assertSame($set1, $this->element->getErrorMessages()); - $this->element->setErrorMessages($set2); - $this->assertSame($set2, $this->element->getErrorMessages()); - } - - public function testCustomErrorMessageStackShouldBeClearable() - { - $this->testCustomErrorMessagesShouldBeManagedInAStack(); - $this->element->clearErrorMessages(); - $messages = $this->element->getErrorMessages(); - $this->assertTrue(empty($messages)); - } - - public function testCustomErrorMessagesShouldBeTranslated() - { - $translations = array( - 'foo' => 'Foo message', - ); - $translate = new Zend_Translate('array', $translations); - $this->element->setTranslator($translate) - ->addErrorMessage('foo') - ->addValidator('Alpha'); - $this->assertFalse($this->element->isValid(123)); - $messages = $this->element->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('Foo message', array_shift($messages)); - } - - public function testCustomErrorMessagesShouldAllowValueSubstitution() - { - $this->element->addErrorMessage('"%value%" is an invalid value') - ->addValidator('Alpha'); - $this->assertFalse($this->element->isValid(123)); - $this->assertTrue($this->element->hasErrors()); - $messages = $this->element->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('"123" is an invalid value', array_shift($messages)); - } - - public function testShouldAllowMarkingElementAsInvalid() - { - $this->element->setValue('foo'); - $this->element->addErrorMessage('Invalid value entered'); - $this->assertFalse($this->element->hasErrors()); - $this->element->markAsError(); - $this->assertTrue($this->element->hasErrors()); - $messages = $this->element->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('Invalid value entered', array_shift($messages)); - } - - public function testShouldAllowPushingErrorsOntoErrorStackWithErrorMessages() - { - $this->element->setValue('foo'); - $this->assertFalse($this->element->hasErrors()); - $this->element->setErrors(array('Error 1', 'Error 2')) - ->addError('Error 3') - ->addErrors(array('Error 4', 'Error 5')); - $this->assertTrue($this->element->hasErrors()); - $messages = $this->element->getMessages(); - $this->assertEquals(5, count($messages)); - foreach (range(1, 5) as $id) { - $message = 'Error ' . $id; - $this->assertContains($message, $messages); - } - } - - public function testHasErrorsShouldIndicateStatusOfValidationErrors() - { - $this->element->setValue('foo'); - $this->assertFalse($this->element->hasErrors()); - $this->element->markAsError(); - $this->assertTrue($this->element->hasErrors()); - } - - /**#@-*/ - - public function testAddingErrorToArrayElementShouldLoopOverAllValues() - { - $this->element->setIsArray(true) - ->setValue(array('foo', 'bar', 'baz')) - ->addError('error with value %value%'); - $errors = $this->element->getMessages(); - require_once 'Zend/Json.php'; - $errors = Zend_Json::encode($errors); - foreach (array('foo', 'bar', 'baz') as $value) { - $message = 'error with value ' . $value; - $this->assertContains($message, $errors); - } - } - - /** ZF-2568 */ - public function testTranslatedMessagesCanContainVariableSubstitution() - { - $localeFile = dirname(__FILE__) . '/_files/locale/array.php'; - $translations = include($localeFile); - $translations['notDigits'] .= ' "%value%"'; - $translator = new Zend_Translate('array', $translations, 'en'); - $translator->setLocale('en'); - - $this->element->setAllowEmpty(false) - ->setTranslator($translator) - ->addValidator('digits'); - - $this->element->isValid('abc'); - $messages = $this->element->getMessages(); - $found = false; - foreach ($messages as $key => $message) { - if ($key == 'notDigits') { - $found = true; - break; - } - } - $this->assertTrue($found, 'String Empty message not found: ' . var_export($messages, 1)); - $this->assertContains(' "abc"', $message); - $this->assertContains('Translating the notDigits string', $message); - } - - public function testCanRemoveValidator() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getValidator('Zend_Validate_Digits')); - $this->element->addValidator('digits'); - $digits = $this->element->getValidator('digits'); - $this->assertTrue($digits instanceof Zend_Validate_Digits); - $this->element->removeValidator('digits'); - $this->assertFalse($this->element->getValidator('digits')); - } - - public function testCanClearAllValidators() - { - $this->_checkZf2794(); - - $this->testCanAddMultipleValidators(); - $validators = $this->element->getValidators(); - $this->element->clearValidators(); - $test = $this->element->getValidators(); - $this->assertNotEquals($validators, $test); - $this->assertTrue(empty($test)); - foreach (array_keys($validators) as $validator) { - $this->assertFalse($this->element->getValidator($validator)); - } - } - - public function testCanValidateElement() - { - $this->element->addValidator(new Zend_Validate_NotEmpty()) - ->addValidator(new Zend_Validate_EmailAddress()); - try { - $result = $this->element->isValid('matthew@zend.com'); - } catch (Exception $e) { - $this->fail('Validating an element should work'); - } - } - - public function testCanValidateArrayValue() - { - $this->element->setIsArray(true) - ->addValidator('InArray', false, array(array('foo', 'bar', 'baz', 'bat'))); - $this->assertTrue($this->element->isValid(array('foo', 'bat'))); - } - - public function testShouldAllowZeroAsNonEmptyValue() - { - $this->element->addValidator('between', false, array(1, 100)); - $this->assertFalse($this->element->isValid('0')); - } - - public function testIsValidPopulatesElementValue() - { - $this->testCanValidateElement(); - $this->assertEquals('matthew@zend.com', $this->element->getValue()); - } - - public function testErrorsPopulatedFollowingFailedIsValidCheck() - { - $this->element->addValidator(new Zend_Validate_NotEmpty()) - ->addValidator(new Zend_Validate_EmailAddress()); - - $result = $this->element->isValid('matthew'); - if ($result) { - $this->fail('Invalid data should fail validations'); - } - $errors = $this->element->getErrors(); - $this->assertTrue(is_array($errors)); - $this->assertTrue(0 < count($errors)); - } - - public function testMessagesPopulatedFollowingFailedIsValidCheck() - { - require_once 'Zend/Validate/NotEmpty.php'; - require_once 'Zend/Validate/EmailAddress.php'; - $this->element->addValidator(new Zend_Validate_NotEmpty()) - ->addValidator(new Zend_Validate_EmailAddress()); - - $result = $this->element->isValid('matthew'); - if ($result) { - $this->fail('Invalid data should fail validations'); - } - $messages = $this->element->getMessages(); - $this->assertTrue(is_array($messages)); - $this->assertTrue(0 < count($messages)); - } - - public function testOptionalElementDoesNotPerformValidationsOnEmptyValuesByDefault() - { - $this->element->addValidator(new Zend_Validate_EmailAddress()); - - $result = $this->element->isValid(''); - if (!$result) { - $this->fail('Empty data should not fail validations'); - } - $errors = $this->element->getErrors(); - $this->assertTrue(is_array($errors)); - $this->assertTrue(empty($errors)); - } - - public function testOptionalElementDoesPerformValidationsWhenAllowEmptyIsFalse() - { - $this->element->setAllowEmpty(false) - ->addValidator(new Zend_Validate_EmailAddress()); - - $result = $this->element->isValid(''); - if ($result) { - $this->fail('Empty data should fail validations when AllowEmpty is false'); - } - $errors = $this->element->getErrors(); - $this->assertTrue(is_array($errors)); - $this->assertTrue(0 < count($errors)); - } - - public function testAddingInvalidFilterTypeThrowsException() - { - try { - $this->element->addFilter(123); - $this->fail('Invalid filter type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid filter', $e->getMessage()); - } - } - - public function testCanAddSingleFilterAsString() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getFilter('digits')); - - $this->element->addFilter('digits'); - $filter = $this->element->getFilter('digits'); - $this->assertTrue($filter instanceof Zend_Filter_Digits); - } - - public function testCanNotRetrieveSingleFilterRegisteredAsStringUsingClassName() - { - $this->assertFalse($this->element->getFilter('digits')); - - $this->element->addFilter('digits'); - $this->assertFalse($this->element->getFilter('Zend_Filter_Digits')); - } - - public function testCanAddSingleFilterAsFilterObject() - { - $this->assertFalse($this->element->getFilter('Zend_Filter_Digits')); - - require_once 'Zend/Filter/Digits.php'; - $filter = new Zend_Filter_Digits(); - $this->element->addFilter($filter); - $test = $this->element->getFilter('Zend_Filter_Digits'); - $this->assertSame($filter, $test); - } - - public function testCanRetrieveSingleFilterRegisteredAsFilterObjectUsingShortName() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getFilter('digits')); - - require_once 'Zend/Filter/Digits.php'; - $filter = new Zend_Filter_Digits(); - $this->element->addFilter($filter); - $test = $this->element->getFilter('digits'); - } - - public function testRetrievingNamedFilterShouldNotReorderFilters() - { - $this->element->addFilters(array( - 'Alpha', - 'Alnum', - 'Digits', - )); - - $filter = $this->element->getFilter('Alnum'); - $filters = $this->element->getFilters(); - $i = 0; - $order = array(); - - foreach (array_keys($filters) as $name) { - $order[$name] = $i; - ++$i; - } - $this->assertEquals(1, $order['Zend_Filter_Alnum'], var_export($order, 1)); - } - - public function testOptionsAreCastToArrayWhenAddingFilter() - { - $this->_checkZf2794(); - - try { - $this->element->addFilter('Alnum', true); - } catch (Exception $e) { - $this->fail('Should be able to add non-array filter options'); - } - $filter = $this->element->getFilter('Alnum'); - $this->assertTrue($filter instanceof Zend_Filter_Alnum); - $this->assertTrue($filter->allowWhiteSpace); - } - - public function testShouldUseFilterConstructorOptionsAsPassedToAddFilter() - { - $this->element->addFilter('HtmlEntities', array('quoteStyle' => ENT_QUOTES, 'charSet' => 'UTF-8')); - $filter = $this->element->getFilter('HtmlEntities'); - $this->assertTrue($filter instanceof Zend_Filter_HtmlEntities); - $this->assertEquals(ENT_QUOTES, $filter->getQuoteStyle()); - $this->assertEquals('UTF-8', $filter->getCharSet()); - } - - public function testCanAddMultipleFilters() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getFilter('Zend_Filter_Digits')); - $this->assertFalse($this->element->getFilter('Zend_Filter_Alnum')); - $this->element->addFilters(array('digits', 'alnum')); - $digits = $this->element->getFilter('digits'); - $this->assertTrue($digits instanceof Zend_Filter_Digits); - $alnum = $this->element->getFilter('alnum'); - $this->assertTrue($alnum instanceof Zend_Filter_Alnum); - } - - public function testRemovingUnregisteredFilterReturnsObjectInstance() - { - $this->assertSame($this->element, $this->element->removeFilter('bogus')); - } - - public function testCanRemoveFilter() - { - $this->_checkZf2794(); - - $this->assertFalse($this->element->getFilter('Zend_Filter_Digits')); - $this->element->addFilter('digits'); - $digits = $this->element->getFilter('digits'); - $this->assertTrue($digits instanceof Zend_Filter_Digits); - $this->element->removeFilter('digits'); - $this->assertFalse($this->element->getFilter('digits')); - } - - public function testCanClearAllFilters() - { - $this->_checkZf2794(); - - $this->testCanAddMultipleFilters(); - $filters = $this->element->getFilters(); - $this->element->clearFilters(); - $test = $this->element->getFilters(); - $this->assertNotEquals($filters, $test); - $this->assertTrue(empty($test)); - foreach (array_keys($filters) as $filter) { - $this->assertFalse($this->element->getFilter($filter)); - } - } - - public function testGetViewReturnsNullWithNoViewRenderer() - { - $this->assertNull($this->element->getView()); - } - - public function testGetViewReturnsViewRendererViewInstanceIfViewRendererActive() - { - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $viewRenderer->initView(); - $view = $viewRenderer->view; - $test = $this->element->getView(); - $this->assertSame($view, $test); - } - - public function testCanSetView() - { - $view = new Zend_View(); - $this->assertNull($this->element->getView()); - $this->element->setView($view); - $received = $this->element->getView(); - $this->assertSame($view, $received); - } - - public function testViewHelperDecoratorRegisteredByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - } - - public function testCanDisableRegisteringDefaultDecoratorsDuringInitialization() - { - $element = new Zend_Form_Element('foo', array('disableLoadDefaultDecorators' => true)); - $decorators = $element->getDecorators(); - $this->assertEquals(array(), $decorators); - } - - public function testAddingInvalidDecoratorThrowsException() - { - try { - $this->element->addDecorator(123); - $this->fail('Invalid decorator type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid decorator', $e->getMessage()); - } - } - - public function testCanAddSingleDecoratorAsString() - { - $this->_checkZf2794(); - - $this->element->clearDecorators(); - $this->assertFalse($this->element->getDecorator('viewHelper')); - - $this->element->addDecorator('viewHelper'); - $decorator = $this->element->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - } - - public function testCanNotRetrieveSingleDecoratorRegisteredAsStringUsingClassName() - { - $this->assertFalse($this->element->getDecorator('Zend_Form_Decorator_ViewHelper')); - } - - public function testCanAddSingleDecoratorAsDecoratorObject() - { - $this->element->clearDecorators(); - $this->assertFalse($this->element->getDecorator('viewHelper')); - - $decorator = new Zend_Form_Decorator_ViewHelper; - $this->element->addDecorator($decorator); - $test = $this->element->getDecorator('Zend_Form_Decorator_ViewHelper'); - $this->assertSame($decorator, $test); - } - - /** - * @see ZF-3597 - */ - public function testAddingConcreteDecoratorShouldHonorOrder() - { - require_once dirname(__FILE__) . '/_files/decorators/TableRow.php'; - $decorator = new My_Decorator_TableRow(); - $this->element->setLabel('Foo') - ->setDescription('sample description') - ->clearDecorators() - ->addDecorators(array( - 'ViewHelper', - $decorator, - )); - $html = $this->element->render($this->getView()); - $this->assertRegexp('#<tr><td>Foo</td><td>.*?<input[^>]+>.*?</td><td>sample description</td></tr>#s', $html, $html); - } - - public function testCanRetrieveSingleDecoratorRegisteredAsDecoratorObjectUsingShortName() - { - $this->_checkZf2794(); - - $this->element->clearDecorators(); - $this->assertFalse($this->element->getDecorator('viewHelper')); - - $decorator = new Zend_Form_Decorator_ViewHelper; - $this->element->addDecorator($decorator); - $test = $this->element->getDecorator('viewHelper'); - $this->assertSame($decorator, $test); - } - - public function testCanAddMultipleDecorators() - { - $this->_checkZf2794(); - - $this->element->clearDecorators(); - $this->assertFalse($this->element->getDecorator('viewHelper')); - - $testDecorator = new Zend_Form_ElementTest_Decorator; - $this->element->addDecorators(array( - 'ViewHelper', - $testDecorator - )); - - $viewHelper = $this->element->getDecorator('viewHelper'); - $this->assertTrue($viewHelper instanceof Zend_Form_Decorator_ViewHelper); - $decorator = $this->element->getDecorator('decorator'); - $this->assertSame($testDecorator, $decorator); - } - - public function testRemovingUnregisteredDecoratorReturnsObjectInstance() - { - $this->_checkZf2794(); - - $this->assertSame($this->element, $this->element->removeDecorator('bogus')); - } - - public function testCanRemoveDecorator() - { - $this->testViewHelperDecoratorRegisteredByDefault(); - $this->element->removeDecorator('viewHelper'); - $this->assertFalse($this->element->getDecorator('viewHelper')); - } - - /** - * @see ZF-3069 - */ - public function testRemovingNamedDecoratorsShouldWork() - { - $this->_checkZf2794(); - $this->element->setDecorators(array( - 'ViewHelper', - array(array('div' => 'HtmlTag'), array('tag' => 'div')), - array(array('div2' => 'HtmlTag'), array('tag' => 'div')), - )); - $decorators = $this->element->getDecorators(); - $this->assertTrue(array_key_exists('div', $decorators)); - $this->assertTrue(array_key_exists('div2', $decorators)); - $this->element->removeDecorator('div'); - $decorators = $this->element->getDecorators(); - $this->assertFalse(array_key_exists('div', $decorators)); - $this->assertTrue(array_key_exists('div2', $decorators)); - } - - public function testCanClearAllDecorators() - { - $this->testCanAddMultipleDecorators(); - $this->element->clearDecorators(); - $this->assertFalse($this->element->getDecorator('viewHelper')); - $this->assertFalse($this->element->getDecorator('decorator')); - } - - public function testCanAddDecoratorAliasesToAllowMultipleDecoratorsOfSameType() - { - $this->_checkZf2794(); - - $this->element->setDecorators(array( - array('HtmlTag', array('tag' => 'span')), - array('decorator' => array('FooBar' => 'HtmlTag'), 'options' => array('tag' => 'div')), - )); - $decorator = $this->element->getDecorator('FooBar'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_HtmlTag); - $this->assertEquals('div', $decorator->getOption('tag')); - - $decorator = $this->element->getDecorator('HtmlTag'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_HtmlTag); - $this->assertEquals('span', $decorator->getOption('tag')); - } - - public function testRetrievingNamedDecoratorShouldNotReorderDecorators() - { - $this->element->setDecorators(array( - 'ViewHelper', - 'Errors', - array(array('inner' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element')), - 'Label', - array(array('outer' => 'HtmlTag'), array('tag' => 'div')), - )); - - $decorator = $this->element->getDecorator('inner'); - $decorators = $this->element->getDecorators(); - $i = 0; - $order = array(); - - foreach (array_keys($decorators) as $name) { - $order[$name] = $i; - ++$i; - } - $this->assertEquals(2, $order['inner'], var_export($order, 1)); - } - - /** - * @see ZF-3376 - */ - public function testSetDecoratorsShouldAcceptReturnOfGetDecorators() - { - $this->element->setDecorators(array( - 'ViewHelper', - 'Errors', - array('input' => 'HtmlTag', array('tag' => 'div', 'class' => 'input')), - 'Label', - array('element' => 'HtmlTag', array('tag' => 'div', 'class' => 'element')), - )); - $decorators = $this->element->getDecorators(); - $this->element->setDecorators($decorators); - $this->assertSame($decorators, $this->element->getDecorators()); - } - - public function testRenderElementReturnsMarkup() - { - $this->element->setName('foo'); - $html = $this->element->render($this->getView()); - $this->assertTrue(is_string($html)); - $this->assertFalse(empty($html)); - $this->assertContains('<input', $html); - $this->assertContains('"foo"', $html); - } - - public function testRenderElementRendersLabelWhenProvided() - { - $this->element->setView($this->getView()); - $this->element->setName('foo') - ->setLabel('Foo'); - $html = $this->element->render(); - $this->assertTrue(is_string($html)); - $this->assertFalse(empty($html)); - $this->assertContains('<label', $html); - $this->assertContains('Foo', $html); - $this->assertContains('</label>', $html); - } - - public function testRenderElementRendersValueWhenProvided() - { - $this->element->setView($this->getView()); - $this->element->setName('foo') - ->setValue('bar'); - $html = $this->element->render(); - $this->assertTrue(is_string($html)); - $this->assertFalse(empty($html)); - $this->assertContains('<input', $html); - $this->assertContains('"foo"', $html); - $this->assertContains('"bar"', $html); - } - - public function testRenderElementRendersErrorsWhenProvided() - { - $this->_checkZf2794(); - - $this->element->setView($this->getView()) - ->setRequired(true) - ->setName('foo') - ->addValidator('NotEmpty'); - $this->element->isValid(''); - - $html = $this->element->render(); - $this->assertTrue(is_string($html)); - $this->assertFalse(empty($html)); - $this->assertContains('error', $html); - $this->assertRegexp('/empty/i', $html); - } - - public function testToStringProxiesToRender() - { - $this->element->setView($this->getView()); - $this->element->setName('foo'); - $html = $this->element->__toString(); - $this->assertTrue(is_string($html)); - $this->assertFalse(empty($html)); - $this->assertContains('<input', $html); - $this->assertContains('"foo"', $html); - } - - public function raiseDecoratorException($content, $element, $options) - { - throw new Exception('Raising exception in decorator callback'); - } - - public function handleDecoratorErrors($errno, $errstr, $errfile = '', $errline = 0, array $errcontext = array()) - { - $this->error = $errstr; - } - - public function testToStringRaisesErrorWhenExceptionCaught() - { - $this->element->setDecorators(array( - array( - 'decorator' => 'Callback', - 'options' => array('callback' => array($this, 'raiseDecoratorException')) - ), - )); - $origErrorHandler = set_error_handler(array($this, 'handleDecoratorErrors'), E_USER_WARNING); - - $text = $this->element->__toString(); - - restore_error_handler(); - - $this->assertTrue(empty($text)); - $this->assertTrue(isset($this->error)); - $this->assertEquals('Raising exception in decorator callback', $this->error); - } - - public function getOptions() - { - $options = array( - 'name' => 'changed', - 'value' => 'foo', - 'label' => 'bar', - 'order' => 50, - 'required' => false, - 'foo' => 'bar', - 'baz' => 'bat' - ); - return $options; - } - - public function testCanSetObjectStateViaSetOptions() - { - $options = $this->getOptions(); - $this->element->setOptions($options); - $this->assertEquals('changed', $this->element->getName()); - $this->assertEquals('foo', $this->element->getValue()); - $this->assertEquals('bar', $this->element->getLabel()); - $this->assertEquals(50, $this->element->getOrder()); - $this->assertFalse($this->element->isRequired()); - $this->assertEquals('bar', $this->element->foo); - $this->assertEquals('bat', $this->element->baz); - } - - public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig() - { - $options = $this->getOptions(); - $config = new Zend_Config($options); - $options['config'] = $config; - $options['options'] = $config->toArray(); - $this->element->setOptions($options); - } - - public function testSetOptionsSkipsSettingAccessorsRequiringObjectsWhenNoObjectPresent() - { - $options = $this->getOptions(); - $options['translator'] = true; - $options['pluginLoader'] = true; - $options['view'] = true; - $this->element->setOptions($options); - } - - public function testSetOptionsSetsArrayOfStringValidators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['validators'] = array( - 'notEmpty', - 'digits' - ); - $this->element->setOptions($options); - $validator = $this->element->getValidator('notEmpty'); - $this->assertTrue($validator instanceof Zend_Validate_NotEmpty); - $validator = $this->element->getValidator('digits'); - $this->assertTrue($validator instanceof Zend_Validate_Digits); - } - - public function testSetOptionsSetsArrayOfArrayValidators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['validators'] = array( - array('notEmpty', true, array('bar')), - array('digits', true, array('bar')), - ); - $this->element->setOptions($options); - $validator = $this->element->getValidator('notEmpty'); - $this->assertTrue($validator instanceof Zend_Validate_NotEmpty); - $this->assertTrue($validator->zfBreakChainOnFailure); - $validator = $this->element->getValidator('digits'); - $this->assertTrue($validator instanceof Zend_Validate_Digits); - $this->assertTrue($validator->zfBreakChainOnFailure); - } - - public function testSetOptionsSetsArrayOfAssociativeArrayValidators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['validators'] = array( - array( - 'options' => array('bar'), - 'breakChainOnFailure' => true, - 'validator' => 'notEmpty', - ), - array( - 'options' => array('bar'), - 'validator' => 'digits', - 'breakChainOnFailure' => true, - ), - ); - $this->element->setOptions($options); - $validator = $this->element->getValidator('notEmpty'); - $this->assertTrue($validator instanceof Zend_Validate_NotEmpty); - $this->assertTrue($validator->zfBreakChainOnFailure); - $validator = $this->element->getValidator('digits'); - $this->assertTrue($validator instanceof Zend_Validate_Digits); - $this->assertTrue($validator->zfBreakChainOnFailure); - } - - public function testSetOptionsSetsArrayOfStringFilters() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['filters'] = array('StringToUpper', 'Alpha'); - $this->element->setOptions($options); - $filter = $this->element->getFilter('StringToUpper'); - $this->assertTrue($filter instanceof Zend_Filter_StringToUpper); - $filter = $this->element->getFilter('Alpha'); - $this->assertTrue($filter instanceof Zend_Filter_Alpha); - } - - public function testSetOptionsSetsArrayOfArrayFilters() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['filters'] = array( - array('StringToUpper', array('bar' => 'baz')), - array('Alpha', array('foo')), - ); - $this->element->setOptions($options); - $filter = $this->element->getFilter('StringToUpper'); - $this->assertTrue($filter instanceof Zend_Filter_StringToUpper); - $filter = $this->element->getFilter('Alpha'); - $this->assertTrue($filter instanceof Zend_Filter_Alpha); - } - - public function testSetOptionsSetsArrayOfAssociativeArrayFilters() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['filters'] = array( - array( - 'options' => array('baz'), - 'filter' => 'StringToUpper' - ), - array( - 'options' => array('foo'), - 'filter' => 'Alpha', - ), - ); - $this->element->setOptions($options); - $filter = $this->element->getFilter('StringToUpper'); - $this->assertTrue($filter instanceof Zend_Filter_StringToUpper); - $filter = $this->element->getFilter('Alpha'); - $this->assertTrue($filter instanceof Zend_Filter_Alpha); - } - - public function testSetOptionsSetsArrayOfStringDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array('label', 'form'); - $this->element->setOptions($options); - $this->assertFalse($this->element->getDecorator('viewHelper')); - $this->assertFalse($this->element->getDecorator('errors')); - $decorator = $this->element->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $decorator = $this->element->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - } - - public function testSetOptionsSetsArrayOfArrayDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array( - array('label', array('id' => 'mylabel')), - array('form', array('id' => 'form')), - ); - $this->element->setOptions($options); - $this->assertFalse($this->element->getDecorator('viewHelper')); - $this->assertFalse($this->element->getDecorator('errors')); - - $decorator = $this->element->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $options = $decorator->getOptions(); - $this->assertEquals('mylabel', $options['id']); - - $decorator = $this->element->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - $options = $decorator->getOptions(); - $this->assertEquals('form', $options['id']); - } - - public function testSetOptionsSetsArrayOfAssocArrayDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array( - array( - 'options' => array('id' => 'mylabel'), - 'decorator' => 'label', - ), - array( - 'options' => array('id' => 'form'), - 'decorator' => 'form', - ), - ); - $this->element->setOptions($options); - $this->assertFalse($this->element->getDecorator('viewHelper')); - $this->assertFalse($this->element->getDecorator('errors')); - - $decorator = $this->element->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $options = $decorator->getOptions(); - $this->assertEquals('mylabel', $options['id']); - - $decorator = $this->element->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - $options = $decorator->getOptions(); - $this->assertEquals('form', $options['id']); - } - - public function testSetOptionsSetsGlobalPrefixPaths() - { - $options = $this->getOptions(); - $options['prefixPath'] = array( - 'prefix' => 'Zend_Foo', - 'path' => 'Zend/Foo/' - ); - $this->element->setOptions($options); - - foreach (array('validate', 'filter', 'decorator') as $type) { - $loader = $this->element->getPluginLoader($type); - $paths = $loader->getPaths('Zend_Foo_' . ucfirst($type)); - $this->assertTrue(is_array($paths), "Failed for type $type: " . var_export($paths, 1)); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - } - - public function testSetOptionsSetsIndividualPrefixPathsFromKeyedArrays() - { - $options = $this->getOptions(); - $options['prefixPath'] = array( - 'filter' => array('prefix' => 'Zend_Foo', 'path' => 'Zend/Foo/') - ); - $this->element->setOptions($options); - - $loader = $this->element->getPluginLoader('filter'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testSetOptionsSetsIndividualPrefixPathsFromUnKeyedArrays() - { - $options = $this->getOptions(); - $options['prefixPath'] = array( - array('type' => 'decorator', 'prefix' => 'Zend_Foo', 'path' => 'Zend/Foo/') - ); - $this->element->setOptions($options); - - $loader = $this->element->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testCanSetObjectStateViaSetConfig() - { - $config = new Zend_Config($this->getOptions()); - $this->element->setConfig($config); - $this->assertEquals('changed', $this->element->getName()); - $this->assertEquals('foo', $this->element->getValue()); - $this->assertEquals('bar', $this->element->getLabel()); - $this->assertEquals(50, $this->element->getOrder()); - $this->assertFalse($this->element->isRequired()); - $this->assertEquals('bar', $this->element->foo); - $this->assertEquals('bat', $this->element->baz); - } - - public function testPassingConfigObjectToConstructorSetsObjectState() - { - $config = new Zend_Config($this->getOptions()); - $element = new Zend_Form_Element($config); - $this->assertEquals('changed', $element->getName()); - $this->assertEquals('foo', $element->getValue()); - $this->assertEquals('bar', $element->getLabel()); - $this->assertEquals(50, $element->getOrder()); - $this->assertFalse($element->isRequired()); - $this->assertEquals('bar', $element->foo); - $this->assertEquals('bat', $element->baz); - } - - public function testValueIsFilteredPriorToValidation() - { - $this->_checkZf2794(); - - $this->element->addFilter('StringTrim') - ->addValidator('StringLength', false, array(3, 8)); - $this->assertTrue($this->element->isValid(' foobar ')); - $this->assertEquals('foobar', $this->element->getValue()); - - $this->element->setFilters(array('StringTrim')) - ->setRequired(true) - ->setValidators(array('NotEmpty')); - $this->assertFalse($this->element->isValid(' ')); - } - - // Extensions - - public function testInitCalledBeforeLoadDecorators() - { - $element = new Zend_Form_ElementTest_Element('test'); - $decorators = $element->getDecorators(); - $this->assertTrue(empty($decorators)); - } - - /** - * @group ZF-3217 - */ - public function testElementShouldOverloadToRenderDecorators() - { - $this->element->setLabel('Foo Label') - ->setView($this->getView()); - $html = $this->element->renderViewHelper(); - $this->assertContains('<input', $html); - $this->assertContains('id="' . $this->element->getFullyQualifiedName() . '"', $html, 'Received: ' . $html); - $this->assertNotContains('<dd', $html); - $this->assertNotContains('<label', $html); - - $html = $this->element->renderLabel('this is the content'); - $this->assertRegexp('#<label[^>]*for="' . $this->element->getFullyQualifiedName() . '"[^>]*>Foo Label</label>#', $html); - $this->assertContains('this is the content', $html); - $this->assertNotContains('<input', $html); - } - - /** - * @group ZF-3217 - * @expectedException Zend_Form_Element_Exception - */ - public function testOverloadingToInvalidMethodsShouldThrowAnException() - { - $html = $this->element->bogusMethodCall(); - } - - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -class Zend_Form_ElementTest_Decorator extends Zend_Form_Decorator_Abstract -{ -} - -class Zend_Form_ElementTest_Element extends Zend_Form_Element -{ - public function init() - { - $this->setDisableLoadDefaultDecorators(true); - } -} - -class Zend_Form_ElementTest_ArrayFilter implements Zend_Filter_Interface -{ - public function filter($value) - { - $value = array_filter($value, array($this, '_filter')); - return $value; - } - - protected function _filter($value) - { - if (is_array($value)) { - return array_filter($value, array($this, '_filter')); - } - return (strstr($value, 'ba')); - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_ElementTest::main') { - Zend_Form_ElementTest::main(); -} diff --git a/tests/Zend/Form/FormTest.php b/tests/Zend/Form/FormTest.php deleted file mode 100644 index 0ca23d5bfa953d710a03cdc80ab05b22bacc83e3..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/FormTest.php +++ /dev/null @@ -1,3605 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_FormTest::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -// error_reporting(E_ALL); - -require_once 'Zend/Form.php'; - -require_once 'Zend/Config.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Form/Decorator/Form.php'; -require_once 'Zend/Form/DisplayGroup.php'; -require_once 'Zend/Form/Element.php'; -require_once 'Zend/Form/Element/Text.php'; -require_once 'Zend/Form/SubForm.php'; -require_once 'Zend/Loader/PluginLoader.php'; -require_once 'Zend/Registry.php'; -require_once 'Zend/Translate.php'; -require_once 'Zend/View.php'; - -class Zend_Form_FormTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite('Zend_Form_FormTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function clearRegistry() - { - if (Zend_Registry::isRegistered('Zend_Translate')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_Translate']); - } - } - - public function setUp() - { - $this->clearRegistry(); - Zend_Form::setDefaultTranslator(null); - - if (isset($this->error)) { - unset($this->error); - } - - Zend_Controller_Action_HelperBroker::resetHelpers(); - $this->form = new Zend_Form(); - } - - public function tearDown() - { - $this->clearRegistry(); - } - - public function testZendFormImplementsZendValidateInterface() - { - $this->assertTrue($this->form instanceof Zend_Validate_Interface); - } - - // Configuration - - public function getOptions() - { - $options = array( - 'name' => 'foo', - 'class' => 'someform', - 'action' => '/foo/bar', - 'method' => 'put', - ); - return $options; - } - - public function testCanSetObjectStateViaSetOptions() - { - $options = $this->getOptions(); - $this->form->setOptions($options); - $this->assertEquals('foo', $this->form->getName()); - $this->assertEquals('someform', $this->form->getAttrib('class')); - $this->assertEquals('/foo/bar', $this->form->getAction()); - $this->assertEquals('put', $this->form->getMethod()); - } - - public function testCanSetObjectStateByPassingOptionsToConstructor() - { - $options = $this->getOptions(); - $form = new Zend_Form($options); - $this->assertEquals('foo', $form->getName()); - $this->assertEquals('someform', $form->getAttrib('class')); - $this->assertEquals('/foo/bar', $form->getAction()); - $this->assertEquals('put', $form->getMethod()); - } - - public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig() - { - $options = $this->getOptions(); - $config = new Zend_Config($options); - $options['config'] = $config; - $options['options'] = $config->toArray(); - $this->form->setOptions($options); - } - - public function testSetOptionsSkipsSettingAccessorsRequiringObjectsWhenNonObjectPassed() - { - $options = $this->getOptions(); - $options['pluginLoader'] = true; - $options['subForms'] = true; - $options['view'] = true; - $options['translator'] = true; - $options['default'] = true; - $options['attrib'] = true; - $this->form->setOptions($options); - } - - public function testSetOptionsWithAttribsDoesNotOverwriteActionOrMethodOrName() - { - $attribs = $this->getOptions(); - unset($attribs['action'], $attribs['method']); - $options = array( - 'name' => 'MYFORM', - 'action' => '/bar/baz', - 'method' => 'GET', - 'attribs' => $attribs, - ); - $form = new Zend_Form($options); - $this->assertEquals($options['name'], $form->getName()); - $this->assertEquals($options['action'], $form->getAction()); - $this->assertEquals(strtolower($options['method']), strtolower($form->getMethod())); - } - - public function getElementOptions() - { - $elements = array( - 'foo' => 'text', - array('text', 'bar', array('class' => 'foobar')), - array( - 'options' => array('class' => 'barbaz'), - 'type' => 'text', - 'name' => 'baz', - ), - 'bat' => array( - 'options' => array('class' => 'bazbat'), - 'type' => 'text', - ), - 'lol' => array( - 'text', - array('class' => 'lolcat'), - ) - ); - return $elements; - } - - public function testSetOptionsSetsElements() - { - $options = $this->getOptions(); - $options['elements'] = $this->getElementOptions(); - $this->form->setOptions($options); - - $this->assertTrue(isset($this->form->foo)); - $this->assertTrue($this->form->foo instanceof Zend_Form_Element_Text); - - $this->assertTrue(isset($this->form->bar)); - $this->assertTrue($this->form->bar instanceof Zend_Form_Element_Text); - $this->assertEquals('foobar', $this->form->bar->class); - - $this->assertTrue(isset($this->form->baz)); - $this->assertTrue($this->form->baz instanceof Zend_Form_Element_Text); - $this->assertEquals('barbaz', $this->form->baz->class); - - $this->assertTrue(isset($this->form->bat)); - $this->assertTrue($this->form->bat instanceof Zend_Form_Element_Text); - $this->assertEquals('bazbat', $this->form->bat->class); - - $this->assertTrue(isset($this->form->lol)); - $this->assertTrue($this->form->lol instanceof Zend_Form_Element_Text); - $this->assertEquals('lolcat', $this->form->lol->class); - } - - public function testSetOptionsSetsDefaultValues() - { - $options = $this->getOptions(); - $options['defaults'] = array( - 'bar' => 'barvalue', - 'bat' => 'batvalue', - ); - $options['elements'] = $this->getElementOptions(); - $this->form->setOptions($options); - - $this->assertEquals('barvalue', $this->form->bar->getValue()); - $this->assertEquals('batvalue', $this->form->bat->getValue()); - } - - public function testSetOptionsSetsArrayOfStringDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array('label', 'errors'); - $this->form->setOptions($options); - $this->assertFalse($this->form->getDecorator('form')); - - $decorator = $this->form->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $decorator = $this->form->getDecorator('errors'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Errors); - } - - public function testSetOptionsSetsArrayOfArrayDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array( - array('label', array('id' => 'mylabel')), - array('errors', array('id' => 'errors')), - ); - $this->form->setOptions($options); - $this->assertFalse($this->form->getDecorator('form')); - - $decorator = $this->form->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $options = $decorator->getOptions(); - $this->assertEquals('mylabel', $options['id']); - - $decorator = $this->form->getDecorator('errors'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Errors); - $options = $decorator->getOptions(); - $this->assertEquals('errors', $options['id']); - } - - public function testSetOptionsSetsArrayOfAssocArrayDecorators() - { - $this->_checkZf2794(); - - $options = $this->getOptions(); - $options['decorators'] = array( - array( - 'options' => array('id' => 'mylabel'), - 'decorator' => 'label', - ), - array( - 'options' => array('id' => 'errors'), - 'decorator' => 'errors', - ), - ); - $this->form->setOptions($options); - $this->assertFalse($this->form->getDecorator('form')); - - $decorator = $this->form->getDecorator('label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $options = $decorator->getOptions(); - $this->assertEquals('mylabel', $options['id']); - - $decorator = $this->form->getDecorator('errors'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Errors); - $options = $decorator->getOptions(); - $this->assertEquals('errors', $options['id']); - } - - public function testSetOptionsSetsGlobalPrefixPaths() - { - $options = $this->getOptions(); - $options['prefixPath'] = array( - 'prefix' => 'Zend_Foo', - 'path' => 'Zend/Foo/' - ); - $this->form->setOptions($options); - - foreach (array('element', 'decorator') as $type) { - $loader = $this->form->getPluginLoader($type); - $paths = $loader->getPaths('Zend_Foo_' . ucfirst($type)); - $this->assertTrue(is_array($paths), "Failed for type $type: " . var_export($paths, 1)); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - } - - public function testSetOptionsSetsIndividualPrefixPathsFromKeyedArrays() - { - $options = $this->getOptions(); - $options['prefixPath'] = array( - 'element' => array('prefix' => 'Zend_Foo', 'path' => 'Zend/Foo/') - ); - $this->form->setOptions($options); - - $loader = $this->form->getPluginLoader('element'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testSetOptionsSetsIndividualPrefixPathsFromUnKeyedArrays() - { - $options = $this->getOptions(); - $options['prefixPath'] = array( - array('type' => 'decorator', 'prefix' => 'Zend_Foo', 'path' => 'Zend/Foo/') - ); - $this->form->setOptions($options); - - $loader = $this->form->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testSetOptionsSetsDisplayGroups() - { - $options = $this->getOptions(); - $options['displayGroups'] = array( - 'barbat' => array(array('bar', 'bat'), array('order' => 20)), - array(array('foo', 'baz'), 'foobaz', array('order' => 10)), - array( - 'name' => 'ghiabc', - 'elements' => array('ghi', 'abc'), - 'options' => array('order' => 15), - ), - ); - $options['elements'] = array( - 'foo' => 'text', - 'bar' => 'text', - 'baz' => 'text', - 'bat' => 'text', - 'abc' => 'text', - 'ghi' => 'text', - 'jkl' => 'text', - 'mno' => 'text', - ); - $this->form->setOptions($options); - - $this->assertTrue(isset($this->form->barbat)); - $elements = $this->form->barbat->getElements(); - $expected = array('bar', 'bat'); - $this->assertEquals($expected, array_keys($elements)); - $this->assertEquals(20, $this->form->barbat->getOrder()); - - $this->assertTrue(isset($this->form->foobaz)); - $elements = $this->form->foobaz->getElements(); - $expected = array('foo', 'baz'); - $this->assertEquals($expected, array_keys($elements)); - $this->assertEquals(10, $this->form->foobaz->getOrder()); - - $this->assertTrue(isset($this->form->ghiabc)); - $elements = $this->form->ghiabc->getElements(); - $expected = array('ghi', 'abc'); - $this->assertEquals($expected, array_keys($elements)); - $this->assertEquals(15, $this->form->ghiabc->getOrder()); - } - - /** - * @group ZF-3250 - */ - public function testDisplayGroupOrderInConfigShouldNotMatter() - { - require_once 'Zend/Config/Xml.php'; - $config = new Zend_Config_Xml(dirname(__FILE__) . '/_files/config/zf3250.xml', 'sitearea', true); - $form = new Zend_Form($config->test); - // no assertions needed; throws error if order matters - } - - /** - * @group ZF-3112 - */ - public function testSetOptionsShouldCreateDisplayGroupsLast() - { - $options = array(); - $options['displayGroups'] = array( - 'barbat' => array(array('bar', 'bat'), array('order' => 20)), - array(array('foo', 'baz'), 'foobaz', array('order' => 10)), - array( - 'name' => 'ghiabc', - 'elements' => array('ghi', 'abc'), - 'options' => array('order' => 15), - ), - ); - $options = array_merge($options, $this->getOptions()); - $options['elements'] = array( - 'foo' => 'text', - 'bar' => 'text', - 'baz' => 'text', - 'bat' => 'text', - 'abc' => 'text', - 'ghi' => 'text', - 'jkl' => 'text', - 'mno' => 'text', - ); - $this->form = new Zend_Form($options); - - $this->assertTrue(isset($this->form->barbat)); - $elements = $this->form->barbat->getElements(); - $expected = array('bar', 'bat'); - $this->assertEquals($expected, array_keys($elements)); - $this->assertEquals(20, $this->form->barbat->getOrder()); - - $this->assertTrue(isset($this->form->foobaz)); - $elements = $this->form->foobaz->getElements(); - $expected = array('foo', 'baz'); - $this->assertEquals($expected, array_keys($elements)); - $this->assertEquals(10, $this->form->foobaz->getOrder()); - - $this->assertTrue(isset($this->form->ghiabc)); - $elements = $this->form->ghiabc->getElements(); - $expected = array('ghi', 'abc'); - $this->assertEquals($expected, array_keys($elements)); - $this->assertEquals(15, $this->form->ghiabc->getOrder()); - } - - public function testSetConfigSetsObjectState() - { - $config = new Zend_Config($this->getOptions()); - $this->form->setConfig($config); - $this->assertEquals('foo', $this->form->getName()); - $this->assertEquals('someform', $this->form->getAttrib('class')); - $this->assertEquals('/foo/bar', $this->form->getAction()); - $this->assertEquals('put', $this->form->getMethod()); - } - - public function testCanSetObjectStateByPassingConfigObjectToConstructor() - { - $config = new Zend_Config($this->getOptions()); - $form = new Zend_Form($config); - $this->assertEquals('foo', $form->getName()); - $this->assertEquals('someform', $form->getAttrib('class')); - $this->assertEquals('/foo/bar', $form->getAction()); - $this->assertEquals('put', $form->getMethod()); - } - - - // Attribs: - - public function testAttribsArrayInitiallyEmpty() - { - $attribs = $this->form->getAttribs(); - $this->assertTrue(is_array($attribs)); - $this->assertTrue(empty($attribs)); - } - - public function testRetrievingUndefinedAttribReturnsNull() - { - $this->assertNull($this->form->getAttrib('foo')); - } - - public function testCanAddAndRetrieveSingleAttribs() - { - $this->testRetrievingUndefinedAttribReturnsNull(); - $this->form->setAttrib('foo', 'bar'); - $this->assertEquals('bar', $this->form->getAttrib('foo')); - } - - public function testCanAddAndRetrieveMultipleAttribs() - { - $this->form->setAttrib('foo', 'bar'); - $this->assertEquals('bar', $this->form->getAttrib('foo')); - $this->form->addAttribs(array( - 'bar' => 'baz', - 'baz' => 'bat', - 'bat' => 'foo' - )); - $test = $this->form->getAttribs(); - $attribs = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - 'bat' => 'foo' - ); - $this->assertSame($attribs, $test); - } - - public function testSetAttribsOverwritesExistingAttribs() - { - $this->testCanAddAndRetrieveMultipleAttribs(); - $array = array('bogus' => 'value', 'not' => 'real'); - $this->form->setAttribs($array); - $this->assertSame($array, $this->form->getAttribs()); - } - - public function testCanRemoveSingleAttrib() - { - $this->testCanAddAndRetrieveSingleAttribs(); - $this->assertTrue($this->form->removeAttrib('foo')); - $this->assertNull($this->form->getAttrib('foo')); - } - - public function testRemoveAttribReturnsFalseIfAttribDoesNotExist() - { - $this->assertFalse($this->form->removeAttrib('foo')); - } - - public function testCanClearAllAttribs() - { - $this->testCanAddAndRetrieveMultipleAttribs(); - $this->form->clearAttribs(); - $attribs = $this->form->getAttribs(); - $this->assertTrue(is_array($attribs)); - $this->assertTrue(empty($attribs)); - } - - public function testNameIsInitiallyNull() - { - $this->assertNull($this->form->getName()); - } - - public function testCanSetName() - { - $this->testNameIsInitiallyNull(); - $this->form->setName('foo'); - $this->assertEquals('foo', $this->form->getName()); - } - - public function testZeroAsNameIsAllowed() - { - try { - $this->form->setName(0); - $this->assertEquals(0, $this->form->getName()); - } catch (Zend_Form_Exception $e) { - $this->fail('Should allow zero as form name'); - } - } - - public function testSetNameNormalizesValueToContainOnlyValidVariableCharacters() - { - $this->form->setName('f%\o^&*)o\(%$b#@!.a}{;-,r'); - $this->assertEquals('foobar', $this->form->getName()); - - try { - $this->form->setName('%\^&*)\(%$#@!.}{;-,'); - $this->fail('Empty names should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid name provided', $e->getMessage()); - } - } - - public function testActionDefaultsToEmptyString() - { - $this->assertSame('', $this->form->getAction()); - } - - public function testCanSetAction() - { - $this->testActionDefaultsToEmptyString(); - $this->form->setAction('/foo/bar'); - $this->assertEquals('/foo/bar', $this->form->getAction()); - } - - public function testMethodDefaultsToPost() - { - $this->assertEquals('post', $this->form->getMethod()); - } - - public function testCanSetMethod() - { - $this->testMethodDefaultsToPost(); - $this->form->setMethod('get'); - $this->assertEquals('get', $this->form->getMethod()); - } - - public function testMethodLimitedToGetPostPutAndDelete() - { - foreach (array('get', 'post', 'put', 'delete') as $method) { - $this->form->setMethod($method); - $this->assertEquals($method, $this->form->getMethod()); - } - try { - $this->form->setMethod('bogus'); - $this->fail('Invalid method type should throw exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('invalid', $e->getMessage()); - } - } - - public function testEnctypeDefaultsToUrlEncoded() - { - $this->assertEquals(Zend_Form::ENCTYPE_URLENCODED, $this->form->getEnctype()); - } - - public function testCanSetEnctype() - { - $this->testEnctypeDefaultsToUrlEncoded(); - $this->form->setEnctype(Zend_Form::ENCTYPE_MULTIPART); - $this->assertEquals(Zend_Form::ENCTYPE_MULTIPART, $this->form->getEnctype()); - } - - public function testLegendInitiallyNull() - { - $this->assertNull($this->form->getLegend()); - } - - public function testCanSetLegend() - { - $this->testLegendInitiallyNull(); - $legend = "This is a legend"; - $this->form->setLegend($legend); - $this->assertEquals($legend, $this->form->getLegend()); - } - - public function testDescriptionInitiallyNull() - { - $this->assertNull($this->form->getDescription()); - } - - public function testCanSetDescription() - { - $this->testDescriptionInitiallyNull(); - $description = "This is a description"; - $this->form->setDescription($description); - $this->assertEquals($description, $this->form->getDescription()); - } - - // Plugin loaders - - public function testGetPluginLoaderRetrievesDefaultDecoratorPluginLoader() - { - $loader = $this->form->getPluginLoader('decorator'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - $paths = $loader->getPaths('Zend_Form_Decorator'); - $this->assertTrue(is_array($paths), var_export($loader, 1)); - $this->assertTrue(0 < count($paths)); - $this->assertContains('Form', $paths[0]); - $this->assertContains('Decorator', $paths[0]); - } - - public function testPassingInvalidTypeToSetPluginLoaderThrowsException() - { - $loader = new Zend_Loader_PluginLoader(); - try { - $this->form->setPluginLoader($loader, 'foo'); - $this->fail('Invalid plugin loader type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid type', $e->getMessage()); - } - } - - public function testPassingInvalidTypeToGetPluginLoaderThrowsException() - { - try { - $this->form->getPluginLoader('foo'); - $this->fail('Invalid plugin loader type should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid type', $e->getMessage()); - } - } - - public function testCanSetCustomDecoratorPluginLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->form->setPluginLoader($loader, 'decorator'); - $test = $this->form->getPluginLoader('decorator'); - $this->assertSame($loader, $test); - } - - public function testPassingInvalidTypeToAddPrefixPathThrowsException() - { - try { - $this->form->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'foo'); - $this->fail('Passing invalid loader type to addPrefixPath() should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Invalid type', $e->getMessage()); - } - } - - public function testCanAddDecoratorPluginLoaderPrefixPath() - { - $loader = $this->form->getPluginLoader('decorator'); - $this->form->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testUpdatedDecoratorPrefixPathUsedForNewElements() - { - $loader = $this->form->getPluginLoader('decorator'); - $this->form->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $foo = new Zend_Form_Element_Text('foo'); - $this->form->addElement($foo); - $loader = $foo->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - - $this->form->addElement('text', 'bar'); - $bar = $this->form->bar; - $loader = $bar->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testUpdatedDecoratorPrefixPathUsedForNewDisplayGroups() - { - $loader = $this->form->getPluginLoader('decorator'); - $this->form->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $this->setupElements(); - $foo = $this->form->foo; - $loader = $foo->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testUpdatedPrefixPathUsedForNewSubForms() - { - $loader = $this->form->getPluginLoader('decorator'); - $this->form->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $this->setupSubForm(); - $loader = $this->form->sub->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testGetPluginLoaderRetrievesDefaultElementPluginLoader() - { - $loader = $this->form->getPluginLoader('element'); - $this->assertTrue($loader instanceof Zend_Loader_PluginLoader); - $paths = $loader->getPaths('Zend_Form_Element'); - $this->assertTrue(is_array($paths), var_export($loader, 1)); - $this->assertTrue(0 < count($paths)); - $this->assertContains('Form', $paths[0]); - $this->assertContains('Element', $paths[0]); - } - - public function testCanSetCustomDecoratorElementLoader() - { - $loader = new Zend_Loader_PluginLoader(); - $this->form->setPluginLoader($loader, 'element'); - $test = $this->form->getPluginLoader('element'); - $this->assertSame($loader, $test); - } - - public function testCanAddElementPluginLoaderPrefixPath() - { - $loader = $this->form->getPluginLoader('element'); - $this->form->addPrefixPath('Zend_Foo', 'Zend/Foo/', 'element'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertTrue(is_array($paths)); - $this->assertContains('Foo', $paths[0]); - } - - public function testAddAllPluginLoaderPrefixPathsSimultaneously() - { - $decoratorLoader = new Zend_Loader_PluginLoader(); - $elementLoader = new Zend_Loader_PluginLoader(); - $this->form->setPluginLoader($decoratorLoader, 'decorator') - ->setPluginLoader($elementLoader, 'element') - ->addPrefixPath('Zend', 'Zend/'); - - $paths = $decoratorLoader->getPaths('Zend_Decorator'); - $this->assertTrue(is_array($paths), var_export($paths, 1)); - $this->assertContains('Decorator', $paths[0]); - - $paths = $elementLoader->getPaths('Zend_Element'); - $this->assertTrue(is_array($paths), var_export($paths, 1)); - $this->assertContains('Element', $paths[0]); - } - - // Elements: - - public function testCanAddAndRetrieveSingleElements() - { - $element = new Zend_Form_Element('foo'); - $this->form->addElement($element); - $this->assertSame($element, $this->form->getElement('foo')); - } - - public function testGetElementReturnsNullForUnregisteredElement() - { - $this->assertNull($this->form->getElement('foo')); - } - - public function testCanAddAndRetrieveSingleElementsByStringType() - { - $this->form->addElement('text', 'foo'); - $element = $this->form->getElement('foo'); - $this->assertTrue($element instanceof Zend_Form_Element); - $this->assertTrue($element instanceof Zend_Form_Element_Text); - $this->assertEquals('foo', $element->getName()); - } - - public function testAddElementAsStringElementThrowsExceptionWhenNoNameProvided() - { - try { - $this->form->addElement('text'); - $this->fail('Should not be able to specify string element type without name'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('must have', $e->getMessage()); - } - } - - public function testCreateElementReturnsNewElement() - { - $element = $this->form->createElement('text', 'foo'); - $this->assertTrue($element instanceof Zend_Form_Element); - } - - public function testCreateElementDoesNotAttachElementToForm() - { - $element = $this->form->createElement('text', 'foo'); - $this->assertTrue($element instanceof Zend_Form_Element); - $this->assertNull($this->form->foo); - } - - public function testCanAddAndRetrieveMultipleElements() - { - $this->form->addElements(array( - 'foo' => 'text', - array('text', 'bar'), - array('text', 'baz', array('foo' => 'bar')), - new Zend_Form_Element_Text('bat'), - )); - $elements = $this->form->getElements(); - $names = array('foo', 'bar', 'baz', 'bat'); - $this->assertEquals($names, array_keys($elements)); - $foo = $elements['foo']; - $this->assertTrue($foo instanceof Zend_Form_Element_Text); - $bar = $elements['bar']; - $this->assertTrue($bar instanceof Zend_Form_Element_Text); - $baz = $elements['baz']; - $this->assertTrue($baz instanceof Zend_Form_Element_Text); - $this->assertEquals('bar', $baz->foo, var_export($baz->getAttribs(), 1)); - $bat = $elements['bat']; - $this->assertTrue($bat instanceof Zend_Form_Element_Text); - } - - public function testSetElementsOverwritesExistingElements() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->setElements(array( - 'bogus' => 'text' - )); - $elements = $this->form->getElements(); - $names = array('bogus'); - $this->assertEquals($names, array_keys($elements)); - } - - public function testCanRemoveSingleElement() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->assertTrue($this->form->removeElement('bar')); - $this->assertNull($this->form->getElement('bar')); - } - - public function testRemoveElementReturnsFalseWhenElementNotRegistered() - { - $this->assertFalse($this->form->removeElement('bogus')); - } - - public function testCanClearAllElements() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->clearElements(); - $elements = $this->form->getElements(); - $this->assertTrue(is_array($elements)); - $this->assertTrue(empty($elements)); - } - - public function testGetValueReturnsNullForUndefinedElements() - { - $this->assertNull($this->form->getValue('foo')); - } - - public function testCanSetElementDefaultValues() - { - $this->testCanAddAndRetrieveMultipleElements(); - $values = array( - 'foo' => 'foovalue', - 'bar' => 'barvalue', - 'baz' => 'bazvalue', - 'bat' => 'batvalue' - ); - $this->form->setDefaults($values); - $elements = $this->form->getElements(); - foreach (array_keys($values) as $name) { - $this->assertEquals($name . 'value', $elements[$name]->getValue(), var_export($elements[$name], 1)); - } - } - - public function testSettingElementDefaultsDoesNotSetElementValuesToNullIfNotInDefaultsArray() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->baz->setValue('testing'); - $this->form->bar->setValue('testing'); - $values = array( - 'foo' => 'foovalue', - 'bat' => 'batvalue' - ); - $this->form->setDefaults($values); - $this->assertEquals('foovalue', $this->form->foo->getValue()); - $this->assertEquals('batvalue', $this->form->bat->getValue()); - $this->assertNotNull($this->form->baz->getValue()); - $this->assertNotNull($this->form->bar->getValue()); - } - - public function testCanRetrieveSingleElementValue() - { - $this->form->addElement('text', 'foo', array('value' => 'foovalue')); - $this->assertEquals('foovalue', $this->form->getValue('foo')); - } - - public function testCanRetrieveAllElementValues() - { - $this->testCanAddAndRetrieveMultipleElements(); - $values = array( - 'foo' => 'foovalue', - 'bar' => 'barvalue', - 'baz' => 'bazvalue', - 'bat' => 'batvalue' - ); - $this->form->setDefaults($values); - $test = $this->form->getValues(); - $elements = $this->form->getElements(); - foreach (array_keys($values) as $name) { - $this->assertEquals($values[$name], $test[$name]); - } - } - - public function testRetrievingAllElementValuesSkipsThoseFlaggedAsIgnore() - { - $this->form->addElements(array( - 'foo' => 'text', - 'bar' => 'text', - 'baz' => 'text' - )); - $this->form->setDefaults(array( - 'foo' => 'Foo Value', - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - )); - $this->form->bar->setIgnore(true); - $test = $this->form->getValues(); - $this->assertFalse(array_key_exists('bar', $test)); - $this->assertTrue(array_key_exists('foo', $test)); - $this->assertTrue(array_key_exists('baz', $test)); - } - - public function testCanRetrieveSingleUnfilteredElementValue() - { - $foo = new Zend_Form_Element_Text('foo'); - $foo->addFilter('StringToUpper') - ->setValue('foovalue'); - $this->form->addElement($foo); - $this->assertEquals('FOOVALUE', $this->form->getValue('foo')); - $this->assertEquals('foovalue', $this->form->getUnfilteredValue('foo')); - } - - public function testCanRetrieveAllUnfilteredElementValues() - { - $foo = new Zend_Form_Element_Text('foo'); - $foo->addFilter('StringToUpper') - ->setValue('foovalue'); - $bar = new Zend_Form_Element_Text('bar'); - $bar->addFilter('StringToUpper') - ->setValue('barvalue'); - $this->form->addElements(array($foo, $bar)); - $values = $this->form->getValues(); - $unfiltered = $this->form->getUnfilteredValues(); - foreach (array('foo', 'bar') as $key) { - $value = $key . 'value'; - $this->assertEquals(strtoupper($value), $values[$key]); - $this->assertEquals($value, $unfiltered[$key]); - } - } - - public function testOverloadingElements() - { - $this->form->addElement('text', 'foo'); - $this->assertTrue(isset($this->form->foo)); - $element = $this->form->foo; - $this->assertTrue($element instanceof Zend_Form_Element); - unset($this->form->foo); - $this->assertFalse(isset($this->form->foo)); - - $bar = new Zend_Form_Element_Text('bar'); - $this->form->bar = $bar; - $this->assertTrue(isset($this->form->bar)); - $element = $this->form->bar; - $this->assertSame($bar, $element); - } - - public function testOverloadingGetReturnsNullForUndefinedFormItems() - { - $this->assertNull($this->form->bogus); - } - - public function testOverloadingSetThrowsExceptionForInvalidTypes() - { - try { - $this->form->foo = true; - $this->fail('Overloading should not allow scalars'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Only form elements and groups may be overloaded', $e->getMessage()); - } - - try { - $this->form->foo = new Zend_Config(array()); - $this->fail('Overloading should not allow arbitrary object types'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('Only form elements and groups may be overloaded', $e->getMessage()); - $this->assertContains('Zend_Config', $e->getMessage()); - } - } - - public function testFormIsNotAnArrayByDefault() - { - $this->assertFalse($this->form->isArray()); - } - - public function testCanSetArrayFlag() - { - $this->testFormIsNotAnArrayByDefault(); - $this->form->setIsArray(true); - $this->assertTrue($this->form->isArray()); - $this->form->setIsArray(false); - $this->assertFalse($this->form->isArray()); - } - - public function testElementsBelongToReturnsFormNameWhenFormIsArray() - { - $this->form->setName('foo') - ->setIsArray(true); - $this->assertEquals('foo', $this->form->getElementsBelongTo()); - } - - public function testElementsInitiallyBelongToNoArrays() - { - $this->assertNull($this->form->getElementsBelongTo()); - } - - public function testCanSetArrayToWhichElementsBelong() - { - $this->testElementsInitiallyBelongToNoArrays(); - $this->form->setElementsBelongTo('foo'); - $this->assertEquals('foo', $this->form->getElementsBelongTo()); - } - - public function testSettingArrayToWhichElementsBelongSetsArrayFlag() - { - $this->testFormIsNotAnArrayByDefault(); - $this->testCanSetArrayToWhichElementsBelong(); - $this->assertTrue($this->form->isArray()); - } - - public function testArrayToWhichElementsBelongCanConsistOfValidVariableCharsOnly() - { - $this->testElementsInitiallyBelongToNoArrays(); - $this->form->setElementsBelongTo('f%\o^&*)o\(%$b#@!.a}{;-,r'); - $this->assertEquals('foobar', $this->form->getElementsBelongTo()); - } - - public function testSettingArrayToWhichElementsBelongEmptyClearsIt() - { - $this->testCanSetArrayToWhichElementsBelong(); - $this->form->setElementsBelongTo(''); - $this->assertNull($this->form->getElementsBelongTo()); - } - - public function testSettingArrayToWhichElementsBelongEmptySetsArrayFlagToFalse() - { - $this->testSettingArrayToWhichElementsBelongEmptyClearsIt(); - $this->assertFalse($this->form->isArray()); - } - - /** - * @group ZF-3146 - */ - public function testSetElementsBelongToShouldApplyToBothExistingAndFutureElements() - { - $this->form->addElement('text', 'testBelongsTo'); - $this->form->setElementsBelongTo('foo'); - $this->assertEquals('foo', $this->form->testBelongsTo->getBelongsTo(), 'Failed determining testBelongsTo belongs to array'); - $this->setupElements(); - foreach ($this->form->getElements() as $element) { - $message = sprintf('Failed determining element "%s" belongs to foo', $element->getName()); - $this->assertEquals('foo', $element->getBelongsTo(), $message); - } - } - - /** - * @group ZF-3742 - */ - public function testElementsInDisplayGroupsShouldInheritFormElementsBelongToSetting() - { - $subForm = new Zend_Form_SubForm(); - $subForm->addElements(array( - new Zend_Form_Element_Text('foo'), - new Zend_Form_Element_Text('bar'), - new Zend_Form_Element_Text('baz'), - new Zend_Form_Element_Text('bat'), - )) - ->addDisplayGroup(array('bar', 'baz'), 'barbaz'); - $this->form->addSubForm($subForm, 'sub') - ->setElementsBelongTo('myform') - ->setView(new Zend_View); - $html = $this->form->render(); - foreach (array('foo', 'bar', 'baz', 'bat') as $test) { - $this->assertContains('id="myform-sub-' . $test . '"', $html); - $this->assertContains('name="myform[sub][' . $test . ']"', $html); - } - } - - public function testIsValidWithOneLevelElementsBelongTo() - { - $this->form->addElement('text', 'test')->test - ->addValidator('Identical', false, array('Test Value')); - $this->form->setElementsBelongTo('foo'); - - $data = array( - 'foo' => array( - 'test' => 'Test Value', - ), - ); - - $this->assertTrue($this->form->isValid($data)); - } - - public function testIsValidWithMultiLevelElementsBelongTo() - { - $this->form->addElement('text', 'test')->test - ->addValidator('Identical', false, array('Test Value')); - $this->form->setElementsBelongTo('foo[bar][zot]'); - - $data = array( - 'foo' => array( - 'bar' => array( - 'zot' => array( - 'test' => 'Test Value', - ), - ), - ), - ); - - $this->assertTrue($this->form->isValid($data)); - } - - // Sub forms - - public function testCanAddAndRetrieveSingleSubForm() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $this->form->addSubForm($subForm, 'page1'); - $test = $this->form->getSubForm('page1'); - $this->assertSame($subForm, $test); - } - - public function testAddingSubFormSetsSubFormName() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $this->form->addSubForm($subForm, 'page1'); - $this->assertEquals('page1', $subForm->getName()); - } - - public function testGetSubFormReturnsNullForUnregisteredSubForm() - { - $this->assertNull($this->form->getSubForm('foo')); - } - - public function testCanAddAndRetrieveMultipleSubForms() - { - $page1 = new Zend_Form_SubForm(); - $page2 = new Zend_Form_SubForm(); - $page3 = new Zend_Form_SubForm(); - $this->form->addSubForms(array( - 'page1' => $page1, - array($page2, 'page2'), - array($page3, 'page3', 3) - )); - $subforms = $this->form->getSubForms(); - $keys = array('page1', 'page2', 'page3'); - $this->assertEquals($keys, array_keys($subforms)); - $this->assertSame($page1, $subforms['page1']); - $this->assertSame($page2, $subforms['page2']); - $this->assertSame($page3, $subforms['page3']); - } - - public function testSetSubFormsOverwritesExistingSubForms() - { - $this->testCanAddAndRetrieveMultipleSubForms(); - $foo = new Zend_Form_SubForm(); - $this->form->setSubForms(array('foo' => $foo)); - $subforms = $this->form->getSubForms(); - $keys = array('foo'); - $this->assertEquals($keys, array_keys($subforms)); - $this->assertSame($foo, $subforms['foo']); - } - - public function testCanRemoveSingleSubForm() - { - $this->testCanAddAndRetrieveMultipleSubForms(); - $this->assertTrue($this->form->removeSubForm('page2')); - $this->assertNull($this->form->getSubForm('page2')); - } - - public function testRemoveSubFormReturnsFalseForNonexistantSubForm() - { - $this->assertFalse($this->form->removeSubForm('foo')); - } - - public function testCanClearAllSubForms() - { - $this->testCanAddAndRetrieveMultipleSubForms(); - $this->form->clearSubForms(); - $subforms = $this->form->getSubForms(); - $this->assertTrue(is_array($subforms)); - $this->assertTrue(empty($subforms)); - } - - public function testOverloadingSubForms() - { - $foo = new Zend_Form_SubForm; - $this->form->addSubForm($foo, 'foo'); - $this->assertTrue(isset($this->form->foo)); - $subform = $this->form->foo; - $this->assertSame($foo, $subform); - unset($this->form->foo); - $this->assertFalse(isset($this->form->foo)); - - $bar = new Zend_Form_SubForm(); - $this->form->bar = $bar; - $this->assertTrue(isset($this->form->bar)); - $subform = $this->form->bar; - $this->assertSame($bar, $subform); - } - - public function testCanSetDefaultsForSubFormElementsFromForm() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $this->form->addSubForm($subForm, 'page1'); - - $data = array('foo' => 'foo value', 'bar' => 'bar value'); - $this->form->setDefaults($data); - $this->assertEquals($data['foo'], $subForm->foo->getValue()); - $this->assertEquals($data['bar'], $subForm->bar->getValue()); - } - - public function testCanSetDefaultsForSubFormElementsFromFormWithArray() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $this->form->addSubForm($subForm, 'page1'); - - $data = array( 'page1' => array( - 'foo' => 'foo value', - 'bar' => 'bar value' - )); - $this->form->setDefaults($data); - $this->assertEquals($data['page1']['foo'], $subForm->foo->getValue()); - $this->assertEquals($data['page1']['bar'], $subForm->bar->getValue()); - } - - public function testGetValuesReturnsSubFormValues() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $subForm->foo->setValue('foo value'); - $subForm->bar->setValue('bar value'); - $this->form->addSubForm($subForm, 'page1'); - - $values = $this->form->getValues(); - $this->assertTrue(isset($values['page1'])); - $this->assertTrue(isset($values['page1']['foo'])); - $this->assertTrue(isset($values['page1']['bar'])); - $this->assertEquals($subForm->foo->getValue(), $values['page1']['foo']); - $this->assertEquals($subForm->bar->getValue(), $values['page1']['bar']); - } - - public function testGetValuesReturnsSubFormValuesFromArrayToWhichElementsBelong() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')) - ->setElementsBelongTo('subform'); - $subForm->foo->setValue('foo value'); - $subForm->bar->setValue('bar value'); - $this->form->addSubForm($subForm, 'page1'); - - $values = $this->form->getValues(); - $this->assertTrue(isset($values['subform']), var_export($values, 1)); - $this->assertTrue(isset($values['subform']['foo'])); - $this->assertTrue(isset($values['subform']['bar'])); - $this->assertEquals($subForm->foo->getValue(), $values['subform']['foo']); - $this->assertEquals($subForm->bar->getValue(), $values['subform']['bar']); - } - - public function testGetValuesReturnsNestedSubFormValuesFromArraysToWhichElementsBelong() - { - $form = new Zend_Form(); - $form->setElementsBelongTo('foobar'); - - $form->addElement('text', 'firstName') - ->getElement('firstName') - ->setRequired(true); - - $form->addElement('text', 'lastName') - ->getElement('lastName') - ->setRequired(true); - - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('baz[quux]'); - $subForm->addElement('text', 'email') - ->getElement('email')->setRequired(true); - - $subSubForm = new Zend_Form_SubForm(); - $subSubForm->setElementsBelongTo('bat'); - $subSubForm->addElement('checkbox', 'home') - ->getElement('home')->setRequired(true); - - $subForm->addSubForm($subSubForm, 'subSub'); - - $form->addSubForm($subForm, 'sub') - ->addElement('submit', 'save', array('value' => 'submit', 'ignore' => true)); - - - $data = array('foobar' => array( - 'firstName' => 'Mabel', - 'lastName' => 'Cow', - 'baz' => array( - 'quux' => array( - 'email' => 'mabel@cow.org', - 'bat' => array( - 'home' => 1, - ) - ), - ) - )); - $this->assertTrue($form->isValid($data)); - - $values = $form->getValues(); - $this->assertEquals($data, $values); - } - - public function testGetValueCanReturnSubFormValues() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $subForm->foo->setValue('foo value'); - $subForm->bar->setValue('bar value'); - $this->form->addSubForm($subForm, 'page1'); - - $values = $this->form->getValue('page1'); - $this->assertTrue(isset($values['foo']), var_export($values, 1)); - $this->assertTrue(isset($values['bar'])); - $this->assertEquals($subForm->foo->getValue(), $values['foo']); - $this->assertEquals($subForm->bar->getValue(), $values['bar']); - } - - public function testGetValueCanReturnSubFormValuesFromArrayToWhichElementsBelong() - { - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')) - ->setElementsBelongTo('subform'); - $subForm->foo->setValue('foo value'); - $subForm->bar->setValue('bar value'); - $this->form->addSubForm($subForm, 'page1'); - - $values = $this->form->getValue('subform'); - $this->assertTrue(isset($values['foo']), var_export($values, 1)); - $this->assertTrue(isset($values['bar'])); - $this->assertEquals($subForm->foo->getValue(), $values['foo']); - $this->assertEquals($subForm->bar->getValue(), $values['bar']); - } - - public function testIsValidCanValidateSubFormsWithArbitraryElementsBelong() - { - $subForm = new Zend_Form_SubForm(); - $subForm->addElement('text', 'test')->test - ->setRequired(true)->addValidator('Identical', false, array('Test Value')); - $this->form->addSubForm($subForm, 'sub'); - - $this->form->setElementsBelongTo('foo[bar]'); - $subForm->setElementsBelongTo('my[subform]'); - - $data = array( - 'foo' => array( - 'bar' => array( - 'my' => array( - 'subform' => array( - 'test' => 'Test Value', - ), - ), - ), - ), - ); - - $this->assertTrue($this->form->isValid($data)); - } - - public function testIsValidCanValidateNestedSubFormsWithArbitraryElementsBelong() - { - $subForm = new Zend_Form_SubForm(); - $subForm->addElement('text', 'test1')->test1 - ->setRequired(true)->addValidator('Identical', false, array('Test1 Value')); - $this->form->addSubForm($subForm, 'sub'); - - $subSubForm = new Zend_Form_SubForm(); - $subSubForm->addElement('text', 'test2')->test2 - ->setRequired(true)->addValidator('Identical', false, array('Test2 Value')); - $subForm->addSubForm($subSubForm, 'subSub'); - - $this->form->setElementsBelongTo('form[first]'); - // Notice we skipped subForm, to mix manual and auto elementsBelongTo. - $subSubForm->setElementsBelongTo('subsubform[first]'); - - $data = array( - 'form' => array( - 'first' => array( - 'sub' => array( - 'test1' => 'Test1 Value', - - 'subsubform' => array( - 'first' => array( - 'test2' => 'Test2 Value', - ), - ), - ), - ), - ), - ); - - $this->assertTrue($this->form->isValid($data)); - } - - - // Display groups - - public function testCanAddAndRetrieveSingleDisplayGroups() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->addDisplayGroup(array('bar', 'bat'), 'barbat'); - $group = $this->form->getDisplayGroup('barbat'); - $this->assertTrue($group instanceof Zend_Form_DisplayGroup); - $elements = $group->getElements(); - $expected = array('bar' => $this->form->bar, 'bat' => $this->form->bat); - $this->assertEquals($expected, $elements); - } - - public function testDisplayGroupsMustContainAtLeastOneElement() - { - try { - $this->form->addDisplayGroup(array(), 'foo'); - $this->fail('Empty display group should raise exception'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('No valid elements', $e->getMessage()); - } - } - - public function testCanAddAndRetrieveMultipleDisplayGroups() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->addDisplayGroups(array( - array(array('bar', 'bat'), 'barbat'), - 'foobaz' => array('baz', 'foo') - )); - $groups = $this->form->getDisplayGroups(); - $expected = array( - 'barbat' => array('bar' => $this->form->bar, 'bat' => $this->form->bat), - 'foobaz' => array('baz' => $this->form->baz, 'foo' => $this->form->foo), - ); - foreach ($groups as $group) { - $this->assertTrue($group instanceof Zend_Form_DisplayGroup); - } - $this->assertEquals($expected['barbat'], $groups['barbat']->getElements()); - $this->assertEquals($expected['foobaz'], $groups['foobaz']->getElements()); - } - - public function testSetDisplayGroupsOverwritesExistingDisplayGroups() - { - $this->testCanAddAndRetrieveMultipleDisplayGroups(); - $this->form->setDisplayGroups(array('foobar' => array('bar', 'foo'))); - $groups = $this->form->getDisplayGroups(); - $expected = array('bar' => $this->form->bar, 'foo' => $this->form->foo); - $this->assertEquals(1, count($groups)); - $this->assertTrue(isset($groups['foobar'])); - $this->assertEquals($expected, $groups['foobar']->getElements()); - } - - public function testCanRemoveSingleDisplayGroup() - { - $this->testCanAddAndRetrieveMultipleDisplayGroups(); - $this->assertTrue($this->form->removeDisplayGroup('barbat')); - $this->assertNull($this->form->getDisplayGroup('barbat')); - } - - public function testRemoveDisplayGroupReturnsFalseForNonexistantGroup() - { - $this->assertFalse($this->form->removeDisplayGroup('bogus')); - } - - public function testCanClearAllDisplayGroups() - { - $this->testCanAddAndRetrieveMultipleDisplayGroups(); - $this->form->clearDisplayGroups(); - $groups = $this->form->getDisplayGroups(); - $this->assertTrue(is_array($groups)); - $this->assertTrue(empty($groups)); - } - - public function testOverloadingDisplayGroups() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->addDisplayGroup(array('foo', 'bar'), 'foobar'); - $this->assertTrue(isset($this->form->foobar)); - $group = $this->form->foobar; - $expected = array('foo' => $this->form->foo, 'bar' => $this->form->bar); - $this->assertEquals($expected, $group->getElements()); - unset($this->form->foobar); - $this->assertFalse(isset($this->form->foobar)); - - $this->form->barbaz = array('bar', 'baz'); - $this->assertTrue(isset($this->form->barbaz)); - $group = $this->form->barbaz; - $expected = array('bar' => $this->form->bar, 'baz' => $this->form->baz); - $this->assertSame($expected, $group->getElements()); - } - - public function testDefaultDisplayGroupClassExists() - { - $this->assertEquals('Zend_Form_DisplayGroup', $this->form->getDefaultDisplayGroupClass()); - } - - public function testCanSetDefaultDisplayGroupClass() - { - $this->testDefaultDisplayGroupClassExists(); - $this->form->setDefaultDisplayGroupClass('Zend_Form_FormTest_DisplayGroup'); - $this->assertEquals('Zend_Form_FormTest_DisplayGroup', $this->form->getDefaultDisplayGroupClass()); - } - - public function testDefaultDisplayGroupClassUsedForNewDisplayGroups() - { - $this->form->setDefaultDisplayGroupClass('Zend_Form_FormTest_DisplayGroup'); - $this->setupElements(); - $this->form->addDisplayGroup(array('foo', 'bar'), 'foobar'); - $displayGroup = $this->form->getDisplayGroup('foobar'); - $this->assertTrue($displayGroup instanceof Zend_Form_FormTest_DisplayGroup); - } - - public function testCanPassDisplayGroupClassWhenAddingDisplayGroup() - { - $this->setupElements(); - $this->form->addDisplayGroup(array('foo', 'bar'), 'foobar', array('displayGroupClass' => 'Zend_Form_FormTest_DisplayGroup')); - $this->assertTrue($this->form->foobar instanceof Zend_Form_FormTest_DisplayGroup); - } - - /** - * @group ZF-3254 - */ - public function testAddingDisplayGroupShouldPassOptions() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->addDisplayGroup(array('bar', 'bat'), 'barbat', array('disableLoadDefaultDecorators' => true)); - $group = $this->form->getDisplayGroup('barbat'); - $this->assertTrue($group instanceof Zend_Form_DisplayGroup); - $decorators = $group->getDecorators(); - $this->assertTrue(is_array($decorators)); - $this->assertTrue(empty($decorators)); - } - - // Processing - - public function testPopulateProxiesToSetDefaults() - { - $this->testCanAddAndRetrieveMultipleElements(); - $values = array( - 'foo' => 'foovalue', - 'bar' => 'barvalue', - 'baz' => 'bazvalue', - 'bat' => 'batvalue' - ); - $this->form->populate($values); - $test = $this->form->getValues(); - $elements = $this->form->getElements(); - foreach (array_keys($values) as $name) { - $this->assertEquals($values[$name], $test[$name]); - } - } - - public function setupElements() - { - $foo = new Zend_Form_Element_Text('foo'); - $foo->addValidator('NotEmpty') - ->addValidator('Alpha'); - $bar = new Zend_Form_Element_Text('bar'); - $bar->addValidator('NotEmpty') - ->addValidator('Digits'); - $baz = new Zend_Form_Element_Text('baz'); - $baz->addValidator('NotEmpty') - ->addValidator('Alnum'); - $this->form->addElements(array($foo, $bar, $baz)); - $this->elementValues = array( - 'foo' => 'fooBarBAZ', - 'bar' => '123456789', - 'baz' => 'foo123BAR', - ); - } - - public function testIsValidShouldThrowExceptionWithNonArrayArgument() - { - try { - $this->form->isValid(true); - $this->fail('isValid() should raise exception with non-array argument'); - } catch (Zend_Form_Exception $e) { - $this->assertContains('expects an array', $e->getMessage()); - } - } - - public function testCanValidateFullFormContainingOnlyElements() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->assertTrue($this->form->isValid($this->elementValues)); - $values = array( - 'foo' => '12345', - 'bar' => 'abc', - 'baz' => 'abc-123' - ); - $this->assertFalse($this->form->isValid($values)); - - $validator = $this->form->foo->getValidator('alpha'); - $this->assertEquals('12345', $validator->value); - - $validator = $this->form->bar->getValidator('digits'); - $this->assertEquals('abc', $validator->value); - - $validator = $this->form->baz->getValidator('alnum'); - $this->assertEquals('abc-123', $validator->value); - } - - public function testValidationTakesElementRequiredFlagsIntoAccount() - { - $this->_checkZf2794(); - - $this->setupElements(); - - $this->assertTrue($this->form->isValid(array())); - - $this->form->getElement('foo')->setRequired(true); - $this->assertTrue($this->form->isValid(array( - 'foo' => 'abc', - 'baz' => 'abc123' - ))); - $this->assertFalse($this->form->isValid(array( - 'baz' => 'abc123' - ))); - } - - public function testCanValidatePartialFormContainingOnlyElements() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->form->getElement('foo')->setRequired(true); - $this->form->getElement('bar')->setRequired(true); - $this->form->getElement('baz')->setRequired(true); - $this->assertTrue($this->form->isValidPartial(array( - 'foo' => 'abc', - 'baz' => 'abc123' - ))); - $this->assertFalse($this->form->isValidPartial(array( - 'foo' => '123', - 'baz' => 'abc-123' - ))); - } - - public function setupSubForm() - { - $subForm = new Zend_Form_SubForm(); - $foo = new Zend_Form_Element_Text('subfoo'); - $foo->addValidators(array('NotEmpty', 'Alpha'))->setRequired(true); - $bar = new Zend_Form_Element_Text('subbar'); - $bar->addValidators(array('NotEmpty', 'Digits')); - $baz = new Zend_Form_Element_Text('subbaz'); - $baz->addValidators(array('NotEmpty', 'Alnum'))->setRequired(true); - $subForm->addElements(array($foo, $bar, $baz)); - $this->form->addSubForm($subForm, 'sub'); - } - - public function testFullDataArrayUsedToValidateSubFormByDefault() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->setupSubForm(); - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'subfoo' => 'abcdef', - 'subbar' => '123456', - 'subbaz' => '123abc', - ); - $this->assertTrue($this->form->isValid($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'subfoo' => '123', - 'subbar' => 'abc', - 'subbaz' => '123-abc', - ); - $this->assertFalse($this->form->isValid($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'subfoo' => 'abc', - 'subbaz' => '123abc', - ); - $this->assertTrue($this->form->isValid($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'subbar' => '123', - 'subbaz' => '123abc', - ); - $this->assertFalse($this->form->isValid($data)); - } - - public function testDataKeyWithSameNameAsSubFormIsUsedForValidatingSubForm() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->setupSubForm(); - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'sub' => array( - 'subfoo' => 'abcdef', - 'subbar' => '123456', - 'subbaz' => '123abc', - ), - ); - $this->assertTrue($this->form->isValid($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'sub' => array( - 'subfoo' => '123', - 'subbar' => 'abc', - 'subbaz' => '123-abc', - ) - ); - $this->assertFalse($this->form->isValid($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'sub' => array( - 'subfoo' => 'abc', - 'subbaz' => '123abc', - ) - ); - $this->assertTrue($this->form->isValid($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'sub' => array( - 'subbar' => '123', - 'subbaz' => '123abc', - ) - ); - $this->assertFalse($this->form->isValid($data)); - } - - public function testCanValidateNestedFormsWithElementsBelongingToArrays() - { - $form = new Zend_Form(); - $form->setElementsBelongTo('foobar'); - - $form->addElement('text', 'firstName') - ->getElement('firstName') - ->setRequired(true); - - $form->addElement('text', 'lastName') - ->getElement('lastName') - ->setRequired(true); - - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('baz'); - $subForm->addElement('text', 'email') - ->getElement('email')->setRequired(true); - - $subSubForm = new Zend_Form_SubForm(); - $subSubForm->setElementsBelongTo('bat'); - $subSubForm->addElement('checkbox', 'home') - ->getElement('home')->setRequired(true); - - $subForm->addSubForm($subSubForm, 'subSub'); - - $form->addSubForm($subForm, 'sub') - ->addElement('submit', 'save', array('value' => 'submit')); - - - $data = array('foobar' => array( - 'firstName' => 'Mabel', - 'lastName' => 'Cow', - 'baz' => array( - 'email' => 'mabel@cow.org', - 'bat' => array( - 'home' => 1, - ) - ) - )); - $this->assertTrue($form->isValid($data)); - $this->assertEquals('Mabel', $form->firstName->getValue()); - $this->assertEquals('Cow', $form->lastName->getValue()); - $this->assertEquals('mabel@cow.org', $form->sub->email->getValue()); - $this->assertEquals(1, $form->sub->subSub->home->getValue()); - } - - public function testCanValidatePartialFormContainingSubForms() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->setupSubForm(); - - $data = array( - 'subfoo' => 'abcdef', - 'subbar' => '123456', - ); - $this->assertTrue($this->form->isValidPartial($data)); - - $data = array( - 'foo' => 'abcdef', - 'baz' => '123abc', - 'sub' => array( - 'subbar' => '123', - ) - ); - $this->assertTrue($this->form->isValidPartial($data)); - - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'sub' => array( - 'subfoo' => '123', - ) - ); - $this->assertFalse($this->form->isValidPartial($data)); - } - - public function testCanValidatePartialNestedFormsWithElementsBelongingToArrays() - { - $this->_checkZf2794(); - - $form = new Zend_Form(); - $form->setElementsBelongTo('foobar'); - - $form->addElement('text', 'firstName') - ->getElement('firstName') - ->setRequired(false); - - $form->addElement('text', 'lastName') - ->getElement('lastName') - ->setRequired(true); - - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('baz'); - $subForm->addElement('text', 'email') - ->getElement('email') - ->setRequired(true) - ->addValidator('NotEmpty'); - - $subSubForm = new Zend_Form_SubForm(); - $subSubForm->setElementsBelongTo('bat'); - $subSubForm->addElement('checkbox', 'home') - ->getElement('home') - ->setRequired(true) - ->addValidator('InArray', false, array(array('1'))); - - $subForm->addSubForm($subSubForm, 'subSub'); - - $form->addSubForm($subForm, 'sub') - ->addElement('submit', 'save', array('value' => 'submit')); - - - $data = array('foobar' => array( - 'lastName' => 'Cow', - )); - $this->assertTrue($form->isValidPartial($data)); - $this->assertEquals('Cow', $form->lastName->getValue()); - $firstName = $form->firstName->getValue(); - $email = $form->sub->email->getValue(); - $home = $form->sub->subSub->home->getValue(); - $this->assertTrue(empty($firstName)); - $this->assertTrue(empty($email)); - $this->assertTrue(empty($home)); - - $form->sub->subSub->home->addValidator('StringLength', false, array(4, 6)); - $data['foobar']['baz'] = array('bat' => array('home' => 'ab')); - - $this->assertFalse($form->isValidPartial($data), var_export($data, 1)); - $this->assertEquals('0', $form->sub->subSub->home->getValue()); - $messages = $form->getMessages(); - $this->assertFalse(empty($messages)); - $this->assertTrue(isset($messages['foobar']['baz']['bat']['home']), var_export($messages, 1)); - $this->assertTrue(isset($messages['foobar']['baz']['bat']['home']['notInArray']), var_export($messages, 1)); - } - - public function testCanValidatePartialNestedFormsWithMultiLevelElementsBelongingToArrays() - { - $this->_checkZf2794(); - - $form = new Zend_Form(); - $form->setElementsBelongTo('foo[bar]'); - - $form->addElement('text', 'firstName') - ->getElement('firstName') - ->setRequired(false); - - $form->addElement('text', 'lastName') - ->getElement('lastName') - ->setRequired(true); - - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('baz'); - $subForm->addElement('text', 'email') - ->getElement('email') - ->setRequired(true) - ->addValidator('NotEmpty'); - - $subSubForm = new Zend_Form_SubForm(); - $subSubForm->setElementsBelongTo('bat[quux]'); - $subSubForm->addElement('checkbox', 'home') - ->getElement('home') - ->setRequired(true) - ->addValidator('InArray', false, array(array('1'))); - - $subForm->addSubForm($subSubForm, 'subSub'); - - $form->addSubForm($subForm, 'sub') - ->addElement('submit', 'save', array('value' => 'submit')); - - - $data = array('foo' => array( - 'bar' => array( - 'lastName' => 'Cow', - ), - )); - $this->assertTrue($form->isValidPartial($data)); - $this->assertEquals('Cow', $form->lastName->getValue()); - $firstName = $form->firstName->getValue(); - $email = $form->sub->email->getValue(); - $home = $form->sub->subSub->home->getValue(); - $this->assertTrue(empty($firstName)); - $this->assertTrue(empty($email)); - $this->assertTrue(empty($home)); - - $form->sub->subSub->home->addValidator('StringLength', false, array(4, 6)); - $data['foo']['bar']['baz'] = array('bat' => array('quux' => array('home' => 'ab'))); - - $this->assertFalse($form->isValidPartial($data), var_export($data, 1)); - $this->assertEquals('0', $form->sub->subSub->home->getValue()); - } - - public function testCanGetMessagesOfNestedFormsWithMultiLevelElementsBelongingToArrays() - { - $this->_checkZf2794(); - - $form = new Zend_Form(); - $form->setElementsBelongTo('foo[bar]'); - - $form->addElement('text', 'firstName') - ->getElement('firstName') - ->setRequired(false); - - $form->addElement('text', 'lastName') - ->getElement('lastName') - ->setRequired(true); - - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('baz'); - $subForm->addElement('text', 'email') - ->getElement('email') - ->setRequired(true) - ->addValidator('NotEmpty'); - - $subSubForm = new Zend_Form_SubForm(); - $subSubForm->setElementsBelongTo('bat[quux]'); - $subSubForm->addElement('checkbox', 'home') - ->getElement('home') - ->setRequired(true) - ->addValidator('InArray', false, array(array('1'))); - - $subForm->addSubForm($subSubForm, 'subSub'); - - $form->addSubForm($subForm, 'sub') - ->addElement('submit', 'save', array('value' => 'submit')); - - - $data = array('foo' => array( - 'bar' => array( - 'lastName' => 'Cow', - ), - )); - - - $form->sub->subSub->home->addValidator('StringLength', false, array(4, 6)); - $data['foo']['bar']['baz'] = array('bat' => array('quux' => array('home' => 'ab'))); - - $form->isValidPartial($data); - - $messages = $form->getMessages(); - $this->assertFalse(empty($messages)); - $this->assertTrue(isset($messages['foo']['bar']['baz']['bat']['quux']['home']), var_export($messages, 1)); - $this->assertTrue(isset($messages['foo']['bar']['baz']['bat']['quux']['home']['notInArray']), var_export($messages, 1)); - } - - public function testValidatingFormWithDisplayGroupsDoesSameAsWithout() - { - $this->setupElements(); - $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz'); - $this->assertTrue($this->form->isValid($this->elementValues)); - $this->assertFalse($this->form->isValid(array( - 'foo' => '123', - 'bar' => 'abc', - 'baz' => 'abc-123' - ))); - } - - public function testValidatePartialFormWithDisplayGroupsDoesSameAsWithout() - { - $this->setupElements(); - $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz'); - $this->assertTrue($this->form->isValid(array( - 'foo' => 'abc', - 'baz' => 'abc123' - ))); - $this->assertFalse($this->form->isValid(array( - 'foo' => '123', - 'baz' => 'abc-123' - ))); - } - - public function testProcessAjaxReturnsJsonTrueForValidForm() - { - $this->setupElements(); - $return = $this->form->processAjax($this->elementValues); - $this->assertTrue(Zend_Json::decode($return)); - } - - public function testProcessAjaxReturnsJsonTrueForValidPartialForm() - { - $this->setupElements(); - $data = array('foo' => 'abcdef', 'baz' => 'abc123'); - $return = $this->form->processAjax($data); - $this->assertTrue(Zend_Json::decode($return)); - } - - public function testProcessAjaxReturnsJsonWithAllErrorMessagesForInvalidForm() - { - $this->setupElements(); - $data = array('foo' => '123456', 'bar' => 'abcdef', 'baz' => 'abc-123'); - $return = Zend_Json::decode($this->form->processAjax($data)); - $this->assertTrue(is_array($return)); - $this->assertEquals(array_keys($data), array_keys($return)); - } - - public function testProcessAjaxReturnsJsonWithAllErrorMessagesForInvalidPartialForm() - { - $this->setupElements(); - $data = array('baz' => 'abc-123'); - $return = Zend_Json::decode($this->form->processAjax($data)); - $this->assertTrue(is_array($return)); - $this->assertEquals(array_keys($data), array_keys($return), var_export($return, 1)); - } - - public function testPersistDataStoresDataInSession() - { - $this->markTestIncomplete('Zend_Form does not implement session storage at this time'); - } - - public function testCanCheckIfErrorsAreRegistered() - { - $this->assertFalse($this->form->isErrors()); - $this->testCanValidateFullFormContainingOnlyElements(); - $this->assertTrue($this->form->isErrors()); - } - - public function testCanRetrieveErrorCodesFromAllElementsAfterFailedValidation() - { - $this->_checkZf2794(); - - $this->testCanValidateFullFormContainingOnlyElements(); - $codes = $this->form->getErrors(); - $keys = array('foo', 'bar', 'baz'); - $this->assertEquals($keys, array_keys($codes)); - } - - public function testCanRetrieveErrorCodesFromSingleElementAfterFailedValidation() - { - $this->_checkZf2794(); - - $this->testCanValidateFullFormContainingOnlyElements(); - $codes = $this->form->getErrors(); - $keys = array('foo', 'bar', 'baz'); - $errors = $this->form->getErrors('foo'); - $foo = $this->form->foo; - $this->assertEquals($foo->getErrors(), $errors); - } - - public function testCanRetrieveErrorMessagesFromAllElementsAfterFailedValidation() - { - $this->_checkZf2794(); - - $this->testCanValidateFullFormContainingOnlyElements(); - $codes = $this->form->getMessages(); - $keys = array('foo', 'bar', 'baz'); - $this->assertEquals($keys, array_keys($codes)); - } - - public function testCanRetrieveErrorMessagesFromSingleElementAfterFailedValidation() - { - $this->_checkZf2794(); - - $this->testCanValidateFullFormContainingOnlyElements(); - $codes = $this->form->getMessages(); - $keys = array('foo', 'bar', 'baz'); - $messages = $this->form->getMessages('foo'); - $foo = $this->form->foo; - $this->assertEquals($foo->getMessages(), $messages); - } - - public function testErrorCodesFromSubFormReturnedInSeparateArray() - { - $this->_checkZf2794(); - - $this->testFullDataArrayUsedToValidateSubFormByDefault(); - $codes = $this->form->getErrors(); - $this->assertTrue(array_key_exists('sub', $codes)); - $this->assertTrue(is_array($codes['sub'])); - $keys = array('subfoo', 'subbar', 'subbaz'); - $this->assertEquals($keys, array_keys($codes['sub'])); - } - - public function testCanRetrieveErrorCodesFromSingleSubFormAfterFailedValidation() - { - $this->_checkZf2794(); - - $this->testFullDataArrayUsedToValidateSubFormByDefault(); - $codes = $this->form->getErrors('sub'); - $this->assertTrue(is_array($codes)); - $this->assertFalse(empty($codes)); - $keys = array('subfoo', 'subbar', 'subbaz'); - $this->assertEquals($keys, array_keys($codes)); - } - - public function testGetErrorsHonorsElementsBelongTo() - { - $this->_checkZf2794(); - - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('foo[bar]'); - $subForm->addElement('text', 'test')->test - ->setRequired(true); - - $this->form->addSubForm($subForm, 'sub'); - - $data = array('foo' => array( - 'bar' => array( - 'test' => '', - ), - )); - - $this->form->isValid($data); - $codes = $this->form->getErrors(); - $this->assertFalse(empty($codes['foo']['bar']['test'])); - } - - public function testErrorMessagesFromSubFormReturnedInSeparateArray() - { - $this->_checkZf2794(); - - $this->testFullDataArrayUsedToValidateSubFormByDefault(); - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'subfoo' => '123', - 'subbar' => 'abc', - 'subbaz' => '123-abc', - ); - $this->assertFalse($this->form->isValid($data)); - - $codes = $this->form->getMessages(); - $this->assertTrue(array_key_exists('sub', $codes)); - $this->assertTrue(is_array($codes['sub'])); - $keys = array('subfoo', 'subbar', 'subbaz'); - $this->assertEquals($keys, array_keys($codes['sub'])); - } - - public function testCanRetrieveErrorMessagesFromSingleSubFormAfterFailedValidation() - { - $this->_checkZf2794(); - - $this->testFullDataArrayUsedToValidateSubFormByDefault(); - $data = array( - 'foo' => 'abcdef', - 'bar' => '123456', - 'baz' => '123abc', - 'subfoo' => '123', - 'subbar' => 'abc', - 'subbaz' => '123-abc', - ); - - $this->assertFalse($this->form->isValid($data)); - $codes = $this->form->getMessages('sub'); - $this->assertTrue(is_array($codes)); - $this->assertFalse(empty($codes)); - $keys = array('subfoo', 'subbar', 'subbaz'); - $this->assertEquals($keys, array_keys($codes), var_export($codes, 1)); - } - - public function testErrorMessagesAreLocalizedWhenTranslateAdapterPresent() - { - $this->_checkZf2794(); - - $translations = include dirname(__FILE__) . '/_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $this->form->addElements(array( - 'foo' => array( - 'type' => 'text', - 'options' => array( - 'required' => true, - 'validators' => array('NotEmpty') - ) - ), - 'bar' => array( - 'type' => 'text', - 'options' => array( - 'required' => true, - 'validators' => array('Digits') - ) - ), - )) - ->setTranslator($translate); - - $data = array( - 'foo' => '', - 'bar' => 'abc', - ); - if ($this->form->isValid($data)) { - $this->fail('Form should not validate'); - } - - $messages = $this->form->getMessages(); - $this->assertTrue(isset($messages['foo'])); - $this->assertTrue(isset($messages['bar'])); - - foreach ($messages['foo'] as $key => $message) { - if (array_key_exists($key, $translations)) { - $this->assertEquals($translations[$key], $message); - } else { - $this->fail('Translation for ' . $key . ' does not exist?'); - } - } - foreach ($messages['bar'] as $key => $message) { - if (array_key_exists($key, $translations)) { - $this->assertEquals($translations[$key], $message); - } else { - $this->fail('Translation for ' . $key . ' does not exist?'); - } - } - } - - public function testErrorMessagesFromPartialValidationAreLocalizedWhenTranslateAdapterPresent() - { - $this->_checkZf2794(); - - $translations = include dirname(__FILE__) . '/_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $this->form->addElements(array( - 'foo' => array( - 'type' => 'text', - 'options' => array( - 'required' => true, - 'validators' => array('NotEmpty') - ) - ), - 'bar' => array( - 'type' => 'text', - 'options' => array( - 'required' => true, - 'validators' => array('Digits') - ) - ), - )) - ->setTranslator($translate); - - $data = array( - 'foo' => '', - ); - if ($this->form->isValidPartial($data)) { - $this->fail('Form should not validate'); - } - - $messages = $this->form->getMessages(); - $this->assertTrue(isset($messages['foo'])); - $this->assertFalse(isset($messages['bar'])); - - foreach ($messages['foo'] as $key => $message) { - if (array_key_exists($key, $translations)) { - $this->assertEquals($translations[$key], $message); - } else { - $this->fail('Translation for ' . $key . ' does not exist?'); - } - } - } - - public function testErrorMessagesFromProcessAjaxAreLocalizedWhenTranslateAdapterPresent() - { - $this->_checkZf2794(); - - $translations = include dirname(__FILE__) . '/_files/locale/array.php'; - $translate = new Zend_Translate('array', $translations, 'en'); - $translate->setLocale('en'); - - $this->form->addElements(array( - 'foo' => array( - 'type' => 'text', - 'options' => array( - 'required' => true, - 'validators' => array('NotEmpty') - ) - ), - 'bar' => array( - 'type' => 'text', - 'options' => array( - 'required' => true, - 'validators' => array('Digits') - ) - ), - )) - ->setTranslator($translate); - - $data = array( - 'foo' => '', - ); - $return = $this->form->processAjax($data); - $messages = Zend_Json::decode($return); - $this->assertTrue(is_array($messages)); - - $this->assertTrue(isset($messages['foo'])); - $this->assertFalse(isset($messages['bar'])); - - foreach ($messages['foo'] as $key => $message) { - if (array_key_exists($key, $translations)) { - $this->assertEquals($translations[$key], $message); - } else { - $this->fail('Translation for ' . $key . ' does not exist?'); - } - } - } - - /**#@+ - * @group ZF-2988 - */ - public function testSettingErrorMessageShouldOverrideValidationErrorMessages() - { - $this->form->addElement('text', 'foo', array('validators' => array('Alpha'))); - $this->form->addErrorMessage('Invalid values entered'); - $this->assertFalse($this->form->isValid(array('foo' => 123))); - $messages = $this->form->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('Invalid values entered', array_shift($messages)); - } - - public function testCustomErrorMessagesShouldBeManagedInAStack() - { - $this->form->addElement('text', 'foo', array('validators' => array('Alpha'))); - $this->form->addErrorMessage('Invalid values entered'); - $this->form->addErrorMessage('Really, they are not valid'); - $messages = $this->form->getErrorMessages(); - $this->assertEquals(2, count($messages)); - - $this->assertFalse($this->form->isValid(array('foo' => 123))); - $messages = $this->form->getMessages(); - $this->assertEquals(2, count($messages)); - $this->assertEquals('Invalid values entered', array_shift($messages)); - $this->assertEquals('Really, they are not valid', array_shift($messages)); - } - - public function testShouldAllowSettingMultipleErrorMessagesAtOnce() - { - $set1 = array('foo', 'bar', 'baz'); - $this->form->addErrorMessages($set1); - $this->assertSame($set1, $this->form->getErrorMessages()); - } - - public function testSetErrorMessagesShouldOverwriteMessages() - { - $set1 = array('foo', 'bar', 'baz'); - $set2 = array('bat', 'cat'); - $this->form->addErrorMessages($set1); - $this->assertSame($set1, $this->form->getErrorMessages()); - $this->form->setErrorMessages($set2); - $this->assertSame($set2, $this->form->getErrorMessages()); - } - - public function testCustomErrorMessageStackShouldBeClearable() - { - $this->testCustomErrorMessagesShouldBeManagedInAStack(); - $this->form->clearErrorMessages(); - $messages = $this->form->getErrorMessages(); - $this->assertTrue(empty($messages)); - } - - public function testCustomErrorMessagesShouldBeTranslated() - { - $translations = array( - 'foo' => 'Foo message', - ); - $translate = new Zend_Translate('array', $translations); - $this->form->addElement('text', 'foo', array('validators' => array('Alpha'))); - $this->form->setTranslator($translate) - ->addErrorMessage('foo'); - $this->assertFalse($this->form->isValid(array('foo' => 123))); - $messages = $this->form->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('Foo message', array_shift($messages)); - } - - public function testShouldAllowMarkingFormAsInvalid() - { - $this->form->addErrorMessage('Invalid values entered'); - $this->assertFalse($this->form->isErrors()); - $this->form->markAsError(); - $this->assertTrue($this->form->isErrors()); - $messages = $this->form->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertEquals('Invalid values entered', array_shift($messages)); - } - - public function testShouldAllowPushingErrorsOntoErrorStackWithErrorMessages() - { - $this->assertFalse($this->form->isErrors()); - $this->form->setErrors(array('Error 1', 'Error 2')) - ->addError('Error 3') - ->addErrors(array('Error 4', 'Error 5')); - $this->assertTrue($this->form->isErrors()); - $messages = $this->form->getMessages(); - $this->assertEquals(5, count($messages)); - foreach (range(1, 5) as $id) { - $message = 'Error ' . $id; - $this->assertContains($message, $messages); - } - } - - /**#@-*/ - - // View object - - public function getView() - { - $view = new Zend_View(); - $libPath = dirname(__FILE__) . '/../../../library'; - $view->addHelperPath($libPath . '/Zend/View/Helper'); - return $view; - } - - public function testGetViewRetrievesFromViewRendererByDefault() - { - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $viewRenderer->initView(); - $view = $viewRenderer->view; - $test = $this->form->getView(); - $this->assertSame($view, $test); - } - - public function testGetViewReturnsNullWhenNoViewRegisteredWithViewRenderer() - { - $this->assertNull($this->form->getView()); - } - - public function testCanSetView() - { - $view = new Zend_View(); - $this->assertNull($this->form->getView()); - $this->form->setView($view); - $received = $this->form->getView(); - $this->assertSame($view, $received); - } - - // Decorators - - public function testFormDecoratorRegisteredByDefault() - { - $this->_checkZf2794(); - - $decorator = $this->form->getDecorator('form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - } - - public function testCanDisableRegisteringFormDecoratorsDuringInitialization() - { - $form = new Zend_Form(array('disableLoadDefaultDecorators' => true)); - $decorators = $form->getDecorators(); - $this->assertEquals(array(), $decorators); - } - - public function testCanAddSingleDecoratorAsString() - { - $this->_checkZf2794(); - - $this->form->clearDecorators(); - $this->assertFalse($this->form->getDecorator('viewHelper')); - - $this->form->addDecorator('viewHelper'); - $decorator = $this->form->getDecorator('viewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - } - - public function testNotCanRetrieveSingleDecoratorRegisteredAsStringUsingClassName() - { - $this->assertFalse($this->form->getDecorator('Zend_Form_Decorator_Form')); - } - - public function testCanAddSingleDecoratorAsDecoratorObject() - { - $this->form->clearDecorators(); - $this->assertFalse($this->form->getDecorator('viewHelper')); - - $decorator = new Zend_Form_Decorator_ViewHelper; - $this->form->addDecorator($decorator); - $test = $this->form->getDecorator('Zend_Form_Decorator_ViewHelper'); - $this->assertSame($decorator, $test); - } - - public function testCanRetrieveSingleDecoratorRegisteredAsDecoratorObjectUsingShortName() - { - $this->_checkZf2794(); - - $this->form->clearDecorators(); - $this->assertFalse($this->form->getDecorator('viewHelper')); - - $decorator = new Zend_Form_Decorator_ViewHelper; - $this->form->addDecorator($decorator); - $test = $this->form->getDecorator('viewHelper'); - $this->assertSame($decorator, $test); - } - - public function testCanAddMultipleDecorators() - { - $this->_checkZf2794(); - - $this->form->clearDecorators(); - $this->assertFalse($this->form->getDecorator('viewHelper')); - - $testDecorator = new Zend_Form_Decorator_Errors; - $this->form->addDecorators(array( - 'ViewHelper', - $testDecorator - )); - - $viewHelper = $this->form->getDecorator('viewHelper'); - $this->assertTrue($viewHelper instanceof Zend_Form_Decorator_ViewHelper); - $decorator = $this->form->getDecorator('errors'); - $this->assertSame($testDecorator, $decorator); - } - - public function testRemoveDecoratorReturnsFalseForUnregisteredDecorators() - { - $this->_checkZf2794(); - - $this->assertFalse($this->form->removeDecorator('foobar')); - } - - public function testCanRemoveDecorator() - { - $this->_checkZf2794(); - - $this->testFormDecoratorRegisteredByDefault(); - $this->form->removeDecorator('form'); - $this->assertFalse($this->form->getDecorator('form')); - } - - /** - * @group ZF-3069 - */ - public function testRemovingNamedDecoratorShouldWork() - { - $this->_checkZf2794(); - $this->form->setDecorators(array( - 'FormElements', - array(array('div' => 'HtmlTag'), array('tag' => 'div')), - array(array('fieldset' => 'HtmlTag'), array('tag' => 'fieldset')), - )); - $decorators = $this->form->getDecorators(); - $this->assertTrue(array_key_exists('div', $decorators)); - $this->assertTrue(array_key_exists('fieldset', $decorators)); - $this->form->removeDecorator('div'); - $decorators = $this->form->getDecorators(); - $this->assertFalse(array_key_exists('div', $decorators)); - $this->assertTrue(array_key_exists('fieldset', $decorators)); - } - - public function testCanClearAllDecorators() - { - $this->_checkZf2794(); - - $this->testCanAddMultipleDecorators(); - $this->form->clearDecorators(); - $this->assertFalse($this->form->getDecorator('viewHelper')); - $this->assertFalse($this->form->getDecorator('fieldset')); - } - - public function testCanAddDecoratorAliasesToAllowMultipleDecoratorsOfSameType() - { - $this->_checkZf2794(); - - $this->form->setDecorators(array( - array('HtmlTag', array('tag' => 'div')), - array('decorator' => array('FooBar' => 'HtmlTag'), 'options' => array('tag' => 'dd')), - )); - $decorator = $this->form->getDecorator('FooBar'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_HtmlTag); - $this->assertEquals('dd', $decorator->getOption('tag')); - - $decorator = $this->form->getDecorator('HtmlTag'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_HtmlTag); - $this->assertEquals('div', $decorator->getOption('tag')); - } - - public function testRetrievingNamedDecoratorShouldNotReorderDecorators() - { - $this->form->setDecorators(array( - 'FormElements', - array(array('div' => 'HtmlTag'), array('tag' => 'div')), - array(array('fieldset' => 'HtmlTag'), array('tag' => 'fieldset')), - 'Form', - )); - - $decorator = $this->form->getDecorator('fieldset'); - $decorators = $this->form->getDecorators(); - $i = 0; - $order = array(); - - foreach (array_keys($decorators) as $name) { - $order[$name] = $i; - ++$i; - } - $this->assertEquals(2, $order['fieldset'], var_export($order, 1)); - } - - // Rendering - - public function checkMarkup($html) - { - $this->assertFalse(empty($html)); - $this->assertContains('<form', $html); - $this->assertRegexp('/<form[^>]+action="' . $this->form->getAction() . '"/', $html); - $this->assertRegexp('/<form[^>]+method="' . $this->form->getMethod() . '"/i', $html); - $this->assertRegexp('#<form[^>]+enctype="application/x-www-form-urlencoded"#', $html); - $this->assertContains('</form>', $html); - } - - public function testRenderReturnsMarkup() - { - $this->setupElements(); - $html = $this->form->render($this->getView()); - $this->checkMarkup($html); - } - - public function testRenderReturnsMarkupRepresentingAllElements() - { - $this->testRenderReturnsMarkup(); - $html = $this->form->render(); - foreach ($this->form->getElements() as $key => $element) { - $this->assertFalse(empty($key)); - $this->assertFalse(is_numeric($key)); - $this->assertContains('<input', $html); - $this->assertRegexp('/<input type="text" name="' . $key . '"/', $html); - } - } - - public function testRenderReturnsMarkupContainingSubForms() - { - $this->setupElements(); - $this->setupSubForm(); - $this->form->setView($this->getView()); - $html = $this->form->render(); - $this->assertRegexp('/<fieldset/', $html); - $this->assertContains('</fieldset>', $html); - foreach ($this->form->sub as $key => $item) { - $this->assertFalse(empty($key)); - $this->assertFalse(is_numeric($key)); - $this->assertContains('<input', $html); - $pattern = '/<input type="text" name="sub\[' . $key . '\]"/'; - $this->assertRegexp($pattern, $html, 'Pattern: ' . $pattern . "\nHTML:\n" . $html); - } - } - - public function testRenderReturnsMarkupContainingDisplayGroups() - { - $this->setupElements(); - $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz', array('legend' => 'Display Group')); - $this->form->setView($this->getView()); - $html = $this->html = $this->form->render(); - $this->assertRegexp('/<fieldset/', $html); - $this->assertContains('</fieldset>', $html); - $this->assertRegexp('#<legend>Display Group</legend>#', $html, $html); - $dom = new DOMDocument(); - $dom->loadHTML($html); - $fieldsets = $dom->getElementsByTagName('fieldset'); - $this->assertTrue(0 < $fieldsets->length); - $fieldset = $fieldsets->item(0); - $nodes = $fieldset->childNodes; - $this->assertNotNull($nodes); - for ($i = 0; $i < $nodes->length; ++$i) { - $node = $nodes->item($i); - if ('input' != $node->nodeName) { - continue; - } - $this->assertTrue($node->hasAttribute('name')); - $nameNode = $node->getAttributeNode('name'); - switch ($i) { - case 0: - $this->assertEquals('foo', $nameNode->nodeValue); - break; - case 1: - $this->assertEquals('baz', $nameNode->nodeValue); - break; - default: - $this->fail('There should only be two input nodes in this display group: ' . $html); - } - } - } - - public function testRenderDoesNotRepeatElementsInDisplayGroups() - { - $this->testRenderReturnsMarkupContainingDisplayGroups(); - if (!preg_match_all('#<input[^>]+name="foo"#', $this->html, $matches)) { - $this->fail("Should find foo element in rendered form"); - } - $this->assertEquals(1, count($matches)); - $this->assertEquals(1, count($matches[0])); - } - - public function testElementsRenderAsArrayMembersWhenElementsBelongToAnArray() - { - $this->setupElements(); - $this->form->setElementsBelongTo('anArray'); - $html = $this->form->render($this->getView()); - $this->assertContains('name="anArray[foo]"', $html); - $this->assertContains('name="anArray[bar]"', $html); - $this->assertContains('name="anArray[baz]"', $html); - $this->assertContains('id="anArray-foo"', $html); - $this->assertContains('id="anArray-bar"', $html); - $this->assertContains('id="anArray-baz"', $html); - } - - public function testElementsRenderAsSubArrayMembersWhenElementsBelongToASubArray() - { - $this->setupElements(); - $this->form->setElementsBelongTo('data[foo]'); - $html = $this->form->render($this->getView()); - $this->assertContains('name="data[foo][foo]"', $html); - $this->assertContains('name="data[foo][bar]"', $html); - $this->assertContains('name="data[foo][baz]"', $html); - $this->assertContains('id="data-foo-foo"', $html); - $this->assertContains('id="data-foo-bar"', $html); - $this->assertContains('id="data-foo-baz"', $html); - } - - public function testElementsRenderAsArrayMembersWhenRenderAsArrayToggled() - { - $this->setupElements(); - $this->form->setName('data') - ->setIsArray(true); - $html = $this->form->render($this->getView()); - $this->assertContains('name="data[foo]"', $html); - $this->assertContains('name="data[bar]"', $html); - $this->assertContains('name="data[baz]"', $html); - $this->assertContains('id="data-foo"', $html); - $this->assertContains('id="data-bar"', $html); - $this->assertContains('id="data-baz"', $html); - } - - public function testElementsRenderAsMembersOfSubFormsWithElementsBelongTo() - { - $this->form->setName('data') - ->setIsArray(true); - $subForm = new Zend_Form_SubForm(); - $subForm->setElementsBelongTo('billing[info]'); - $subForm->addElement('text', 'name'); - $subForm->addElement('text', 'number'); - $this->form->addSubForm($subForm, 'sub'); - - $html = $this->form->render($this->getView()); - $this->assertContains('name="data[billing][info][name]', $html); - $this->assertContains('name="data[billing][info][number]', $html); - $this->assertContains('id="data-billing-info-name"', $html); - $this->assertContains('id="data-billing-info-number"', $html); - } - - public function testToStringProxiesToRender() - { - $this->setupElements(); - $this->form->setView($this->getView()); - $html = $this->form->__toString(); - $this->checkMarkup($html); - } - - public function raiseDecoratorException($content, $element, $options) - { - throw new Exception('Raising exception in decorator callback'); - } - - public function handleDecoratorErrors($errno, $errstr, $errfile = '', $errline = 0, array $errcontext = array()) - { - $this->error = $errstr; - } - - public function testToStringRaisesErrorWhenExceptionCaught() - { - $this->form->setDecorators(array( - array( - 'decorator' => 'Callback', - 'options' => array('callback' => array($this, 'raiseDecoratorException')) - ), - )); - $origErrorHandler = set_error_handler(array($this, 'handleDecoratorErrors'), E_USER_WARNING); - - $text = $this->form->__toString(); - - restore_error_handler(); - - $this->assertTrue(empty($text)); - $this->assertTrue(isset($this->error)); - $this->assertContains('Raising exception in decorator callback', $this->error); - } - - /** - * ZF-2718 - */ - public function testHiddenElementsGroupedWhenRendered() - { - $this->markTestIncomplete('Scheduling for future release'); - $this->form->addElements(array( - array('type' => 'hidden', 'name' => 'first', 'options' => array('value' => 'first value')), - array('type' => 'text', 'name' => 'testone'), - array('type' => 'hidden', 'name' => 'second', 'options' => array('value' => 'second value')), - array('type' => 'text', 'name' => 'testtwo'), - array('type' => 'hidden', 'name' => 'third', 'options' => array('value' => 'third value')), - array('type' => 'text', 'name' => 'testthree'), - )); - $html = $this->form->render($this->getView()); - if (!preg_match('#(<input type="hidden" name="[^>].*>\s*){3}#', $html, $matches)) { - $this->fail('Hidden elements should be grouped'); - } - foreach (array('first', 'second', 'third') as $which) { - $this->assertRegexp('#<input[^]*name="' . $which . '"#', $matches[0]); - $this->assertRegexp('#<input[^]*value="' . $which . ' value"#', $matches[0]); - } - } - - // Localization - - public function testTranslatorIsNullByDefault() - { - $this->assertNull($this->form->getTranslator()); - } - - public function testCanSetTranslator() - { - require_once 'Zend/Translate/Adapter/Array.php'; - $translator = new Zend_Translate('array', array('foo' => 'bar')); - $this->form->setTranslator($translator); - $received = $this->form->getTranslator($translator); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testCanSetDefaultGlobalTranslator() - { - $this->assertNull($this->form->getTranslator()); - $translator = new Zend_Translate('array', array('foo' => 'bar')); - Zend_Form::setDefaultTranslator($translator); - - $received = Zend_Form::getDefaultTranslator(); - $this->assertSame($translator->getAdapter(), $received); - - $received = $this->form->getTranslator(); - $this->assertSame($translator->getAdapter(), $received); - - $form = new Zend_Form(); - $received = $form->getTranslator(); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testLocalTranslatorPreferredOverDefaultGlobalTranslator() - { - $this->assertNull($this->form->getTranslator()); - $translatorDefault = new Zend_Translate('array', array('foo' => 'bar')); - Zend_Form::setDefaultTranslator($translatorDefault); - - $received = $this->form->getTranslator(); - $this->assertSame($translatorDefault->getAdapter(), $received); - - $translator = new Zend_Translate('array', array('foo' => 'bar')); - $this->form->setTranslator($translator); - $received = $this->form->getTranslator(); - $this->assertNotSame($translatorDefault->getAdapter(), $received); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testTranslatorFromRegistryUsedWhenNoneRegistered() - { - $this->assertNull($this->form->getTranslator()); - $translator = new Zend_Translate('array', array('foo' => 'bar')); - Zend_Registry::set('Zend_Translate', $translator); - - $received = Zend_Form::getDefaultTranslator(); - $this->assertSame($translator->getAdapter(), $received); - - $received = $this->form->getTranslator(); - $this->assertSame($translator->getAdapter(), $received); - - $form = new Zend_Form(); - $received = $form->getTranslator(); - $this->assertSame($translator->getAdapter(), $received); - } - - public function testCanDisableTranslation() - { - $this->testCanSetDefaultGlobalTranslator(); - $this->form->setDisableTranslator(true); - $this->assertNull($this->form->getTranslator()); - } - - // Iteration - - public function testFormObjectIsIterableAndIteratesElements() - { - $this->setupElements(); - $expected = array('foo', 'bar', 'baz'); - $received = array(); - foreach ($this->form as $key => $value) { - $received[] = $key; - } - $this->assertSame($expected, $received); - } - - public function testFormObjectIteratesElementsInExpectedOrder() - { - $this->setupElements(); - $this->form->addElement('text', 'checkorder', array('order' => 2)); - $expected = array('foo', 'bar', 'checkorder', 'baz'); - $received = array(); - foreach ($this->form as $key => $value) { - $received[] = $key; - $this->assertTrue($value instanceof Zend_Form_Element); - } - $this->assertSame($expected, $received); - } - - public function testFormObjectIteratesElementsInExpectedOrderWhenAllElementsHaveOrder() - { - $this->form->addElement('submit', 'submit')->submit->setLabel('Submit')->setOrder(30); - $this->form->addElement('text', 'name')->name->setLabel('Name')->setOrder(10); - $this->form->addElement('text', 'email')->email->setLabel('E-mail')->setOrder(20); - - $expected = array('name', 'email', 'submit'); - $received = array(); - foreach ($this->form as $key => $value) { - $received[] = $key; - $this->assertTrue($value instanceof Zend_Form_Element); - } - $this->assertSame($expected, $received); - } - - public function testFormObjectIteratesElementsInExpectedOrderWhenFirstElementHasNoOrderSpecified() - { - $this->form->addElement(new Zend_Form_Element('a',array('label'=>'a'))) - ->addElement(new Zend_Form_Element('b',array('label'=>'b', 'order' => 0))) - ->addElement(new Zend_Form_Element('c',array('label'=>'c', 'order' => 1))) - ->setView($this->getView()); - $test = $this->form->render(); - $this->assertContains('name="a"', $test); - if (!preg_match_all('/(<input[^>]+>)/', $test, $matches)) { - $this->fail('Expected markup not found'); - } - $order = array(); - foreach ($matches[1] as $element) { - if (preg_match('/name="(a|b|c)"/', $element, $m)) { - $order[] = $m[1]; - } - } - $this->assertSame(array('b', 'c', 'a'), $order); - } - - public function testFormObjectIteratesElementsAndSubforms() - { - $this->setupElements(); - $this->setupSubForm(); - $expected = array('foo', 'bar', 'baz', 'sub'); - $received = array(); - foreach ($this->form as $key => $value) { - $received[] = $key; - $this->assertTrue(($value instanceof Zend_Form_Element) - or ($value instanceof Zend_Form_SubForm)); - } - $this->assertSame($expected, $received); - } - - public function testFormObjectIteratesDisplayGroupsButSkipsDisplayGroupElements() - { - $this->setupElements(); - $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz'); - $expected = array('bar', 'foobaz'); - $received = array(); - foreach ($this->form as $key => $value) { - $received[] = $key; - $this->assertTrue(($value instanceof Zend_Form_Element) - or ($value instanceof Zend_Form_DisplayGroup)); - } - $this->assertSame($expected, $received); - } - - public function testRemovingFormItemsShouldNotRaiseExceptionsDuringIteration() - { - $this->setupElements(); - $bar = $this->form->bar; - $this->form->removeElement('bar'); - - try { - foreach ($this->form as $item) { - } - } catch (Exception $e) { - $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage()); - } - - $this->form->addElement($bar); - $this->form->addDisplayGroup(array('baz', 'bar'), 'bazbar'); - $this->form->removeDisplayGroup('bazbar'); - - try { - foreach ($this->form as $item) { - } - } catch (Exception $e) { - $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage()); - } - - $subForm = new Zend_Form_SubForm; - $subForm->addElements(array('foo' => 'text', 'bar' => 'text')); - $this->form->addSubForm($subForm, 'page1'); - $this->form->removeSubForm('page1'); - - try { - foreach ($this->form as $item) { - } - } catch (Exception $e) { - $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage()); - } - } - - public function testClearingAttachedItemsShouldNotCauseIterationToRaiseExceptions() - { - $form = new Zend_Form(); - $form->addElements(array( - 'username' => 'text', - 'password' => 'text', - )); - $form->clearElements(); - - try { - foreach ($form as $item) { - } - } catch (Zend_Form_Exception $e) { - $message = "Clearing elements prior to iteration should not cause iteration to fail;\n" - . $e->getMessage(); - $this->fail($message); - } - - $form->addElements(array( - 'username' => 'text', - 'password' => 'text', - )) - ->addDisplayGroup(array('username', 'password'), 'login'); - $form->clearDisplayGroups(); - - try { - foreach ($form as $item) { - } - } catch (Zend_Form_Exception $e) { - $message = "Clearing display groups prior to iteration should not cause iteration to fail;\n" - . $e->getMessage(); - $this->fail($message); - } - - $subForm = new Zend_Form_SubForm(); - $form->addSubForm($subForm, 'foo'); - $form->clearSubForms(); - - try { - foreach ($form as $item) { - } - } catch (Zend_Form_Exception $e) { - $message = "Clearing sub forms prior to iteration should not cause iteration to fail;\n" - . $e->getMessage(); - $this->fail($message); - } - } - - // Countable - - public function testCanCountFormObject() - { - $this->setupElements(); - $this->assertEquals(3, count($this->form)); - } - - public function testCountingFormObjectCountsSubForms() - { - $this->setupElements(); - $this->setupSubForm(); - $this->assertEquals(4, count($this->form)); - } - - public function testCountingFormCountsDisplayGroupsButOmitsElementsInDisplayGroups() - { - $this->testCountingFormObjectCountsSubForms(); - $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz'); - $this->assertEquals(3, count($this->form)); - } - - // Element decorators and plugin paths - - public function testCanSetAllElementDecoratorsAtOnce() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->form->setElementDecorators(array( - array('ViewHelper'), - array('Label'), - array('Fieldset'), - )); - foreach ($this->form->getElements() as $element) { - $this->assertFalse($element->getDecorator('Errors')); - $this->assertFalse($element->getDecorator('HtmlTag')); - $decorator = $element->getDecorator('ViewHelper'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper); - $decorator = $element->getDecorator('Label'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Label); - $decorator = $element->getDecorator('Fieldset'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Fieldset); - } - } - - /** - * @group ZF-3597 - */ - public function testSettingElementDecoratorsWithConcreteDecoratorShouldHonorOrder() - { - $this->form->setDecorators(array( - 'FormElements', - array('HtmlTag', array('tag' => 'table')), - 'Form', - )); - $this->form->addElementPrefixPath('My_Decorator', dirname(__FILE__) . '/_files/decorators/', 'decorator'); - $this->form->addElement('text', 'test', array( - 'label' => 'Foo', - 'description' => 'sample description', - )); - - require_once dirname(__FILE__) . '/_files/decorators/TableRow.php'; - $decorator = new My_Decorator_TableRow(); - $this->form->setElementDecorators(array( - 'ViewHelper', - $decorator, - )); - $html = $this->form->render($this->getView()); - $this->assertRegexp('#<tr><td>Foo</td><td>.*?<input[^>]+>.*?</td><td>sample description</td></tr>#s', $html, $html); - } - - /**#@+ - * @group ZF-3228 - */ - public function testShouldAllowSpecifyingSpecificElementsToDecorate() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->form->setElementDecorators( - array( - 'Description', - 'Form', - 'Fieldset', - ), - array( - 'bar', - ) - ); - - $element = $this->form->bar; - $this->assertFalse($element->getDecorator('ViewHelper')); - $this->assertFalse($element->getDecorator('Errors')); - $this->assertFalse($element->getDecorator('Label')); - $this->assertFalse($element->getDecorator('HtmlTag')); - $decorator = $element->getDecorator('Description'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Description); - $decorator = $element->getDecorator('Form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - $decorator = $element->getDecorator('Fieldset'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Fieldset); - - foreach (array('foo', 'baz') as $name) { - $element = $this->form->$name; - $this->assertFalse($element->getDecorator('Description')); - $this->assertFalse($element->getDecorator('Form')); - $this->assertFalse($element->getDecorator('Fieldset')); - } - } - - public function testShouldAllowSpecifyingListOfElementsNotToDecorate() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->form->setElementDecorators( - array( - 'Description', - 'Form', - 'Fieldset', - ), - array( - 'foo', - 'baz', - ), - false - ); - - $element = $this->form->bar; - $this->assertFalse($element->getDecorator('ViewHelper')); - $this->assertFalse($element->getDecorator('Errors')); - $this->assertFalse($element->getDecorator('Label')); - $this->assertFalse($element->getDecorator('HtmlTag')); - $decorator = $element->getDecorator('Description'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Description); - $decorator = $element->getDecorator('Form'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Form); - $decorator = $element->getDecorator('Fieldset'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Fieldset); - - foreach (array('foo', 'baz') as $name) { - $element = $this->form->$name; - $this->assertFalse($element->getDecorator('Description')); - $this->assertFalse($element->getDecorator('Form')); - $this->assertFalse($element->getDecorator('Fieldset')); - } - } - /**#@-*/ - - public function testCanSetAllElementFiltersAtOnce() - { - $this->_checkZf2794(); - - $this->setupElements(); - $this->form->setElementFilters(array( - 'Alnum', - 'StringToLower' - )); - foreach ($this->form->getElements() as $element) { - $filter = $element->getFilter('Alnum'); - $this->assertTrue($filter instanceof Zend_Filter_Alnum); - $filter = $element->getFilter('StringToLower'); - $this->assertTrue($filter instanceof Zend_Filter_StringToLower); - } - } - - public function testCanSetGlobalElementPrefixPath() - { - $this->setupElements(); - $this->form->addElementPrefixPath('Zend_Foo', 'Zend/Foo/'); - $this->form->addElement('text', 'prefixTest'); - foreach ($this->form->getElements() as $element) { - $loader = $element->getPluginLoader('validate'); - $paths = $loader->getPaths('Zend_Foo_Validate'); - $this->assertFalse(empty($paths), $element->getName() . ':' . var_export($loader->getPaths(), 1)); - $this->assertContains('Foo', $paths[0]); - $this->assertContains('Validate', $paths[0]); - - $paths = $element->getPluginLoader('filter')->getPaths('Zend_Foo_Filter'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - $this->assertContains('Filter', $paths[0]); - - $paths = $element->getPluginLoader('decorator')->getPaths('Zend_Foo_Decorator'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - $this->assertContains('Decorator', $paths[0]); - } - } - - public function testCustomGlobalElementPrefixPathUsedInNewlyCreatedElements() - { - $this->_checkZf2794(); - - $this->form->addElementPrefixPath('My_Decorator', dirname(__FILE__) . '/_files/decorators', 'decorator'); - $this->form->addElement('text', 'prefixTest'); - $element = $this->form->prefixTest; - $label = $element->getDecorator('Label'); - $this->assertTrue($label instanceof My_Decorator_Label, get_class($label)); - } - - /** - * @group ZF-3093 - */ - public function testSettingElementPrefixPathPropagatesToAttachedSubForms() - { - $subForm = new Zend_Form_SubForm(); - $subForm->addElement('text', 'foo'); - $this->form->addSubForm($subForm, 'subForm'); - $this->form->addElementPrefixPath('Zend_Foo', 'Zend/Foo/'); - $loader = $this->form->subForm->foo->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo_Decorator'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - $this->assertContains('Decorator', $paths[0]); - } - - public function testCanSetElementValidatorPrefixPath() - { - $this->setupElements(); - $this->form->addElementPrefixPath('Zend_Foo', 'Zend/Foo/', 'validate'); - $this->form->addElement('text', 'prefixTest'); - foreach ($this->form->getElements() as $element) { - $loader = $element->getPluginLoader('validate'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - $this->assertNotContains('Validate', $paths[0]); - } - } - - public function testCanSetElementFilterPrefixPath() - { - $this->setupElements(); - $this->form->addElementPrefixPath('Zend_Foo', 'Zend/Foo/', 'filter'); - $this->form->addElement('text', 'prefixTest'); - foreach ($this->form->getElements() as $element) { - $loader = $element->getPluginLoader('filter'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - $this->assertNotContains('Filter', $paths[0]); - } - } - - public function testCanSetElementDecoratorPrefixPath() - { - $this->setupElements(); - $this->form->addElementPrefixPath('Zend_Foo', 'Zend/Foo/', 'decorator'); - $this->form->addElement('text', 'prefixTest'); - foreach ($this->form->getElements() as $element) { - $loader = $element->getPluginLoader('decorator'); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - $this->assertNotContains('Decorator', $paths[0]); - } - } - - // Display Group decorators and plugin paths - - public function setupDisplayGroups() - { - $this->testCanAddAndRetrieveMultipleElements(); - $this->form->addElements(array( - 'test1' => 'text', - 'test2' => 'text', - 'test3' => 'text', - 'test4' => 'text' - )); - $this->form->addDisplayGroup(array('bar', 'bat'), 'barbat'); - $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz'); - } - - public function testCanSetAllDisplayGroupDecoratorsAtOnce() - { - $this->_checkZf2794(); - - $this->setupDisplayGroups(); - $this->form->setDisplayGroupDecorators(array( - array('Callback', array('callback' => 'strip_tags')), - )); - foreach ($this->form->getDisplayGroups() as $element) { - $this->assertFalse($element->getDecorator('FormElements')); - $this->assertFalse($element->getDecorator('HtmlTag')); - $this->assertFalse($element->getDecorator('Fieldset')); - $this->assertFalse($element->getDecorator('DtDdWrapper')); - - $decorator = $element->getDecorator('Callback'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Callback); - } - } - - public function testCanSetDisplayGroupPrefixPath() - { - $this->setupDisplayGroups(); - $this->form->addDisplayGroupPrefixPath('Zend_Foo', 'Zend/Foo/'); - $this->form->addDisplayGroup(array('test1', 'test2'), 'testgroup'); - foreach ($this->form->getDisplayGroups() as $group) { - $loader = $group->getPluginLoader(); - $paths = $loader->getPaths('Zend_Foo'); - $this->assertFalse(empty($paths)); - $this->assertContains('Foo', $paths[0]); - } - } - - /** - * @group ZF-3213 - */ - public function testShouldAllowSettingDisplayGroupPrefixPathViaConfigOptions() - { - require_once 'Zend/Config/Ini.php'; - $config = new Zend_Config_Ini(dirname(__FILE__) . '/_files/config/zf3213.ini', 'form'); - $form = new Zend_Form($config); - $dg = $form->foofoo; - $paths = $dg->getPluginLoader()->getPaths('My_Decorator'); - $this->assertTrue($paths !== false); - } - - // Subform decorators - - public function testCanSetAllSubFormDecoratorsAtOnce() - { - $this->_checkZf2794(); - - $this->setupSubForm(); - $this->form->setSubFormDecorators(array( - array('Callback', array('callback' => 'strip_tags')), - )); - foreach ($this->form->getSubForms() as $subForm) { - $this->assertFalse($subForm->getDecorator('FormElements')); - $this->assertFalse($subForm->getDecorator('HtmlTag')); - $this->assertFalse($subForm->getDecorator('Fieldset')); - $this->assertFalse($subForm->getDecorator('DtDdWrapper')); - - $decorator = $subForm->getDecorator('Callback'); - $this->assertTrue($decorator instanceof Zend_Form_Decorator_Callback); - } - } - - // Extension - - public function testInitCalledPriorToLoadingDefaultDecorators() - { - $form = new Zend_Form_FormTest_FormExtension(); - $decorators = $form->getDecorators(); - $this->assertTrue(empty($decorators)); - } - - // Clone - - /** - * @group ZF-3819 - */ - public function testCloningShouldCloneAllChildren() - { - $form = new Zend_Form(); - $foo = new Zend_Form_SubForm(array( - 'name' => 'foo', - 'elements' => array( - 'one' => 'text', - 'two' => 'text', - ), - )); - $form->addElement('text', 'bar') - ->addElement('text', 'baz') - ->addElement('text', 'bat') - ->addDisplayGroup(array('bar', 'bat'), 'barbat') - ->addSubForm($foo, 'foo'); - $bar = $form->bar; - $baz = $form->baz; - $bat = $form->bat; - $barbat = $form->barbat; - - $cloned = clone $form; - $this->assertNotSame($foo, $cloned->foo); - $this->assertNotSame($bar, $cloned->bar); - $this->assertNotSame($baz, $cloned->baz); - $this->assertNotSame($bat, $cloned->bat); - $this->assertNotSame($barbat, $cloned->getDisplayGroup('barbat')); - $this->assertNotSame($foo->one, $cloned->foo->one); - $this->assertNotSame($foo->two, $cloned->foo->two); - } - - // Reset - - /** - * @group ZF-3227 - */ - public function testFormsShouldAllowResetting() - { - $form = new Zend_Form(); - $foo = new Zend_Form_SubForm(array( - 'name' => 'foo', - 'elements' => array( - 'one' => 'text', - 'two' => 'text', - ), - )); - $form->addElement('text', 'bar') - ->addElement('text', 'baz') - ->addElement('text', 'bat') - ->addDisplayGroup(array('bar', 'bat'), 'barbat') - ->addSubForm($foo, 'foo'); - $values = array( - 'bar' => 'Bar Value', - 'baz' => 'Baz Value', - 'bat' => 'Bat Value', - 'foo' => array( - 'one' => 'One Value', - 'two' => 'Two Value', - ), - ); - $form->populate($values); - $test = $form->getValues(); - $this->assertEquals($values, $test); - $form->reset(); - $test = $form->getValues(); - $this->assertNotEquals($values, $test); - $this->assertEquals(0, array_sum($test)); - } - - /** - * @group ZF-3217 - */ - public function testFormShouldOverloadToRenderDecorators() - { - $this->setupElements(); - $this->form->setView($this->getView()); - $html = $this->form->renderFormElements(); - foreach ($this->form->getElements() as $element) { - $this->assertContains('id="' . $element->getFullyQualifiedName() . '"', $html, 'Received: ' . $html); - } - $this->assertNotContains('<dl', $html); - $this->assertNotContains('<form', $html); - - $html = $this->form->renderForm('this is the content'); - $this->assertContains('<form', $html); - $this->assertContains('</form>', $html); - $this->assertContains('this is the content', $html); - } - - /** - * @group ZF-3217 - * @expectedException Zend_Form_Exception - */ - public function testOverloadingToInvalidMethodsShouldThrowAnException() - { - $html = $this->form->bogusMethodCall(); - } - - /** - * Used by test methods susceptible to ZF-2794, marks a test as incomplete - * - * @link http://framework.zend.com/issues/browse/ZF-2794 - * @return void - */ - protected function _checkZf2794() - { - if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) { - $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows'); - } - } -} - -class Zend_Form_FormTest_DisplayGroup extends Zend_Form_DisplayGroup -{ -} - -class Zend_Form_FormTest_FormExtension extends Zend_Form -{ - public function init() - { - $this->setDisableLoadDefaultDecorators(true); - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_FormTest::main') { - Zend_Form_FormTest::main(); -} diff --git a/tests/Zend/Form/SubFormTest.php b/tests/Zend/Form/SubFormTest.php deleted file mode 100644 index 9ccb17ca829d2e8fd3f348c82971e43e84722e48..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/SubFormTest.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Form_SubFormTest::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -// error_reporting(E_ALL); - -require_once 'Zend/Form/SubForm.php'; -require_once 'Zend/View.php'; - -class Zend_Form_SubFormTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - $suite = new PHPUnit_Framework_TestSuite('Zend_Form_SubFormTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - Zend_Form::setDefaultTranslator(null); - - $this->form = new Zend_Form_SubForm(); - } - - public function tearDown() - { - } - - // General - public function testSubFormUtilizesDefaultDecorators() - { - $decorators = $this->form->getDecorators(); - $this->assertTrue(array_key_exists('Zend_Form_Decorator_FormElements', $decorators)); - $this->assertTrue(array_key_exists('Zend_Form_Decorator_HtmlTag', $decorators)); - $this->assertTrue(array_key_exists('Zend_Form_Decorator_Fieldset', $decorators)); - $this->assertTrue(array_key_exists('Zend_Form_Decorator_DtDdWrapper', $decorators)); - - $htmlTag = $decorators['Zend_Form_Decorator_HtmlTag']; - $tag = $htmlTag->getOption('tag'); - $this->assertEquals('dl', $tag); - } - - public function testSubFormIsArrayByDefault() - { - $this->assertTrue($this->form->isArray()); - } - - public function testElementsBelongToSubFormNameByDefault() - { - $this->testSubFormIsArrayByDefault(); - $this->form->setName('foo'); - $this->assertEquals($this->form->getName(), $this->form->getElementsBelongTo()); - } - - // Extensions - - public function testInitCalledBeforeLoadDecorators() - { - $form = new Zend_Form_SubFormTest_SubForm(); - $decorators = $form->getDecorators(); - $this->assertTrue(empty($decorators)); - } - - // Bugfixes - - /** - * @see ZF-2883 - */ - public function testDisplayGroupsShouldInheritSubFormNamespace() - { - $this->form->addElement('text', 'foo') - ->addElement('text', 'bar') - ->addDisplayGroup(array('foo', 'bar'), 'foobar'); - - $form = new Zend_Form(); - $form->addSubForm($this->form, 'attributes'); - $html = $form->render(new Zend_View()); - - $this->assertContains('name="attributes[foo]"', $html); - $this->assertContains('name="attributes[bar]"', $html); - } - - /** - * @see ZF-3272 - */ - public function testRenderedSubFormDtShouldContainNoBreakSpace() - { - $subForm = new Zend_Form_SubForm(array( - 'elements' => array( - 'foo' => 'text', - 'bar' => 'text', - ), - )); - $form = new Zend_Form(); - $form->addSubForm($subForm, 'foobar') - ->setView(new Zend_View); - $html = $form->render(); - $this->assertContains('<dt> </dt>', $html); - } -} - -class Zend_Form_SubFormTest_SubForm extends Zend_Form_SubForm -{ - public function init() - { - $this->setDisableLoadDefaultDecorators(true); - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Form_SubFormTest::main') { - Zend_Form_SubFormTest::main(); -} diff --git a/tests/Zend/Form/_files/config/multiOptions.ini b/tests/Zend/Form/_files/config/multiOptions.ini deleted file mode 100644 index 3459d39498b8a7e17e1aa12498b587807522722a..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/config/multiOptions.ini +++ /dev/null @@ -1,7 +0,0 @@ -[testing] -options.first.key = "aa" -options.first.value = 1 -options.second.value = "xxxx" -options.second.key = 2 -options.third.key = "ssss" -options.third.value = 444 diff --git a/tests/Zend/Form/_files/config/multiOptions.xml b/tests/Zend/Form/_files/config/multiOptions.xml deleted file mode 100644 index c0f87740aae937d5b2094f39583449dcc293fca1..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/config/multiOptions.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<configdata> - <testing> - <options> - <first> - <key>aa</key> - <value>1</value> - </first> - <second> - <value>xxxx</value> - <key>2</key> - </second> - <third> - <key>ssss</key> - <value>444</value> - </third> - </options> - </testing> -</configdata> diff --git a/tests/Zend/Form/_files/config/zf3213.ini b/tests/Zend/Form/_files/config/zf3213.ini deleted file mode 100644 index 052f008d9e84923cecfa243075840f07a9ab69ec..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/config/zf3213.ini +++ /dev/null @@ -1,7 +0,0 @@ -[form] -displayGroupPrefixPath.myname.prefix = "My_Decorator" -displayGroupPrefixPath.myname.path = "My/Decorator/" -elements.foo.type = "text" -elements.foo.name = "foo" -displayGroups.foofoo.elements[] = "foo" -displayGroups.foofoo.name= "foofoo" diff --git a/tests/Zend/Form/_files/config/zf3250.xml b/tests/Zend/Form/_files/config/zf3250.xml deleted file mode 100644 index 49fd06e97cebf344dae8d0fc16eb0785f42b3292..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/config/zf3250.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<forms> - <sitearea> - <test> - <displayGroups> - <DisplayGroup> - <elements> - <ElementName1>ElementName1</ElementName1> - <ElementName2>ElementName2</ElementName2> - </elements> - <options> - <name>login</name> - <label>Test</label> - <legend>Form 1</legend> - </options> - </DisplayGroup> - </displayGroups> - <elements> - <ElementName1> - <type>text</type> - <name>ElementName1</name> - <options> - <label>Label 1</label> - </options> - </ElementName1> - <ElementName2> - <type>text</type> - <name>ElementName2</name> - <options> - <label>Label 2</label> - </options> - </ElementName2> - <ElementName3> - <type>text</type> - <name>ElementName3</name> - <options> - <label>Label 3</label> - </options> - </ElementName3> - <ElementName4> - <type>text</type> - <name>ElementName4</name> - <options> - <label>Label 4</label> - </options> - </ElementName4> - </elements> - <legend>Form 1</legend> - <method>post</method> - </test> - </sitearea> -</forms> diff --git a/tests/Zend/Form/_files/decorators/Label.php b/tests/Zend/Form/_files/decorators/Label.php deleted file mode 100644 index 4455cb024c3b4e1d99474e2c955156184cef7d23..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/decorators/Label.php +++ /dev/null @@ -1,50 +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_Form - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Label.php 9354 2008-05-04 21:26:53Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Form/Decorator/Abstract.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Form - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class My_Decorator_Label extends Zend_Form_Decorator_Abstract -{ - - /** - * Test Function for render - * - * @param string $content Content to display - * @return string - */ - public function render($content) - { - return $content; - } - -} diff --git a/tests/Zend/Form/_files/decorators/TableRow.php b/tests/Zend/Form/_files/decorators/TableRow.php deleted file mode 100644 index 2cbd0ebdcebd5656d2ed2a7e10fe20a0494d7717..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/decorators/TableRow.php +++ /dev/null @@ -1,51 +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_Form - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TableRow.php 10670 2008-08-05 13:33:44Z matthew $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Form/Decorator/Abstract.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Form - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class My_Decorator_TableRow extends Zend_Form_Decorator_Abstract -{ - - /** - * Test Function for render - * - * @param string $content Content to display - * @return string - */ - public function render($content) - { - $e = $this->getElement(); - return "<tr><td>{$e->getLabel()}</td><td>{$content}</td><td>{$e->getDescription()}</td></tr>"; - } - -} diff --git a/tests/Zend/Form/_files/locale/array.php b/tests/Zend/Form/_files/locale/array.php deleted file mode 100644 index 45852eb66cf06ff92cb4ec209bee8672db0229c8..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/locale/array.php +++ /dev/null @@ -1,32 +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_Form - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: array.php 9354 2008-05-04 21:26:53Z thomas $ - */ - -return array( - 'notDigits' => 'Translating the notDigits string', - 'stringEmpty' => 'Translating the stringEmpty string', - 'isEmpty' => 'Translating the isEmpty string', - - 'submit' => 'Submit Button', - 'foovalue' => 'Foo Value', - 'barvalue' => 'Bar Value', - 'Foo' => 'Foo Translation', - 'Bar' => 'Bar Translation', -); diff --git a/tests/Zend/Form/_files/views/contentWrappingDecorator.phtml b/tests/Zend/Form/_files/views/contentWrappingDecorator.phtml deleted file mode 100644 index d83a25c226ca5d414223ab60cb723646b7a41504..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/views/contentWrappingDecorator.phtml +++ /dev/null @@ -1,3 +0,0 @@ -This text prefixes the content -<?php echo $this->content ?> -This text appends the content diff --git a/tests/Zend/Form/_files/views/decorator.phtml b/tests/Zend/Form/_files/views/decorator.phtml deleted file mode 100644 index d2acecd80201eab04635f2dc556bda4bdf51693b..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/views/decorator.phtml +++ /dev/null @@ -1,8 +0,0 @@ -This is content from the view script - -<?php foreach ($this->getVars() as $key => $value): - if ($key == 'decorator') { - continue; - } - echo $key, ': ', $value, "\n"; -endforeach; ?> diff --git a/tests/Zend/Form/_files/views/decoratorCausesReplacement.phtml b/tests/Zend/Form/_files/views/decoratorCausesReplacement.phtml deleted file mode 100644 index af0fe68920c5ea5430a2ef3b9e0fd1fc11486b40..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/views/decoratorCausesReplacement.phtml +++ /dev/null @@ -1,4 +0,0 @@ -This text prefixes the content -<?php echo $this->content ?> -This text appends the content -<?php $this->decorator->setOption('placement', false) ?> diff --git a/tests/Zend/Form/_files/views/replacingDecorator.phtml b/tests/Zend/Form/_files/views/replacingDecorator.phtml deleted file mode 100644 index f6b3fba8bebb97c234d481aa4b194a8f5fe0bb32..0000000000000000000000000000000000000000 --- a/tests/Zend/Form/_files/views/replacingDecorator.phtml +++ /dev/null @@ -1 +0,0 @@ -This is content from the view script diff --git a/tests/Zend/Gdata/AllTests.php b/tests/Zend/Gdata/AllTests.php deleted file mode 100644 index 970d801470b97996fd22f7a4145945e02753489c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/AllTests.php +++ /dev/null @@ -1,392 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Gdata_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -/** - * Tests of the authentication URL generator - */ -require_once 'Zend/Gdata/AuthSubTest.php'; - -/** - * Tests that do not require online access to servers - */ -require_once 'Zend/Gdata/AppTest.php'; -require_once 'Zend/Gdata/App/UtilTest.php'; -require_once 'Zend/Gdata/App/AuthorTest.php'; -require_once 'Zend/Gdata/App/CategoryTest.php'; -require_once 'Zend/Gdata/App/ContentTest.php'; -require_once 'Zend/Gdata/App/ControlTest.php'; -require_once 'Zend/Gdata/App/EntryTest.php'; -require_once 'Zend/Gdata/App/FeedTest.php'; -require_once 'Zend/Gdata/App/GeneratorTest.php'; -require_once 'Zend/Gdata/App/CaptchaRequiredExceptionTest.php'; -require_once 'Zend/Gdata/GdataTest.php'; -require_once 'Zend/Gdata/QueryTest.php'; - -require_once 'Zend/Gdata/AttendeeStatusTest.php'; -require_once 'Zend/Gdata/AttendeeTypeTest.php'; -require_once 'Zend/Gdata/CommentsTest.php'; -require_once 'Zend/Gdata/EntryLinkTest.php'; -require_once 'Zend/Gdata/EventStatusTest.php'; -require_once 'Zend/Gdata/ExtendedPropertyTest.php'; -require_once 'Zend/Gdata/FeedLinkTest.php'; -require_once 'Zend/Gdata/OpenSearchItemsPerPageTest.php'; -require_once 'Zend/Gdata/OpenSearchStartIndexTest.php'; -require_once 'Zend/Gdata/OpenSearchTotalResultsTest.php'; -require_once 'Zend/Gdata/OriginalEventTest.php'; -require_once 'Zend/Gdata/RecurrenceTest.php'; -require_once 'Zend/Gdata/RecurrenceExceptionTest.php'; -require_once 'Zend/Gdata/ReminderTest.php'; -require_once 'Zend/Gdata/TransparencyTest.php'; -require_once 'Zend/Gdata/VisibilityTest.php'; -require_once 'Zend/Gdata/WhenTest.php'; -require_once 'Zend/Gdata/WhereTest.php'; -require_once 'Zend/Gdata/WhoTest.php'; - -require_once 'Zend/Gdata/Gbase/ItemEntryTest.php'; -require_once 'Zend/Gdata/Gbase/ItemFeedTest.php'; -require_once 'Zend/Gdata/Gbase/ItemQueryTest.php'; -require_once 'Zend/Gdata/Gbase/SnippetFeedTest.php'; -require_once 'Zend/Gdata/Gbase/SnippetQueryTest.php'; -require_once 'Zend/Gdata/Gbase/QueryTest.php'; -require_once 'Zend/Gdata/Gbase/BaseAttributeTest.php'; - -require_once 'Zend/Gdata/CalendarTest.php'; -require_once 'Zend/Gdata/CalendarFeedTest.php'; -require_once 'Zend/Gdata/CalendarEventTest.php'; -require_once 'Zend/Gdata/CalendarFeedCompositeTest.php'; -require_once 'Zend/Gdata/Calendar/EventQueryTest.php'; -require_once 'Zend/Gdata/Calendar/EventQueryExceptionTest.php'; -require_once 'Zend/Gdata/Calendar/EventEntryTest.php'; -require_once 'Zend/Gdata/Calendar/AccessLevelTest.php'; -require_once 'Zend/Gdata/Calendar/ColorTest.php'; -require_once 'Zend/Gdata/Calendar/HiddenTest.php'; -require_once 'Zend/Gdata/Calendar/LinkTest.php'; -require_once 'Zend/Gdata/Calendar/SelectedTest.php'; -require_once 'Zend/Gdata/Calendar/SendEventNotificationsTest.php'; -require_once 'Zend/Gdata/Calendar/TimezoneTest.php'; -require_once 'Zend/Gdata/Calendar/WebContentTest.php'; -require_once 'Zend/Gdata/Calendar/QuickAddTest.php'; - -require_once 'Zend/Gdata/Spreadsheets/ColCountTest.php'; -require_once 'Zend/Gdata/Spreadsheets/RowCountTest.php'; -require_once 'Zend/Gdata/Spreadsheets/CellTest.php'; -require_once 'Zend/Gdata/Spreadsheets/CustomTest.php'; -require_once 'Zend/Gdata/Spreadsheets/WorksheetEntryTest.php'; -require_once 'Zend/Gdata/Spreadsheets/CellEntryTest.php'; -require_once 'Zend/Gdata/Spreadsheets/ListEntryTest.php'; -require_once 'Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php'; -require_once 'Zend/Gdata/Spreadsheets/WorksheetFeedTest.php'; -require_once 'Zend/Gdata/Spreadsheets/CellFeedTest.php'; -require_once 'Zend/Gdata/Spreadsheets/ListFeedTest.php'; -require_once 'Zend/Gdata/Spreadsheets/DocumentQueryTest.php'; -require_once 'Zend/Gdata/Spreadsheets/CellQueryTest.php'; -require_once 'Zend/Gdata/Spreadsheets/ListQueryTest.php'; - -require_once 'Zend/Gdata/Docs/DocumentListFeedTest.php'; -require_once 'Zend/Gdata/Docs/DocumentListEntryTest.php'; -require_once 'Zend/Gdata/Docs/QueryTest.php'; - -require_once 'Zend/Gdata/Photos/PhotosAlbumEntryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosAlbumFeedTest.php'; -require_once 'Zend/Gdata/Photos/PhotosAlbumQueryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosCommentEntryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosPhotoEntryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosPhotoFeedTest.php'; -require_once 'Zend/Gdata/Photos/PhotosPhotoQueryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosTagEntryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosUserEntryTest.php'; -require_once 'Zend/Gdata/Photos/PhotosUserFeedTest.php'; -require_once 'Zend/Gdata/Photos/PhotosUserQueryTest.php'; - -require_once 'Zend/Gdata/GappsTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListEntryTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListFeedTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListQueryTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListRecipientEntryTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListRecipientFeedTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListRecipientQueryTest.php'; -require_once 'Zend/Gdata/Gapps/EmailListTest.php'; -require_once 'Zend/Gdata/Gapps/ErrorTest.php'; -require_once 'Zend/Gdata/Gapps/LoginTest.php'; -require_once 'Zend/Gdata/Gapps/NameTest.php'; -require_once 'Zend/Gdata/Gapps/NicknameEntryTest.php'; -require_once 'Zend/Gdata/Gapps/NicknameFeedTest.php'; -require_once 'Zend/Gdata/Gapps/NicknameQueryTest.php'; -require_once 'Zend/Gdata/Gapps/NicknameTest.php'; -require_once 'Zend/Gdata/Gapps/QuotaTest.php'; -require_once 'Zend/Gdata/Gapps/ServiceExceptionTest.php'; -require_once 'Zend/Gdata/Gapps/UserEntryTest.php'; -require_once 'Zend/Gdata/Gapps/UserFeedTest.php'; -require_once 'Zend/Gdata/Gapps/UserQueryTest.php'; - -require_once 'Zend/Gdata/YouTube/PlaylistListFeedTest.php'; -require_once 'Zend/Gdata/YouTube/PlaylistListEntryTest.php'; -require_once 'Zend/Gdata/YouTube/SubscriptionFeedTest.php'; -require_once 'Zend/Gdata/YouTube/SubscriptionEntryTest.php'; -require_once 'Zend/Gdata/YouTube/PlaylistVideoEntryTest.php'; -require_once 'Zend/Gdata/YouTube/VideoEntryTest.php'; -require_once 'Zend/Gdata/YouTube/PlaylistVideoFeedTest.php'; -require_once 'Zend/Gdata/YouTube/VideoFeedTest.php'; -require_once 'Zend/Gdata/YouTube/UserProfileEntryTest.php'; -require_once 'Zend/Gdata/YouTube/CommentFeedTest.php'; -require_once 'Zend/Gdata/YouTube/CommentEntryTest.php'; -require_once 'Zend/Gdata/YouTube/ContactFeedTest.php'; -require_once 'Zend/Gdata/YouTube/ContactEntryTest.php'; - - -/** - * Tests that do require online access to servers - * and authentication credentials - */ -require_once 'Zend/Gdata/GdataOnlineTest.php'; -require_once 'Zend/Gdata/GbaseOnlineTest.php'; -require_once 'Zend/Gdata/CalendarOnlineTest.php'; -require_once 'Zend/Gdata/SpreadsheetsOnlineTest.php'; -require_once 'Zend/Gdata/DocsOnlineTest.php'; -require_once 'Zend/Gdata/PhotosOnlineTest.php'; -require_once 'Zend/Gdata/GappsOnlineTest.php'; -require_once 'Zend/Gdata/YouTubeOnlineTest.php'; -require_once 'Zend/Gdata/SkipTests.php'; - -class Zend_Gdata_AllTests -{ - - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Gdata'); - - /** - * Tests of the authentication URL generator - */ - $suite->addTestSuite('Zend_Gdata_AuthSubTest'); - - /** - * Tests that do not require online access to servers - */ - $suite->addTestSuite('Zend_Gdata_AppTest'); - $suite->addTestSuite('Zend_Gdata_App_UtilTest'); - $suite->addTestSuite('Zend_Gdata_App_AuthorTest'); - $suite->addTestSuite('Zend_Gdata_App_CategoryTest'); - $suite->addTestSuite('Zend_Gdata_App_ContentTest'); - $suite->addTestSuite('Zend_Gdata_App_ControlTest'); - $suite->addTestSuite('Zend_Gdata_App_EntryTest'); - $suite->addTestSuite('Zend_Gdata_App_FeedTest'); - $suite->addTestSuite('Zend_Gdata_App_GeneratorTest'); - $suite->addTestSuite('Zend_Gdata_App_CaptchaRequiredExceptionTest'); - $suite->addTestSuite('Zend_Gdata_GdataTest'); - $suite->addTestSuite('Zend_Gdata_QueryTest'); - - $suite->addTestSuite('Zend_Gdata_AttendeeStatusTest'); - $suite->addTestSuite('Zend_Gdata_AttendeeTypeTest'); - $suite->addTestSuite('Zend_Gdata_CommentsTest'); - $suite->addTestSuite('Zend_Gdata_EntryLinkTest'); - $suite->addTestSuite('Zend_Gdata_EventStatusTest'); - $suite->addTestSuite('Zend_Gdata_ExtendedPropertyTest'); - $suite->addTestSuite('Zend_Gdata_FeedLinkTest'); - $suite->addTestSuite('Zend_Gdata_OpenSearchItemsPerPageTest'); - $suite->addTestSuite('Zend_Gdata_OpenSearchStartIndexTest'); - $suite->addTestSuite('Zend_Gdata_OpenSearchTotalResultsTest'); - $suite->addTestSuite('Zend_Gdata_OriginalEventTest'); - $suite->addTestSuite('Zend_Gdata_RecurrenceTest'); - $suite->addTestSuite('Zend_Gdata_RecurrenceExceptionTest'); - $suite->addTestSuite('Zend_Gdata_ReminderTest'); - $suite->addTestSuite('Zend_Gdata_TransparencyTest'); - $suite->addTestSuite('Zend_Gdata_VisibilityTest'); - $suite->addTestSuite('Zend_Gdata_WhenTest'); - $suite->addTestSuite('Zend_Gdata_WhereTest'); - $suite->addTestSuite('Zend_Gdata_WhoTest'); - - $suite->addTestSuite('Zend_Gdata_Gbase_ItemEntryTest'); - $suite->addTestSuite('Zend_Gdata_Gbase_ItemFeedTest'); - $suite->addTestSuite('Zend_Gdata_Gbase_ItemQueryTest'); - $suite->addTestSuite('Zend_Gdata_Gbase_SnippetFeedTest'); - $suite->addTestSuite('Zend_Gdata_Gbase_SnippetQueryTest'); - $suite->addTestSuite('Zend_Gdata_Gbase_QueryTest'); - $suite->addTestSuite('Zend_Gdata_Gbase_BaseAttributeTest'); - - $suite->addTestSuite('Zend_Gdata_CalendarTest'); - $suite->addTestSuite('Zend_Gdata_CalendarFeedTest'); - $suite->addTestSuite('Zend_Gdata_CalendarEventTest'); - $suite->addTestSuite('Zend_Gdata_CalendarFeedCompositeTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_EventQueryTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_EventQueryExceptionTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_EventEntryTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_AccessLevelTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_ColorTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_HiddenTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_LinkTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_SelectedTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_SendEventNotificationsTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_TimezoneTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_WebContentTest'); - $suite->addTestSuite('Zend_Gdata_Calendar_QuickAddTest'); - - $suite->addTestSuite('Zend_Gdata_Spreadsheets_ColCountTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_RowCountTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_CustomTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_WorksheetEntryTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellEntryTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_ListEntryTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_SpreadsheetFeedTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_WorksheetFeedTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellFeedTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_ListFeedTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_DocumentQueryTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellQueryTest'); - $suite->addTestSuite('Zend_Gdata_Spreadsheets_ListQueryTest'); - - $suite->addTestSuite('Zend_Gdata_Docs_DocumentListFeedTest'); - $suite->addTestSuite('Zend_Gdata_Docs_DocumentListEntryTest'); - $suite->addTestSuite('Zend_Gdata_Docs_QueryTest'); - - $suite->addTestSuite('Zend_Gdata_Photos_PhotosAlbumEntryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosAlbumFeedTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosAlbumQueryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosCommentEntryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosPhotoEntryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosPhotoFeedTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosPhotoQueryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosTagEntryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosUserEntryTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosUserFeedTest'); - $suite->addTestSuite('Zend_Gdata_Photos_PhotosUserQueryTest'); - - $suite->addTestSuite('Zend_Gdata_GappsTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListEntryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListFeedTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListQueryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListRecipientEntryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListRecipientFeedTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListRecipientQueryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_EmailListTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_ErrorTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_LoginTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_NameTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_NicknameEntryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_NicknameFeedTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_NicknameQueryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_NicknameTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_QuotaTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_ServiceExceptionTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_UserEntryTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_UserFeedTest'); - $suite->addTestSuite('Zend_Gdata_Gapps_UserQueryTest'); - - $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistListFeedTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistListEntryTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_SubscriptionFeedTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_SubscriptionEntryTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistVideoEntryTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_VideoEntryTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistVideoFeedTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_VideoFeedTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_UserProfileEntryTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_CommentFeedTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_CommentEntryTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_ContactFeedTest'); - $suite->addTestSuite('Zend_Gdata_YouTube_ContactEntryTest'); - - $skippingOnlineTests = true; - if (defined('TESTS_ZEND_GDATA_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_ONLINE_ENABLED') == true && - defined('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED') && - constant('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED') == true) { - /** - * Tests that do require online access to servers - * and authentication credentials - */ - $skippingOnlineTests = false; - if (defined('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_GdataOnlineTest'); - } - - if (defined('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_GbaseOnlineTest'); - } - - if (defined('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_CalendarOnlineTest'); - } - - if (defined('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_SpreadsheetsOnlineTest'); - } - - if (defined('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_DocsOnlineTest'); - } - - if (defined('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_PhotosOnlineTest'); - } - } - if (defined('TESTS_ZEND_GDATA_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_ONLINE_ENABLED') == true) { - /** - * Tests that do require online access to servers, but - * don't require the standard authentication credentials - */ - $skippingOnlineTests = false; - if (defined('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_GappsOnlineTest'); - } - if (defined('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED') && - constant('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED') == true) { - $suite->addTestSuite('Zend_Gdata_YouTubeOnlineTest'); - } - } - if ($skippingOnlineTests) { - $suite->addTestSuite('Zend_Gdata_SkipOnlineTest'); - } - return $suite; - } - -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Gdata_AllTests::main') { - Zend_Gdata_AllTests::main(); -} diff --git a/tests/Zend/Gdata/App/AuthorTest.php b/tests/Zend/Gdata/App/AuthorTest.php deleted file mode 100644 index e5bafcabf3a05f0883a4d4e7c4f9dd68b08b8346..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/AuthorTest.php +++ /dev/null @@ -1,113 +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_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Extension/Author.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_AuthorTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->authorText = file_get_contents( - 'Zend/Gdata/App/_files/AuthorElementSample1.xml', - true); - $this->author = new Zend_Gdata_App_Extension_Author(); - } - - public function testEmptyAuthorShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->author->extensionElements)); - $this->assertTrue(count($this->author->extensionElements) == 0); - } - - public function testNormalAuthorShouldHaveNoExtensionElements() { - $this->author->name = new Zend_Gdata_App_Extension_Name('Jeff Scudder'); - $this->assertEquals($this->author->name->text, 'Jeff Scudder'); - $this->assertEquals(count($this->author->extensionElements), 0); - $newAuthor = new Zend_Gdata_App_Extension_Author(); - $newAuthor->transferFromXML($this->author->saveXML()); - $this->assertEquals(count($newAuthor->extensionElements), 0); - $newAuthor->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newAuthor->extensionElements), 1); - $this->assertEquals($newAuthor->name->text, 'Jeff Scudder'); - - /* try constructing using magic factory */ - $app = new Zend_Gdata_App(); - $newAuthor2 = $app->newAuthor(); - $newAuthor2->transferFromXML($newAuthor->saveXML()); - $this->assertEquals(count($newAuthor2->extensionElements), 1); - $this->assertEquals($newAuthor2->name->text, 'Jeff Scudder'); - } - - public function testEmptyAuthorToAndFromStringShouldMatch() { - $authorXml = $this->author->saveXML(); - $newAuthor = new Zend_Gdata_App_Extension_Author(); - $newAuthor->transferFromXML($authorXml); - $newAuthorXml = $newAuthor->saveXML(); - $this->assertTrue($authorXml == $newAuthorXml); - } - - public function testAuthorWithNameEmailToAndFromStringShouldMatch() { - $this->author->name = new Zend_Gdata_App_Extension_Name('Jeff Scudder'); - $this->author->email = new Zend_Gdata_App_Extension_Email( - 'api.jscudder@gmail.com'); - $this->author->uri = new Zend_Gdata_App_Extension_Uri( - 'http://code.google.com/apis/gdata/'); - $authorXml = $this->author->saveXML(); - $newAuthor = new Zend_Gdata_App_Extension_Author(); - $newAuthor->transferFromXML($authorXml); - $newAuthorXml = $newAuthor->saveXML(); - $this->assertTrue($authorXml == $newAuthorXml); - $this->assertEquals('Jeff Scudder', $newAuthor->name->text); - $this->assertEquals('api.jscudder@gmail.com', $newAuthor->email->text); - $this->assertEquals('http://code.google.com/apis/gdata/', $newAuthor->uri->text); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->author->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->author->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->author->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->author->extensionAttributes['foo2']['value']); - $authorXml = $this->author->saveXML(); - $newAuthor = new Zend_Gdata_App_Extension_Author(); - $newAuthor->transferFromXML($authorXml); - //var_dump($this->author); - //print $authorXml; - $this->assertEquals('bar', $newAuthor->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newAuthor->extensionAttributes['foo2']['value']); - } - - public function testConvertFullAuthorToAndFromString() { - $this->author->transferFromXML($this->authorText); - $this->assertEquals($this->author->name->text, 'John Doe'); - $this->assertEquals($this->author->email->text, - 'johndoes@someemailadress.com'); - $this->assertEquals($this->author->uri->text, 'http://www.google.com'); - } - -} diff --git a/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php b/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php deleted file mode 100644 index 4e8d5ec57b30e24a46982bc8a45edde5881de09d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php +++ /dev/null @@ -1,53 +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_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - require_once 'Zend/Gdata/App/CaptchaRequiredException.php'; - - /** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_CaptchaRequiredExceptionTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->exampleException = new Zend_Gdata_App_CaptchaRequiredException('testtoken', 'Captcha?ctoken=testtoken'); - } - - public function testExceptionContainsValidInformation() { - $this->assertEquals('testtoken', $this->exampleException->getCaptchaToken()); - $this->assertEquals('https://www.google.com/accounts/Captcha?ctoken=testtoken', $this->exampleException->getCaptchaUrl()); - } - - public function testExceptionIsThrowable() { - $caught = false; - try { - throw $this->exampleException; - } - catch(Zend_Gdata_App_CaptchaRequiredException $e) { - $caught = true; - } - - $this->assertTrue($caught); - } - -} diff --git a/tests/Zend/Gdata/App/CategoryTest.php b/tests/Zend/Gdata/App/CategoryTest.php deleted file mode 100644 index 4593d69b9980aba2f4ec80b60e204696df312fc8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/CategoryTest.php +++ /dev/null @@ -1,109 +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_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Extension/Category.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_CategoryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->categoryText = file_get_contents( - 'Zend/Gdata/App/_files/CategoryElementSample1.xml', - true); - $this->category = new Zend_Gdata_App_Extension_Category(); - } - - public function testEmptyCategoryShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->category->extensionElements)); - $this->assertTrue(count($this->category->extensionElements) == 0); - } - - public function testNormalCategoryShouldHaveNoExtensionElements() { - - $this->category->scheme = 'http://schemas.google.com/g/2005#kind'; - $this->assertEquals($this->category->scheme, 'http://schemas.google.com/g/2005#kind'); - $this->assertEquals(count($this->category->extensionElements), 0); - $newCategory = new Zend_Gdata_App_Extension_Category(); - $newCategory->transferFromXML($this->category->saveXML()); - $this->assertEquals(0, count($newCategory->extensionElements)); - $newCategory->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newCategory->extensionElements), 1); - $this->assertEquals($newCategory->scheme, 'http://schemas.google.com/g/2005#kind'); - - /* try constructing using magic factory */ - $app = new Zend_Gdata_App(); - $newCategory2 = $app->newCategory(); - $newCategory2->transferFromXML($newCategory->saveXML()); - $this->assertEquals(count($newCategory2->extensionElements), 1); - $this->assertEquals($newCategory2->scheme, 'http://schemas.google.com/g/2005#kind'); - } - - public function testEmptyCategoryToAndFromStringShouldMatch() { - $categoryXml = $this->category->saveXML(); - $newCategory = new Zend_Gdata_App_Extension_Category(); - $newCategory->transferFromXML($categoryXml); - $newCategoryXml = $newCategory->saveXML(); - $this->assertTrue($categoryXml == $newCategoryXml); - } - - public function testCategoryWithSchemeAndTermToAndFromStringShouldMatch() { - $this->category->scheme = 'http://schemas.google.com/g/2005#kind'; - $this->category->term = 'http://schemas.google.com/g/2005#event'; - $this->category->label = 'event kind'; - $categoryXml = $this->category->saveXML(); - $newCategory = new Zend_Gdata_App_Extension_Category(); - $newCategory->transferFromXML($categoryXml); - $newCategoryXml = $newCategory->saveXML(); - $this->assertTrue($categoryXml == $newCategoryXml); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $newCategory->scheme); - $this->assertEquals('http://schemas.google.com/g/2005#event', $newCategory->term); - $this->assertEquals('event kind', $newCategory->label); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->category->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->category->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->category->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->category->extensionAttributes['foo2']['value']); - $categoryXml = $this->category->saveXML(); - $newCategory = new Zend_Gdata_App_Extension_Category(); - $newCategory->transferFromXML($categoryXml); - $this->assertEquals('bar', $newCategory->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newCategory->extensionAttributes['foo2']['value']); - } - - public function testConvertFullCategoryToAndFromString() { - $this->category->transferFromXML($this->categoryText); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $this->category->scheme); - $this->assertEquals('http://schemas.google.com/g/2005#event', $this->category->term); - $this->assertEquals('event kind', $this->category->label); - } - -} diff --git a/tests/Zend/Gdata/App/ContentTest.php b/tests/Zend/Gdata/App/ContentTest.php deleted file mode 100644 index 140f115c2f66c121f1f4e377c6741dc26afd6feb..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/ContentTest.php +++ /dev/null @@ -1,92 +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. - * - * @content Zend - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Extension/Content.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_ContentTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->contentText = file_get_contents( - 'Zend/Gdata/App/_files/ContentElementSample1.xml', - true); - $this->contentText2 = file_get_contents( - 'Zend/Gdata/App/_files/ContentElementSample2.xml', - true); - $this->content = new Zend_Gdata_App_Extension_Content(); - } - - public function testEmptyContentShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->content->extensionElements)); - $this->assertTrue(count($this->content->extensionElements) == 0); - } - - public function testEmptyContentToAndFromStringShouldMatch() { - $contentXml = $this->content->saveXML(); - $newContent = new Zend_Gdata_App_Extension_Content(); - $newContent->transferFromXML($contentXml); - $newContentXml = $newContent->saveXML(); - $this->assertTrue($contentXml == $newContentXml); - } - - public function testContentWithTextAndTypeToAndFromStringShouldMatch() { - $this->content->text = '<img src="http://www.example.com/image.jpg"/>'; - $this->content->type = 'xhtml'; - $contentXml = $this->content->saveXML(); - $newContent = new Zend_Gdata_App_Extension_Content(); - $newContent->transferFromXML($contentXml); - $newContentXml = $newContent->saveXML(); - $this->assertEquals($newContentXml, $contentXml); - $this->assertEquals('<img src="http://www.example.com/image.jpg"/>', $newContent->text); - $this->assertEquals('xhtml', $newContent->type); - } - - public function testContentWithSrcAndTypeToAndFromStringShouldMatch() { - $this->content->src = 'http://www.example.com/image.png'; - $this->content->type = 'image/png'; - $contentXml = $this->content->saveXML(); - $newContent = new Zend_Gdata_App_Extension_Content(); - $newContent->transferFromXML($contentXml); - $newContentXml = $newContent->saveXML(); - $this->assertEquals($newContentXml, $contentXml); - $this->assertEquals('http://www.example.com/image.png', $newContent->src); - $this->assertEquals('image/png', $newContent->type); - } - - public function testConvertContentWithSrcAndTypeToAndFromString() { - $this->content->transferFromXML($this->contentText); - $this->assertEquals('http://www.example.com/image.png', $this->content->src); - $this->assertEquals('image/png', $this->content->type); - } - - public function testConvertContentWithTextAndTypeToAndFromString() { - $this->content->transferFromXML($this->contentText2); - $this->assertEquals('xhtml', $this->content->type); - $this->assertEquals(1, count($this->content->extensionElements)); - } - -} diff --git a/tests/Zend/Gdata/App/ControlTest.php b/tests/Zend/Gdata/App/ControlTest.php deleted file mode 100644 index 091b007aa7cb10a445d69b6ba3f131a34b22fcb3..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/ControlTest.php +++ /dev/null @@ -1,70 +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. - * - * @control Zend - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Extension/Control.php'; -require_once 'Zend/Gdata/App/Extension/Draft.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_ControlTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->controlText = file_get_contents( - 'Zend/Gdata/App/_files/ControlElementSample1.xml', - true); - $this->control = new Zend_Gdata_App_Extension_Control(); - } - - public function testEmptyControlShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->control->extensionElements)); - $this->assertTrue(count($this->control->extensionElements) == 0); - } - - public function testEmptyControlToAndFromStringShouldMatch() { - $controlXml = $this->control->saveXML(); - $newControl = new Zend_Gdata_App_Extension_Control(); - $newControl->transferFromXML($controlXml); - $newControlXml = $newControl->saveXML(); - $this->assertTrue($controlXml == $newControlXml); - } - - public function testControlWithDraftToAndFromStringShouldMatch() { - $draft = new Zend_Gdata_App_Extension_Draft('yes'); - $this->control->draft = $draft; - $controlXml = $this->control->saveXML(); - $newControl = new Zend_Gdata_App_Extension_Control(); - $newControl->transferFromXML($controlXml); - $newControlXml = $newControl->saveXML(); - $this->assertEquals($newControlXml, $controlXml); - $this->assertEquals('yes', $newControl->draft->text); - } - - public function testConvertControlWithDraftToAndFromString() { - $this->control->transferFromXML($this->controlText); - $this->assertEquals('yes', $this->control->draft->text); - } - -} diff --git a/tests/Zend/Gdata/App/EntryTest.php b/tests/Zend/Gdata/App/EntryTest.php deleted file mode 100644 index 11abb0152affbb6bf6a45da150a6ee8c253d2236..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/EntryTest.php +++ /dev/null @@ -1,97 +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. - * - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Entry.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_EntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->enryText = file_get_contents( - 'Zend/Gdata/App/_files/EntrySample1.xml', - true); - $this->enry = new Zend_Gdata_App_Entry(); - } - - public function testEmptyEntryShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->enry->extensionElements)); - $this->assertTrue(count($this->enry->extensionElements) == 0); - } - - public function testEmptyEntryToAndFromStringShouldMatch() { - $enryXml = $this->enry->saveXML(); - $newEntry = new Zend_Gdata_App_Entry(); - $newEntry->transferFromXML($enryXml); - $newEntryXml = $newEntry->saveXML(); - $this->assertTrue($enryXml == $newEntryXml); - } - - public function testConvertEntryToAndFromString() { - $this->enry->transferFromXML($this->enryText); - $enryXml = $this->enry->saveXML(); - $newEntry = new Zend_Gdata_App_Entry(); - $newEntry->transferFromXML($enryXml); -/* - $this->assertEquals(1, count($newEntry->entry)); - $this->assertEquals('dive into mark', $newEntry->title->text); - $this->assertEquals('text', $newEntry->title->type); - $this->assertEquals('2005-07-31T12:29:29Z', $newEntry->updated->text); - $this->assertEquals('tag:example.org,2003:3', $newEntry->id->text); - $this->assertEquals(2, count($newEntry->link)); - $this->assertEquals('http://example.org/', - $newEntry->getAlternateLink()->href); - $this->assertEquals('en', - $newEntry->getAlternateLink()->hrefLang); - $this->assertEquals('text/html', - $newEntry->getAlternateLink()->type); - $this->assertEquals('http://example.org/enry.atom', - $newEntry->getSelfLink()->href); - $this->assertEquals('application/atom+xml', - $newEntry->getSelfLink()->type); - $this->assertEquals('Copyright (c) 2003, Mark Pilgrim', - $newEntry->rights->text); - $entry = $newEntry->entry[0]; - $this->assertEquals('Atom draft-07 snapshot', $entry->title->text); - $this->assertEquals('tag:example.org,2003:3.2397', - $entry->id->text); - $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text); - $this->assertEquals('2003-12-13T08:29:29-04:00', - $entry->published->text); - $this->assertEquals('Mark Pilgrim', - $entry->author[0]->name->text); - $this->assertEquals('http://example.org/', - $entry->author[0]->uri->text); - $this->assertEquals(2, count($entry->contributor)); - $this->assertEquals('Sam Ruby', - $entry->contributor[0]->name->text); - $this->assertEquals('Joe Gregorio', - $entry->contributor[1]->name->text); - $this->assertEquals('xhtml', $entry->content->type); -*/ - } - - -} diff --git a/tests/Zend/Gdata/App/FeedTest.php b/tests/Zend/Gdata/App/FeedTest.php deleted file mode 100644 index 659365dcc0cb8f9c149544e94a5c983919f8d7f4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/FeedTest.php +++ /dev/null @@ -1,107 +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. - * - * @feed Zend - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Feed.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_FeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/App/_files/FeedSample1.xml', - true); - $this->feed = new Zend_Gdata_App_Feed(); - } - - public function testEmptyFeedShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyFeedToAndFromStringShouldMatch() { - $feedXml = $this->feed->saveXML(); - $newFeed = new Zend_Gdata_App_Feed(); - $newFeed->transferFromXML($feedXml); - $newFeedXml = $newFeed->saveXML(); - $this->assertTrue($feedXml == $newFeedXml); - } - - public function testConvertFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $feedXml = $this->feed->saveXML(); - $newFeed = new Zend_Gdata_App_Feed(); - $newFeed->transferFromXML($feedXml); - $this->assertEquals(1, count($newFeed->entry)); - $this->assertEquals('dive into mark', $newFeed->title->text); - $this->assertEquals('text', $newFeed->title->type); - $this->assertEquals('2005-07-31T12:29:29Z', $newFeed->updated->text); - $this->assertEquals('tag:example.org,2003:3', $newFeed->id->text); - $this->assertEquals(2, count($newFeed->link)); - $this->assertEquals('http://example.org/', - $newFeed->getAlternateLink()->href); - $this->assertEquals('en', - $newFeed->getAlternateLink()->hrefLang); - $this->assertEquals('text/html', - $newFeed->getAlternateLink()->type); - $this->assertEquals('http://example.org/feed.atom', - $newFeed->getSelfLink()->href); - $this->assertEquals('application/atom+xml', - $newFeed->getSelfLink()->type); - $this->assertEquals('Copyright (c) 2003, Mark Pilgrim', - $newFeed->rights->text); - $entry = $newFeed->entry[0]; - $this->assertEquals('Atom draft-07 snapshot', $entry->title->text); - $this->assertEquals('tag:example.org,2003:3.2397', - $entry->id->text); - $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text); - $this->assertEquals('2003-12-13T08:29:29-04:00', - $entry->published->text); - $this->assertEquals('Mark Pilgrim', - $entry->author[0]->name->text); - $this->assertEquals('http://example.org/', - $entry->author[0]->uri->text); - $this->assertEquals(2, count($entry->contributor)); - $this->assertEquals('Sam Ruby', - $entry->contributor[0]->name->text); - $this->assertEquals('Joe Gregorio', - $entry->contributor[1]->name->text); - $this->assertEquals('xhtml', $entry->content->type); - } - - public function testCanAddIndividualEntries() { - $this->feed->transferFromXML($this->feedText); - $this->assertEquals(1, count($this->feed->entry)); - $oldTitle = $this->feed->entry[0]->title->text; - $newEntry = new Zend_Gdata_App_Entry(); - $newEntry->setTitle(new Zend_Gdata_App_Extension_Title("Foo")); - $this->feed->addEntry($newEntry); - $this->assertEquals(2, count($this->feed->entry)); - $this->assertEquals($oldTitle, $this->feed->entry[0]->title->text); - $this->assertEquals("Foo", $this->feed->entry[1]->title->text); - } - -} diff --git a/tests/Zend/Gdata/App/GeneratorTest.php b/tests/Zend/Gdata/App/GeneratorTest.php deleted file mode 100644 index 217fbd4c175d37e327c7d1316c62f15446ec843a..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/GeneratorTest.php +++ /dev/null @@ -1,77 +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. - * - * @generator Zend - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/App/Extension/Generator.php'; -require_once 'Zend/Gdata/App/Extension/Draft.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_GeneratorTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->generatorText = file_get_contents( - 'Zend/Gdata/App/_files/GeneratorElementSample1.xml', - true); - $this->generator = new Zend_Gdata_App_Extension_Generator(); - } - - public function testEmptyGeneratorShouldHaveEmptyExtensionsList() { - $this->assertTrue(is_array($this->generator->extensionElements)); - $this->assertTrue(count($this->generator->extensionElements) == 0); - } - - public function testEmptyGeneratorToAndFromStringShouldMatch() { - $generatorXml = $this->generator->saveXML(); - $newGenerator = new Zend_Gdata_App_Extension_Generator(); - $newGenerator->transferFromXML($generatorXml); - $newGeneratorXml = $newGenerator->saveXML(); - $this->assertTrue($generatorXml == $newGeneratorXml); - } - - public function testGeneratorToAndFromStringShouldMatch() { - $this->generator->uri = 'http://code.google.com/apis/gdata/'; - $this->generator->version = '1.0'; - $this->generator->text = 'Google data APIs'; - $generatorXml = $this->generator->saveXML(); - $newGenerator = new Zend_Gdata_App_Extension_Generator(); - $newGenerator->transferFromXML($generatorXml); - $newGeneratorXml = $newGenerator->saveXML(); - $this->assertEquals($newGeneratorXml, $generatorXml); - $this->assertEquals('http://code.google.com/apis/gdata/', - $newGenerator->uri); - $this->assertEquals('1.0', $newGenerator->version); - $this->assertEquals('Google data APIs', $newGenerator->text); - } - - public function testConvertGeneratorWithDraftToAndFromString() { - $this->generator->transferFromXML($this->generatorText); - $this->assertEquals('http://code.google.com/apis/gdata/', - $this->generator->uri); - $this->assertEquals('1.0', $this->generator->version); - $this->assertEquals('Google data APIs', $this->generator->text); - } - -} diff --git a/tests/Zend/Gdata/App/HttpExceptionTest.php b/tests/Zend/Gdata/App/HttpExceptionTest.php deleted file mode 100755 index 384d1b156361e0ea89ba197050bda9a8984e4a78..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/HttpExceptionTest.php +++ /dev/null @@ -1,67 +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. - * - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/App.php'; -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/ClientLogin.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_App_HttpExceptionTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $this->sprKey = constant('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY'); - $this->wksId = constant('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID'); - $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->gdata = new Zend_Gdata_Spreadsheets($client); - } - - public function testGetRawResponseBody() - { - try { - $rowData = array(); - $entry = $this->gdata->insertRow($rowData, $this->sprKey); - $this->fail('Expecting Zend_Gdata_App_HttpException'); - } catch (Zend_Gdata_App_HttpException $hExc) { - $this->assertThat($hExc, - $this->isInstanceOf('Zend_Gdata_App_HttpException'), - 'Expecting Zend_Gdata_App_HttpException, got ' - . get_class($hExc)); - - $message = $hExc->getMessage(); - $this->assertEquals($message, 'Expected response code 200, got 400'); - $body = $hExc->getRawResponseBody(); - $this->assertNotNull($body); - $this->assertNotEquals(stripos($body, - 'Blank rows cannot be written; use delete instead.'), false); - } - } -} diff --git a/tests/Zend/Gdata/App/UtilTest.php b/tests/Zend/Gdata/App/UtilTest.php deleted file mode 100644 index 27b57eac57919bda4898898c01fe7cc3e6630f49..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/UtilTest.php +++ /dev/null @@ -1,148 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/App/Util.php'; -require_once 'Zend/Gdata/App/Exception.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_App_UtilTest extends PHPUnit_Framework_TestCase -{ - - public function testFormatTimestampFromString() - { - // assert that a correctly formatted timestamp is not modified - $date = Zend_Gdata_App_Util::formatTimestamp('2006-12-01'); - $this->assertEquals('2006-12-01', $date); - } - - public function testFormatTimestampFromStringWithTimezone() - { - // assert that a correctly formatted timestamp is not modified - $date = Zend_Gdata_App_Util::formatTimestamp('2007-01-10T13:31:12-04:00'); - $this->assertEquals('2007-01-10T13:31:12-04:00', $date); - } - - public function testFormatTimestampWithMilliseconds() - { - // assert that a correctly formatted timestamp is not modified - $date = Zend_Gdata_App_Util::formatTimestamp('1956-12-14T43:09:54.52376Z'); - $this->assertEquals('1956-12-14T43:09:54.52376Z', $date); - } - - public function testFormatTimestampUsingZuluAsOffset() - { - // assert that a correctly formatted timestamp is not modified - $date = Zend_Gdata_App_Util::formatTimestamp('2024-03-19T01:38:12Z'); - $this->assertEquals('2024-03-19T01:38:12Z', $date); - } - - public function testFormatTimestampUsingLowercaseTAndZ() - { - // assert that a correctly formatted timestamp is not modified - $date = Zend_Gdata_App_Util::formatTimestamp('1945-07-19t12:19:08z'); - $this->assertEquals('1945-07-19t12:19:08z', $date); - } - - public function testFormatTimestampFromStringWithNonCompliantDate() - { - // assert that a non-compliant date is converted to RFC 3339 - $date = Zend_Gdata_App_Util::formatTimestamp('2007/07/13'); - $this->assertEquals('2007-07-13T00:00:00', $date); - } - - public function testFormatTimestampFromInteger() - { - $ts = 1164960000; // Fri Dec 1 00:00:00 PST 2006 - $date = Zend_Gdata_App_Util::formatTimestamp($ts); - $this->assertEquals('2006-12-01T08:00:00+00:00', $date); - } - - public function testExceptionFormatTimestampNonsense() - { - $util = new Zend_Gdata_App_Util(); - try { - $ts = Zend_Gdata_App_Util::formatTimestamp('nonsense string'); - } catch (Zend_Gdata_App_Exception $e) { - $this->assertEquals('Invalid timestamp: nonsense string.', $e->getMessage()); - return; - } - // Excetion not thrown, this is bad. - $this->fail("Exception not thrown."); - } - - public function testExceptionFormatTimestampSemiInvalid() - { - $util = new Zend_Gdata_App_Util(); - try { - $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05adslfkja'); - } catch (Zend_Gdata_App_Exception $e) { - $this->assertEquals('Invalid timestamp: 2007-06-05adslfkja.', $e->getMessage()); - return; - } - // Excetion not thrown, this is bad. - $this->fail("Exception not thrown."); - } - - public function testExceptionFormatTimestampInvalidTime() - { - $util = new Zend_Gdata_App_Util(); - try { - $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05Tadslfkja'); - } catch (Zend_Gdata_App_Exception $e) { - $this->assertEquals('Invalid timestamp: 2007-06-05Tadslfkja.', $e->getMessage()); - return; - } - // Excetion not thrown, this is bad. - $this->fail("Exception not thrown."); - } - - public function testExceptionFormatTimestampInvalidOffset() - { - $util = new Zend_Gdata_App_Util(); - try { - $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05T02:51:12+egg'); - } catch (Zend_Gdata_App_Exception $e) { - $this->assertEquals('Invalid timestamp: 2007-06-05T02:51:12+egg.', $e->getMessage()); - return; - } - // Excetion not thrown, this is bad. - $this->fail("Exception not thrown."); - } - - public function testExceptionFormatTimestampInvalidOffsetHours() - { - $util = new Zend_Gdata_App_Util(); - try { - $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05T02:51:12-ab:00'); - } catch (Zend_Gdata_App_Exception $e) { - $this->assertEquals('Invalid timestamp: 2007-06-05T02:51:12-ab:00.', $e->getMessage()); - return; - } - // Excetion not thrown, this is bad. - $this->fail("Exception not thrown."); - } - -} diff --git a/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml b/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml deleted file mode 100644 index 772b6f5d6c0905af9e06650d59e8a2a7b0767d5e..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<author xmlns="http://www.w3.org/2005/Atom"> - <name xmlns="http://www.w3.org/2005/Atom">John Doe</name> - <email xmlns="http://www.w3.org/2005/Atom">johndoes@someemailadress.com</email> - <uri xmlns="http://www.w3.org/2005/Atom">http://www.google.com</uri> -</author> diff --git a/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml b/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml deleted file mode 100644 index 2a8b60981cd1282873979ed4a3b8f6e22f3621a2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/g/2005#event" - label="event kind"></category> diff --git a/tests/Zend/Gdata/App/_files/ContentElementSample1.xml b/tests/Zend/Gdata/App/_files/ContentElementSample1.xml deleted file mode 100644 index 91acb5bc9b962682e483b2f4775c85220fdac688..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/ContentElementSample1.xml +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<content type="image/png" - src="http://www.example.com/image.png"/> diff --git a/tests/Zend/Gdata/App/_files/ContentElementSample2.xml b/tests/Zend/Gdata/App/_files/ContentElementSample2.xml deleted file mode 100644 index 18cdfc1c66507c97ea5284a1094b85c14de9d898..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/ContentElementSample2.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<content type="xhtml"><img src="http://www.example.com/image.jpg"/></content> diff --git a/tests/Zend/Gdata/App/_files/ControlElementSample1.xml b/tests/Zend/Gdata/App/_files/ControlElementSample1.xml deleted file mode 100644 index 5fbd7ef426a28f8c6b4517b8b330473f64f3b03f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/ControlElementSample1.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<control xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://purl.org/atom/app#"> - <app:draft>yes</app:draft> -</control> diff --git a/tests/Zend/Gdata/App/_files/EntrySample1.xml b/tests/Zend/Gdata/App/_files/EntrySample1.xml deleted file mode 100644 index 27de4025244ff28226e1442227110a6c4553444e..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/EntrySample1.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<entry xmlns="http://www.w3.org/2005/Atom"> - <title>Atom draft-07 snapshot</title> - <link rel="alternate" type="text/html" - href="http://example.org/2005/04/02/atom"/> - <link rel="enclosure" type="audio/mpeg" length="1337" - href="http://example.org/audio/ph34r_my_podcast.mp3"/> - <id>tag:example.org,2003:3.2397</id> - <updated>2005-07-31T12:29:29Z</updated> - <published>2003-12-13T08:29:29-04:00</published> - <author> - <name>Mark Pilgrim</name> - <uri>http://example.org/</uri> - <email>f8dy@example.com</email> - </author> - <contributor> - <name>Sam Ruby</name> - </contributor> - <contributor> - <name>Joe Gregorio</name> - </contributor> - <content type="xhtml" xml:lang="en" - xml:base="http://diveintomark.org/"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <p><i>[Update: The Atom draft is finished.]</i></p> - </div> - </content> -</entry> diff --git a/tests/Zend/Gdata/App/_files/FeedSample1.xml b/tests/Zend/Gdata/App/_files/FeedSample1.xml deleted file mode 100644 index b1a4b36845c84c40ae0e5e130198ffb9cab883be..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/FeedSample1.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - <title type="text">dive into mark</title> - <subtitle type="html"> - A <em>lot</em> of effort - went into making this effortless - </subtitle> - <updated>2005-07-31T12:29:29Z</updated> - <id>tag:example.org,2003:3</id> - <link rel="alternate" type="text/html" - hreflang="en" href="http://example.org/"/> - <link rel="self" type="application/atom+xml" - href="http://example.org/feed.atom"/> - <rights>Copyright (c) 2003, Mark Pilgrim</rights> - <generator uri="http://www.example.com/" version="1.0"> - Example Toolkit - </generator> - <entry> - <title>Atom draft-07 snapshot</title> - <link rel="alternate" type="text/html" - href="http://example.org/2005/04/02/atom"/> - <link rel="enclosure" type="audio/mpeg" length="1337" - href="http://example.org/audio/ph34r_my_podcast.mp3"/> - <id>tag:example.org,2003:3.2397</id> - <updated>2005-07-31T12:29:29Z</updated> - <published>2003-12-13T08:29:29-04:00</published> - <author> - <name>Mark Pilgrim</name> - <uri>http://example.org/</uri> - <email>f8dy@example.com</email> - </author> - <contributor> - <name>Sam Ruby</name> - </contributor> - <contributor> - <name>Joe Gregorio</name> - </contributor> - <content type="xhtml" xml:lang="en" - xml:base="http://diveintomark.org/"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <p><i>[Update: The Atom draft is finished.]</i></p> - </div> - </content> - </entry> -</feed> diff --git a/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml b/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml deleted file mode 100644 index 00ae0218181a941fa73f1677fa51504c8d96e090..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<generator xmlns="http://www.w3.org/2005/Atom" uri="http://code.google.com/apis/gdata/" version="1.0">Google data APIs</generator> diff --git a/tests/Zend/Gdata/AppTest.php b/tests/Zend/Gdata/AppTest.php deleted file mode 100644 index ad31cf4a03ad36a00ec604e0b12eb57e3ef6e142..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/AppTest.php +++ /dev/null @@ -1,49 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/App.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_AppTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->fileName = 'Zend/Gdata/App/_files/FeedSample1.xml'; - } - - public function testImportFile() - { - $feed = Zend_Gdata_App::importFile($this->fileName, - 'Zend_Gdata_App_Feed', true); - $this->assertEquals('dive into mark', $feed->title->text); - } - - public function testSetAndGetHttpMethodOverride() - { - Zend_Gdata_App::setHttpMethodOverride(true); - $this->assertEquals(true, Zend_Gdata_App::getHttpMethodOverride()); - } -} diff --git a/tests/Zend/Gdata/AttendeeStatusTest.php b/tests/Zend/Gdata/AttendeeStatusTest.php deleted file mode 100644 index fbe4b7477e1331edd9278c777c4f72d1464c69f5..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/AttendeeStatusTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/AttendeeStatus.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_AttendeeStatusTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->attendeeStatusText = file_get_contents( - 'Zend/Gdata/_files/AttendeeStatusElementSample1.xml', - true); - $this->attendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); - } - - public function testEmptyAttendeeStatusShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->attendeeStatus->extensionElements)); - $this->assertTrue(count($this->attendeeStatus->extensionElements) == 0); - } - - public function testEmptyAttendeeStatusShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->attendeeStatus->extensionAttributes)); - $this->assertTrue(count($this->attendeeStatus->extensionAttributes) == 0); - } - - public function testSampleAttendeeStatusShouldHaveNoExtensionElements() { - $this->attendeeStatus->transferFromXML($this->attendeeStatusText); - $this->assertTrue(is_array($this->attendeeStatus->extensionElements)); - $this->assertTrue(count($this->attendeeStatus->extensionElements) == 0); - } - - public function testSampleAttendeeStatusShouldHaveNoExtensionAttributes() { - $this->attendeeStatus->transferFromXML($this->attendeeStatusText); - $this->assertTrue(is_array($this->attendeeStatus->extensionAttributes)); - $this->assertTrue(count($this->attendeeStatus->extensionAttributes) == 0); - } - - public function testNormalAttendeeStatusShouldHaveNoExtensionElements() { - $this->attendeeStatus->value = "http://schemas.google.com/g/2005#event.accepted"; - - $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $this->attendeeStatus->value); - - $this->assertEquals(0, count($this->attendeeStatus->extensionElements)); - $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); - $newAttendeeStatus->transferFromXML($this->attendeeStatus->saveXML()); - $this->assertEquals(0, count($newAttendeeStatus->extensionElements)); - $newAttendeeStatus->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newAttendeeStatus->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $newAttendeeStatus->value); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newAttendeeStatus2 = $gdata->newAttendeeStatus(); - $newAttendeeStatus2->transferFromXML($newAttendeeStatus->saveXML()); - $this->assertEquals(1, count($newAttendeeStatus2->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $newAttendeeStatus2->value); - } - - public function testEmptyAttendeeStatusToAndFromStringShouldMatch() { - $attendeeStatusXml = $this->attendeeStatus->saveXML(); - $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); - $newAttendeeStatus->transferFromXML($attendeeStatusXml); - $newAttendeeStatusXml = $newAttendeeStatus->saveXML(); - $this->assertTrue($attendeeStatusXml == $newAttendeeStatusXml); - } - - public function testAttendeeStatusWithValueToAndFromStringShouldMatch() { - $this->attendeeStatus->value = "http://schemas.google.com/g/2005#event.accepted"; - $attendeeStatusXml = $this->attendeeStatus->saveXML(); - $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); - $newAttendeeStatus->transferFromXML($attendeeStatusXml); - $newAttendeeStatusXml = $newAttendeeStatus->saveXML(); - $this->assertTrue($attendeeStatusXml == $newAttendeeStatusXml); - $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $this->attendeeStatus->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->attendeeStatus->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->attendeeStatus->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->attendeeStatus->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->attendeeStatus->extensionAttributes['foo2']['value']); - $attendeeStatusXml = $this->attendeeStatus->saveXML(); - $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); - $newAttendeeStatus->transferFromXML($attendeeStatusXml); - $this->assertEquals('bar', $newAttendeeStatus->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newAttendeeStatus->extensionAttributes['foo2']['value']); - } - - public function testConvertFullAttendeeStatusToAndFromString() { - $this->attendeeStatus->transferFromXML($this->attendeeStatusText); - $this->assertEquals("http://schemas.google.com/g/2005#event.invited", $this->attendeeStatus->value); - } - -} diff --git a/tests/Zend/Gdata/AttendeeTypeTest.php b/tests/Zend/Gdata/AttendeeTypeTest.php deleted file mode 100644 index 43e377f419692a51591c4cbcb2d8b7cc938f73d4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/AttendeeTypeTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/AttendeeType.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_AttendeeTypeTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->attendeeTypeText = file_get_contents( - 'Zend/Gdata/_files/AttendeeTypeElementSample1.xml', - true); - $this->attendeeType = new Zend_Gdata_Extension_AttendeeType(); - } - - public function testEmptyAttendeeTypeShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->attendeeType->extensionElements)); - $this->assertTrue(count($this->attendeeType->extensionElements) == 0); - } - - public function testEmptyAttendeeTypeShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->attendeeType->extensionAttributes)); - $this->assertTrue(count($this->attendeeType->extensionAttributes) == 0); - } - - public function testSampleAttendeeTypeShouldHaveNoExtensionElements() { - $this->attendeeType->transferFromXML($this->attendeeTypeText); - $this->assertTrue(is_array($this->attendeeType->extensionElements)); - $this->assertTrue(count($this->attendeeType->extensionElements) == 0); - } - - public function testSampleAttendeeTypeShouldHaveNoExtensionAttributes() { - $this->attendeeType->transferFromXML($this->attendeeTypeText); - $this->assertTrue(is_array($this->attendeeType->extensionAttributes)); - $this->assertTrue(count($this->attendeeType->extensionAttributes) == 0); - } - - public function testNormalAttendeeTypeShouldHaveNoExtensionElements() { - $this->attendeeType->value = "http://schemas.google.com/g/2005#event.optional"; - - $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $this->attendeeType->value); - - $this->assertEquals(0, count($this->attendeeType->extensionElements)); - $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); - $newAttendeeType->transferFromXML($this->attendeeType->saveXML()); - $this->assertEquals(0, count($newAttendeeType->extensionElements)); - $newAttendeeType->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newAttendeeType->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $newAttendeeType->value); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newAttendeeType2 = $gdata->newAttendeeType(); - $newAttendeeType2->transferFromXML($newAttendeeType->saveXML()); - $this->assertEquals(1, count($newAttendeeType2->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $newAttendeeType2->value); - } - - public function testEmptyAttendeeTypeToAndFromStringShouldMatch() { - $attendeeTypeXml = $this->attendeeType->saveXML(); - $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); - $newAttendeeType->transferFromXML($attendeeTypeXml); - $newAttendeeTypeXml = $newAttendeeType->saveXML(); - $this->assertTrue($attendeeTypeXml == $newAttendeeTypeXml); - } - - public function testAttendeeTypeWithValueToAndFromStringShouldMatch() { - $this->attendeeType->value = "http://schemas.google.com/g/2005#event.optional"; - $attendeeTypeXml = $this->attendeeType->saveXML(); - $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); - $newAttendeeType->transferFromXML($attendeeTypeXml); - $newAttendeeTypeXml = $newAttendeeType->saveXML(); - $this->assertTrue($attendeeTypeXml == $newAttendeeTypeXml); - $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $this->attendeeType->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->attendeeType->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->attendeeType->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->attendeeType->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->attendeeType->extensionAttributes['foo2']['value']); - $attendeeTypeXml = $this->attendeeType->saveXML(); - $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); - $newAttendeeType->transferFromXML($attendeeTypeXml); - $this->assertEquals('bar', $newAttendeeType->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newAttendeeType->extensionAttributes['foo2']['value']); - } - - public function testConvertFullAttendeeTypeToAndFromString() { - $this->attendeeType->transferFromXML($this->attendeeTypeText); - $this->assertEquals("http://schemas.google.com/g/2005#event.required", $this->attendeeType->value); - } - -} diff --git a/tests/Zend/Gdata/AuthSubTest.php b/tests/Zend/Gdata/AuthSubTest.php deleted file mode 100755 index a7941243b07cefe2f73c67fd70fc1f42c21f0266..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/AuthSubTest.php +++ /dev/null @@ -1,112 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/AuthSub.php'; -require_once 'Zend/Gdata/HttpClient.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_AuthSubTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - } - - public function testNormalGetAuthSubTokenUri() - { - $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri( - 'http://www.example.com/foo.php', //next - 'http://www.google.com/calendar/feeds', //scope - 0, //secure - 1); //session - - // Note: the scope here is not encoded. It should be encoded, - // but the method getAuthSubTokenUri calls urldecode($scope). - // This currently works (no reported bugs) as web browsers will - // handle the encoding in most cases. - $this->assertEquals('https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Ffoo.php&scope=http://www.google.com/calendar/feeds&secure=0&session=1', $uri); - } - - public function testGetAuthSubTokenUriModifiedBase() - { - $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri( - 'http://www.example.com/foo.php', //next - 'http://www.google.com/calendar/feeds', //scope - 0, //secure - 1, //session - 'http://www.otherauthservice.com/accounts/AuthSubRequest'); - - // Note: the scope here is not encoded. It should be encoded, - // but the method getAuthSubTokenUri calls urldecode($scope). - // This currently works (no reported bugs) as web browsers will - // handle the encoding in most cases. - $this->assertEquals('http://www.otherauthservice.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Ffoo.php&scope=http://www.google.com/calendar/feeds&secure=0&session=1', $uri); - } - - public function testSecureAuthSubSigning() - { - if (!extension_loaded('openssl')) { - $this->markTestSkipped('The openssl extension is not available'); - } else { - $c = new Zend_Gdata_HttpClient(); - $c->setAuthSubPrivateKeyFile("Zend/Gdata/_files/RsaKey.pem", - null, true); - $c->setAuthSubToken('abcdefg'); - $requestData = $c->filterHttpRequest('POST', - 'http://www.example.com/feed', - array(), - 'foo bar', - 'text/plain'); - - $authHeaderCheckPassed = false; - $headers = $requestData['headers']; - foreach ($headers as $headerName => $headerValue) { - if (strtolower($headerName) == 'authorization') { - preg_match('/data="([^"]*)"/', $headerValue, $matches); - $dataToSign = $matches[1]; - preg_match('/sig="([^"]*)"/', $headerValue, $matches); - $sig = $matches[1]; - if (function_exists('openssl_verify')) { - $fp = fopen('Zend/Gdata/_files/RsaCert.pem', 'r', true); - $cert = ''; - while (!feof($fp)) { - $cert .= fread($fp, 8192); - } - fclose($fp); - $pubkeyid = openssl_get_publickey($cert); - $verified = openssl_verify($dataToSign, - base64_decode($sig), $pubkeyid); - $this->assertEquals( - 1, $verified, - 'The generated signature was unable ' . - 'to be verified.'); - $authHeaderCheckPassed = true; - } - } - } - $this->assertEquals(true, $authHeaderCheckPassed, - 'Auth header not found for sig verification.'); - } - } -} diff --git a/tests/Zend/Gdata/Calendar/AccessLevelTest.php b/tests/Zend/Gdata/Calendar/AccessLevelTest.php deleted file mode 100644 index 92b43988e3acfa57ebc8e943b2b8b88a002802f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/AccessLevelTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/AccessLevel.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_AccessLevelTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->accessLevelText = file_get_contents( - 'Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml', - true); - $this->accessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); - } - - public function testEmptyAccessLevelShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->accessLevel->extensionElements)); - $this->assertTrue(count($this->accessLevel->extensionElements) == 0); - } - - public function testEmptyAccessLevelShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->accessLevel->extensionAttributes)); - $this->assertTrue(count($this->accessLevel->extensionAttributes) == 0); - } - - public function testSampleAccessLevelShouldHaveNoExtensionElements() { - $this->accessLevel->transferFromXML($this->accessLevelText); - $this->assertTrue(is_array($this->accessLevel->extensionElements)); - $this->assertTrue(count($this->accessLevel->extensionElements) == 0); - } - - public function testSampleAccessLevelShouldHaveNoExtensionAttributes() { - $this->accessLevel->transferFromXML($this->accessLevelText); - $this->assertTrue(is_array($this->accessLevel->extensionAttributes)); - $this->assertTrue(count($this->accessLevel->extensionAttributes) == 0); - } - - public function testNormalAccessLevelShouldHaveNoExtensionElements() { - $this->accessLevel->value = 'freebusy'; - $this->assertEquals($this->accessLevel->value, 'freebusy'); - $this->assertEquals(count($this->accessLevel->extensionElements), 0); - $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); - $newAccessLevel->transferFromXML($this->accessLevel->saveXML()); - $this->assertEquals(count($newAccessLevel->extensionElements), 0); - $newAccessLevel->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newAccessLevel->extensionElements), 1); - $this->assertEquals($newAccessLevel->value, 'freebusy'); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newAccessLevel2 = $cal->newAccessLevel(); - $newAccessLevel2->transferFromXML($newAccessLevel->saveXML()); - $this->assertEquals(count($newAccessLevel2->extensionElements), 1); - $this->assertEquals($newAccessLevel2->value, 'freebusy'); - } - - public function testEmptyAccessLevelToAndFromStringShouldMatch() { - $accessLevelXml = $this->accessLevel->saveXML(); - $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); - $newAccessLevel->transferFromXML($accessLevelXml); - $newAccessLevelXml = $newAccessLevel->saveXML(); - $this->assertTrue($accessLevelXml == $newAccessLevelXml); - } - - public function testAccessLevelWithValueToAndFromStringShouldMatch() { - $this->accessLevel->value = 'freebusy'; - $accessLevelXml = $this->accessLevel->saveXML(); - $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); - $newAccessLevel->transferFromXML($accessLevelXml); - $newAccessLevelXml = $newAccessLevel->saveXML(); - $this->assertTrue($accessLevelXml == $newAccessLevelXml); - $this->assertEquals('freebusy', $newAccessLevel->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->accessLevel->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->accessLevel->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->accessLevel->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->accessLevel->extensionAttributes['foo2']['value']); - $accessLevelXml = $this->accessLevel->saveXML(); - $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); - $newAccessLevel->transferFromXML($accessLevelXml); - $this->assertEquals('bar', $newAccessLevel->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newAccessLevel->extensionAttributes['foo2']['value']); - } - - public function testConvertFullAccessLevelToAndFromString() { - $this->accessLevel->transferFromXML($this->accessLevelText); - $this->assertEquals($this->accessLevel->value, 'owner'); - } - -} diff --git a/tests/Zend/Gdata/Calendar/ColorTest.php b/tests/Zend/Gdata/Calendar/ColorTest.php deleted file mode 100644 index 9dc552b79e21fc889073e9c4bfc7490b33118270..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/ColorTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/Color.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_ColorTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->colorText = file_get_contents( - 'Zend/Gdata/Calendar/_files/ColorElementSample1.xml', - true); - $this->color = new Zend_Gdata_Calendar_Extension_Color(); - } - - public function testEmptyColorShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->color->extensionElements)); - $this->assertTrue(count($this->color->extensionElements) == 0); - } - - public function testEmptyColorShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->color->extensionAttributes)); - $this->assertTrue(count($this->color->extensionAttributes) == 0); - } - - public function testSampleColorShouldHaveNoExtensionElements() { - $this->color->transferFromXML($this->colorText); - $this->assertTrue(is_array($this->color->extensionElements)); - $this->assertTrue(count($this->color->extensionElements) == 0); - } - - public function testSampleColorShouldHaveNoExtensionAttributes() { - $this->color->transferFromXML($this->colorText); - $this->assertTrue(is_array($this->color->extensionAttributes)); - $this->assertTrue(count($this->color->extensionAttributes) == 0); - } - - public function testNormalColorShouldHaveNoExtensionElements() { - $this->color->value = '#abcdef'; - $this->assertEquals($this->color->value, '#abcdef'); - $this->assertEquals(count($this->color->extensionElements), 0); - $newColor = new Zend_Gdata_Calendar_Extension_Color(); - $newColor->transferFromXML($this->color->saveXML()); - $this->assertEquals(count($newColor->extensionElements), 0); - $newColor->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newColor->extensionElements), 1); - $this->assertEquals($newColor->value, '#abcdef'); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newColor2 = $cal->newColor(); - $newColor2->transferFromXML($newColor->saveXML()); - $this->assertEquals(count($newColor2->extensionElements), 1); - $this->assertEquals($newColor2->value, '#abcdef'); - } - - public function testEmptyColorToAndFromStringShouldMatch() { - $colorXml = $this->color->saveXML(); - $newColor = new Zend_Gdata_Calendar_Extension_Color(); - $newColor->transferFromXML($colorXml); - $newColorXml = $newColor->saveXML(); - $this->assertTrue($colorXml == $newColorXml); - } - - public function testColorWithValueToAndFromStringShouldMatch() { - $this->color->value = '#abcdef'; - $colorXml = $this->color->saveXML(); - $newColor = new Zend_Gdata_Calendar_Extension_Color(); - $newColor->transferFromXML($colorXml); - $newColorXml = $newColor->saveXML(); - $this->assertTrue($colorXml == $newColorXml); - $this->assertEquals('#abcdef', $newColor->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->color->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->color->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->color->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->color->extensionAttributes['foo2']['value']); - $colorXml = $this->color->saveXML(); - $newColor = new Zend_Gdata_Calendar_Extension_Color(); - $newColor->transferFromXML($colorXml); - $this->assertEquals('bar', $newColor->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newColor->extensionAttributes['foo2']['value']); - } - - public function testConvertFullColorToAndFromString() { - $this->color->transferFromXML($this->colorText); - $this->assertEquals($this->color->value, '#5A6986'); - } - -} diff --git a/tests/Zend/Gdata/Calendar/EventEntryTest.php b/tests/Zend/Gdata/Calendar/EventEntryTest.php deleted file mode 100644 index ba68b7d377fa7f721d048c803a178f1f4bdddf56..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/EventEntryTest.php +++ /dev/null @@ -1,132 +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. - * - * @feed Zend - * @package Zend_Gdata_App - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/EventEntry.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_Calendar_EventEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/Calendar/_files/EventEntrySample1.xml', - true); - $this->entry = new Zend_Gdata_Calendar_EventEntry(); - } - - public function testSetters() { - $entry = new Zend_Gdata_Calendar_EventEntry(); - $who = new Zend_Gdata_Extension_Who(); - $who->setValueString("John Doe"); - $who->setEmail("john@doe.com"); - $entry->setWho($who); - $whoRetrieved = $entry->getWho(); - $this->assertEquals("john@doe.com", $whoRetrieved->getEmail()); - $this->assertEquals("John Doe", $whoRetrieved->getValueString()); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyEventEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newEventEntry = new Zend_Gdata_Calendar_EventEntry(); - $newEventEntry->transferFromXML($entryXml); - $newEventEntryXml = $newEventEntry->saveXML(); - $this->assertTrue($entryXml == $newEventEntryXml); - } - - public function testConvertEventEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newEventEntry = new Zend_Gdata_Calendar_EventEntry(); - $newEventEntry->transferFromXML($entryXml); - $newEventEntryXml = $newEventEntry->saveXML(); - $this->assertEquals($entryXml, $newEventEntryXml); - $this->assertEquals('http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z', - $newEventEntry->id->text); - $this->assertEquals('Mantek', - $newEventEntry->extendedProperty[0]->value); - $this->assertEquals('s0dtsvq4pe15ku09jideg67fv4', - $newEventEntry->originalEvent->id); - $this->assertEquals('s0dtsvq4pe15ku09jideg67fv4', - $newEventEntry->originalEvent->id); - $this->assertEquals('http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments', - $newEventEntry->comments->feedLink->href); - } - -/* - public function testEventEntryWithTextAndTypeToAndFromStringShouldMatch() { - $this->feed->text = '<img src="http://www.example.com/image.jpg"/>'; - $this->feed->type = 'xhtml'; - $feedXml = $this->feed->saveXML(); - $newEventEntry = new Zend_Gdata_App_EventEntry(); - $newEventEntry->transferFromXML($feedXml); - $newEventEntryXml = $newEventEntry->saveXML(); - $this->assertEquals($newEventEntryXml, $feedXml); - $this->assertEquals('<img src="http://www.example.com/image.jpg"/>', $newEventEntry->text); - $this->assertEquals('xhtml', $newEventEntry->type); - } - - public function testEventEntryWithSrcAndTypeToAndFromStringShouldMatch() { - $this->feed->src = 'http://www.example.com/image.png'; - $this->feed->type = 'image/png'; - $feedXml = $this->feed->saveXML(); - $newEventEntry = new Zend_Gdata_App_EventEntry(); - $newEventEntry->transferFromXML($feedXml); - $newEventEntryXml = $newEventEntry->saveXML(); - $this->assertEquals($newEventEntryXml, $feedXml); - $this->assertEquals('http://www.example.com/image.png', $newEventEntry->src); - $this->assertEquals('image/png', $newEventEntry->type); - } - - public function testConvertEventEntryWithSrcAndTypeToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $this->assertEquals('http://www.example.com/image.png', $this->feed->src); - $this->assertEquals('image/png', $this->feed->type); - } -*/ - -} diff --git a/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php b/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php deleted file mode 100644 index ec7749df147d0fa97bc7b2dd1b96939c2fa1a01c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php +++ /dev/null @@ -1,63 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventQuery.php'; -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Calendar_EventQueryExceptionTest extends PHPUnit_Framework_TestCase -{ - - const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com'; - - public function setUp() - { - $this->query = new Zend_Gdata_Calendar_EventQuery(); - } - - /** - * @expectedException Zend_Gdata_App_Exception - */ - public function testSingleEventsThrowsExceptionOnSetInvalidValue() - { - $this->query->resetParameters(); - $singleEvents = 'puppy'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setSingleEvents($singleEvents); - } - - /** - * @expectedException Zend_Gdata_App_Exception - */ - public function testFutureEventsThrowsExceptionOnSetInvalidValue() - { - $this->query->resetParameters(); - $futureEvents = 'puppy'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setFutureEvents($futureEvents); - } - -} diff --git a/tests/Zend/Gdata/Calendar/EventQueryTest.php b/tests/Zend/Gdata/Calendar/EventQueryTest.php deleted file mode 100644 index f8c97b0d9ca40d6f13fd5174d0d36bb9a6287212..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/EventQueryTest.php +++ /dev/null @@ -1,254 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventQuery.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Calendar_EventQueryTest extends PHPUnit_Framework_TestCase -{ - - const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com'; - const ZEND_CONFERENCE_EVENT = 'bn2h4o4mc3a03ci4t48j3m56pg'; - const ZEND_CONFERENCE_EVENT_COMMENT = 'i9q87onko1uphfs7i21elnnb4g'; - const SAMPLE_RFC3339 = "2007-06-05T18:38:00"; - public function setUp() - { - $this->query = new Zend_Gdata_Calendar_EventQuery(); - } - - public function testDefaultBaseUrlForQuery() - { - $queryUrl = $this->query->getQueryUrl(); - $this->assertEquals('http://www.google.com/calendar/feeds/default/public/full', - $queryUrl); - } - - public function testAlternateBaseUrlForQuery() - { - $this->query = new Zend_Gdata_Calendar_EventQuery('http://www.foo.com'); - $queryUrl = $this->query->getQueryUrl(); - // the URL passed in the constructor has the user, visibility - // projection appended for the return value of $query->getQueryUrl() - $this->assertEquals('http://www.foo.com/default/public/full', $queryUrl); - } - - public function testUpdatedMinMaxParam() - { - $updatedMin = '2006-09-20'; - $updatedMax = '2006-11-05'; - $this->query->resetParameters(); - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setUpdatedMin($updatedMin); - $this->query->setUpdatedMax($updatedMax); - $this->assertTrue($this->query->updatedMin != null); - $this->assertTrue($this->query->updatedMax != null); - $this->assertTrue($this->query->user != null); - $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($updatedMin), $this->query->getUpdatedMin()); - $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($updatedMax), $this->query->getUpdatedMax()); - $this->assertEquals(self::GOOGLE_DEVELOPER_CALENDAR, $this->query->getUser()); - - $this->query->updatedMin = null; - $this->assertFalse($this->query->updatedMin != null); - $this->query->updatedMax = null; - $this->assertFalse($this->query->updatedMax != null); - $this->query->user = null; - $this->assertFalse($this->query->user != null); - } - - public function testStartMinMaxParam() - { - $this->query->resetParameters(); - $startMin = '2006-10-30'; - $startMax = '2006-11-01'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setStartMin($startMin); - $this->query->setStartMax($startMax); - $this->assertTrue($this->query->startMin != null); - $this->assertTrue($this->query->startMax != null); - $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($startMin), $this->query->getStartMin()); - $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($startMax), $this->query->getStartMax()); - - $this->query->startMin = null; - $this->assertFalse($this->query->startMin != null); - $this->query->startMax = null; - $this->assertFalse($this->query->startMax != null); - $this->query->user = null; - $this->assertFalse($this->query->user != null); - } - - public function testVisibilityParam() - { - $this->query->resetParameters(); - $visibility = 'private'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setVisibility($visibility); - $this->assertTrue($this->query->visibility != null); - $this->assertEquals($visibility, $this->query->getVisibility()); - $this->query->visibility = null; - $this->assertFalse($this->query->visibility != null); - } - - public function testProjectionParam() - { - $this->query->resetParameters(); - $projection = 'composite'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setProjection($projection); - $this->assertTrue($this->query->projection != null); - $this->assertEquals($projection, $this->query->getProjection()); - $this->query->projection = null; - $this->assertFalse($this->query->projection != null); - } - - public function testOrderbyParam() - { - $this->query->resetParameters(); - $orderby = 'starttime'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setOrderby($orderby); - $this->assertTrue($this->query->orderby != null); - $this->assertEquals($orderby, $this->query->getOrderby()); - $this->query->orderby = null; - $this->assertFalse($this->query->orderby != null); - } - - public function testEventParam() - { - $this->query->resetParameters(); - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setEvent(self::ZEND_CONFERENCE_EVENT); - $this->assertTrue($this->query->event != null); - $this->assertEquals(self::ZEND_CONFERENCE_EVENT, $this->query->getEvent()); - $this->query->event = null; - $this->assertFalse($this->query->event != null); - } - - public function testCommentsParam() - { - $this->query->resetParameters(); - $comment = 'we need to reschedule'; - $this->query->setComments($comment); - $this->assertTrue($this->query->comments != null); - $this->assertEquals($comment, $this->query->getComments()); - $this->query->comments = null; - $this->assertFalse(isset($this->query->comments)); - } - - public function testSortOrder() - { - $this->query->resetParameters(); - $sortOrder = 'ascending'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setSortOrder($sortOrder); - $this->assertTrue($this->query->sortOrder != null); - $this->assertEquals($sortOrder, $this->query->getSortOrder()); - $this->query->sortOrder = null; - $this->assertFalse($this->query->sortOrder != null); - } - - public function testRecurrenceExpansionStart() - { - $this->query->resetParameters(); - $res = self::SAMPLE_RFC3339; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setRecurrenceExpansionStart($res); - $this->assertTrue($this->query->recurrenceExpansionStart != null); - $this->assertEquals($res, $this->query->getRecurrenceExpansionStart()); - $this->query->recurrenceExpansionStart = null; - $this->assertFalse($this->query->recurrenceExpansionStart != null); - } - - public function testRecurrenceExpansionEnd() - { - $this->query->resetParameters(); - $ree = self::SAMPLE_RFC3339; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setRecurrenceExpansionEnd($ree); - $this->assertTrue($this->query->recurrenceExpansionEnd != null); - $this->assertEquals($ree, $this->query->getRecurrenceExpansionEnd()); - $this->query->recurrenceExpansionEnd = null; - $this->assertFalse($this->query->recurrenceExpansionEnd != null); - } - - public function testSingleEvents() - { - $this->query->resetParameters(); - // Test string handling - $singleEvents = 'true'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setSingleEvents($singleEvents); - $this->assertTrue($this->query->singleEvents === true); - // Test bool handling - $singleEvents = false; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setSingleEvents($singleEvents); - $this->assertTrue($this->query->singleEvents === false); - // Test unsetting - $this->assertEquals($singleEvents, $this->query->getSingleEvents()); - $this->query->setSingleEvents(null); - $this->assertFalse($this->query->singleEvents != null); - } - - public function testFutureEvents() - { - $this->query->resetParameters(); - // Test string handling - $singleEvents = 'true'; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setFutureEvents($singleEvents); - $this->assertTrue($this->query->futureEvents === true); - // Test bool handling - $singleEvents = false; - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setFutureEvents($singleEvents); - $this->assertTrue($this->query->futureEvents === false); - // Test unsetting - $this->query->futureEvents = null; - $this->assertFalse($this->query->futureEvents != null); - - } - - public function testCustomQueryURIGeneration() - { - $this->query->resetParameters(); - $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); - $this->query->setVisibility("private"); - $this->query->setProjection("composite"); - $this->query->setEvent(self::ZEND_CONFERENCE_EVENT); - $this->query->setComments(self::ZEND_CONFERENCE_EVENT_COMMENT); - $this->assertEquals("http://www.google.com/calendar/feeds/developer-calendar@google.com/private/composite/" . - self::ZEND_CONFERENCE_EVENT . "/comments/" . self::ZEND_CONFERENCE_EVENT_COMMENT, - $this->query->getQueryUrl()); - } - - public function testDefaultQueryURIGeneration() - { - $this->query->resetParameters(); - $this->assertEquals("http://www.google.com/calendar/feeds/default/public/full", - $this->query->getQueryUrl()); - - } -} diff --git a/tests/Zend/Gdata/Calendar/HiddenTest.php b/tests/Zend/Gdata/Calendar/HiddenTest.php deleted file mode 100644 index 9be8c50e9693142d190b5af19137c7a8d14a392b..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/HiddenTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/Hidden.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_HiddenTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->hiddenText = file_get_contents( - 'Zend/Gdata/Calendar/_files/HiddenElementSample1.xml', - true); - $this->hidden = new Zend_Gdata_Calendar_Extension_Hidden(); - } - - public function testEmptyHiddenShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->hidden->extensionElements)); - $this->assertTrue(count($this->hidden->extensionElements) == 0); - } - - public function testEmptyHiddenShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->hidden->extensionAttributes)); - $this->assertTrue(count($this->hidden->extensionAttributes) == 0); - } - - public function testSampleHiddenShouldHaveNoExtensionElements() { - $this->hidden->transferFromXML($this->hiddenText); - $this->assertTrue(is_array($this->hidden->extensionElements)); - $this->assertTrue(count($this->hidden->extensionElements) == 0); - } - - public function testSampleHiddenShouldHaveNoExtensionAttributes() { - $this->hidden->transferFromXML($this->hiddenText); - $this->assertTrue(is_array($this->hidden->extensionAttributes)); - $this->assertTrue(count($this->hidden->extensionAttributes) == 0); - } - - public function testNormalHiddenShouldHaveNoExtensionElements() { - $this->hidden->value = true; - $this->assertEquals($this->hidden->value, true); - $this->assertEquals(count($this->hidden->extensionElements), 0); - $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); - $newHidden->transferFromXML($this->hidden->saveXML()); - $this->assertEquals(count($newHidden->extensionElements), 0); - $newHidden->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newHidden->extensionElements), 1); - $this->assertEquals($newHidden->value, true); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newHidden2 = $cal->newHidden(); - $newHidden2->transferFromXML($newHidden->saveXML()); - $this->assertEquals(count($newHidden2->extensionElements), 1); - $this->assertEquals($newHidden2->value, true); - } - - public function testEmptyHiddenToAndFromStringShouldMatch() { - $hiddenXml = $this->hidden->saveXML(); - $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); - $newHidden->transferFromXML($hiddenXml); - $newHiddenXml = $newHidden->saveXML(); - $this->assertTrue($hiddenXml == $newHiddenXml); - } - - public function testHiddenWithValueToAndFromStringShouldMatch() { - $this->hidden->value = true; - $hiddenXml = $this->hidden->saveXML(); - $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); - $newHidden->transferFromXML($hiddenXml); - $newHiddenXml = $newHidden->saveXML(); - $this->assertTrue($hiddenXml == $newHiddenXml); - $this->assertEquals(true, $newHidden->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->hidden->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->hidden->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->hidden->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->hidden->extensionAttributes['foo2']['value']); - $hiddenXml = $this->hidden->saveXML(); - $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); - $newHidden->transferFromXML($hiddenXml); - $this->assertEquals('bar', $newHidden->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newHidden->extensionAttributes['foo2']['value']); - } - - public function testConvertFullHiddenToAndFromString() { - $this->hidden->transferFromXML($this->hiddenText); - $this->assertEquals($this->hidden->value, false); - } - -} diff --git a/tests/Zend/Gdata/Calendar/LinkTest.php b/tests/Zend/Gdata/Calendar/LinkTest.php deleted file mode 100644 index b8fcf8e9644f996bab981b0e61be447caf600c1c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/LinkTest.php +++ /dev/null @@ -1,161 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/Link.php'; -require_once 'Zend/Gdata/Calendar/Extension/WebContent.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_LinkTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->linkText = file_get_contents( - 'Zend/Gdata/Calendar/_files/LinkElementSample1.xml', - true); - $this->link = new Zend_Gdata_Calendar_Extension_Link(); - } - - public function testEmptyLinkShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->link->extensionElements)); - $this->assertTrue(count($this->link->extensionElements) == 0); - } - - public function testEmptyLinkShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->link->extensionAttributes)); - $this->assertTrue(count($this->link->extensionAttributes) == 0); - } - - public function testSampleLinkShouldHaveNoExtensionElements() { - $this->link->transferFromXML($this->linkText); - $this->assertTrue(is_array($this->link->extensionElements)); - $this->assertTrue(count($this->link->extensionElements) == 0); - } - - public function testSampleLinkShouldHaveNoExtensionAttributes() { - $this->link->transferFromXML($this->linkText); - $this->assertTrue(is_array($this->link->extensionAttributes)); - $this->assertTrue(count($this->link->extensionAttributes) == 0); - } - - public function testNormalLinkShouldHaveNoExtensionElements() { - $this->link->rel = "http://nowhere.invalid/"; - $this->link->title = "Somewhere"; - $this->link->href = "http://somewhere.invalid/"; - $this->link->type = "text/plain"; - $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2"); - - $this->assertEquals($this->link->rel, "http://nowhere.invalid/"); - $this->assertEquals($this->link->title, "Somewhere"); - $this->assertEquals($this->link->href, "http://somewhere.invalid/"); - $this->assertEquals($this->link->type, "text/plain"); - $this->assertEquals($this->link->webcontent->url, "a"); - $this->assertEquals($this->link->webcontent->height, "1"); - $this->assertEquals($this->link->webcontent->width, "2"); - - $this->assertEquals(count($this->link->extensionElements), 0); - $newLink = new Zend_Gdata_Calendar_Extension_Link(); - $newLink->transferFromXML($this->link->saveXML()); - $this->assertEquals(count($newLink->extensionElements), 0); - $newLink->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newLink->extensionElements), 1); - $this->assertEquals($newLink->rel, "http://nowhere.invalid/"); - $this->assertEquals($newLink->title, "Somewhere"); - $this->assertEquals($newLink->href, "http://somewhere.invalid/"); - $this->assertEquals($newLink->type, "text/plain"); - $this->assertEquals($newLink->webcontent->url, "a"); - $this->assertEquals($newLink->webcontent->height, "1"); - $this->assertEquals($newLink->webcontent->width, "2"); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newLink2 = $cal->newLink(); - $newLink2->transferFromXML($newLink->saveXML()); - $this->assertEquals(count($newLink2->extensionElements), 1); - $this->assertEquals($newLink2->rel, "http://nowhere.invalid/"); - $this->assertEquals($newLink2->title, "Somewhere"); - $this->assertEquals($newLink2->href, "http://somewhere.invalid/"); - $this->assertEquals($newLink2->type, "text/plain"); - $this->assertEquals($newLink2->webcontent->url, "a"); - $this->assertEquals($newLink2->webcontent->height, "1"); - $this->assertEquals($newLink2->webcontent->width, "2"); - } - - public function testEmptyLinkToAndFromStringShouldMatch() { - $linkXml = $this->link->saveXML(); - $newLink = new Zend_Gdata_Calendar_Extension_Link(); - $newLink->transferFromXML($linkXml); - $newLinkXml = $newLink->saveXML(); - $this->assertTrue($linkXml == $newLinkXml); - } - - public function testLinkWithValueToAndFromStringShouldMatch() { - $this->link->rel = "http://nowhere.invalid/"; - $this->link->title = "Somewhere"; - $this->link->href = "http://somewhere.invalid/"; - $this->link->type = "text/plain"; - $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2"); - $linkXml = $this->link->saveXML(); - $newLink = new Zend_Gdata_Calendar_Extension_Link(); - $newLink->transferFromXML($linkXml); - $newLinkXml = $newLink->saveXML(); - $this->assertTrue($linkXml == $newLinkXml); - $this->assertEquals($this->link->rel, "http://nowhere.invalid/"); - $this->assertEquals($this->link->title, "Somewhere"); - $this->assertEquals($this->link->href, "http://somewhere.invalid/"); - $this->assertEquals($this->link->type, "text/plain"); - $this->assertEquals($this->link->webcontent->url, "a"); - $this->assertEquals($this->link->webcontent->height, "1"); - $this->assertEquals($this->link->webcontent->width, "2"); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->link->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->link->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->link->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->link->extensionAttributes['foo2']['value']); - $linkXml = $this->link->saveXML(); - $newLink = new Zend_Gdata_Calendar_Extension_Link(); - $newLink->transferFromXML($linkXml); - $this->assertEquals('bar', $newLink->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newLink->extensionAttributes['foo2']['value']); - } - - public function testConvertFullLinkToAndFromString() { - $this->link->transferFromXML($this->linkText); - $this->assertEquals($this->link->rel, "http://schemas.google.com/gCal/2005/webContent"); - $this->assertEquals($this->link->title, "Independence Day"); - $this->assertEquals($this->link->href, "http://www.google.com/calendar/images/google-holiday.gif"); - $this->assertEquals($this->link->type, "image/gif"); - $this->assertEquals($this->link->webcontent->url, "http://www.google.com/logos/july4th06.gif"); - $this->assertEquals($this->link->webcontent->height, "120"); - $this->assertEquals($this->link->webcontent->width, "276"); - } - -} diff --git a/tests/Zend/Gdata/Calendar/QuickAddTest.php b/tests/Zend/Gdata/Calendar/QuickAddTest.php deleted file mode 100644 index 177b52bd972ee239164447691a27101b60294001..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/QuickAddTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/QuickAdd.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_QuickAddTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->quickAddText = file_get_contents( - 'Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml', - true); - $this->quickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); - } - - public function testEmptyQuickAddShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->quickAdd->extensionElements)); - $this->assertTrue(count($this->quickAdd->extensionElements) == 0); - } - - public function testEmptyQuickAddShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->quickAdd->extensionAttributes)); - $this->assertTrue(count($this->quickAdd->extensionAttributes) == 0); - } - - public function testSampleQuickAddShouldHaveNoExtensionElements() { - $this->quickAdd->transferFromXML($this->quickAddText); - $this->assertTrue(is_array($this->quickAdd->extensionElements)); - $this->assertTrue(count($this->quickAdd->extensionElements) == 0); - } - - public function testSampleQuickAddShouldHaveNoExtensionAttributes() { - $this->quickAdd->transferFromXML($this->quickAddText); - $this->assertTrue(is_array($this->quickAdd->extensionAttributes)); - $this->assertTrue(count($this->quickAdd->extensionAttributes) == 0); - } - - public function testNormalQuickAddShouldHaveNoExtensionElements() { - $this->quickAdd->value = false; - $this->assertEquals($this->quickAdd->value, false); - $this->assertEquals(count($this->quickAdd->extensionElements), 0); - $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); - $newQuickAdd->transferFromXML($this->quickAdd->saveXML()); - $this->assertEquals(count($newQuickAdd->extensionElements), 0); - $newQuickAdd->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newQuickAdd->extensionElements), 1); - $this->assertEquals($newQuickAdd->value, false); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newQuickAdd2 = $cal->newQuickAdd(); - $newQuickAdd2->transferFromXML($newQuickAdd->saveXML()); - $this->assertEquals(count($newQuickAdd2->extensionElements), 1); - $this->assertEquals($newQuickAdd2->value, false); - } - - public function testEmptyQuickAddToAndFromStringShouldMatch() { - $quickAddXml = $this->quickAdd->saveXML(); - $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); - $newQuickAdd->transferFromXML($quickAddXml); - $newQuickAddXml = $newQuickAdd->saveXML(); - $this->assertTrue($quickAddXml == $newQuickAddXml); - } - - public function testQuickAddWithValueToAndFromStringShouldMatch() { - $this->quickAdd->value = false; - $quickAddXml = $this->quickAdd->saveXML(); - $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); - $newQuickAdd->transferFromXML($quickAddXml); - $newQuickAddXml = $newQuickAdd->saveXML(); - $this->assertTrue($quickAddXml == $newQuickAddXml); - $this->assertEquals(false, $newQuickAdd->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->quickAdd->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->quickAdd->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->quickAdd->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->quickAdd->extensionAttributes['foo2']['value']); - $quickAddXml = $this->quickAdd->saveXML(); - $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); - $newQuickAdd->transferFromXML($quickAddXml); - $this->assertEquals('bar', $newQuickAdd->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newQuickAdd->extensionAttributes['foo2']['value']); - } - - public function testConvertFullQuickAddToAndFromString() { - $this->quickAdd->transferFromXML($this->quickAddText); - $this->assertEquals($this->quickAdd->value, true); - } - -} diff --git a/tests/Zend/Gdata/Calendar/SelectedTest.php b/tests/Zend/Gdata/Calendar/SelectedTest.php deleted file mode 100644 index 3c15c9ba73840b13b7f1ef382d701bc4a62e6773..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/SelectedTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/Selected.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_SelectedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->selectedText = file_get_contents( - 'Zend/Gdata/Calendar/_files/SelectedElementSample1.xml', - true); - $this->selected = new Zend_Gdata_Calendar_Extension_Selected(); - } - - public function testEmptySelectedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->selected->extensionElements)); - $this->assertTrue(count($this->selected->extensionElements) == 0); - } - - public function testEmptySelectedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->selected->extensionAttributes)); - $this->assertTrue(count($this->selected->extensionAttributes) == 0); - } - - public function testSampleSelectedShouldHaveNoExtensionElements() { - $this->selected->transferFromXML($this->selectedText); - $this->assertTrue(is_array($this->selected->extensionElements)); - $this->assertTrue(count($this->selected->extensionElements) == 0); - } - - public function testSampleSelectedShouldHaveNoExtensionAttributes() { - $this->selected->transferFromXML($this->selectedText); - $this->assertTrue(is_array($this->selected->extensionAttributes)); - $this->assertTrue(count($this->selected->extensionAttributes) == 0); - } - - public function testNormalSelectedShouldHaveNoExtensionElements() { - $this->selected->value = true; - $this->assertEquals($this->selected->value, true); - $this->assertEquals(count($this->selected->extensionElements), 0); - $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); - $newSelected->transferFromXML($this->selected->saveXML()); - $this->assertEquals(count($newSelected->extensionElements), 0); - $newSelected->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newSelected->extensionElements), 1); - $this->assertEquals($newSelected->value, true); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newSelected2 = $cal->newSelected(); - $newSelected2->transferFromXML($newSelected->saveXML()); - $this->assertEquals(count($newSelected2->extensionElements), 1); - $this->assertEquals($newSelected2->value, true); - } - - public function testEmptySelectedToAndFromStringShouldMatch() { - $selectedXml = $this->selected->saveXML(); - $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); - $newSelected->transferFromXML($selectedXml); - $newSelectedXml = $newSelected->saveXML(); - $this->assertTrue($selectedXml == $newSelectedXml); - } - - public function testSelectedWithValueToAndFromStringShouldMatch() { - $this->selected->value = true; - $selectedXml = $this->selected->saveXML(); - $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); - $newSelected->transferFromXML($selectedXml); - $newSelectedXml = $newSelected->saveXML(); - $this->assertTrue($selectedXml == $newSelectedXml); - $this->assertEquals(true, $newSelected->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->selected->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->selected->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->selected->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->selected->extensionAttributes['foo2']['value']); - $selectedXml = $this->selected->saveXML(); - $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); - $newSelected->transferFromXML($selectedXml); - $this->assertEquals('bar', $newSelected->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newSelected->extensionAttributes['foo2']['value']); - } - - public function testConvertFullSelectedToAndFromString() { - $this->selected->transferFromXML($this->selectedText); - $this->assertEquals($this->selected->value, false); - } - -} diff --git a/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php b/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php deleted file mode 100644 index 6e3fe2ef7bf5fdddbbe25b4eca1caf7a1f0b7050..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/SendEventNotifications.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_SendEventNotificationsTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->sendEventNotificationsText = file_get_contents( - 'Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml', - true); - $this->sendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); - } - - public function testEmptySendEventNotificationsShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->sendEventNotifications->extensionElements)); - $this->assertTrue(count($this->sendEventNotifications->extensionElements) == 0); - } - - public function testEmptySendEventNotificationsShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->sendEventNotifications->extensionAttributes)); - $this->assertTrue(count($this->sendEventNotifications->extensionAttributes) == 0); - } - - public function testSampleSendEventNotificationsShouldHaveNoExtensionElements() { - $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); - $this->assertTrue(is_array($this->sendEventNotifications->extensionElements)); - $this->assertTrue(count($this->sendEventNotifications->extensionElements) == 0); - } - - public function testSampleSendEventNotificationsShouldHaveNoExtensionAttributes() { - $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); - $this->assertTrue(is_array($this->sendEventNotifications->extensionAttributes)); - $this->assertTrue(count($this->sendEventNotifications->extensionAttributes) == 0); - } - - public function testNormalSendEventNotificationsShouldHaveNoExtensionElements() { - $this->sendEventNotifications->value = true; - $this->assertEquals($this->sendEventNotifications->value, true); - $this->assertEquals(count($this->sendEventNotifications->extensionElements), 0); - $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); - $newSendEventNotifications->transferFromXML($this->sendEventNotifications->saveXML()); - $this->assertEquals(count($newSendEventNotifications->extensionElements), 0); - $newSendEventNotifications->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newSendEventNotifications->extensionElements), 1); - $this->assertEquals($newSendEventNotifications->value, true); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newSendEventNotifications2 = $cal->newSendEventNotifications(); - $newSendEventNotifications2->transferFromXML($newSendEventNotifications->saveXML()); - $this->assertEquals(count($newSendEventNotifications2->extensionElements), 1); - $this->assertEquals($newSendEventNotifications2->value, true); - } - - public function testEmptySendEventNotificationsToAndFromStringShouldMatch() { - $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); - $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); - $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); - $newSendEventNotificationsXml = $newSendEventNotifications->saveXML(); - $this->assertTrue($sendEventNotificationsXml == $newSendEventNotificationsXml); - } - - public function testSendEventNotificationsWithValueToAndFromStringShouldMatch() { - $this->sendEventNotifications->value = true; - $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); - $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); - $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); - $newSendEventNotificationsXml = $newSendEventNotifications->saveXML(); - $this->assertTrue($sendEventNotificationsXml == $newSendEventNotificationsXml); - $this->assertEquals(true, $newSendEventNotifications->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->sendEventNotifications->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->sendEventNotifications->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->sendEventNotifications->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->sendEventNotifications->extensionAttributes['foo2']['value']); - $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); - $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); - $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); - $this->assertEquals('bar', $newSendEventNotifications->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newSendEventNotifications->extensionAttributes['foo2']['value']); - } - - public function testConvertFullSendEventNotificationsToAndFromString() { - $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); - $this->assertEquals($this->sendEventNotifications->value, false); - } - -} diff --git a/tests/Zend/Gdata/Calendar/TimezoneTest.php b/tests/Zend/Gdata/Calendar/TimezoneTest.php deleted file mode 100644 index 5e54113e54454e5032b8a3e95a00cdab9ea65ece..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/TimezoneTest.php +++ /dev/null @@ -1,120 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/Timezone.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_TimezoneTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->timezoneText = file_get_contents( - 'Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml', - true); - $this->timezone = new Zend_Gdata_Calendar_Extension_Timezone(); - } - - public function testEmptyTimezoneShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->timezone->extensionElements)); - $this->assertTrue(count($this->timezone->extensionElements) == 0); - } - - public function testEmptyTimezoneShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->timezone->extensionAttributes)); - $this->assertTrue(count($this->timezone->extensionAttributes) == 0); - } - - public function testSampleTimezoneShouldHaveNoExtensionElements() { - $this->timezone->transferFromXML($this->timezoneText); - $this->assertTrue(is_array($this->timezone->extensionElements)); - $this->assertTrue(count($this->timezone->extensionElements) == 0); - } - - public function testSampleTimezoneShouldHaveNoExtensionAttributes() { - $this->timezone->transferFromXML($this->timezoneText); - $this->assertTrue(is_array($this->timezone->extensionAttributes)); - $this->assertTrue(count($this->timezone->extensionAttributes) == 0); - } - - public function testNormalTimezoneShouldHaveNoExtensionElements() { - $this->timezone->value = "America/Chicago"; - $this->assertEquals($this->timezone->value, "America/Chicago"); - $this->assertEquals(count($this->timezone->extensionElements), 0); - $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); - $newTimezone->transferFromXML($this->timezone->saveXML()); - $this->assertEquals(count($newTimezone->extensionElements), 0); - $newTimezone->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newTimezone->extensionElements), 1); - $this->assertEquals($newTimezone->value, "America/Chicago"); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newTimezone2 = $cal->newTimezone(); - $newTimezone2->transferFromXML($newTimezone->saveXML()); - $this->assertEquals(count($newTimezone2->extensionElements), 1); - $this->assertEquals($newTimezone2->value, "America/Chicago"); - } - - public function testEmptyTimezoneToAndFromStringShouldMatch() { - $timezoneXml = $this->timezone->saveXML(); - $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); - $newTimezone->transferFromXML($timezoneXml); - $newTimezoneXml = $newTimezone->saveXML(); - $this->assertTrue($timezoneXml == $newTimezoneXml); - } - - public function testTimezoneWithValueToAndFromStringShouldMatch() { - $this->timezone->value = "America/Chicago"; - $timezoneXml = $this->timezone->saveXML(); - $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); - $newTimezone->transferFromXML($timezoneXml); - $newTimezoneXml = $newTimezone->saveXML(); - $this->assertTrue($timezoneXml == $newTimezoneXml); - $this->assertEquals("America/Chicago", $newTimezone->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->timezone->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->timezone->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->timezone->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->timezone->extensionAttributes['foo2']['value']); - $timezoneXml = $this->timezone->saveXML(); - $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); - $newTimezone->transferFromXML($timezoneXml); - $this->assertEquals('bar', $newTimezone->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newTimezone->extensionAttributes['foo2']['value']); - } - - public function testConvertFullTimezoneToAndFromString() { - $this->timezone->transferFromXML($this->timezoneText); - $this->assertEquals($this->timezone->value, "America/Los_Angeles"); - } - -} diff --git a/tests/Zend/Gdata/Calendar/WebContentTest.php b/tests/Zend/Gdata/Calendar/WebContentTest.php deleted file mode 100644 index 5f33926e4efd13979d232eac7b6b471df2eb5927..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/WebContentTest.php +++ /dev/null @@ -1,136 +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_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar/Extension/WebContent.php'; -require_once 'Zend/Gdata/Calendar.php'; - -/** - * @package Zend_Gdata_Calendar - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Calendar_WebContentTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->webContentText = file_get_contents( - 'Zend/Gdata/Calendar/_files/WebContentElementSample1.xml', - true); - $this->webContent = new Zend_Gdata_Calendar_Extension_WebContent(); - } - - public function testEmptyWebContentShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->webContent->extensionElements)); - $this->assertTrue(count($this->webContent->extensionElements) == 0); - } - - public function testEmptyWebContentShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->webContent->extensionAttributes)); - $this->assertTrue(count($this->webContent->extensionAttributes) == 0); - } - - public function testSampleWebContentShouldHaveNoExtensionElements() { - $this->webContent->transferFromXML($this->webContentText); - $this->assertTrue(is_array($this->webContent->extensionElements)); - $this->assertTrue(count($this->webContent->extensionElements) == 0); - } - - public function testSampleWebContentShouldHaveNoExtensionAttributes() { - $this->webContent->transferFromXML($this->webContentText); - $this->assertTrue(is_array($this->webContent->extensionAttributes)); - $this->assertTrue(count($this->webContent->extensionAttributes) == 0); - } - - public function testNormalWebContentShouldHaveNoExtensionElements() { - $this->webContent->url = "http://nowhere.invalid/"; - $this->webContent->height = "100"; - $this->webContent->width = "200"; - - $this->assertEquals($this->webContent->url, "http://nowhere.invalid/"); - $this->assertEquals($this->webContent->height, "100"); - $this->assertEquals($this->webContent->width, "200"); - - $this->assertEquals(count($this->webContent->extensionElements), 0); - $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); - $newWebContent->transferFromXML($this->webContent->saveXML()); - $this->assertEquals(count($newWebContent->extensionElements), 0); - $newWebContent->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(count($newWebContent->extensionElements), 1); - $this->assertEquals($newWebContent->url, "http://nowhere.invalid/"); - $this->assertEquals($newWebContent->height, "100"); - $this->assertEquals($newWebContent->width, "200"); - - /* try constructing using magic factory */ - $cal = new Zend_Gdata_Calendar(); - $newWebContent2 = $cal->newWebContent(); - $newWebContent2->transferFromXML($newWebContent->saveXML()); - $this->assertEquals(count($newWebContent2->extensionElements), 1); - $this->assertEquals($newWebContent2->url, "http://nowhere.invalid/"); - $this->assertEquals($newWebContent2->height, "100"); - $this->assertEquals($newWebContent2->width, "200"); - } - - public function testEmptyWebContentToAndFromStringShouldMatch() { - $webContentXml = $this->webContent->saveXML(); - $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); - $newWebContent->transferFromXML($webContentXml); - $newWebContentXml = $newWebContent->saveXML(); - $this->assertTrue($webContentXml == $newWebContentXml); - } - - public function testWebContentWithValueToAndFromStringShouldMatch() { - $this->webContent->url = "http://nowhere.invalid/"; - $this->webContent->height = "100"; - $this->webContent->width = "200"; - $webContentXml = $this->webContent->saveXML(); - $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); - $newWebContent->transferFromXML($webContentXml); - $newWebContentXml = $newWebContent->saveXML(); - $this->assertTrue($webContentXml == $newWebContentXml); - $this->assertEquals($this->webContent->url, "http://nowhere.invalid/"); - $this->assertEquals($this->webContent->height, "100"); - $this->assertEquals($this->webContent->width, "200"); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->webContent->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->webContent->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->webContent->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->webContent->extensionAttributes['foo2']['value']); - $webContentXml = $this->webContent->saveXML(); - $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); - $newWebContent->transferFromXML($webContentXml); - $this->assertEquals('bar', $newWebContent->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newWebContent->extensionAttributes['foo2']['value']); - } - - public function testConvertFullWebContentToAndFromString() { - $this->webContent->transferFromXML($this->webContentText); - $this->assertEquals($this->webContent->url, "http://www.google.com/logos/july4th06.gif"); - $this->assertEquals($this->webContent->height, "120"); - $this->assertEquals($this->webContent->width, "276"); - } - -} diff --git a/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml deleted file mode 100644 index 47843bc6cd68d18feebdac099dabbad2103f8eb1..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<accesslevel xmlns="http://schemas.google.com/gCal/2005" value="owner"/> diff --git a/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml deleted file mode 100644 index 8e9f29b682c8d7dd55eb01d8a0f71f6ee23e6385..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<color xmlns="http://schemas.google.com/gCal/2005" value="#5A6986"/> diff --git a/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml b/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml deleted file mode 100644 index 8c4763b72547f2e27c3e6f3f631e6d9ed1d8c40b..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:gCal='http://schemas.google.com/gCal/2005'> - <id> - http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z</id> - <published>2007-05-09T16:32:03.000Z</published> - <updated>2007-05-09T16:34:33.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>www2007 recurring</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDlUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/63314411673'> - </link> - <author> - <name>gdata ops</name> - <email>gdata.ops.test@gmail.com</email> - </author> - <gd:originalEvent id='s0dtsvq4pe15ku09jideg67fv4' - href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4'> - <gd:when startTime='2007-05-09T14:30:00.000-05:00'></gd:when> - </gd:originalEvent> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments'> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gCal:timezone value='America/Los_Angeles'> - </gCal:timezone> - <gd:when startTime='2007-05-09T17:30:00.000-05:00' - endTime='2007-05-09T18:30:00.000-05:00'> - <gd:reminder minutes='10' method='alert'></gd:reminder> - <gd:reminder minutes='10' method='email'></gd:reminder> - </gd:when> - <gd:where valueString='Down by the river'></gd:where> - <gd:extendedProperty name='http://frank.schemas/2005#prop' value='Mantek' /> -</entry> diff --git a/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml b/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml deleted file mode 100644 index 32eb50c3bf42243311eefca78daf028fa16b2852..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml +++ /dev/null @@ -1,362 +0,0 @@ -<?xml version="1.0"?> -<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="http://schemas.google.com/gCal/2005"> - <id>http://www.google.com/calendar/feeds/default/private/composite</id> - <updated>2007-05-31T01:15:00.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">GData Ops Demo's Composite View</title> - <subtitle type="text">GData Is Awesome</subtitle> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite?max-results=25"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <generator version="1.0" uri="http://www.google.com/calendar">Google Calendar</generator> - <openSearch:totalResults>7</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>25</openSearch:itemsPerPage> - <gCal:timezone value="America/Chicago"/> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8</id> - <published>2007-09-14T15:37:53.000Z</published> - <updated>2007-09-14T15:37:53.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event' /> - <title type='text'>Specialized Event</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=NXY5bDNzcWRxdDBiN21nMW5obm1nZGZ1cDhfMjAwNzA5MTNUMTUwMDAwWiBnZGF0YS5vcHMuZGVtb0Bt' - title='alternate' /> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8' /> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:recurrence>DTSTART;TZID=America/Los_Angeles:20070913T080000 - DTEND;TZID=America/Los_Angeles:20070913T090000 - RRULE:FREQ=DAILY;UNTIL=20070920T150000Z;WKST=SU BEGIN:VTIMEZONE - TZID:America/Los_Angeles X-LIC-LOCATION:America/Los_Angeles - BEGIN:DAYLIGHT TZOFFSETFROM:-0800 TZOFFSETTO:-0700 TZNAME:PDT - DTSTART:19700308T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU - END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:-0700 TZOFFSETTO:-0800 - TZNAME:PST DTSTART:19701101T020000 - RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU END:STANDARD - END:VTIMEZONE</gd:recurrence> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed' /> - <gd:visibility value='http://schemas.google.com/g/2005#event.default' /> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque' /> - <gCal:uid value='5v9l3sqdqt0b7mg1nhnmgdfup8@google.com' /> - <gCal:sequence value='0' /> - <gd:reminder minutes='10' method='sms' /> - <gd:reminder minutes='10' method='alert' /> - <gCal:sendEventNotifications value="false"/> - <gd:recurrenceException specialized='false'> - <gd:entryLink> - <entry> - <id>5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z</id> - <published>2007-09-14T15:37:53.000Z</published> - <updated>2007-09-14T15:41:06.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event' /> - <title type='text'>Specialized Event</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=NXY5bDNzcWRxdDBiN21nMW5obm1nZGZ1cDhfMjAwNzA5MTRUMTUwMDAwWiBnZGF0YS5vcHMuZGVtb0Bt' - title='alternate' /> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:originalEvent id='5v9l3sqdqt0b7mg1nhnmgdfup8' - href='http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8'> - - <gd:when startTime='2007-09-14T08:00:00.000-07:00' /> - </gd:originalEvent> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments'> - - <feed> - <id> - http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments</id> - <updated>2007-09-14T15:42:41.390Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#message' /> - <title type='text'>Comments for: Specialized - Event</title> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments' - title='alternate' /> - </feed> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed' /> - <gd:visibility value='http://schemas.google.com/g/2005#event.default' /> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque' /> - <gCal:uid value='5v9l3sqdqt0b7mg1nhnmgdfup8@google.com' /> - <gCal:sequence value='0' /> - <gd:when startTime='2007-09-14T08:00:00.000-07:00' - endTime='2007-09-14T09:00:00.000-07:00'> - <gd:reminder minutes='10' method='alert' /> - </gd:when> - <gd:who rel='http://schemas.google.com/g/2005#event.attendee' - valueString='gdata ops' email='gdata.ops.test@gmail.com'> - <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.invited' /> - </gd:who> - <gd:who rel='http://schemas.google.com/g/2005#event.organizer' - valueString='GData Ops Demo' - email='gdata.ops.demo@gmail.com'> - <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.accepted' /> - </gd:who> - <gd:where valueString='' /> - </entry> - </gd:entryLink> - </gd:recurrenceException> - <gd:who rel='http://schemas.google.com/g/2005#event.organizer' - valueString='GData Ops Demo' email='gdata.ops.demo@gmail.com'> - <gd:attendeeStatus value='' /> - </gd:who> - <gd:where valueString='' /> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/private/composite/sh6kv08egsls7mc5tf6np8hi9c</id> - <published>2007-05-24T20:49:14.000Z</published> - <updated>2007-05-24T20:49:14.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <category scheme="http://schemas.google.com/g/2005" term="http://schemas.google.com/g/2005#event"/> - <title type="text">Tennis Game</title> - <content type="text">Meet for a quick lesson.</content> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=c2g2a3YwOGVnc2xzN21jNXRmNm5wOGhpOWNfMjAwNzA1MDEgZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/sh6kv08egsls7mc5tf6np8hi9c"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:recurrence>DTSTART;VALUE=DATE:20070501 DTEND;VALUE=DATE:20070502 RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904</gd:recurrence> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> - <gCal:sendEventNotifications value="false"/> - <gd:where valueString="South Tennis Courts"/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g</id> - <published>2007-05-09T16:44:38.000Z</published> - <updated>2007-05-17T10:33:49.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">all day event may 24</title> - <content type="text"/> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=bHEyYWk2aW1zYnEyMDlxM2FldHVyaG81MGcgZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:comments> - <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/lq2ai6imsbq209q3aeturho50g/comments"> - <feed> - <updated>2007-05-31T01:15:13.249Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <title type="text">Comments for: all day event may 24</title> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/lq2ai6imsbq209q3aeturho50g/comments" title="alternate"/> - <entry> - <id>dfr2c8pbtb8g6uphrsrlpao7mc</id> - <published>2007-05-23T20:38:08.000Z</published> - <updated>2007-05-23T20:38:08.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <content type="html"><p>This is my comments!</p></content> - <author> - <name>User 1</name> - <email>user1@nowhere.invalid</email> - </author> - </entry> - <entry> - <id>i9q87onko1uphfs7i21elnnb4g</id> - <published>2007-06-01T21:21:47.000Z</published> - <updated>2007-06-01T21:21:47.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <content type="html"><p>This is a user supplied comment.</p></content> - <author> - <name>User 2</name> - <email>user2@nowhere.invalid</email> - </author> - </entry> - </feed> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/> - <gCal:sendEventNotifications value="false"/> - <gd:when startTime="2007-05-24" endTime="2007-05-25"> - <gd:reminder minutes="10" method="alert"/> - <gd:reminder minutes="10" method="email"/> - </gd:when> - <gd:where valueString="Mountain View, California"/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/private/composite/4v2a4eddoqja2727ptkq78euq8</id> - <published>2007-05-09T16:43:58.000Z</published> - <updated>2007-05-17T10:33:49.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">all day event may 23</title> - <content type="text"/> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=NHYyYTRlZGRvcWphMjcyN3B0a3E3OGV1cTggZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/4v2a4eddoqja2727ptkq78euq8"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:comments> - <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/4v2a4eddoqja2727ptkq78euq8/comments"> - <feed> - <updated>2007-05-31T01:15:13.250Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <title type="text">Comments for: all day event may 23</title> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/4v2a4eddoqja2727ptkq78euq8/comments" title="alternate"/> - </feed> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/> - <gCal:sendEventNotifications value="false"/> - <gd:when startTime="2007-05-23" endTime="2007-05-24"> - <gd:reminder minutes="10" method="alert"/> - <gd:reminder minutes="10" method="email"/> - </gd:when> - <gd:where/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/private/composite/14gfovd20fqvtj1d1np7ei9tbg</id> - <published>2007-05-09T16:43:53.000Z</published> - <updated>2007-05-17T10:33:49.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">all day event may 22</title> - <content type="text"/> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=MTRnZm92ZDIwZnF2dGoxZDFucDdlaTl0YmcgZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/14gfovd20fqvtj1d1np7ei9tbg"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:comments> - <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/14gfovd20fqvtj1d1np7ei9tbg/comments"> - <feed> - <updated>2007-05-31T01:15:13.250Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <title type="text">Comments for: all day event may 22</title> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/14gfovd20fqvtj1d1np7ei9tbg/comments" title="alternate"/> - </feed> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/> - <gCal:sendEventNotifications value="false"/> - <gd:when startTime="2007-05-22" endTime="2007-05-23"> - <gd:reminder minutes="10" method="alert"/> - <gd:reminder minutes="10" method="email"/> - </gd:when> - <gd:where/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z</id> - <published>2007-05-09T16:32:03.000Z</published> - <updated>2007-05-09T16:34:33.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">www2007 recurring</title> - <content type="text"/> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDlUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt" title="alternate"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:originalEvent id="s0dtsvq4pe15ku09jideg67fv4" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4"> - <gd:when startTime="2007-05-09T14:30:00.000-05:00"/> - </gd:originalEvent> - <gd:comments> - <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments"> - <feed> - <updated>2007-05-31T01:15:13.251Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <title type="text">Comments for: www2007 recurring</title> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments" title="alternate"/> - </feed> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> - <gCal:sendEventNotifications value="false"/> - <gd:when startTime="2007-05-09T17:30:00.000-05:00" endTime="2007-05-09T18:30:00.000-05:00"> - <gd:reminder minutes="10" method="alert"/> - <gd:reminder minutes="10" method="email"/> - </gd:when> - <gd:where valueString=""/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4</id> - <published>2007-05-09T16:32:03.000Z</published> - <updated>2007-05-09T16:32:03.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">www2007 recurring</title> - <content type="text"/> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDhUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt" title="alternate"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:recurrence>DTSTART;TZID=America/Anchorage:20070508T113000 DTEND;TZID=America/Anchorage:20070508T123000 RRULE:FREQ=DAILY;UNTIL=20070513T193000Z;WKST=SU BEGIN:VTIMEZONE TZID:America/Anchorage X-LIC-LOCATION:America/Anchorage BEGIN:DAYLIGHT TZOFFSETFROM:-0900 TZOFFSETTO:-0800 TZNAME:AKDT DTSTART:19700308T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:-0800 TZOFFSETTO:-0900 TZNAME:AKST DTSTART:19701101T020000 RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU END:STANDARD END:VTIMEZONE</gd:recurrence> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> - <gCal:sendEventNotifications value="false"/> - <gd:reminder minutes="10" method="alert"/> - <gd:reminder minutes="10" method="email"/> - <gd:recurrenceException specialized="true"> - <gd:entryLink> - <entry> - <id>s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z</id> - <published>2007-05-09T16:32:03.000Z</published> - <updated>2007-05-09T16:34:33.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> - <title type="text">www2007 recurring</title> - <content type="text"/> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDlUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt" title="alternate"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:originalEvent id="s0dtsvq4pe15ku09jideg67fv4" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4"> - <gd:when startTime="2007-05-09T14:30:00.000-05:00"/> - </gd:originalEvent> - <gd:comments> - <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments"> - <feed> - <updated>2007-05-31T01:15:13.259Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <title type="text">Comments for: www2007 recurring</title> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments" title="alternate"/> - </feed> - </gd:feedLink> - </gd:comments> - <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> - <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> - <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> - <gCal:sendEventNotifications value="false"/> - <gd:when startTime="2007-05-09T17:30:00.000-05:00" endTime="2007-05-09T18:30:00.000-05:00"> - <gd:reminder minutes="10" method="alert"/> - <gd:reminder minutes="10" method="email"/> - </gd:when> - <gd:where valueString=""/> - </entry> - </gd:entryLink> - </gd:recurrenceException> - <gd:where valueString=""/> - </entry> -</feed> - diff --git a/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml deleted file mode 100644 index 21c03d72933232905c6cd88b500db372c559e9d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hidden xmlns="http://schemas.google.com/gCal/2005" value="false"/> diff --git a/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml deleted file mode 100644 index a39056fd54c1983b9850f13ff5e488513f7cfee1..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<atom:link xmlns:atom="http://www.w3.org/2005/Atom" - rel="http://schemas.google.com/gCal/2005/webContent" - title="Independence Day" - href="http://www.google.com/calendar/images/google-holiday.gif" - type="image/gif"> - <gCal:webContent xmlns:gCal="http://schemas.google.com/gCal/2005" - url="http://www.google.com/logos/july4th06.gif" - width="276" height="120" /> -</atom:link> \ No newline at end of file diff --git a/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml b/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml deleted file mode 100644 index 3919a7863c3d33c90570f5978e1cb7db1a496f6c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml +++ /dev/null @@ -1,192 +0,0 @@ -<?xml version="1.0"?> -<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="http://schemas.google.com/gCal/2005"> - <id>http://www.google.com/calendar/feeds/default</id> - <updated>2007-05-30T00:23:26.998Z</updated> - <title type="text">GData Ops Demo's Calendar List</title> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default"/> - <link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - <uri>http://test.address.invalid/</uri> - </author> - <generator version="1.0" uri="http://www.google.com/calendar">Google Calendar</generator> - <openSearch:startIndex>1</openSearch:startIndex> - <entry> - <id>http://www.google.com/calendar/feeds/default/gdata.ops.demo%40gmail.com</id> - <published>2007-05-30T00:23:27.006Z</published> - <updated>2007-05-30T00:20:38.000Z</updated> - <title type="text">GData Ops Demo</title> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/gdata.ops.demo%40gmail.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/gdata.ops.demo%41gmail.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/gdata.ops.demo%40gmail.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Chicago"/> - <gCal:hidden value="false"/> - <gCal:color value="#2952A3"/> - <gCal:selected value="true"/> - <gCal:accesslevel value="owner"/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.005Z</published> - <updated>2007-05-30T00:20:38.000Z</updated> - <title type="text">My Other Awesome Calendar</title> - <summary type="text">This is my other calendar.</summary> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Chicago"/> - <gCal:hidden value="false"/> - <gCal:color value="#A32929"/> - <gCal:selected value="true"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString="Palo Alto, California"/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.005Z</published> - <updated>2007-05-22T05:35:47.000Z</updated> - <title type="text">Sample Calendar A</title> - <summary type="text"/> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Los_Angeles"/> - <gCal:hidden value="false"/> - <gCal:color value="#5A6986"/> - <gCal:selected value="false"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString=""/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.005Z</published> - <updated>2007-05-21T07:31:41.000Z</updated> - <title type="text">Sample Calendar B</title> - <summary type="text"/> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Los_Angeles"/> - <gCal:hidden value="false"/> - <gCal:color value="#5A6986"/> - <gCal:selected value="false"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString=""/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.006Z</published> - <updated>2007-05-22T21:02:34.000Z</updated> - <title type="text">Sample Calendar C</title> - <summary type="text"/> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Los_Angeles"/> - <gCal:hidden value="false"/> - <gCal:color value="#B1440E"/> - <gCal:selected value="true"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString=""/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.006Z</published> - <updated>2007-05-17T10:12:36.000Z</updated> - <title type="text">Sample Calendar D</title> - <summary type="text"/> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Los_Angeles"/> - <gCal:hidden value="false"/> - <gCal:color value="#528800"/> - <gCal:selected value="false"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString=""/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.006Z</published> - <updated>2007-05-17T10:52:01.000Z</updated> - <title type="text">Sample Calender E</title> - <summary type="text"/> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Chicago"/> - <gCal:hidden value="false"/> - <gCal:color value="#5A6986"/> - <gCal:selected value="false"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString=""/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/usa__en%40holiday.calendar.google.com</id> - <published>2007-05-30T00:23:27.006Z</published> - <updated>2007-05-17T09:48:29.000Z</updated> - <title type="text">US Holidays</title> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/private/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/usa__en%40holiday.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Los_Angeles"/> - <gCal:hidden value="false"/> - <gCal:color value="#5A6986"/> - <gCal:selected value="false"/> - <gCal:accesslevel value="read"/> - </entry> - <entry> - <id>http://www.google.com/calendar/feeds/default/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com</id> - <published>2007-05-30T00:23:27.005Z</published> - <updated>2007-05-30T00:20:02.000Z</updated> - <title type="text">My Awesome Calendar</title> - <summary type="text">This is my awesome calendar</summary> - <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com/private/full"/> - <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com/acl/full"/> - <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com"/> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:timezone value="America/Los_Angeles"/> - <gCal:hidden value="false"/> - <gCal:color value="#5A6986"/> - <gCal:selected value="false"/> - <gCal:accesslevel value="owner"/> - <gd:where valueString="Mountain View, California"/> - </entry> -</feed> - diff --git a/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml deleted file mode 100644 index 2eaa4960fc33d3c73bdbc8e5ce3a84aeadd89407..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<quickadd xmlns="http://schemas.google.com/gCal/2005" value="true"/> diff --git a/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml deleted file mode 100644 index 8f8179cde34d0e4fcb1971159646f03c5ce7d3f6..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<selected xmlns="http://schemas.google.com/gCal/2005" value="false"/> diff --git a/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml deleted file mode 100644 index 3173035452858ec92f6c46c14b430854aa1e93f7..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<sendEventNotifications xmlns="http://schemas.google.com/gCal/2005" value="false"/> diff --git a/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml b/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml deleted file mode 100644 index 08bb95a3157c69d62289f264748105dd455e5c97..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml +++ /dev/null @@ -1,460 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:gCal='http://schemas.google.com/gCal/2005'> - <id> - http://www.google.com/calendar/feeds/default/private/full</id> - <updated>2007-03-20T21:29:57.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>GData Ops Demo</title> - <subtitle type='text'>Demo Feed</subtitle> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full'> - </link> - <link rel='http://schemas.google.com/g/2005#post' - type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full'> - </link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full?updated-min=2001-01-01&max-results=25'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - <uri>http://test.address.invalid/</uri> - </author> - <generator version='1.0' uri='http://www.google.com/calendar'> - Google Calendar</generator> - <openSearch:totalResults>10</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>25</openSearch:itemsPerPage> - <gCal:timezone value='America/Los_Angeles'></gCal:timezone> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100</id> - <published>2007-03-20T21:29:52.000Z</published> - <updated>2007-03-20T21:29:57.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>test deleted</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=bzk5ZmxtZ21rZmtmcnI4dTc0NWdocjMxMDAgZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100/63310109397'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.canceled'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-03-23T12:00:00.000-07:00' - endTime='2007-03-23T13:00:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0</id> - <published>2007-03-20T21:26:04.000Z</published> - <updated>2007-03-20T21:28:46.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Afternoon at Dolores Park with Kim</title> - <content type='text'>This will be fun.</content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=MnF0M2FvNWhiYXE3bTlpZ3I1YWs5ZXNqbzAgZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0/63310109326'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.private'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:who rel='http://schemas.google.com/g/2005#event.organizer' - valueString='GData Ops Demo' email='gdata.ops.demo@gmail.com'> - <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.accepted'> - </gd:attendeeStatus> - </gd:who> - <gd:who rel='http://schemas.google.com/g/2005#event.attendee' - valueString='Ryan Boyd (API)' email='api.rboyd@gmail.com'> - <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.invited'> - </gd:attendeeStatus> - </gd:who> - <gd:when startTime='2007-03-24T12:00:00.000-07:00' - endTime='2007-03-24T15:00:00.000-07:00'> - <gd:reminder minutes='20' method="alert"></gd:reminder> - </gd:when> - <gd:where valueString='Dolores Park with Kim'></gd:where> - <gCal:quickadd value="true" /> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos</id> - <published>2007-03-20T21:28:37.000Z</published> - <updated>2007-03-20T21:28:37.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Team meeting</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=dXZzcWhnN2tsbmFlNDB2NTB2aWhyMXB2b3NfMjAwNzAzMjNUMTYwMDAwWiBnZGF0YS5vcHMuZGVtb0Bt' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos/63310109317'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gd:recurrence>DTSTART;TZID=America/Los_Angeles:20070323T090000 - DTEND;TZID=America/Los_Angeles:20070323T100000 - RRULE:FREQ=WEEKLY;BYDAY=FR;UNTIL=20070817T160000Z;WKST=SU - BEGIN:VTIMEZONE TZID:America/Los_Angeles - X-LIC-LOCATION:America/Los_Angeles BEGIN:STANDARD - TZOFFSETFROM:-0700 TZOFFSETTO:-0800 TZNAME:PST - DTSTART:19701025T020000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU - END:STANDARD BEGIN:DAYLIGHT TZOFFSETFROM:-0800 TZOFFSETTO:-0700 - TZNAME:PDT DTSTART:19700405T020000 - RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU END:DAYLIGHT - END:VTIMEZONE</gd:recurrence> - <gCal:sendEventNotifications value='true'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:visibility value='http://schemas.google.com/g/2005#event.public'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:reminder minutes='10'></gd:reminder> - <gd:where valueString=''></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo</id> - <published>2007-03-20T21:25:46.000Z</published> - <updated>2007-03-20T21:25:46.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Movie with Kim and danah</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=c3Q0dms5a2lmZnM2cmFzcmwzMmU0YTdhbG8gZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo/63310109146'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-03-24T20:00:00.000-07:00' - endTime='2007-03-24T21:00:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo</id> - <published>2007-03-20T21:24:43.000Z</published> - <updated>2007-03-20T21:25:08.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Dinner with Kim and Sarah</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=b2ZsMWU0NXVidHNvaDZndHUxMjdjbHMyb28gZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo/63310109108'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-03-20T19:00:00.000-07:00' - endTime='2007-03-20T21:30:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g</id> - <published>2007-03-20T21:24:19.000Z</published> - <updated>2007-03-20T21:25:05.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Dinner with Jane and John</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=YjY5czJhdmZpMmpvaWdzY2xlY3ZqbGM5MWcgZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g/63310109105'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-03-22T17:00:00.000-07:00' - endTime='2007-03-22T19:30:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc</id> - <published>2007-03-20T21:24:33.000Z</published> - <updated>2007-03-20T21:24:33.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Tennis with Elizabeth</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=dTlwNjZra2lvdG44YnFoOWs3ajRyY25qamMgZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc/63310109073'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-03-24T10:00:00.000-07:00' - endTime='2007-03-24T11:00:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c</id> - <published>2007-03-20T21:24:00.000Z</published> - <updated>2007-03-20T21:24:00.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>Lunch with Jenn</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=NzZvajJrY2VpZG9iM3M3MDh0dmZudWFxM2MgZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c/63310109040'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-03-20T11:30:00.000-07:00' - endTime='2007-03-20T12:30:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco</id> - <published>2007-03-20T07:50:02.000Z</published> - <updated>2007-03-20T20:39:26.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>test entry</title> - <content type='text'>test desc</content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=NW5wOWVjOG03dW9hdWsxdmVkaDVtaG9kY28gZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco/63310106366'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.private'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:who rel='http://schemas.google.com/g/2005#event.attendee' - valueString='Vivian Li' email='vli@google.com'> - <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.declined'> - </gd:attendeeStatus> - </gd:who> - <gd:who rel='http://schemas.google.com/g/2005#event.organizer' - valueString='GData Ops Demo' email='gdata.ops.demo@gmail.com'> - <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.accepted'> - </gd:attendeeStatus> - </gd:who> - <gd:when startTime='2007-03-21T08:00:00.000-07:00' - endTime='2007-03-21T09:00:00.000-07:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where valueString='anywhere'></gd:where> - </entry> - <entry> - <id> - http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg</id> - <published>2007-02-14T23:23:37.000Z</published> - <updated>2007-02-14T23:25:30.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://schemas.google.com/g/2005#event'></category> - <title type='text'>test</title> - <content type='text'></content> - <link rel='alternate' type='text/html' - href='http://www.google.com/calendar/event?eid=ZnU2c2wwcnFha2YzbzBhMTNvbzFpMWExbWcgZ2RhdGEub3BzLmRlbW9AbQ' - title='alternate'></link> - <link rel='self' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg'> - </link> - <link rel='edit' type='application/atom+xml' - href='http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg/63307178730'> - </link> - <author> - <name>GData Ops Demo</name> - <email>gdata.ops.demo@gmail.com</email> - </author> - <gCal:sendEventNotifications value='false'> - </gCal:sendEventNotifications> - <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> - </gd:eventStatus> - <gd:comments> - <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg/comments'> - </gd:feedLink> - </gd:comments> - <gd:visibility value='http://schemas.google.com/g/2005#event.default'> - </gd:visibility> - <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> - </gd:transparency> - <gd:when startTime='2007-02-15T08:30:00.000-08:00' - endTime='2007-02-15T09:30:00.000-08:00'> - <gd:reminder minutes='10'></gd:reminder> - </gd:when> - <gd:where></gd:where> - </entry> -</feed> diff --git a/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml deleted file mode 100644 index f0792d63c7cb972937f57f0f8cf7ccf2221d5eff..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<timezone xmlns="http://schemas.google.com/gCal/2005" value="America/Los_Angeles"/> diff --git a/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml b/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml deleted file mode 100644 index bea486dd290a09b151bb62edf2fc28e7037d03b3..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<gCal:webContent xmlns:gCal="http://schemas.google.com/gCal/2005" - url="http://www.google.com/logos/july4th06.gif" - width="276" height="120" /> diff --git a/tests/Zend/Gdata/CalendarEventTest.php b/tests/Zend/Gdata/CalendarEventTest.php deleted file mode 100644 index 907f3412b566d057b159bd155f97bbfd7de5ed2f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/CalendarEventTest.php +++ /dev/null @@ -1,488 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_CalendarEventTest extends PHPUnit_Framework_TestCase -{ - protected $eventFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $eventFeedText = file_get_contents( - 'Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml', - true); - $this->eventFeed = new Zend_Gdata_Calendar_EventFeed($eventFeedText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testEventFeedToAndFromString() - { - $entryCount = 0; - foreach ($this->eventFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->eventFeed and convert back to objects */ - $newEventFeed = new Zend_Gdata_Calendar_EventFeed( - $this->eventFeed->saveXML()); - $newEntryCount = 0; - foreach ($newEventFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testEntryCount() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->eventFeed as $entry) { - $entryCount++; - } - $this->assertEquals(10, $entryCount); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $feed = $this->eventFeed; - - // Assert that the feed's author is correct - $feedAuthor = $feed->getAuthor(); - $this->assertEquals($feedAuthor, $feed->author); - $this->assertEquals(1, count($feedAuthor)); - $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($feedAuthor[0], "name", "text", "GData Ops Demo"); - $this->verifyProperty2($feedAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); - $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://test.address.invalid/"); - - // Assert that each entry has valid author data - foreach ($feed as $entry) { - $entryAuthor = $entry->getAuthor(); - $this->assertEquals(1, count($entryAuthor)); - $this->verifyProperty2($entryAuthor[0], "name", "text", "GData Ops Demo"); - $this->verifyProperty2($entryAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); - $this->verifyProperty($entryAuthor[0], "uri", null); - } - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $feed = $this->eventFeed; - - // Assert that the feed's ID is correct - $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($feed, "id", "text", - "http://www.google.com/calendar/feeds/default/private/full"); - - // Assert that all entry's have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - } - - // Assert one of the entry's IDs - $entry = $feed[1]; - $this->verifyProperty2($entry, "id", "text", - "http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $feed = $this->eventFeed; - - // Assert that all entry's have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - } - - // Assert one of the entry's Published dates - $entry = $feed[1]; - $this->verifyProperty2($entry, "published", "text", "2007-03-20T21:26:04.000Z"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $feed = $this->eventFeed; - - // Assert that the feed's updated date is correct - $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($feed, "updated", "text", - "2007-03-20T21:29:57.000Z"); - - // Assert that all entry's have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - } - - // Assert one of the entry's Published dates - $entry = $feed[1]; - $this->verifyProperty2($entry, "updated", "text", "2007-03-20T21:28:46.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $feed = $this->eventFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($feed, "title", "text", - "GData Ops Demo"); - - // Assert that all entry's have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "title", "text", "Afternoon at Dolores Park with Kim"); - } - - /** - * Check for the existence of an <atom:subtitle> and verify that it contains - * the expected value. - */ - public function testSubtitle() - { - $feed = $this->eventFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); - $this->verifyProperty2($feed, "subtitle", "text", - "Demo Feed"); - } - - /** - * Check for the existence of an <gCal:timezone> and verify that it contains - * the expected value. - */ - public function testTimezone() - { - $feed = $this->eventFeed; - - // Assert that the feed's timezone is correct - $this->assertTrue($feed->getTimezone() instanceof Zend_Gdata_Calendar_Extension_Timezone); - $this->verifyProperty2($feed, "timezone", "value", - "America/Los_Angeles"); - } - - /** - * Check for the existence of an <openSearch:startIndex> and verify that it contains - * the expected value. - */ - public function testStartIndex() - { - $feed = $this->eventFeed; - - // Assert that the feed's startIndex is correct - $this->assertTrue($feed->getStartIndex() instanceof Zend_Gdata_Extension_OpenSearchStartIndex); - $this->verifyProperty2($feed, "startIndex", "text", "1"); - } - - /** - * Check for the existence of an <openSearch:itemsPerPage> and verify that it contains - * the expected value. - */ - public function testItemsPerPage() - { - $feed = $this->eventFeed; - - // Assert that the feed's itemsPerPage is correct - $this->assertTrue($feed->getItemsPerPage() instanceof Zend_Gdata_Extension_OpenSearchItemsPerPage); - $this->verifyProperty2($feed, "itemsPerPage", "text", "25"); - } - - /** - * Check for the existence of an <atom:content> and verify that it contains - * the expected value. - */ - public function testContent() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a content object - foreach ($feed as $entry) { - $this->assertTrue($entry->getContent() instanceof Zend_Gdata_App_Extension_Content); - } - - // Assert one of the entry's values - $entry = $feed[1]; - $this->verifyProperty2($entry, "content", "text", "This will be fun."); - } - - /** - * Check for the existence of an <gCal:sendEventNotifications> and verify that it contains - * the expected value. - */ - public function testSendEventNotifications() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a sendEventNotifications object - foreach ($feed as $entry) { - $this->assertTrue($entry->getSendEventNotifications() instanceof Zend_Gdata_Calendar_Extension_SendEventNotifications); - } - - // Assert one of the entry's values - $entry = $feed[1]; - $this->verifyProperty2($entry, "sendEventNotifications", "value", false); - } - - /** - * Check for the existence of an <gd:eventStatus> and verify that it contains - * the expected value. - */ - public function testEventStatus() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a eventStatus object - foreach ($feed as $entry) { - $this->assertTrue($entry->getEventStatus() instanceof Zend_Gdata_Extension_EventStatus); - } - - // Assert one of the entry's values - $entry = $feed[1]; - $this->verifyProperty2($entry, "eventStatus", "value", "http://schemas.google.com/g/2005#event.confirmed"); - } - - /** - * Check for the existence of an <gd:comments> and verify that it contains - * the expected value. - */ - public function testComments() - { - $feed = $this->eventFeed; - - // Assert one of the entry's commments links - $entry = $feed[1]; - $this->assertTrue($entry->getComments() instanceof Zend_Gdata_Extension_Comments); - $this->verifyProperty2($entry->getComments(), "feedLink", "href", "http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0/comments"); - } - - /** - * Check for the existence of an <gCal:visibility> and verify that it contains - * the expected value. - */ - public function testVisibility() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a visibility object - foreach ($feed as $entry) { - $this->assertTrue($entry->getVisibility() instanceof Zend_Gdata_Extension_Visibility); - } - - // Assert one of the entries values - $entry = $feed[1]; - $this->verifyProperty2($entry, "visibility", "value", "http://schemas.google.com/g/2005#event.private"); - } - - /** - * Check for the existence of an <gCal:transparency> and verify that it contains - * the expected value. - */ - public function testTransparency() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a transparency object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTransparency() instanceof Zend_Gdata_Extension_Transparency); - } - - // Assert one of the entries values - $entry = $feed[1]; - $this->verifyProperty2($entry, "transparency", "value", "http://schemas.google.com/g/2005#event.opaque"); - } - - /** - * Check for the existence of an <gd:when> and verify that it contains - * the expected value. - */ - public function testWhen() - { - $feed = $this->eventFeed; - - // Assert one of the entry's values - $entry = $feed[1]; - $when = $entry->getWhen(); - $this->assertEquals($entry->getWhen(), $entry->when); - $this->assertEquals(1, count($when)); - $w = $when[0]; - $this->assertTrue($w instanceof Zend_Gdata_Extension_When); - $this->verifyProperty($w, "startTime", "2007-03-24T12:00:00.000-07:00"); - $this->verifyProperty($w, "endTime", "2007-03-24T15:00:00.000-07:00"); - - // Assert that the associated reminders are correct - $reminders = $w->getReminders(); - $this->assertEquals(1, count($reminders)); - $this->verifyProperty($reminders[0], "minutes", "20"); - $this->verifyProperty($reminders[0], "method", "alert"); - } - - /** - * Check for the existence of an <gd:where> and verify that it contains - * the expected value. - */ - public function testWhere() - { - $feed = $this->eventFeed; - - // Assert one of the entry's values - $entry = $feed[1]; - $where = $entry->getWhere(); - $this->assertEquals(1, count($where)); - $this->assertTrue($where[0] instanceof Zend_Gdata_Extension_Where); - $this->verifyProperty($where[0], "valueString", "Dolores Park with Kim"); - } - - /** - * Check for the existence of an <gd:where> and verify that it contains - * the expected value. - */ - public function testWho() - { - $feed = $this->eventFeed; - - // For one of the entries, make sure that all who entries are of the - // right kind - $entry = $feed[1]; - $who = $entry->getWho(); - foreach ($who as $w) { - $this->assertTrue($w instanceof Zend_Gdata_Extension_Who); - } - $this->assertEquals(2, count($who)); - - // Check one of the who entries to make sure the values are valid - $this->verifyProperty($who[0], "rel", "http://schemas.google.com/g/2005#event.organizer"); - $this->verifyProperty($who[0], "valueString", "GData Ops Demo"); - $this->verifyProperty($who[0], "email", "gdata.ops.demo@gmail.com"); - $this->verifyProperty2($who[0], "attendeeStatus", "value", "http://schemas.google.com/g/2005#event.accepted"); - } - - /** - * Check for the existence of an <atom:generator> and verify that it contains - * the expected value. - */ - public function testGenerator() - { - $feed = $this->eventFeed; - - // Assert that the feed's generator is correct - $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); - $this->verifyProperty2($feed, "generator", "version", "1.0"); - $this->verifyProperty2($feed, "generator", "uri", "http://www.google.com/calendar"); - $this->verifyProperty2($feed, "generator", "text", "Google Calendar"); - } - - /** - * Check for the existence of an <gd:quickadd> and verify that it contains - * the expected value. - */ - public function testQuickAdd() - { - $feed = $this->eventFeed; - - // Assert that one of the event's QuickAdd entries is correct - $quickAdd = $feed->entry[1]->getQuickAdd(); - $this->assertTrue($quickAdd instanceof Zend_Gdata_Calendar_Extension_QuickAdd); - $this->verifyProperty($quickAdd, "value", true); - } - -} diff --git a/tests/Zend/Gdata/CalendarFeedCompositeTest.php b/tests/Zend/Gdata/CalendarFeedCompositeTest.php deleted file mode 100644 index cfdce02d204bfa37279f95b5a3869410522537a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/CalendarFeedCompositeTest.php +++ /dev/null @@ -1,503 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_CalendarFeedCompositeTest extends PHPUnit_Framework_TestCase -{ - protected $eventFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $eventFeedText = file_get_contents( - 'Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml', - true); - $this->eventFeed = new Zend_Gdata_Calendar_EventFeed($eventFeedText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($obj->$propGetter(), $value); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($obj->$propGetter()->$secondGetter(), $value); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testEventFeedToAndFromString() - { - $entryCount = 0; - foreach ($this->eventFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->eventFeed and convert back to objects */ - $newEventFeed = new Zend_Gdata_Calendar_EventFeed( - $this->eventFeed->saveXML()); - $newEntryCount = 0; - foreach ($newEventFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testEntryCount() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->eventFeed as $entry) { - $entryCount++; - } - $this->assertEquals(7, $entryCount); - $this->assertEquals($entryCount, $this->eventFeed->totalResults->text); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $feed = $this->eventFeed; - - // Assert that the feed's author is correct - $feedAuthor = $feed->getAuthor(); - $this->assertEquals($feedAuthor, $feed->author); - $this->assertEquals(1, count($feedAuthor)); - $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($feedAuthor[0], "name", "text", "GData Ops Demo"); - $this->verifyProperty2($feedAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); - - // Assert that each entry has valid author data - foreach ($feed as $entry) { - $entryAuthor = $entry->getAuthor(); - $this->assertEquals(1, count($entryAuthor)); - $this->verifyProperty2($entryAuthor[0], "name", "text", "GData Ops Demo"); - $this->verifyProperty2($entryAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); - $this->verifyProperty($entryAuthor[0], "uri", null); - } - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $feed = $this->eventFeed; - - // Assert that the feed's ID is correct - $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($feed, "id", "text", - "http://www.google.com/calendar/feeds/default/private/composite"); - - // Assert that all entry's have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - } - - // Assert one of the entry's IDs - $entry = $feed[2]; - $this->verifyProperty2($entry, "id", "text", - "http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $feed = $this->eventFeed; - - // Assert that all entry's have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - } - - // Assert one of the entry's Published dates - $entry = $feed[2]; - $this->verifyProperty2($entry, "published", "text", "2007-05-09T16:44:38.000Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $feed = $this->eventFeed; - - // Assert that the feed's updated date is correct - $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($feed, "updated", "text", - "2007-05-31T01:15:00.000Z"); - - // Assert that all entry's have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - } - - // Assert one of the entry's Published dates - $entry = $feed[2]; - $this->verifyProperty2($entry, "updated", "text", "2007-05-17T10:33:49.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $feed = $this->eventFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($feed, "title", "text", - "GData Ops Demo's Composite View"); - - // Assert that all entry's have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - } - - // Assert one of the entry's Titles - $entry = $feed[2]; - $this->verifyProperty2($entry, "title", "text", "all day event may 24"); - } - - /** - * Check for the existence of an <atom:subtitle> and verify that it contains - * the expected value. - */ - public function testSubtitle() - { - $feed = $this->eventFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); - $this->verifyProperty2($feed, "subtitle", "text", - "GData Is Awesome"); - } - - /** - * Check for the existence of an <gCal:timezone> and verify that it contains - * the expected value. - */ - public function testTimezone() - { - $feed = $this->eventFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTimezone() instanceof Zend_Gdata_Calendar_Extension_Timezone); - $this->verifyProperty2($feed, "timezone", "value", - "America/Chicago"); - } - - - /** - * Check for the existence of an <gCal:eventStatus> and verify that it contains - * the expected value. - */ - public function testEventStatus() - { - $feed = $this->eventFeed; - - // Assert that all entry's have an eventStatus object - foreach ($feed as $entry) { - $this->assertTrue($entry->getEventStatus() instanceof Zend_Gdata_Extension_EventStatus); - } - - // Assert one of the entries values - $entry = $feed[2]; - $this->verifyProperty2($entry, "eventStatus", "value", "http://schemas.google.com/g/2005#event.confirmed"); - } - - /** - * Check for the existence of an <gCal:visibility> and verify that it contains - * the expected value. - */ - public function testVisibility() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a visibility object - foreach ($feed as $entry) { - $this->assertTrue($entry->getVisibility() instanceof Zend_Gdata_Extension_Visibility); - } - - // Assert one of the entries values - $entry = $feed[2]; - $this->verifyProperty2($entry, "visibility", "value", "http://schemas.google.com/g/2005#event.default"); - } - - /** - * Check for the existence of an <gCal:transparency> and verify that it contains - * the expected value. - */ - public function testTransparency() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a transparency object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTransparency() instanceof Zend_Gdata_Extension_Transparency); - } - - // Assert one of the entries values - $entry = $feed[2]; - $this->verifyProperty2($entry, "transparency", "value", "http://schemas.google.com/g/2005#event.transparent"); - } - - /** - * Check for the existence of an <gCal:sendEventNotifications> and verify that it contains - * the expected value. - */ - public function testSendEventNotifications() - { - $feed = $this->eventFeed; - - // Assert that all entry's have a sendEventNotifications object - foreach ($feed as $entry) { - $this->assertTrue($entry->getSendEventNotifications() instanceof Zend_Gdata_Calendar_Extension_SendEventNotifications); - } - - // Assert one of the entry's values - $entry = $feed[2]; - $this->verifyProperty2($entry, "sendEventNotifications", "value", false); - } - - /** - * Check for the existence of an <gd:when> and verify that it contains - * the expected value. - */ - public function testWhen() - { - $feed = $this->eventFeed; - - // Assert one of the entry's values - $entry = $feed[2]; - $when = $entry->getWhen(); - $this->assertEquals($entry->getWhen(), $entry->when); - $this->assertEquals(1, count($when)); - $this->assertTrue($when[0] instanceof Zend_Gdata_Extension_When); - $this->verifyProperty($when[0], "startTime", "2007-05-24"); - $this->verifyProperty($when[0], "endTime", "2007-05-25"); - - // Verify that the reminders show up - $reminders = $when[0]->getReminders(); - $this->assertEquals(2, count($reminders)); - $this->assertTrue($reminders[0] instanceof Zend_Gdata_Extension_Reminder); - $this->assertTrue($reminders[1] instanceof Zend_Gdata_Extension_Reminder); - $this->verifyProperty($reminders[0], "minutes", "10"); - $this->verifyProperty($reminders[0], "method", "alert"); - $this->verifyProperty($reminders[1], "minutes", "10"); - $this->verifyProperty($reminders[1], "method", "email"); - } - - /** - * Check for the existence of an <gd:where> and verify that it contains - * the expected value. - */ - public function testWhere() - { - $feed = $this->eventFeed; - - // Assert one of the entry's values - $entry = $feed[2]; - $where = $entry->getWhere(); - $this->assertEquals(1, count($where)); - $this->assertTrue($where[0] instanceof Zend_Gdata_Extension_Where); - $this->verifyProperty($where[0], "valueString", "Mountain View, California"); - } - - /** - * Check for the existence of an <gd:comments> and verify that it contains - * the expected value. - */ - public function testComments() - { - $feed = $this->eventFeed; - - - // Assert one of the entries has the correct values - // Make sure the comment element looks right - $entry = $feed[2]; - $c = $entry->getComments(); - $this->assertEquals($c, $entry->comments); - $this->assertTrue($c instanceof Zend_Gdata_Extension_Comments); - - // Make sure that the feedLink looks right - $fl = $c->getFeedLink(); - $this->assertTrue($fl instanceof Zend_Gdata_Extension_FeedLink); - $this->assertEquals($fl, $c->feedLink); - $this->verifyProperty($fl, "href", "http://www.google.com/calendar/feeds/default/private/full/lq2ai6imsbq209q3aeturho50g/comments"); - - // Make sure the embedded feed looks right - $cFeed = $fl->getFeed(); - $this->assertTrue($cFeed instanceof Zend_Gdata_App_Feed); - $this->assertEquals($cFeed, $fl->feed); - - // Verify the remainder of the comment feed metadata - $this->assertTrue($cFeed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($cFeed, "updated", "text", "2007-05-31T01:15:13.249Z"); - - $this->assertTrue($cFeed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($cFeed, "title", "text", "Comments for: all day event may 24"); - - // Verify that the comments appear to be good - $commentCount = 0; - foreach ($cFeed as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Entry); - $commentCount++; - } - $this->assertEquals(2, $commentCount); - - // Closely examine one of the comments - $comment = $cFeed[1]; - - $this->assertTrue($comment->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($comment, "id", "text", "i9q87onko1uphfs7i21elnnb4g"); - - $this->assertTrue($comment->getPublished() instanceof Zend_Gdata_App_Extension_Published); - $this->verifyProperty2($comment, "published", "text", "2007-06-01T21:21:47.000Z"); - - $this->assertTrue($comment->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($comment, "updated", "text", "2007-06-01T21:21:47.000Z"); - - $this->assertEquals(1, count($comment->author)); - $this->assertTrue($comment->author[0] instanceof Zend_Gdata_App_Extension_Author); - $this->assertTrue($comment->author[0]->getName() instanceof Zend_Gdata_App_Extension_Name); - $this->assertTrue($comment->author[0]->getEmail() instanceof Zend_Gdata_App_Extension_Email); - $this->verifyProperty2($comment->author[0], "name", "text", "User 2"); - $this->verifyProperty2($comment->author[0], "email", "text", "user2@nowhere.invalid"); - - $this->assertTrue($comment->getContent() instanceof Zend_Gdata_App_Extension_Content); - $this->verifyProperty($comment->getContent(), "type", "html"); - $this->assertEquals('<p>This is a user supplied comment.</p>', $comment->getContent()->text); - } - - /** - * Check for the existence of an <gd:where> and verify that it contains - * the expected value. - */ - public function testRecurrence() - { - $feed = $this->eventFeed; - - // Assert one of the entry's values - $entry = $feed[1]; - $this->assertTrue($entry->getRecurrence() instanceof Zend_Gdata_Extension_Recurrence); - $this->verifyProperty2($entry, "recurrence", "text", - "DTSTART;VALUE=DATE:20070501 DTEND;VALUE=DATE:20070502 RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904"); - } - - /** - * Check for the existence of an <openSearch:startIndex> and verify that it contains - * the expected value. - */ - public function testStartIndex() - { - $feed = $this->eventFeed; - - // Assert that the feed's startIndex is correct - $this->assertTrue($feed->getStartIndex() instanceof Zend_Gdata_Extension_OpenSearchStartIndex); - $this->verifyProperty2($feed, "startIndex", "text", "1"); - } - - /** - * Check for the existence of an <openSearch:itemsPerPage> and verify that it contains - * the expected value. - */ - public function testItemsPerPage() - { - $feed = $this->eventFeed; - - // Assert that the feed's itemsPerPage is correct - $this->assertTrue($feed->getItemsPerPage() instanceof Zend_Gdata_Extension_OpenSearchItemsPerPage); - $this->verifyProperty2($feed, "itemsPerPage", "text", "25"); - } - - /** - * Check for the existence of an <atom:generator> and verify that it contains - * the expected value. - */ - public function testGenerator() - { - $feed = $this->eventFeed; - - // Assert that the feed's generator is correct - $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); - $this->verifyProperty2($feed, "generator", "version", "1.0"); - $this->verifyProperty2($feed, "generator", "uri", "http://www.google.com/calendar"); - } - - -} diff --git a/tests/Zend/Gdata/CalendarFeedTest.php b/tests/Zend/Gdata/CalendarFeedTest.php deleted file mode 100644 index 7c2ca929bb4973347bc800ab6811b5a4587c4afd..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/CalendarFeedTest.php +++ /dev/null @@ -1,382 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_CalendarFeedTest extends PHPUnit_Framework_TestCase -{ - protected $listFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $listFeedText = file_get_contents( - 'Zend/Gdata/Calendar/_files/ListFeedSample1.xml', - true); - $this->listFeed = new Zend_Gdata_Calendar_ListFeed($listFeedText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testEventFeedToAndFromString() - { - $entryCount = 0; - foreach ($this->listFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_ListEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->listFeed and convert back to objects */ - $newListFeed = new Zend_Gdata_Calendar_ListFeed( - $this->listFeed->saveXML()); - $newEntryCount = 0; - foreach ($newListFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_ListEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testEntryCount() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->listFeed as $entry) { - $entryCount++; - } - $this->assertEquals(9, $entryCount); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $feed = $this->listFeed; - - // Assert that the feed's author is correct - $feedAuthor = $feed->getAuthor(); - $this->assertEquals($feedAuthor, $feed->author); - $this->assertEquals(1, count($feedAuthor)); - $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($feedAuthor[0], "name", "text", "GData Ops Demo"); - $this->verifyProperty2($feedAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); - $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://test.address.invalid/"); - - // Assert that each entry has valid author data - foreach ($feed as $entry) { - $entryAuthor = $entry->getAuthor(); - $this->assertEquals(1, count($entryAuthor)); - $this->verifyProperty2($entryAuthor[0], "name", "text", "GData Ops Demo"); - $this->verifyProperty2($entryAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); - $this->verifyProperty($entryAuthor[0], "uri", null); - } - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $feed = $this->listFeed; - - // Assert that the feed's ID is correct - $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($feed, "id", "text", - "http://www.google.com/calendar/feeds/default"); - - // Assert that all entry's have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - } - - // Assert one of the entry's IDs - $entry = $feed[1]; - $this->verifyProperty2($entry, "id", "text", - "http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $feed = $this->listFeed; - - // Assert that all entry's have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - } - - // Assert one of the entry's Published dates - $entry = $feed[1]; - $this->verifyProperty2($entry, "published", "text", "2007-05-30T00:23:27.005Z"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $feed = $this->listFeed; - - // Assert that the feed's updated date is correct - $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($feed, "updated", "text", - "2007-05-30T00:23:26.998Z"); - - // Assert that all entry's have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - } - - // Assert one of the entry's Published dates - $entry = $feed[1]; - $this->verifyProperty2($entry, "updated", "text", "2007-05-30T00:20:38.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $feed = $this->listFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($feed, "title", "text", - "GData Ops Demo's Calendar List"); - - // Assert that all entry's have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "title", "text", "My Other Awesome Calendar"); - } - - /** - * Check for the existence of an <gCal:color> and verify that it contains - * the expected value. - */ - public function testColor() - { - $feed = $this->listFeed; - - // Assert that all entry's have an color object - foreach ($feed as $entry) { - $this->assertTrue($entry->getColor() instanceof Zend_Gdata_Calendar_Extension_Color); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "color", "value", "#A32929"); - } - - /** - * Check for the existence of an <gCal:accessLevel> and verify that it contains - * the expected value. - */ - public function testAccessLevel() - { - $feed = $this->listFeed; - - // Assert that all entry's have an accessLevel object - foreach ($feed as $entry) { - $this->assertTrue($entry->getAccessLevel() instanceof Zend_Gdata_Calendar_Extension_AccessLevel); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "accessLevel", "value", "owner"); - } - - /** - * Check for the existence of an <gCal:timezone> and verify that it contains - * the expected value. - */ - public function testTimezone() - { - $feed = $this->listFeed; - - // Assert that all entry's have an accessLevel object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTimezone() instanceof Zend_Gdata_Calendar_Extension_Timezone); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "timezone", "value", "America/Chicago"); - } - - /** - * Check for the existence of an <gCal:hidden> and verify that it contains - * the expected value. - */ - public function testHidden() - { - $feed = $this->listFeed; - - // Assert that all entry's have an accessLevel object - foreach ($feed as $entry) { - $this->assertTrue($entry->getHidden() instanceof Zend_Gdata_Calendar_Extension_Hidden); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "hidden", "value", false); - } - - /** - * Check for the existence of an <gCal:selected> and verify that it contains - * the expected value. - */ - public function testSelected() - { - $feed = $this->listFeed; - - // Assert that all entry's have a selected object - foreach ($feed as $entry) { - $this->assertTrue($entry->getSelected() instanceof Zend_Gdata_Calendar_Extension_Selected); - } - - // Assert one of the entry's Titles - $entry = $feed[1]; - $this->verifyProperty2($entry, "selected", "value", true); - } - - /** - * Check for the existence of an <openSearch:startIndex> and verify that it contains - * the expected value. - */ - public function testStartIndex() - { - $feed = $this->listFeed; - - // Assert that the feed's startIndex is correct - $this->assertTrue($feed->getStartIndex() instanceof Zend_Gdata_Extension_OpenSearchStartIndex); - $this->verifyProperty2($feed, "startIndex", "text", "1"); - } - - /** - * Check for the existence of an <gd:where> and verify that it contains - * the expected value. - */ - public function testWhere() - { - $feed = $this->listFeed; - - // Assert one of the entry's where values - $entry = $feed[1]; - $this->assertEquals($entry->getWhere(), $entry->where); - $this->assertTrue($entry->where[0] instanceof Zend_Gdata_Extension_Where); - $this->assertEquals("Palo Alto, California", $entry->where[0]->getValueString()); - } - - /** - * Check for the existence of an <atom:summary> and verify that it contains - * the expected value. - */ - public function testSummary() - { - $feed = $this->listFeed; - - // Assert one of the entry's summaries - $entry = $feed[1]; - $this->assertTrue($entry->getSummary() instanceof Zend_Gdata_App_Extension_Summary); - $this->verifyProperty2($entry, "summary", "text", "This is my other calendar."); - } - - /** - * Check for the existence of an <atom:generator> and verify that it contains - * the expected value. - */ - public function testGenerator() - { - $feed = $this->listFeed; - - // Assert that the feed's generator is correct - $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); - $this->verifyProperty2($feed, "generator", "version", "1.0"); - $this->verifyProperty2($feed, "generator", "uri", "http://www.google.com/calendar"); - } - -} diff --git a/tests/Zend/Gdata/CalendarOnlineTest.php b/tests/Zend/Gdata/CalendarOnlineTest.php deleted file mode 100644 index 14eaa6b86677295f04908e29ed0fc496bd4dd0b9..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/CalendarOnlineTest.php +++ /dev/null @@ -1,167 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventEntry.php'; -require_once 'Zend/Gdata/ClientLogin.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_CalendarOnlineTest extends PHPUnit_Framework_TestCase -{ - - const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com'; - const ZEND_CONFERENCE_EVENT = 'bn2h4o4mc3a03ci4t48j3m56pg'; - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->gdata = new Zend_Gdata_Calendar($client); - } - - public function testCalendarListFeed() - { - $calFeed = $this->gdata->getCalendarListFeed(); - $this->assertTrue(strpos($calFeed->title->text, 'Calendar List') - !== false); - $calCount = 0; - foreach ($calFeed as $calendar) { - $calCount++; - } - $this->assertTrue($calCount > 0); - } - - /** - * @see ZF-1701 - */ - /* - public function testCalendarOnlineFeed() - { - $eventFeed = $this->gdata->getCalendarEventFeed(); - foreach ($eventFeed as $event) { - $title = $event->title; - $times = $event->when; - $location = $event->where; - $recurrence = $event->recurrence; - } - } - */ - - function getEvent($eventId) - { - $query = $this->gdata->newEventQuery(); - $query->setUser('default'); - $query->setVisibility('private'); - $query->setProjection('full'); - $query->setEvent($eventId); - - $eventEntry = $this->gdata->getCalendarEventEntry($query); - $this->assertTrue( - $eventEntry instanceof Zend_Gdata_Calendar_EventEntry); - return $eventEntry; - } - - public function createEvent( - $title = 'Tennis with Beth', - $desc='Meet for a quick lesson', $where = 'On the courts', - $startDate = '2008-01-20', $startTime = '10:00', - $endDate = '2008-01-20', $endTime = '11:00', $tzOffset = '-08') - { - $newEntry = $this->gdata->newEventEntry(); - $newEntry->title = $this->gdata->newTitle(trim($title)); - $newEntry->where = array($this->gdata->newWhere($where)); - - $newEntry->content = $this->gdata->newContent($desc); - $newEntry->content->type = 'text'; - - $when = $this->gdata->newWhen(); - $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; - $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; - $reminder = $this->gdata->newReminder(); - $reminder->minutes = '30'; - $reminder->method = 'email'; - $when->reminders = array($reminder); - $newEntry->when = array($when); - - $createdEntry = $this->gdata->insertEvent($newEntry); - - $this->assertEquals($title, $createdEntry->title->text); - $this->assertEquals($desc, $createdEntry->content->text); - $this->assertEquals(strtotime($when->startTime), - strtotime($createdEntry->when[0]->startTime)); - $this->assertEquals(strtotime($when->endTime), - strtotime($createdEntry->when[0]->endTime)); - $this->assertEquals($reminder->method, - $createdEntry->when[0]->reminders[0]->method); - $this->assertEquals($reminder->minutes, - $createdEntry->when[0]->reminders[0]->minutes); - $this->assertEquals($where, $createdEntry->where[0]->valueString); - - return $createdEntry; - } - - function updateEvent ($eventId, $newTitle) - { - $eventOld = $this->getEvent($eventId); - $eventOld->title = $this->gdata->newTitle($newTitle); - $eventOld->save(); - $eventNew = $this->getEvent($eventId); - $this->assertEquals($newTitle, $eventNew->title->text); - return $eventNew; - } - - public function testCreateEvent() - { - $createdEntry = $this->createEvent(); - } - - public function testCreateAndUpdateEvent() - { - $newTitle = 'my new title'; - $createdEntry = $this->createEvent(); - preg_match('#.*/([A-Za-z0-9]+)$#', $createdEntry->id->text, $matches); - $id = $matches[1]; - $updatedEvent = $this->updateEvent($id, $newTitle); - $this->assertEquals($newTitle, $updatedEvent->title->text); - } - - public function testCreateAndDeleteEvent() - { - /* deletion can be performed in several different ways-- test all */ - $createdEntry = $this->createEvent(); - $createdEntry->delete(); - - $createdEntry2 = $this->createEvent(); - $this->gdata->delete($createdEntry2); - - $createdEntry3 = $this->createEvent(); - $this->gdata->delete($createdEntry3->getEditLink()->href); - } -} diff --git a/tests/Zend/Gdata/CalendarTest.php b/tests/Zend/Gdata/CalendarTest.php deleted file mode 100644 index 435655799522a34a151b34ef7d6cae08ad647964..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/CalendarTest.php +++ /dev/null @@ -1,96 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Calendar.php'; -require_once 'Zend/Gdata/Calendar/EventFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_CalendarTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->eventFeedText = file_get_contents( - 'Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml', - true); - $this->eventFeed = new Zend_Gdata_Calendar_EventFeed(); - } - - public function testEmptyEventFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->eventFeed->extensionElements)); - $this->assertTrue(count($this->eventFeed->extensionElements) == 0); - } - - public function testEmptyEventFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->eventFeed->extensionAttributes)); - $this->assertTrue(count($this->eventFeed->extensionAttributes) == 0); - } - - public function testSampleEventFeedShouldHaveNoExtensionElements() { - $this->eventFeed->transferFromXML($this->eventFeedText); - $this->assertTrue(is_array($this->eventFeed->extensionElements)); - $this->assertTrue(count($this->eventFeed->extensionElements) == 0); - } - - public function testSampleEventFeedShouldHaveNoExtensionAttributes() { - $this->eventFeed->transferFromXML($this->eventFeedText); - $this->assertTrue(is_array($this->eventFeed->extensionAttributes)); - $this->assertTrue(count($this->eventFeed->extensionAttributes) == 0); - } - - public function testEventFeedToAndFromString() - { - $this->eventFeed->transferFromXML($this->eventFeedText); - $entryCount = 0; - foreach ($this->eventFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->eventFeed and convert back to objects */ - $newEventFeed = new Zend_Gdata_Calendar_EventFeed( - $this->eventFeed->saveXML()); - $newEntryCount = 0; - foreach ($newEventFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - public function testEntryCount() - { - $this->eventFeed->transferFromXML($this->eventFeedText); - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->eventFeed as $entry) { - $entryCount++; - } - $this->assertEquals($entryCount, 10); - $this->assertEquals($entryCount, $this->eventFeed->totalResults->text); - } - -} diff --git a/tests/Zend/Gdata/CommentsTest.php b/tests/Zend/Gdata/CommentsTest.php deleted file mode 100644 index 7fa2e86387c485e5b4699e0696fcfffe3a841541..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/CommentsTest.php +++ /dev/null @@ -1,124 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Comments.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_CommentsTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->commentsText = file_get_contents( - 'Zend/Gdata/_files/CommentsElementSample1.xml', - true); - $this->comments = new Zend_Gdata_Extension_Comments(); - } - - public function testEmptyCommentsShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->comments->extensionElements)); - $this->assertTrue(count($this->comments->extensionElements) == 0); - } - - public function testEmptyCommentsShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->comments->extensionAttributes)); - $this->assertTrue(count($this->comments->extensionAttributes) == 0); - } - - public function testSampleCommentsShouldHaveNoExtensionElements() { - $this->comments->transferFromXML($this->commentsText); - $this->assertTrue(is_array($this->comments->extensionElements)); - $this->assertTrue(count($this->comments->extensionElements) == 0); - } - - public function testSampleCommentsShouldHaveNoExtensionAttributes() { - $this->comments->transferFromXML($this->commentsText); - $this->assertTrue(is_array($this->comments->extensionAttributes)); - $this->assertTrue(count($this->comments->extensionAttributes) == 0); - } - - public function testNormalCommentsShouldHaveNoExtensionElements() { - $this->comments->rel = "http://schemas.google.com/g/2005#regular"; - - $this->assertEquals("http://schemas.google.com/g/2005#regular", $this->comments->rel); - - $this->assertEquals(0, count($this->comments->extensionElements)); - $newComments = new Zend_Gdata_Extension_Comments(); - $newComments->transferFromXML($this->comments->saveXML()); - $this->assertEquals(0, count($newComments->extensionElements)); - $newComments->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newComments->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#regular", $newComments->rel); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newComments2 = $gdata->newComments(); - $newComments2->transferFromXML($newComments->saveXML()); - $this->assertEquals(1, count($newComments2->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#regular", $newComments2->rel); - } - - public function testEmptyCommentsToAndFromStringShouldMatch() { - $commentsXml = $this->comments->saveXML(); - $newComments = new Zend_Gdata_Extension_Comments(); - $newComments->transferFromXML($commentsXml); - $newCommentsXml = $newComments->saveXML(); - $this->assertTrue($commentsXml == $newCommentsXml); - } - - public function testCommentsWithValueToAndFromStringShouldMatch() { - $this->comments->rel = "http://schemas.google.com/g/2005#regular"; - $commentsXml = $this->comments->saveXML(); - $newComments = new Zend_Gdata_Extension_Comments(); - $newComments->transferFromXML($commentsXml); - $newCommentsXml = $newComments->saveXML(); - $this->assertTrue($commentsXml == $newCommentsXml); - $this->assertEquals("http://schemas.google.com/g/2005#regular", $this->comments->rel); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->comments->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->comments->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->comments->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->comments->extensionAttributes['foo2']['value']); - $commentsXml = $this->comments->saveXML(); - $newComments = new Zend_Gdata_Extension_Comments(); - $newComments->transferFromXML($commentsXml); - $this->assertEquals('bar', $newComments->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newComments->extensionAttributes['foo2']['value']); - } - - public function testConvertFullCommentsToAndFromString() { - $this->comments->transferFromXML($this->commentsText); - $this->assertEquals("http://schemas.google.com/g/2005#reviews", $this->comments->rel); - $this->assertTrue($this->comments->feedLink instanceof Zend_Gdata_Extension_FeedLink); - $this->assertEquals("http://example.com/restaurants/SanFrancisco/432432/reviews", $this->comments->feedLink->href); - } - -} diff --git a/tests/Zend/Gdata/Docs/DocumentListEntryTest.php b/tests/Zend/Gdata/Docs/DocumentListEntryTest.php deleted file mode 100755 index 2f496fe52d83dc628890a5e668d01e30024b4827..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Docs/DocumentListEntryTest.php +++ /dev/null @@ -1,66 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Docs.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/Docs/DocumentListEntry.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Docs_DocumentListEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->doc = new Zend_Gdata_Docs_DocumentListEntry( - file_get_contents('Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml', true)); - } - - public function testToAndFromString() - { - $this->assertTrue($this->doc instanceof Zend_Gdata_Docs_DocumentListEntry); - $this->assertTrue($this->doc->title->text === 'Test Spreadsheet'); - - $newDoc = new Zend_Gdata_Docs_DocumentListEntry(); - $doc = new DOMDocument(); - $doc->loadXML($this->doc->saveXML()); - $newDoc->transferFromDom($doc->documentElement); - - $this->assertTrue($newDoc->title == $this->doc->title); - } - - public function testSetMediaSource() - { - // Service object to create the media file source. - $this->docsClient = new Zend_Gdata_Docs(null); - $mediaSource = $this->docsClient->newMediaFileSource('test_file_name'); - $mediaSource->setSlug('test slug'); - $mediaSource->setContentType('test content type'); - $this->doc->setMediaSource($mediaSource); - $this->assertTrue($this->doc->getMediaSource()->getContentType() === - 'test content type'); - $this->assertTrue($this->doc->getMediaSource()->getSlug() === - 'test slug'); - } - -} diff --git a/tests/Zend/Gdata/Docs/DocumentListFeedTest.php b/tests/Zend/Gdata/Docs/DocumentListFeedTest.php deleted file mode 100755 index 77772f39f572fac81e748553fece2953beffdb33..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Docs/DocumentListFeedTest.php +++ /dev/null @@ -1,60 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Docs.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Docs_DocumentListFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->docFeed = new Zend_Gdata_Docs_DocumentListFeed( - file_get_contents('Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml'), - true); - } - - public function testToAndFromString() - { - // There should be 2 entries in the feed. - $this->assertTrue(count($this->docFeed->entries) == 1); - foreach($this->docFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); - } - - $newDocFeed = new Zend_Gdata_Docs_DocumentListFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->docFeed->saveXML()); - $newDocFeed->transferFromDom($doc->documentElement); - - $this->assertTrue(count($newDocFeed->entries) == count($this->docFeed->entries)); - foreach($newDocFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); - } - } - -} diff --git a/tests/Zend/Gdata/Docs/QueryTest.php b/tests/Zend/Gdata/Docs/QueryTest.php deleted file mode 100755 index d480ea2277760a43a8e18c2034623a408b1d0259..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Docs/QueryTest.php +++ /dev/null @@ -1,71 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Docs.php'; -require_once 'Zend/Gdata/Docs/Query.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Docs_QueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->docQuery = new Zend_Gdata_Docs_Query(); - } - - public function testTitle() - { - $this->assertTrue($this->docQuery->getTitle() == null); - $this->docQuery->setTitle('test title'); - $this->assertTrue($this->docQuery->getTitle() == 'test title'); - $this->assertTrue($this->docQuery->getQueryString() == '?title=test+title'); - $this->docQuery->setTitle(null); - $this->assertTrue($this->docQuery->getTitle() == null); - } - - public function testTitleExact() - { - $this->assertTrue($this->docQuery->getTitleExact() == null); - $this->docQuery->setTitleExact('test title'); - $this->assertTrue($this->docQuery->getTitleExact() == 'test title'); - $this->assertTrue($this->docQuery->getQueryString() == '?title-exact=test+title'); - $this->docQuery->setTitleExact(null); - $this->assertTrue($this->docQuery->getTitleExact() == null); - } - - public function testProjection() - { - $this->assertTrue($this->docQuery->getProjection() == 'full'); - $this->docQuery->setProjection('abc'); - $this->assertTrue($this->docQuery->getProjection() == 'abc'); - } - - public function testVisibility() - { - $this->assertTrue($this->docQuery->getVisibility() == 'private'); - $this->docQuery->setVisibility('xyz'); - $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); - } -} diff --git a/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml b/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml deleted file mode 100755 index 1860425cc7608aa90100fb0d2635ad9491e56682..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml +++ /dev/null @@ -1,14 +0,0 @@ -<entry xmlns="http://www.w3.org/2005/Atom"> - <content src="http://foo.com/fm?fmcmd=102key=supercalifragilisticexpealidocious" type="text/html" /> - <author> - <name>test.user</name> - <email>test.user@gmail.com</email> - </author> - <category label="spreadsheet" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet" /> - <id>http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious</id> - <link href="http://foo.com/ccc?key=supercalifragilisticexpealidocious" rel="alternate" type="text/html" /> - <link href="http://foo.com/feeds/worksheets/supercalifragilisticexpealidocious/private/full" rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" type="application/atom+xml" /> - <link href="http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious" rel="self" type="application/atom+xml" /> - <title type="text">Test Spreadsheet</title> - <updated>2007-07-03T18:03:32.045Z</updated> -</entry> diff --git a/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml b/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml deleted file mode 100755 index d19a2f2a8f80392956757b7a925ef56548e6f71b..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml +++ /dev/null @@ -1,38 +0,0 @@ -<ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom"> - <ns1:totalResults xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">2</ns1:totalResults> - <ns1:startIndex xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">1</ns1:startIndex> - <ns0:entry> - <ns0:content src="http://foo.com/fm?fmcmd=102&key=supercalifragilisticexpeadocious" type="text/html"/> - <ns0:author> - <ns0:name>test.user</ns0:name> - <ns0:email>test.user@gmail.com</ns0:email> - </ns0:author> - <ns0:category label="spreadsheet" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet" /> - <ns0:id>http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious</ns0:id> - <ns0:link href="http://foo.com/ccc?key=supercalifragilisticexpeadocious" rel="alternate" type="text/html" /> - <ns0:link href="http://foo.com/feeds/worksheets/supercalifragilisticexpeadocious/private/full" rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" type="application/atom+xml" /> - <ns0:link href="http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious" rel="self" type="application/atom+xml" /> - <ns0:title type="text">Test Spreadsheet</ns0:title> - <ns0:updated>2007-07-03T18:03:32.045Z</ns0:updated> - </ns0:entry> - <ns0:entry> - <ns0:content src="http://docs.google.com/RawDocContents?action=fetch&docID=gr00vy" type="text/html" /> - <ns0:author> - <ns0:name>test.user</ns0:name> - <ns0:email>test.user@gmail.com</ns0:email> - </ns0:author> - <ns0:category label="document" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#document" /> - <ns0:id>http://docs.google.com/feeds/documents/private/full/document%3Agr00vy</ns0:id> - <ns0:link href="http://foobar.com/Doc?id=gr00vy" rel="alternate" type="text/html" /> - <ns0:link href="http://docs.google.com/feeds/documents/private/full/document%3Agr00vy" rel="self" type="application/atom+xml" /> - <ns0:title type="text">Test Document</ns0:title> - <ns0:updated>2007-07-03T18:02:50.338Z</ns0:updated> - </ns0:entry> - <ns0:id>http://docs.google.com/feeds/documents/private/full</ns0:id> - <ns0:link href="http://docs.google.com" rel="alternate" type="text/html" /> - <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" /> - <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" /> - <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="self" type="application/atom+xml" /> - <ns0:title type="text">Available Documents - test.user@gmail.com</ns0:title> - <ns0:updated>2007-07-09T23:07:21.898Z</ns0:updated> -</ns0:feed> diff --git a/tests/Zend/Gdata/DocsOnlineTest.php b/tests/Zend/Gdata/DocsOnlineTest.php deleted file mode 100755 index 8a83fdd52027b846dd153b7805dac7eb07b07831..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/DocsOnlineTest.php +++ /dev/null @@ -1,123 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Docs.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/ClientLogin.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_DocsOnlineTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $this->docTitle = constant('TESTS_ZEND_GDATA_DOCS_DOCUMENTTITLE'); - $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->gdata = new Zend_Gdata_Docs($client); - } - - public function testGetSpreadsheetFeed() - { - $feed = $this->gdata->getDocumentListFeed(); - $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $query = new Zend_Gdata_Docs_Query(); - $feed = $this->gdata->getDocumentListFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $uri = $query->getQueryUrl(); - $feed = $this->gdata->getDocumentListFeed($uri); - $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - } - - public function testQueryForTitle() - { - $query = new Zend_Gdata_Docs_Query(); - $query->title = $this->docTitle; - $feed = $this->gdata->getDocumentListFeed($query); - $this->assertTrue(strpos(strtolower($feed->entries[0]->title), strtolower($this->docTitle)) !== FALSE); - } - - public function testGetDocumentListEntry() - { - $query = new Zend_Gdata_Docs_Query(); - $feed = $this->gdata->getDocumentListFeed($query); - $selfLinkHref = $feed->entries[0]->getSelfLink()->href; - $entry = $this->gdata->getDocumentListEntry($selfLinkHref); - $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); - } - - public function testUploadFindAndDelete() - { - $documentTitle = 'spreadsheet_upload_test.csv'; - $newDocumentEntry = $this->gdata->uploadFile( - 'Zend/Gdata/_files/DocsTest.csv', $documentTitle, - $this->gdata->lookupMimeType('CSV'), - Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI); - $this->assertTrue($newDocumentEntry->title->text === $documentTitle); - - // Get the newly created document. - // First extract the document's ID key from the Atom id. - $idParts = explode('/', $newDocumentEntry->id->text); - $keyParts = explode('%3A', end($idParts)); - $documentFromGetDoc = $this->gdata->getDoc($keyParts[1], $keyParts[0]); - $this->assertTrue($documentFromGetDoc->title->text === $documentTitle); - if ($keyParts[0] == 'document') { - $documentFromGetDocument = $this->gdata->getDocument($keyParts[1]); - $this->assertTrue( - $documentFromGetDocument->title->text === $documentTitle); - } - if ($keyParts[0] == 'spreadsheet') { - $documentFromGetSpreadsheet = $this->gdata->getSpreadsheet( - $keyParts[1]); - $this->assertTrue( - $documentFromGetSpreadsheet->title->text === $documentTitle); - } - if ($keyParts[0] == 'presentation') { - $documentFromGetPresentation = $this->gdata->getPresentation( - $keyParts[1]); - $this->assertTrue( - $documentFromGetPresentation->title->text === $documentTitle); - } - - // Cleanup and remove the new document. - $newDocumentEntry->delete(); - } - -} diff --git a/tests/Zend/Gdata/DocsTest.php b/tests/Zend/Gdata/DocsTest.php deleted file mode 100755 index 6238b3c4d02b334ff3185a934dde5d3caed5055f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/DocsTest.php +++ /dev/null @@ -1,42 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Docs.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_DocsTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->gdata = new Zend_Gdata_Docs(new Zend_Http_Client()); - } - - public function testDocs() - { - $this->assertTrue(true); - } - -} diff --git a/tests/Zend/Gdata/EntryLinkTest.php b/tests/Zend/Gdata/EntryLinkTest.php deleted file mode 100644 index 9769a2ad40a0481819e35b576d5f54967134b3c0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/EntryLinkTest.php +++ /dev/null @@ -1,138 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/EntryLink.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_EntryLinkTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryLinkText = file_get_contents( - 'Zend/Gdata/_files/EntryLinkElementSample1.xml', - true); - $this->entryLink = new Zend_Gdata_Extension_EntryLink(); - } - - public function testEmptyEntryLinkShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entryLink->extensionElements)); - $this->assertTrue(count($this->entryLink->extensionElements) == 0); - } - - public function testEmptyEntryLinkShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entryLink->extensionAttributes)); - $this->assertTrue(count($this->entryLink->extensionAttributes) == 0); - } - - public function testSampleEntryLinkShouldHaveNoExtensionElements() { - $this->entryLink->transferFromXML($this->entryLinkText); - $this->assertTrue(is_array($this->entryLink->extensionElements)); - $this->assertTrue(count($this->entryLink->extensionElements) == 0); - } - - public function testSampleEntryLinkShouldHaveNoExtensionAttributes() { - $this->entryLink->transferFromXML($this->entryLinkText); - $this->assertTrue(is_array($this->entryLink->extensionAttributes)); - $this->assertTrue(count($this->entryLink->extensionAttributes) == 0); - } - - public function testNormalEntryLinkShouldHaveNoExtensionElements() { - $this->entryLink->href = "http://gmail.com/jo/contacts/Bob"; - $this->entryLink->rel = "self"; - $this->entryLink->readOnly = "false"; - - $this->assertEquals("http://gmail.com/jo/contacts/Bob", $this->entryLink->href); - $this->assertEquals("self", $this->entryLink->rel); - $this->assertEquals("false", $this->entryLink->readOnly); - - $this->assertEquals(0, count($this->entryLink->extensionElements)); - $newEntryLink = new Zend_Gdata_Extension_EntryLink(); - $newEntryLink->transferFromXML($this->entryLink->saveXML()); - $this->assertEquals(0, count($newEntryLink->extensionElements)); - $newEntryLink->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newEntryLink->extensionElements)); - $this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink->href); - $this->assertEquals("self", $newEntryLink->rel); - $this->assertEquals("false", $newEntryLink->readOnly); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newEntryLink2 = $gdata->newEntryLink(); - $newEntryLink2->transferFromXML($newEntryLink->saveXML()); - $this->assertEquals(1, count($newEntryLink2->extensionElements)); - $this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink2->href); - $this->assertEquals("self", $newEntryLink2->rel); - $this->assertEquals("false", $newEntryLink2->readOnly); - } - - public function testEmptyEntryLinkToAndFromStringShouldMatch() { - $entryLinkXml = $this->entryLink->saveXML(); - $newEntryLink = new Zend_Gdata_Extension_EntryLink(); - $newEntryLink->transferFromXML($entryLinkXml); - $newEntryLinkXml = $newEntryLink->saveXML(); - $this->assertTrue($entryLinkXml == $newEntryLinkXml); - } - - public function testEntryLinkWithValueToAndFromStringShouldMatch() { - $this->entryLink->href = "http://gmail.com/jo/contacts/Bob"; - $this->entryLink->rel = "self"; - $this->entryLink->readOnly = "false"; - $entryLinkXml = $this->entryLink->saveXML(); - $newEntryLink = new Zend_Gdata_Extension_EntryLink(); - $newEntryLink->transferFromXML($entryLinkXml); - $newEntryLinkXml = $newEntryLink->saveXML(); - $this->assertTrue($entryLinkXml == $newEntryLinkXml); - $this->assertEquals("http://gmail.com/jo/contacts/Bob", $this->entryLink->href); - $this->assertEquals("self", $this->entryLink->rel); - $this->assertEquals("false", $this->entryLink->readOnly); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->entryLink->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->entryLink->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->entryLink->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->entryLink->extensionAttributes['foo2']['value']); - $entryLinkXml = $this->entryLink->saveXML(); - $newEntryLink = new Zend_Gdata_Extension_EntryLink(); - $newEntryLink->transferFromXML($entryLinkXml); - $this->assertEquals('bar', $newEntryLink->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newEntryLink->extensionAttributes['foo2']['value']); - } - - public function testConvertFullEntryLinkToAndFromString() { - $this->entryLink->transferFromXML($this->entryLinkText); - $this->assertEquals("http://gmail.com/jo/contacts/Jo", $this->entryLink->href); - $this->assertEquals("via", $this->entryLink->rel); - $this->assertEquals("true", $this->entryLink->readOnly); - $this->assertTrue($this->entryLink->entry instanceof Zend_Gdata_App_Entry); - $this->assertEquals("Jo March", $this->entryLink->entry->title->text); - } - -} diff --git a/tests/Zend/Gdata/EventStatusTest.php b/tests/Zend/Gdata/EventStatusTest.php deleted file mode 100644 index b3954caf488b2e25be7696465fbcedd43843982f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/EventStatusTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/EventStatus.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_EventStatusTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->eventStatusText = file_get_contents( - 'Zend/Gdata/_files/EventStatusElementSample1.xml', - true); - $this->eventStatus = new Zend_Gdata_Extension_EventStatus(); - } - - public function testEmptyEventStatusShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->eventStatus->extensionElements)); - $this->assertTrue(count($this->eventStatus->extensionElements) == 0); - } - - public function testEmptyEventStatusShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->eventStatus->extensionAttributes)); - $this->assertTrue(count($this->eventStatus->extensionAttributes) == 0); - } - - public function testSampleEventStatusShouldHaveNoExtensionElements() { - $this->eventStatus->transferFromXML($this->eventStatusText); - $this->assertTrue(is_array($this->eventStatus->extensionElements)); - $this->assertTrue(count($this->eventStatus->extensionElements) == 0); - } - - public function testSampleEventStatusShouldHaveNoExtensionAttributes() { - $this->eventStatus->transferFromXML($this->eventStatusText); - $this->assertTrue(is_array($this->eventStatus->extensionAttributes)); - $this->assertTrue(count($this->eventStatus->extensionAttributes) == 0); - } - - public function testNormalEventStatusShouldHaveNoExtensionElements() { - $this->eventStatus->value = "http://schemas.google.com/g/2005#event.tentative"; - - $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $this->eventStatus->value); - - $this->assertEquals(0, count($this->eventStatus->extensionElements)); - $newEventStatus = new Zend_Gdata_Extension_EventStatus(); - $newEventStatus->transferFromXML($this->eventStatus->saveXML()); - $this->assertEquals(0, count($newEventStatus->extensionElements)); - $newEventStatus->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newEventStatus->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $newEventStatus->value); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newEventStatus2 = $gdata->newEventStatus(); - $newEventStatus2->transferFromXML($newEventStatus->saveXML()); - $this->assertEquals(1, count($newEventStatus2->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $newEventStatus2->value); - } - - public function testEmptyEventStatusToAndFromStringShouldMatch() { - $eventStatusXml = $this->eventStatus->saveXML(); - $newEventStatus = new Zend_Gdata_Extension_EventStatus(); - $newEventStatus->transferFromXML($eventStatusXml); - $newEventStatusXml = $newEventStatus->saveXML(); - $this->assertTrue($eventStatusXml == $newEventStatusXml); - } - - public function testEventStatusWithValueToAndFromStringShouldMatch() { - $this->eventStatus->value = "http://schemas.google.com/g/2005#event.tentative"; - $eventStatusXml = $this->eventStatus->saveXML(); - $newEventStatus = new Zend_Gdata_Extension_EventStatus(); - $newEventStatus->transferFromXML($eventStatusXml); - $newEventStatusXml = $newEventStatus->saveXML(); - $this->assertTrue($eventStatusXml == $newEventStatusXml); - $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $this->eventStatus->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->eventStatus->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->eventStatus->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->eventStatus->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->eventStatus->extensionAttributes['foo2']['value']); - $eventStatusXml = $this->eventStatus->saveXML(); - $newEventStatus = new Zend_Gdata_Extension_EventStatus(); - $newEventStatus->transferFromXML($eventStatusXml); - $this->assertEquals('bar', $newEventStatus->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newEventStatus->extensionAttributes['foo2']['value']); - } - - public function testConvertFullEventStatusToAndFromString() { - $this->eventStatus->transferFromXML($this->eventStatusText); - $this->assertEquals("http://schemas.google.com/g/2005#event.confirmed", $this->eventStatus->value); - } - -} diff --git a/tests/Zend/Gdata/ExtendedPropertyTest.php b/tests/Zend/Gdata/ExtendedPropertyTest.php deleted file mode 100644 index 1d592b449ec4d207009419ebab04641a392926ca..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/ExtendedPropertyTest.php +++ /dev/null @@ -1,129 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/ExtendedProperty.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_ExtendedPropertyTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->extendedPropertyText = file_get_contents( - 'Zend/Gdata/_files/ExtendedPropertyElementSample1.xml', - true); - $this->extendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); - } - - public function testEmptyExtendedPropertyShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->extendedProperty->extensionElements)); - $this->assertTrue(count($this->extendedProperty->extensionElements) == 0); - } - - public function testEmptyExtendedPropertyShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->extendedProperty->extensionAttributes)); - $this->assertTrue(count($this->extendedProperty->extensionAttributes) == 0); - } - - public function testSampleExtendedPropertyShouldHaveNoExtensionElements() { - $this->extendedProperty->transferFromXML($this->extendedPropertyText); - $this->assertTrue(is_array($this->extendedProperty->extensionElements)); - $this->assertTrue(count($this->extendedProperty->extensionElements) == 0); - } - - public function testSampleExtendedPropertyShouldHaveNoExtensionAttributes() { - $this->extendedProperty->transferFromXML($this->extendedPropertyText); - $this->assertTrue(is_array($this->extendedProperty->extensionAttributes)); - $this->assertTrue(count($this->extendedProperty->extensionAttributes) == 0); - } - - public function testNormalExtendedPropertyShouldHaveNoExtensionElements() { - $this->extendedProperty->name = "http://www.example.com/schemas/2007#mycal.foo"; - $this->extendedProperty->value = "5678"; - - $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $this->extendedProperty->name); - $this->assertEquals("5678", $this->extendedProperty->value); - - $this->assertEquals(0, count($this->extendedProperty->extensionElements)); - $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); - $newExtendedProperty->transferFromXML($this->extendedProperty->saveXML()); - $this->assertEquals(0, count($newExtendedProperty->extensionElements)); - $newExtendedProperty->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newExtendedProperty->extensionElements)); - $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty->name); - $this->assertEquals("5678", $newExtendedProperty->value); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newExtendedProperty2 = $gdata->newExtendedProperty(); - $newExtendedProperty2->transferFromXML($newExtendedProperty->saveXML()); - $this->assertEquals(1, count($newExtendedProperty2->extensionElements)); - $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty2->name); - $this->assertEquals("5678", $newExtendedProperty2->value); - } - - public function testEmptyExtendedPropertyToAndFromStringShouldMatch() { - $extendedPropertyXml = $this->extendedProperty->saveXML(); - $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); - $newExtendedProperty->transferFromXML($extendedPropertyXml); - $newExtendedPropertyXml = $newExtendedProperty->saveXML(); - $this->assertTrue($extendedPropertyXml == $newExtendedPropertyXml); - } - - public function testExtendedPropertyWithValueToAndFromStringShouldMatch() { - $this->extendedProperty->name = "http://www.example.com/schemas/2007#mycal.foo"; - $this->extendedProperty->value = "5678"; - $extendedPropertyXml = $this->extendedProperty->saveXML(); - $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); - $newExtendedProperty->transferFromXML($extendedPropertyXml); - $newExtendedPropertyXml = $newExtendedProperty->saveXML(); - $this->assertTrue($extendedPropertyXml == $newExtendedPropertyXml); - $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $this->extendedProperty->name); - $this->assertEquals("5678", $this->extendedProperty->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->extendedProperty->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->extendedProperty->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->extendedProperty->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->extendedProperty->extensionAttributes['foo2']['value']); - $extendedPropertyXml = $this->extendedProperty->saveXML(); - $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); - $newExtendedProperty->transferFromXML($extendedPropertyXml); - $this->assertEquals('bar', $newExtendedProperty->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newExtendedProperty->extensionAttributes['foo2']['value']); - } - - public function testConvertFullExtendedPropertyToAndFromString() { - $this->extendedProperty->transferFromXML($this->extendedPropertyText); - $this->assertEquals("http://www.example.com/schemas/2007#mycal.id", $this->extendedProperty->name); - $this->assertEquals("1234", $this->extendedProperty->value); - } - -} diff --git a/tests/Zend/Gdata/FeedLinkTest.php b/tests/Zend/Gdata/FeedLinkTest.php deleted file mode 100644 index d1e4225620ea6c6ca76833d1f1acf13e8b60c611..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/FeedLinkTest.php +++ /dev/null @@ -1,145 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/FeedLink.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_FeedLinkTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedLinkText = file_get_contents( - 'Zend/Gdata/_files/FeedLinkElementSample1.xml', - true); - $this->feedLink = new Zend_Gdata_Extension_FeedLink(); - } - - public function testEmptyFeedLinkShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feedLink->extensionElements)); - $this->assertTrue(count($this->feedLink->extensionElements) == 0); - } - - public function testEmptyFeedLinkShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feedLink->extensionAttributes)); - $this->assertTrue(count($this->feedLink->extensionAttributes) == 0); - } - - public function testSampleFeedLinkShouldHaveNoExtensionElements() { - $this->feedLink->transferFromXML($this->feedLinkText); - $this->assertTrue(is_array($this->feedLink->extensionElements)); - $this->assertTrue(count($this->feedLink->extensionElements) == 0); - } - - public function testSampleFeedLinkShouldHaveNoExtensionAttributes() { - $this->feedLink->transferFromXML($this->feedLinkText); - $this->assertTrue(is_array($this->feedLink->extensionAttributes)); - $this->assertTrue(count($this->feedLink->extensionAttributes) == 0); - } - - public function testNormalFeedLinkShouldHaveNoExtensionElements() { - $this->feedLink->href = "http://www.google.com/calendar/feeds/default/private/full"; - $this->feedLink->rel = "via"; - $this->feedLink->countHint = "5"; - $this->feedLink->readOnly = "false"; - - $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $this->feedLink->href); - $this->assertEquals("via", $this->feedLink->rel); - $this->assertEquals("5", $this->feedLink->countHint); - $this->assertEquals("false", $this->feedLink->readOnly); - - $this->assertEquals(0, count($this->feedLink->extensionElements)); - $newFeedLink = new Zend_Gdata_Extension_FeedLink(); - $newFeedLink->transferFromXML($this->feedLink->saveXML()); - $this->assertEquals(0, count($newFeedLink->extensionElements)); - $newFeedLink->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newFeedLink->extensionElements)); - $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink->href); - $this->assertEquals("via", $newFeedLink->rel); - $this->assertEquals("5", $newFeedLink->countHint); - $this->assertEquals("false", $newFeedLink->readOnly); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newFeedLink2 = $gdata->newFeedLink(); - $newFeedLink2->transferFromXML($newFeedLink->saveXML()); - $this->assertEquals(1, count($newFeedLink2->extensionElements)); - $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink2->href); - $this->assertEquals("via", $newFeedLink2->rel); - $this->assertEquals("5", $newFeedLink2->countHint); - $this->assertEquals("false", $newFeedLink2->readOnly); - } - - public function testEmptyFeedLinkToAndFromStringShouldMatch() { - $feedLinkXml = $this->feedLink->saveXML(); - $newFeedLink = new Zend_Gdata_Extension_FeedLink(); - $newFeedLink->transferFromXML($feedLinkXml); - $newFeedLinkXml = $newFeedLink->saveXML(); - $this->assertTrue($feedLinkXml == $newFeedLinkXml); - } - - public function testFeedLinkWithValueToAndFromStringShouldMatch() { - $this->feedLink->href = "http://www.google.com/calendar/feeds/default/private/full"; - $this->feedLink->rel = "via"; - $this->feedLink->countHint = "5"; - $this->feedLink->readOnly = "false"; - $feedLinkXml = $this->feedLink->saveXML(); - $newFeedLink = new Zend_Gdata_Extension_FeedLink(); - $newFeedLink->transferFromXML($feedLinkXml); - $newFeedLinkXml = $newFeedLink->saveXML(); - $this->assertTrue($feedLinkXml == $newFeedLinkXml); - $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $this->feedLink->href); - $this->assertEquals("via", $this->feedLink->rel); - $this->assertEquals("5", $this->feedLink->countHint); - $this->assertEquals("false", $this->feedLink->readOnly); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->feedLink->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->feedLink->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->feedLink->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->feedLink->extensionAttributes['foo2']['value']); - $feedLinkXml = $this->feedLink->saveXML(); - $newFeedLink = new Zend_Gdata_Extension_FeedLink(); - $newFeedLink->transferFromXML($feedLinkXml); - $this->assertEquals('bar', $newFeedLink->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newFeedLink->extensionAttributes['foo2']['value']); - } - - public function testConvertFullFeedLinkToAndFromString() { - $this->feedLink->transferFromXML($this->feedLinkText); - $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full/3tsi3ag1q40bnsik88k25sgpss/comments", $this->feedLink->href); - $this->assertEquals("http://schemas.google.com/g/2005#feed", $this->feedLink->rel); - $this->assertEquals("0", $this->feedLink->countHint); - $this->assertEquals("true", $this->feedLink->readOnly); - $this->assertTrue($this->feedLink->feed instanceof Zend_Gdata_App_Feed); - $this->assertEquals("Comments for: Sample Event", $this->feedLink->feed->title->text); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListEntryTest.php b/tests/Zend/Gdata/Gapps/EmailListEntryTest.php deleted file mode 100644 index a5dd9319ad1a8420d1503bd019a2c63c960fc10d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListEntryTest.php +++ /dev/null @@ -1,135 +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_Gdata_Gapps - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/EmailListEntry.php'; -require_once 'Zend/Gdata/Gapps.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_EmailListEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_Gapps_EmailListEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($emailListEntry) { - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales', - $emailListEntry->id->text); - $this->assertEquals('1970-01-01T00:00:00.000Z', $emailListEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListEntry->category[0]->scheme); - $this->assertEquals('http://schemas.google.com/apps/2006#emailList', $emailListEntry->category[0]->term); - $this->assertEquals('text', $emailListEntry->title->type); - $this->assertEquals('us-sales', $emailListEntry->title->text);; - $this->assertEquals('self', $emailListEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $emailListEntry->getLink('self')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('self')->href); - $this->assertEquals('edit', $emailListEntry->getLink('edit')->rel); - $this->assertEquals('application/atom+xml', $emailListEntry->getLink('edit')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('edit')->href); - $this->assertEquals('us-sales', $emailListEntry->emailList->name); - $this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipients', $emailListEntry->getFeedLink('http://schemas.google.com/apps/2006#emailList.recipients')->rel); - $this->assertEquals('http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/', $emailListEntry->getFeedLink('http://schemas.google.com/apps/2006#emailList.recipients')->href); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyEmailListEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newEmailListEntry = new Zend_Gdata_Gapps_EmailListEntry(); - $newEmailListEntry->transferFromXML($entryXml); - $newEmailListEntryXml = $newEmailListEntry->saveXML(); - $this->assertTrue($entryXml == $newEmailListEntryXml); - } - - public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals(2, count($this->entry->feedLink)); - } - - public function testGetFeedLinkCanReturnEntriesByRelValue() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals($entry1, $this->entry->getFeedLink('first')); - $this->assertEquals($entry2, $this->entry->getFeedLink('second')); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertEmailListEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newEmailListEntry = new Zend_Gdata_Gapps_EmailListEntry(); - $newEmailListEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newEmailListEntry); - $newEmailListEntryXml = $newEmailListEntry->saveXML(); - $this->assertEquals($entryXml, $newEmailListEntryXml); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListFeedTest.php b/tests/Zend/Gdata/Gapps/EmailListFeedTest.php deleted file mode 100644 index 07dc46db17260f36bdcfa9e8fd9976a45ef95808..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListFeedTest.php +++ /dev/null @@ -1,104 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/EmailListFeed.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_EmailListFeedTest extends PHPUnit_Framework_TestCase -{ - protected $emailListFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $emailListFeedText = file_get_contents( - 'Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml', - true); - $this->emailListFeed = new Zend_Gdata_Gapps_EmailListFeed($emailListFeedText); - $this->emptyEmailListFeed = new Zend_Gdata_Gapps_EmailListFeed(); - } - - public function testEmptyFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emptyEmailListFeed->extensionElements)); - $this->assertTrue(count($this->emptyEmailListFeed->extensionElements) == 0); - } - - public function testEmptyFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emptyEmailListFeed->extensionAttributes)); - $this->assertTrue(count($this->emptyEmailListFeed->extensionAttributes) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emailListFeed->extensionElements)); - $this->assertTrue(count($this->emailListFeed->extensionElements) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emailListFeed->extensionAttributes)); - $this->assertTrue(count($this->emailListFeed->extensionAttributes) == 0); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testXmlImportAndOutputAreNonDestructive() - { - $entryCount = 0; - foreach ($this->emailListFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->emailListFeed and convert back to objects */ - $newEmailListFeed = new Zend_Gdata_Gapps_EmailListFeed( - $this->emailListFeed->saveXML()); - $newEntryCount = 0; - foreach ($newEmailListFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testAllEntriesInFeedAreInstantiated() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->emailListFeed as $entry) { - $entryCount++; - } - $this->assertEquals(2, $entryCount); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListQueryTest.php b/tests/Zend/Gdata/Gapps/EmailListQueryTest.php deleted file mode 100644 index 967da42a08e5e3a48ac0a68d4d6f797df57029f0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListQueryTest.php +++ /dev/null @@ -1,133 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/EmailListQuery.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_EmailListQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->query = new Zend_Gdata_Gapps_EmailListQuery(); - } - - // Test to make sure that URI generation works - public function testDefaultQueryURIGeneration() - { - $this->query->setDomain("foo.bar.invalid"); - $this->assertEquals("https://www.google.com/a/feeds/foo.bar.invalid/emailList/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the domain accessor methods work and propogate - // to the query URI. - public function testCanSetQueryDomain() - { - $this->query->setDomain("my.domain.com"); - $this->assertEquals("my.domain.com", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0", - $this->query->getQueryUrl()); - - $this->query->setDomain("hello.world.baz"); - $this->assertEquals("hello.world.baz", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/hello.world.baz/emailList/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the emailListName accessor methods work and propogate - // to the query URI. - public function testCanSetEmailListNameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setEmailListName("foo"); - $this->assertEquals("foo", $this->query->getEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/foo", - $this->query->getQueryUrl()); - - $this->query->setEmailListName("bar"); - $this->assertEquals("bar", $this->query->getEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/bar", - $this->query->getQueryUrl()); - } - - // Test to make sure that the recipient accessor methods work and propogate - // to the query URI. - public function testCanSetRecipientProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setRecipient("bar@qux.com"); - $this->assertEquals("bar@qux.com", $this->query->getRecipient()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0?recipient=bar%40qux.com", - $this->query->getQueryUrl()); - - $this->query->setRecipient(null); - $this->assertEquals(null, $this->query->getRecipient()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the startUsername accessor methods work and - // propogate to the query URI. - public function testCanSetStartEmailListNameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setStartEmailListName("foo"); - $this->assertEquals("foo", $this->query->getStartEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0?startEmailListName=foo", - $this->query->getQueryUrl()); - - $this->query->setStartEmailListName(null); - $this->assertEquals(null, $this->query->getStartEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that all parameters can be set simultaneously with no - // ill effects. - public function testCanSetAllParameters() - { - $this->query->setDomain("my.domain.com"); - $this->query->setEmailListName("foo"); - $this->query->setRecipient("bar@qux.com"); - $this->query->setStartEmailListName("wibble"); - $this->assertEquals("foo", $this->query->getEmailListName()); - $this->assertEquals("bar@qux.com", $this->query->getRecipient()); - $this->assertEquals("wibble", $this->query->getStartEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/foo?recipient=bar%40qux.com&startEmailListName=wibble", - $this->query->getQueryUrl()); - - $this->query->setRecipient("baz@blah.com"); - $this->query->setEmailListName("xyzzy"); - $this->query->setStartEmailListName("woof"); - $this->assertEquals("xyzzy", $this->query->getEmailListName()); - $this->assertEquals("baz@blah.com", $this->query->getRecipient()); - $this->assertEquals("woof", $this->query->getStartEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/xyzzy?recipient=baz%40blah.com&startEmailListName=woof", - $this->query->getQueryUrl()); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php b/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php deleted file mode 100644 index f0e52eee982ee2548c65455285ba5ddf14a4f23e..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php +++ /dev/null @@ -1,102 +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_Gdata_Gapps - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/EmailListRecipientEntry.php'; -require_once 'Zend/Gdata/Gapps.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_EmailListRecipientEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_Gapps_EmailListRecipientEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($emailListRecipientEntry) { - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', - $emailListRecipientEntry->id->text); - $this->assertEquals('1970-01-01T00:00:00.000Z', $emailListRecipientEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListRecipientEntry->category[0]->scheme); - $this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipient', $emailListRecipientEntry->category[0]->term); - $this->assertEquals('text', $emailListRecipientEntry->title->type); - $this->assertEquals('SusanJones', $emailListRecipientEntry->title->text);; - $this->assertEquals('self', $emailListRecipientEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('self')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('self')->href); - $this->assertEquals('edit', $emailListRecipientEntry->getLink('edit')->rel); - $this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('edit')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('edit')->href); - $this->assertEquals('SusanJones@example.com', $emailListRecipientEntry->who->email); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyEmailListRecipientEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newEmailListRecipientEntry = new Zend_Gdata_Gapps_EmailListRecipientEntry(); - $newEmailListRecipientEntry->transferFromXML($entryXml); - $newEmailListRecipientEntryXml = $newEmailListRecipientEntry->saveXML(); - $this->assertTrue($entryXml == $newEmailListRecipientEntryXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertEmailListRecipientEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newEmailListRecipientEntry = new Zend_Gdata_Gapps_EmailListRecipientEntry(); - $newEmailListRecipientEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newEmailListRecipientEntry); - $newEmailListRecipientEntryXml = $newEmailListRecipientEntry->saveXML(); - $this->assertEquals($entryXml, $newEmailListRecipientEntryXml); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php b/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php deleted file mode 100644 index e714af388b6ced27a406d6220a589d9ea0779d5c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php +++ /dev/null @@ -1,104 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/EmailListRecipientFeed.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_EmailListRecipientFeedTest extends PHPUnit_Framework_TestCase -{ - protected $emailListRecipientFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $emailListRecipientFeedText = file_get_contents( - 'Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml', - true); - $this->emailListRecipientFeed = new Zend_Gdata_Gapps_EmailListRecipientFeed($emailListRecipientFeedText); - $this->emptyEmailListRecipientFeed = new Zend_Gdata_Gapps_EmailListRecipientFeed(); - } - - public function testEmptyFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emptyEmailListRecipientFeed->extensionElements)); - $this->assertTrue(count($this->emptyEmailListRecipientFeed->extensionElements) == 0); - } - - public function testEmptyFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emptyEmailListRecipientFeed->extensionAttributes)); - $this->assertTrue(count($this->emptyEmailListRecipientFeed->extensionAttributes) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emailListRecipientFeed->extensionElements)); - $this->assertTrue(count($this->emailListRecipientFeed->extensionElements) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emailListRecipientFeed->extensionAttributes)); - $this->assertTrue(count($this->emailListRecipientFeed->extensionAttributes) == 0); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testXmlImportAndOutputAreNonDestructive() - { - $entryCount = 0; - foreach ($this->emailListRecipientFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListRecipientEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->emailListRecipientFeed and convert back to objects */ - $newEmailListRecipientFeed = new Zend_Gdata_Gapps_EmailListRecipientFeed( - $this->emailListRecipientFeed->saveXML()); - $newEntryCount = 0; - foreach ($newEmailListRecipientFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListRecipientEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testAllEntriesInFeedAreInstantiated() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->emailListRecipientFeed as $entry) { - $entryCount++; - } - $this->assertEquals(2, $entryCount); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php b/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php deleted file mode 100644 index 9dbf512dd6c3a2da1d47b30ae7977cc577aca472..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php +++ /dev/null @@ -1,85 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/EmailListRecipientQuery.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_EmailListRecipientQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->query = new Zend_Gdata_Gapps_EmailListRecipientQuery(); - } - - // Test to make sure that the domain accessor methods work and propogate - // to the query URI. - public function testCanSetQueryDomain() - { - $this->query->setEmailListName("something"); - $this->query->setDomain("my.domain.com"); - $this->assertEquals("my.domain.com", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/something/recipient/", - $this->query->getQueryUrl()); - - $this->query->setDomain("hello.world.baz"); - $this->assertEquals("hello.world.baz", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/hello.world.baz/emailList/2.0/something/recipient/", - $this->query->getQueryUrl()); - } - - // Test to make sure that the emailListName accessor methods work and propogate - // to the query URI. - public function testCanSetEmailListNameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setEmailListName("foo"); - $this->assertEquals("foo", $this->query->getEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/foo/recipient/", - $this->query->getQueryUrl()); - - $this->query->setEmailListName("bar"); - $this->assertEquals("bar", $this->query->getEmailListName()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/bar/recipient/", - $this->query->getQueryUrl()); - } - - public function testCanSetStartRecipientProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setEmailListName("foo"); - $this->query->setStartRecipient("bar"); - $this->assertEquals("bar", $this->query->getStartRecipient()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/foo/recipient/?startRecipient=bar", - $this->query->getQueryUrl()); - - $this->query->setStartRecipient(null); - $this->assertEquals(null, $this->query->getStartRecipient()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/emailList/2.0/foo/recipient/", - $this->query->getQueryUrl()); - } - -} diff --git a/tests/Zend/Gdata/Gapps/EmailListTest.php b/tests/Zend/Gdata/Gapps/EmailListTest.php deleted file mode 100644 index d3cb7684a9125e038b856a1455bbcecbf13191ec..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/EmailListTest.php +++ /dev/null @@ -1,123 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/Extension/EmailList.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Gapps_EmailListTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->emailListText = file_get_contents( - 'Zend/Gdata/Gapps/_files/EmailListElementSample1.xml', - true); - $this->emailList = new Zend_Gdata_Gapps_Extension_EmailList(); - } - - public function testEmptyEmailListShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emailList->extensionElements)); - $this->assertTrue(count($this->emailList->extensionElements) == 0); - } - - public function testEmptyEmailListShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emailList->extensionAttributes)); - $this->assertTrue(count($this->emailList->extensionAttributes) == 0); - } - - public function testSampleEmailListShouldHaveNoExtensionElements() { - $this->emailList->transferFromXML($this->emailListText); - $this->assertTrue(is_array($this->emailList->extensionElements)); - $this->assertTrue(count($this->emailList->extensionElements) == 0); - } - - public function testSampleEmailListShouldHaveNoExtensionAttributes() { - $this->emailList->transferFromXML($this->emailListText); - $this->assertTrue(is_array($this->emailList->extensionAttributes)); - $this->assertTrue(count($this->emailList->extensionAttributes) == 0); - } - - public function testNormalEmailListShouldHaveNoExtensionElements() { - $this->emailList->name = "test-name"; - - $this->assertEquals("test-name", $this->emailList->name); - - $this->assertEquals(0, count($this->emailList->extensionElements)); - $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); - $newEmailList->transferFromXML($this->emailList->saveXML()); - $this->assertEquals(0, count($newEmailList->extensionElements)); - $newEmailList->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newEmailList->extensionElements)); - $this->assertEquals("test-name", $newEmailList->name); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata_Gapps(); - $newEmailList2 = $gdata->newEmailList(); - $newEmailList2->transferFromXML($newEmailList->saveXML()); - $this->assertEquals(1, count($newEmailList2->extensionElements)); - $this->assertEquals("test-name", $newEmailList2->name); - } - - public function testEmptyEmailListToAndFromStringShouldMatch() { - $emailListXml = $this->emailList->saveXML(); - $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); - $newEmailList->transferFromXML($emailListXml); - $newEmailListXml = $newEmailList->saveXML(); - $this->assertTrue($emailListXml == $newEmailListXml); - } - - public function testEmailListWithValueToAndFromStringShouldMatch() { - $this->emailList->name = "test-name"; - $emailListXml = $this->emailList->saveXML(); - $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); - $newEmailList->transferFromXML($emailListXml); - $newEmailListXml = $newEmailList->saveXML(); - $this->assertTrue($emailListXml == $newEmailListXml); - $this->assertEquals("test-name", $this->emailList->name); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->emailList->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->emailList->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->emailList->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->emailList->extensionAttributes['foo2']['value']); - $emailListXml = $this->emailList->saveXML(); - $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); - $newEmailList->transferFromXML($emailListXml); - $this->assertEquals('bar', $newEmailList->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newEmailList->extensionAttributes['foo2']['value']); - } - - public function testConvertFullEmailListToAndFromString() { - $this->emailList->transferFromXML($this->emailListText); - $this->assertEquals("us-sales", $this->emailList->name); - } - -} diff --git a/tests/Zend/Gdata/Gapps/ErrorTest.php b/tests/Zend/Gdata/Gapps/ErrorTest.php deleted file mode 100644 index 92c4ee4fec7e8b0b0b97948769dc68d07aa74622..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/ErrorTest.php +++ /dev/null @@ -1,83 +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_Gdata_Gapps - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/Error.php'; -require_once 'Zend/Gdata/Gapps.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_ErrorTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->error = new Zend_Gdata_Gapps_Error(); - } - - public function testCanSetAndGetErrorCodeUsingConstant() { - $this->error->setErrorCode( - Zend_Gdata_Gapps_Error::INVALID_EMAIL_ADDRESS); - $this->assertEquals(Zend_Gdata_Gapps_Error::INVALID_EMAIL_ADDRESS, - $this->error->getErrorCode()); - } - - public function testCanSetAndGetErrorCodeUsingInteger() { - $this->error->setErrorCode(123); - $this->assertEquals(123, $this->error->getErrorCode()); - } - - public function testCanSetAndGetReason() { - $text = "The foo is missing a bar."; - $this->error->setReason($text); - $this->assertEquals($text, $this->error->getReason()); - } - - public function testCanSetAndGetInvalidInput() { - $text = "for___baz"; - $this->error->setInvalidInput($text); - $this->assertEquals($text, $this->error->getInvalidInput()); - } - - public function testContstructorAllowsSettingAllVariables() { - $this->error = new Zend_Gdata_Gapps_Error( - Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY, - "foo", "bar"); - $this->assertEquals(Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY, - $this->error->getErrorCode()); - $this->assertEquals("foo", $this->error->getReason()); - $this->assertEquals("bar", $this->error->getInvalidInput()); - } - - public function testToStringProvidesHelpfulMessage() { - $this->error->setErrorCode(Zend_Gdata_Gapps_Error::USER_SUSPENDED); - $this->error->setReason("The foo is missing a bar."); - $this->error->setInvalidInput("for___baz"); - $this->assertEquals("Error 1101: The foo is missing a bar.\n\tInvalid Input: \"for___baz\"", $this->error->__toString()); - - $this->error->setErrorCode(Zend_Gdata_Gapps_Error::UNKNOWN_ERROR); - $this->error->setReason("Unknown error."); - $this->error->setInvalidInput("blah"); - $this->assertEquals("Error 1000: Unknown error.\n\tInvalid Input: \"blah\"", $this->error->__toString()); - } - -} diff --git a/tests/Zend/Gdata/Gapps/LoginTest.php b/tests/Zend/Gdata/Gapps/LoginTest.php deleted file mode 100644 index 465d0c2c4248e8141812232ee78d35e308df3720..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/LoginTest.php +++ /dev/null @@ -1,166 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/Extension/Login.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Gapps_LoginTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->loginText = file_get_contents( - 'Zend/Gdata/Gapps/_files/LoginElementSample1.xml', - true); - $this->login = new Zend_Gdata_Gapps_Extension_Login(); - } - - public function testEmptyLoginShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->login->extensionElements)); - $this->assertTrue(count($this->login->extensionElements) == 0); - } - - public function testEmptyLoginShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->login->extensionAttributes)); - $this->assertTrue(count($this->login->extensionAttributes) == 0); - } - - public function testSampleLoginShouldHaveNoExtensionElements() { - $this->login->transferFromXML($this->loginText); - $this->assertTrue(is_array($this->login->extensionElements)); - $this->assertTrue(count($this->login->extensionElements) == 0); - } - - public function testSampleLoginShouldHaveNoExtensionAttributes() { - $this->login->transferFromXML($this->loginText); - $this->assertTrue(is_array($this->login->extensionAttributes)); - $this->assertTrue(count($this->login->extensionAttributes) == 0); - } - - public function testNormalLoginShouldHaveNoExtensionElements() { - $this->login->username = "johndoe"; - $this->login->password = "abcdefg1234567890"; - $this->login->hashFunctionName = "Foo"; - $this->login->suspended = true; - $this->login->admin = true; - $this->login->changePasswordAtNextLogin = true; - $this->login->agreedToTerms = false; - - $this->assertEquals("johndoe", $this->login->username); - $this->assertEquals("abcdefg1234567890", $this->login->password); - $this->assertEquals("Foo", $this->login->hashFunctionName); - $this->assertEquals(true, $this->login->suspended); - $this->assertEquals(true, $this->login->admin); - $this->assertEquals(true, $this->login->changePasswordAtNextLogin); - $this->assertEquals(false, $this->login->agreedToTerms); - - $this->assertEquals(0, count($this->login->extensionElements)); - $newLogin = new Zend_Gdata_Gapps_Extension_Login(); - $newLogin->transferFromXML($this->login->saveXML()); - $this->assertEquals(0, count($newLogin->extensionElements)); - $newLogin->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newLogin->extensionElements)); - $this->assertEquals("johndoe", $newLogin->username); - $this->assertEquals("abcdefg1234567890", $newLogin->password); - $this->assertEquals("Foo", $newLogin->hashFunctionName); - $this->assertEquals(true, $newLogin->suspended); - $this->assertEquals(true, $newLogin->admin); - $this->assertEquals(true, $newLogin->changePasswordAtNextLogin); - $this->assertEquals(false, $newLogin->agreedToTerms); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata_Gapps(); - $newLogin2 = $gdata->newLogin(); - $newLogin2->transferFromXML($newLogin->saveXML()); - $this->assertEquals(1, count($newLogin2->extensionElements)); - $this->assertEquals("johndoe", $newLogin2->username); - $this->assertEquals("abcdefg1234567890", $newLogin2->password); - $this->assertEquals("Foo", $newLogin2->hashFunctionName); - $this->assertEquals(true, $newLogin2->suspended); - $this->assertEquals(true, $newLogin2->admin); - $this->assertEquals(true, $newLogin2->changePasswordAtNextLogin); - $this->assertEquals(false, $newLogin2->agreedToTerms); - } - - public function testEmptyLoginToAndFromStringShouldMatch() { - $loginXml = $this->login->saveXML(); - $newLogin = new Zend_Gdata_Gapps_Extension_Login(); - $newLogin->transferFromXML($loginXml); - $newLoginXml = $newLogin->saveXML(); - $this->assertTrue($loginXml == $newLoginXml); - } - - public function testLoginWithValueToAndFromStringShouldMatch() { - $this->login->username = "johndoe"; - $this->login->password = "abcdefg1234567890"; - $this->login->hashFunctionName = "Foo"; - $this->login->suspended = true; - $this->login->admin = true; - $this->login->changePasswordAtNextLogin = true; - $this->login->agreedToTerms = false; - $loginXml = $this->login->saveXML(); - $newLogin = new Zend_Gdata_Gapps_Extension_Login(); - $newLogin->transferFromXML($loginXml); - $newLoginXml = $newLogin->saveXML(); - $this->assertTrue($loginXml == $newLoginXml); - $this->assertEquals("johndoe", $this->login->username); - $this->assertEquals("abcdefg1234567890", $this->login->password); - $this->assertEquals("Foo", $this->login->hashFunctionName); - $this->assertEquals(true, $this->login->suspended); - $this->assertEquals(true, $this->login->admin); - $this->assertEquals(true, $this->login->changePasswordAtNextLogin); - $this->assertEquals(false, $this->login->agreedToTerms); - - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->login->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->login->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->login->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->login->extensionAttributes['foo2']['value']); - $loginXml = $this->login->saveXML(); - $newLogin = new Zend_Gdata_Gapps_Extension_Login(); - $newLogin->transferFromXML($loginXml); - $this->assertEquals('bar', $newLogin->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newLogin->extensionAttributes['foo2']['value']); - } - - public function testConvertFullLoginToAndFromString() { - $this->login->transferFromXML($this->loginText); - $this->assertEquals("SusanJones-1321", $this->login->username); - $this->assertEquals("123\$\$abc", $this->login->password); - $this->assertEquals("SHA-1", $this->login->hashFunctionName); - $this->assertEquals(false, $this->login->suspended); - $this->assertEquals(false, $this->login->admin); - $this->assertEquals(false, $this->login->changePasswordAtNextLogin); - $this->assertEquals(true, $this->login->agreedToTerms); - } - -} diff --git a/tests/Zend/Gdata/Gapps/NameTest.php b/tests/Zend/Gdata/Gapps/NameTest.php deleted file mode 100644 index 391b4b7424621e57bf75231442aac98fee02cf94..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/NameTest.php +++ /dev/null @@ -1,130 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/Extension/Name.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Gapps_NameTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->theNameText = file_get_contents( - 'Zend/Gdata/Gapps/_files/NameElementSample1.xml', - true); - $this->theName = new Zend_Gdata_Gapps_Extension_Name(); - } - - public function testEmptyNameShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->theName->extensionElements)); - $this->assertTrue(count($this->theName->extensionElements) == 0); - } - - public function testEmptyNameShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->theName->extensionAttributes)); - $this->assertTrue(count($this->theName->extensionAttributes) == 0); - } - - public function testSampleNameShouldHaveNoExtensionElements() { - $this->theName->transferFromXML($this->theNameText); - $this->assertTrue(is_array($this->theName->extensionElements)); - $this->assertTrue(count($this->theName->extensionElements) == 0); - } - - public function testSampleNameShouldHaveNoExtensionAttributes() { - $this->theName->transferFromXML($this->theNameText); - $this->assertTrue(is_array($this->theName->extensionAttributes)); - $this->assertTrue(count($this->theName->extensionAttributes) == 0); - } - - public function testNormalNameShouldHaveNoExtensionElements() { - $this->theName->givenName = "John"; - $this->theName->familyName = "Doe"; - - $this->assertEquals("John", $this->theName->givenName); - $this->assertEquals("Doe", $this->theName->familyName); - - $this->assertEquals(0, count($this->theName->extensionElements)); - $newName = new Zend_Gdata_Gapps_Extension_Name(); - $newName->transferFromXML($this->theName->saveXML()); - $this->assertEquals(0, count($newName->extensionElements)); - $newName->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newName->extensionElements)); - $this->assertEquals("John", $newName->givenName); - $this->assertEquals("Doe", $newName->familyName); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata_Gapps(); - $newName2 = $gdata->newName(); - $newName2->transferFromXML($newName->saveXML()); - $this->assertEquals(1, count($newName2->extensionElements)); - $this->assertEquals("John", $newName2->givenName); - $this->assertEquals("Doe", $newName2->familyName); - } - - public function testEmptyNameToAndFromStringShouldMatch() { - $nameXml = $this->theName->saveXML(); - $newName = new Zend_Gdata_Gapps_Extension_Name(); - $newName->transferFromXML($nameXml); - $newNameXml = $newName->saveXML(); - $this->assertTrue($nameXml == $newNameXml); - } - - public function testNameWithValueToAndFromStringShouldMatch() { - $this->theName->givenName = "John"; - $this->theName->familyName = "Doe"; - $nameXml = $this->theName->saveXML(); - $newName = new Zend_Gdata_Gapps_Extension_Name(); - $newName->transferFromXML($nameXml); - $newNameXml = $newName->saveXML(); - $this->assertTrue($nameXml == $newNameXml); - $this->assertEquals("John", $this->theName->givenName); - $this->assertEquals("Doe", $this->theName->familyName); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->theName->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->theName->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->theName->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->theName->extensionAttributes['foo2']['value']); - $nameXml = $this->theName->saveXML(); - $newName = new Zend_Gdata_Gapps_Extension_Name(); - $newName->transferFromXML($nameXml); - $this->assertEquals('bar', $newName->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newName->extensionAttributes['foo2']['value']); - } - - public function testConvertFullNameToAndFromString() { - $this->theName->transferFromXML($this->theNameText); - $this->assertEquals("Susan", $this->theName->givenName); - $this->assertEquals("Jones", $this->theName->familyName); - } - -} diff --git a/tests/Zend/Gdata/Gapps/NicknameEntryTest.php b/tests/Zend/Gdata/Gapps/NicknameEntryTest.php deleted file mode 100644 index e92ba648371594d08e389c94228d7c4944529005..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/NicknameEntryTest.php +++ /dev/null @@ -1,107 +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_Gdata_Gapps - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/NicknameEntry.php'; -require_once 'Zend/Gdata/Gapps.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_NicknameEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_Gapps_NicknameEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($nicknameEntry) { - $this->assertEquals('https://www.google.com/a/feeds/example.com/nickname/2.0/Susy', - $nicknameEntry->id->text); - $this->assertEquals('1970-01-01T00:00:00.000Z', $nicknameEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $nicknameEntry->category[0]->scheme); - $this->assertEquals('http://schemas.google.com/apps/2006#nickname', $nicknameEntry->category[0]->term); - $this->assertEquals('text', $nicknameEntry->title->type); - $this->assertEquals('Susy', $nicknameEntry->title->text);; - $this->assertEquals('self', $nicknameEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $nicknameEntry->getLink('self')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/nickname/2.0/Susy', $nicknameEntry->getLink('self')->href); - $this->assertEquals('edit', $nicknameEntry->getLink('edit')->rel); - $this->assertEquals('application/atom+xml', $nicknameEntry->getLink('edit')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/nickname/2.0/Susy', $nicknameEntry->getLink('edit')->href); - $this->assertEquals('Susy', $nicknameEntry->nickname->name); - $this->assertEquals('SusanJones', $nicknameEntry->login->username); - $this->assertEquals(false, $nicknameEntry->login->suspended); - $this->assertEquals(false, $nicknameEntry->login->admin); - $this->assertEquals(false, $nicknameEntry->login->changePasswordAtNextLogin); - $this->assertEquals(true, $nicknameEntry->login->agreedToTerms); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyNicknameEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newNicknameEntry = new Zend_Gdata_Gapps_NicknameEntry(); - $newNicknameEntry->transferFromXML($entryXml); - $newNicknameEntryXml = $newNicknameEntry->saveXML(); - $this->assertTrue($entryXml == $newNicknameEntryXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertNicknameEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newNicknameEntry = new Zend_Gdata_Gapps_NicknameEntry(); - $newNicknameEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newNicknameEntry); - $newNicknameEntryXml = $newNicknameEntry->saveXML(); - $this->assertEquals($entryXml, $newNicknameEntryXml); - } - -} diff --git a/tests/Zend/Gdata/Gapps/NicknameFeedTest.php b/tests/Zend/Gdata/Gapps/NicknameFeedTest.php deleted file mode 100644 index dce0e5ab662fca7458586c8452ce572615e6a671..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/NicknameFeedTest.php +++ /dev/null @@ -1,104 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/NicknameFeed.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_NicknameFeedTest extends PHPUnit_Framework_TestCase -{ - protected $nicknameFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $nicknameFeedText = file_get_contents( - 'Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml', - true); - $this->nicknameFeed = new Zend_Gdata_Gapps_NicknameFeed($nicknameFeedText); - $this->emptyNicknameFeed = new Zend_Gdata_Gapps_NicknameFeed(); - } - - public function testEmptyFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emptyNicknameFeed->extensionElements)); - $this->assertTrue(count($this->emptyNicknameFeed->extensionElements) == 0); - } - - public function testEmptyFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emptyNicknameFeed->extensionAttributes)); - $this->assertTrue(count($this->emptyNicknameFeed->extensionAttributes) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->nicknameFeed->extensionElements)); - $this->assertTrue(count($this->nicknameFeed->extensionElements) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->nicknameFeed->extensionAttributes)); - $this->assertTrue(count($this->nicknameFeed->extensionAttributes) == 0); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testXmlImportAndOutputAreNonDestructive() - { - $entryCount = 0; - foreach ($this->nicknameFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_NicknameEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->nicknameFeed and convert back to objects */ - $newNicknameFeed = new Zend_Gdata_Gapps_NicknameFeed( - $this->nicknameFeed->saveXML()); - $newEntryCount = 0; - foreach ($newNicknameFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_NicknameEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testAllEntriesInFeedAreInstantiated() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->nicknameFeed as $entry) { - $entryCount++; - } - $this->assertEquals(2, $entryCount); - } - -} diff --git a/tests/Zend/Gdata/Gapps/NicknameQueryTest.php b/tests/Zend/Gdata/Gapps/NicknameQueryTest.php deleted file mode 100644 index 5f808a576d5a7687973184c90a561a3563e2997d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/NicknameQueryTest.php +++ /dev/null @@ -1,135 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/NicknameQuery.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_NicknameQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->query = new Zend_Gdata_Gapps_NicknameQuery(); - } - - // Test to make sure that URI generation works - public function testDefaultQueryURIGeneration() - { - $this->query->setDomain("foo.bar.invalid"); - $this->assertEquals("https://www.google.com/a/feeds/foo.bar.invalid/nickname/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the domain accessor methods work and propogate - // to the query URI. - public function testCanSetQueryDomain() - { - $this->query->setDomain("my.domain.com"); - $this->assertEquals("my.domain.com", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0", - $this->query->getQueryUrl()); - - $this->query->setDomain("hello.world.baz"); - $this->assertEquals("hello.world.baz", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/hello.world.baz/nickname/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the username accessor methods work and propogate - // to the query URI. - public function testCanSetUsernameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setUsername("foo"); - $this->assertEquals("foo", $this->query->getUsername()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0?username=foo", - $this->query->getQueryUrl()); - - $this->query->setUsername(null); - $this->assertEquals(null, $this->query->getUsername()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the nickname accessor methods work and propogate - // to the query URI. - public function testCanSetNicknameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setNickname("foo"); - $this->assertEquals("foo", $this->query->getNickname()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0/foo", - $this->query->getQueryUrl()); - - $this->query->setNickname("bar"); - $this->assertEquals("bar", $this->query->getNickname()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0/bar", - $this->query->getQueryUrl()); - } - - // Test to make sure that the startNickname accessor methods work and - // propogate to the query URI. - public function testCanSetStartNicknameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setNickname("foo"); - $this->query->setStartNickname("bar"); - $this->assertEquals("bar", $this->query->getStartNickname()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0/foo?startNickname=bar", - $this->query->getQueryUrl()); - - $this->query->setStartNickname(null); - $this->assertEquals(null, $this->query->getStartNickname()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0/foo", - $this->query->getQueryUrl()); - } - - - // Test to make sure that all parameters can be set simultaneously with no - // ill effects. - public function testCanSetAllParameters() - { - $this->query->setDomain("my.domain.com"); - $this->query->setNickname("foo"); - $this->query->setUsername("bar"); - $this->query->setStartNickname("baz"); - $this->assertEquals("foo", $this->query->getNickname()); - $this->assertEquals("bar", $this->query->getUsername()); - $this->assertEquals("baz", $this->query->getStartNickname()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0/foo?username=bar&startNickname=baz", - $this->query->getQueryUrl()); - - $this->query->setUsername("qux"); - $this->query->setNickname("baz"); - $this->query->setStartNickname("wibble"); - $this->assertEquals("baz", $this->query->getNickname()); - $this->assertEquals("qux", $this->query->getUsername()); - $this->assertEquals("wibble", $this->query->getStartNickname()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/nickname/2.0/baz?username=qux&startNickname=wibble", - $this->query->getQueryUrl()); - } - -} diff --git a/tests/Zend/Gdata/Gapps/NicknameTest.php b/tests/Zend/Gdata/Gapps/NicknameTest.php deleted file mode 100644 index f23d2bf805d29ceec5f1b597abc2c476ceaa8363..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/NicknameTest.php +++ /dev/null @@ -1,123 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/Extension/Nickname.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Gapps_NicknameTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->nicknameText = file_get_contents( - 'Zend/Gdata/Gapps/_files/NicknameElementSample1.xml', - true); - $this->nickname = new Zend_Gdata_Gapps_Extension_Nickname(); - } - - public function testEmptyNicknameShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->nickname->extensionElements)); - $this->assertTrue(count($this->nickname->extensionElements) == 0); - } - - public function testEmptyNicknameShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->nickname->extensionAttributes)); - $this->assertTrue(count($this->nickname->extensionAttributes) == 0); - } - - public function testSampleNicknameShouldHaveNoExtensionElements() { - $this->nickname->transferFromXML($this->nicknameText); - $this->assertTrue(is_array($this->nickname->extensionElements)); - $this->assertTrue(count($this->nickname->extensionElements) == 0); - } - - public function testSampleNicknameShouldHaveNoExtensionAttributes() { - $this->nickname->transferFromXML($this->nicknameText); - $this->assertTrue(is_array($this->nickname->extensionAttributes)); - $this->assertTrue(count($this->nickname->extensionAttributes) == 0); - } - - public function testNormalNicknameShouldHaveNoExtensionElements() { - $this->nickname->name = "Trogdor"; - - $this->assertEquals("Trogdor", $this->nickname->name); - - $this->assertEquals(0, count($this->nickname->extensionElements)); - $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); - $newNickname->transferFromXML($this->nickname->saveXML()); - $this->assertEquals(0, count($newNickname->extensionElements)); - $newNickname->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newNickname->extensionElements)); - $this->assertEquals("Trogdor", $newNickname->name); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata_Gapps(); - $newNickname2 = $gdata->newNickname(); - $newNickname2->transferFromXML($newNickname->saveXML()); - $this->assertEquals(1, count($newNickname2->extensionElements)); - $this->assertEquals("Trogdor", $newNickname2->name); - } - - public function testEmptyNicknameToAndFromStringShouldMatch() { - $nicknameXml = $this->nickname->saveXML(); - $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); - $newNickname->transferFromXML($nicknameXml); - $newNicknameXml = $newNickname->saveXML(); - $this->assertTrue($nicknameXml == $newNicknameXml); - } - - public function testNicknameWithValueToAndFromStringShouldMatch() { - $this->nickname->name = "Trogdor"; - $nicknameXml = $this->nickname->saveXML(); - $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); - $newNickname->transferFromXML($nicknameXml); - $newNicknameXml = $newNickname->saveXML(); - $this->assertTrue($nicknameXml == $newNicknameXml); - $this->assertEquals("Trogdor", $this->nickname->name); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->nickname->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->nickname->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->nickname->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->nickname->extensionAttributes['foo2']['value']); - $nicknameXml = $this->nickname->saveXML(); - $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); - $newNickname->transferFromXML($nicknameXml); - $this->assertEquals('bar', $newNickname->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newNickname->extensionAttributes['foo2']['value']); - } - - public function testConvertFullNicknameToAndFromString() { - $this->nickname->transferFromXML($this->nicknameText); - $this->assertEquals("Jones", $this->nickname->name); - } - -} diff --git a/tests/Zend/Gdata/Gapps/QuotaTest.php b/tests/Zend/Gdata/Gapps/QuotaTest.php deleted file mode 100644 index a3c1515c3f770b08f1262244b46441890a58e598..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/QuotaTest.php +++ /dev/null @@ -1,123 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/Extension/Quota.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_Gapps_QuotaTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->quotaText = file_get_contents( - 'Zend/Gdata/Gapps/_files/QuotaElementSample1.xml', - true); - $this->quota = new Zend_Gdata_Gapps_Extension_Quota(); - } - - public function testEmptyQuotaShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->quota->extensionElements)); - $this->assertTrue(count($this->quota->extensionElements) == 0); - } - - public function testEmptyQuotaShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->quota->extensionAttributes)); - $this->assertTrue(count($this->quota->extensionAttributes) == 0); - } - - public function testSampleQuotaShouldHaveNoExtensionElements() { - $this->quota->transferFromXML($this->quotaText); - $this->assertTrue(is_array($this->quota->extensionElements)); - $this->assertTrue(count($this->quota->extensionElements) == 0); - } - - public function testSampleQuotaShouldHaveNoExtensionAttributes() { - $this->quota->transferFromXML($this->quotaText); - $this->assertTrue(is_array($this->quota->extensionAttributes)); - $this->assertTrue(count($this->quota->extensionAttributes) == 0); - } - - public function testNormalQuotaShouldHaveNoExtensionElements() { - $this->quota->limit = "123456789"; - - $this->assertEquals("123456789", $this->quota->limit); - - $this->assertEquals(0, count($this->quota->extensionElements)); - $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); - $newQuota->transferFromXML($this->quota->saveXML()); - $this->assertEquals(0, count($newQuota->extensionElements)); - $newQuota->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newQuota->extensionElements)); - $this->assertEquals("123456789", $newQuota->limit); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata_Gapps(); - $newQuota2 = $gdata->newQuota(); - $newQuota2->transferFromXML($newQuota->saveXML()); - $this->assertEquals(1, count($newQuota2->extensionElements)); - $this->assertEquals("123456789", $newQuota2->limit); - } - - public function testEmptyQuotaToAndFromStringShouldMatch() { - $quotaXml = $this->quota->saveXML(); - $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); - $newQuota->transferFromXML($quotaXml); - $newQuotaXml = $newQuota->saveXML(); - $this->assertTrue($quotaXml == $newQuotaXml); - } - - public function testQuotaWithValueToAndFromStringShouldMatch() { - $this->quota->limit = "123456789"; - $quotaXml = $this->quota->saveXML(); - $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); - $newQuota->transferFromXML($quotaXml); - $newQuotaXml = $newQuota->saveXML(); - $this->assertTrue($quotaXml == $newQuotaXml); - $this->assertEquals("123456789", $this->quota->limit); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->quota->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->quota->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->quota->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->quota->extensionAttributes['foo2']['value']); - $quotaXml = $this->quota->saveXML(); - $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); - $newQuota->transferFromXML($quotaXml); - $this->assertEquals('bar', $newQuota->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newQuota->extensionAttributes['foo2']['value']); - } - - public function testConvertFullQuotaToAndFromString() { - $this->quota->transferFromXML($this->quotaText); - $this->assertEquals("2048", $this->quota->limit); - } - -} diff --git a/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php b/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php deleted file mode 100644 index 5af004d42564ca574fc788928f7409631bb4b959..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php +++ /dev/null @@ -1,124 +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_Gdata_Gapps - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'Zend/Gdata/Gapps/ServiceException.php'; -require_once 'Zend/Gdata/Gapps/Error.php'; -require_once 'Zend/Gdata/Gapps.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_ServiceExceptionTest extends PHPUnit_Framework_TestCase -{ - protected $fixture; - protected $data; - - public function setUp() { - $this->xmlSample = file_get_contents( - 'Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml', - true); - $this->fixture = new Zend_Gdata_Gapps_ServiceException(); - $this->data[1] = new Zend_Gdata_Gapps_Error(1234, "foo", "bar"); - $this->data[2] = new Zend_Gdata_Gapps_Error(4317, "blah", "woof"); - $this->data[3] = new Zend_Gdata_Gapps_Error(5978, "blue", "puppy"); - $this->data[4] = new Zend_Gdata_Gapps_Error(2398, "red", "kitten"); - } - - /** - * @expectedException Zend_Gdata_Gapps_ServiceException - */ - public function testCanThrowServiceException() { - throw $this->fixture; - } - - public function testCanSetAndGetErrorArray() { - $this->fixture->setErrors($this->data); - $incoming = $this->fixture->getErrors(); - $this->assertTrue(is_array($incoming)); - $this->assertEquals(count($this->data), count($incoming)); - foreach ($this->data as $i) { - $this->assertEquals($i, $incoming[$i->getErrorCode()]); - } - } - - public function testCanInsertSingleError() { - $this->fixture->setErrors($this->data); - $outgoing = new Zend_Gdata_Gapps_Error(1111, "a", "b"); - $this->fixture->addError($outgoing); - $result = $this->fixture->getError(1111); - $this->assertEquals($outgoing, $result); - } - - public function testCanSetPropertiesViaConstructor() { - $this->fixture = new Zend_Gdata_Gapps_ServiceException($this->data); - $incoming = $this->fixture->getErrors(); - $this->assertTrue(is_array($incoming)); - $this->assertEquals(count($this->data), count($incoming)); - foreach($this->data as $i) { - $this->assertEquals($i, $incoming[$i->getErrorCode()]); - } - } - - public function testCanRetrieveASpecificErrorByCode() { - $this->fixture->setErrors($this->data); - $result = $this->fixture->getError(5978); - $this->assertEquals($this->data[3], $result); - } - - public function testRetrievingNonexistantErrorCodeReturnsNull() { - $this->fixture->setErrors($this->data); - $result = $this->fixture->getError(0000); - $this->assertEquals(null, $result); - } - - public function testCanCheckIfAKeyExists() { - $this->fixture->setErrors($this->data); - $this->assertTrue($this->fixture->hasError(2398)); - $this->assertFalse($this->fixture->hasError(0000)); - } - - public function testCanConvertFromXML() { - $this->fixture->importFromString($this->xmlSample); - $incoming = $this->fixture->getErrors(); - $this->assertTrue(is_array($incoming)); - $this->assertEquals(3, count($incoming)); - $this->assertEquals("9925", $incoming[9925]->errorCode); - $this->assertEquals("Foo", $incoming[9925]->invalidInput); - $this->assertEquals("Bar", $incoming[9925]->reason); - } - - public function testCanConvertToString() { - $this->fixture->setErrors($this->data); - $this->assertEquals("The server encountered the following errors processing the request: -Error 1234: foo -\tInvalid Input: \"bar\" -Error 4317: blah -\tInvalid Input: \"woof\" -Error 5978: blue -\tInvalid Input: \"puppy\" -Error 2398: red -\tInvalid Input: \"kitten\"", $this->fixture->__toString()); - } - -} diff --git a/tests/Zend/Gdata/Gapps/UserEntryTest.php b/tests/Zend/Gdata/Gapps/UserEntryTest.php deleted file mode 100644 index 2e6f21711cce15eedca5aa8e1931c8f75a563998..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/UserEntryTest.php +++ /dev/null @@ -1,140 +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_Gdata_Gapps - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps/UserEntry.php'; -require_once 'Zend/Gdata/Gapps.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_UserEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_Gapps_UserEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($userEntry) { - $this->assertEquals('https://www.google.com/a/feeds/example.com/user/2.0/SusanJones', - $userEntry->id->text); - $this->assertEquals('1970-01-01T00:00:00.000Z', $userEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $userEntry->category[0]->scheme); - $this->assertEquals('http://schemas.google.com/apps/2006#user', $userEntry->category[0]->term); - $this->assertEquals('text', $userEntry->title->type); - $this->assertEquals('SusanJones', $userEntry->title->text);; - $this->assertEquals('self', $userEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $userEntry->getLink('self')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/user/2.0/SusanJones', $userEntry->getLink('self')->href); - $this->assertEquals('edit', $userEntry->getLink('edit')->rel); - $this->assertEquals('application/atom+xml', $userEntry->getLink('edit')->type); - $this->assertEquals('https://www.google.com/a/feeds/example.com/user/2.0/SusanJones', $userEntry->getLink('edit')->href); - $this->assertEquals('SusanJones', $userEntry->login->username); - $this->assertEquals('Jones', $userEntry->name->familyName); - $this->assertEquals('Susan', $userEntry->name->givenName); - $this->assertEquals('http://schemas.google.com/apps/2006#user.nicknames', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.nicknames')->rel); - $this->assertEquals('https://www.google.com/a/feeds/example.com/nickname/2.0?username=Susy-1321', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.nicknames')->href); - $this->assertEquals('http://schemas.google.com/apps/2006#user.emailLists', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.emailLists')->rel); - $this->assertEquals('https://www.google.com/a/feeds/example.com/emailList/2.0?recipient=us-sales@example.com', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.emailLists')->href); - $this->assertEquals('2048', $userEntry->quota->limit); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyUserEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newUserEntry = new Zend_Gdata_Gapps_UserEntry(); - $newUserEntry->transferFromXML($entryXml); - $newUserEntryXml = $newUserEntry->saveXML(); - $this->assertTrue($entryXml == $newUserEntryXml); - } - - public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals(2, count($this->entry->feedLink)); - } - - public function testGetFeedLinkCanReturnEntriesByRelValue() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals($entry1, $this->entry->getFeedLink('first')); - $this->assertEquals($entry2, $this->entry->getFeedLink('second')); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertUserEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newUserEntry = new Zend_Gdata_Gapps_UserEntry(); - $newUserEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newUserEntry); - $newUserEntryXml = $newUserEntry->saveXML(); - $this->assertEquals($entryXml, $newUserEntryXml); - } - -} diff --git a/tests/Zend/Gdata/Gapps/UserFeedTest.php b/tests/Zend/Gdata/Gapps/UserFeedTest.php deleted file mode 100644 index 3c6c9740c49b7a03dddde4595b460e368f3ad3f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/UserFeedTest.php +++ /dev/null @@ -1,104 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/UserFeed.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_UserFeedTest extends PHPUnit_Framework_TestCase -{ - protected $userFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $userFeedText = file_get_contents( - 'Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml', - true); - $this->userFeed = new Zend_Gdata_Gapps_UserFeed($userFeedText); - $this->emptyUserFeed = new Zend_Gdata_Gapps_UserFeed(); - } - - public function testEmptyFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->emptyUserFeed->extensionElements)); - $this->assertTrue(count($this->emptyUserFeed->extensionElements) == 0); - } - - public function testEmptyFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->emptyUserFeed->extensionAttributes)); - $this->assertTrue(count($this->emptyUserFeed->extensionAttributes) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->userFeed->extensionElements)); - $this->assertTrue(count($this->userFeed->extensionElements) == 0); - } - - public function testSampleFeedShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->userFeed->extensionAttributes)); - $this->assertTrue(count($this->userFeed->extensionAttributes) == 0); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of EventEntry and object count matches. - */ - public function testXmlImportAndOutputAreNonDestructive() - { - $entryCount = 0; - foreach ($this->userFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_UserEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->userFeed and convert back to objects */ - $newUserFeed = new Zend_Gdata_Gapps_UserFeed( - $this->userFeed->saveXML()); - $newEntryCount = 0; - foreach ($newUserFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Gapps_UserEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that there number of lsit feeds equals the number - * of calendars defined in the sample file. - */ - public function testAllEntriesInFeedAreInstantiated() - { - //TODO feeds implementing ArrayAccess would be helpful here - $entryCount = 0; - foreach ($this->userFeed as $entry) { - $entryCount++; - } - $this->assertEquals(2, $entryCount); - } - -} diff --git a/tests/Zend/Gdata/Gapps/UserQueryTest.php b/tests/Zend/Gdata/Gapps/UserQueryTest.php deleted file mode 100644 index 5c3acdad24993db25fd81fc0311b0da62582dc2d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/UserQueryTest.php +++ /dev/null @@ -1,93 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/UserQuery.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gapps_UserQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->query = new Zend_Gdata_Gapps_UserQuery(); - } - - // Test to make sure that URI generation works - public function testDefaultQueryURIGeneration() - { - $this->query->setDomain("foo.bar.invalid"); - $this->assertEquals("https://www.google.com/a/feeds/foo.bar.invalid/user/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the domain accessor methods work and propogate - // to the query URI. - public function testCanSetQueryDomain() - { - $this->query->setDomain("my.domain.com"); - $this->assertEquals("my.domain.com", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/user/2.0", - $this->query->getQueryUrl()); - - $this->query->setDomain("hello.world.baz"); - $this->assertEquals("hello.world.baz", $this->query->getDomain()); - $this->assertEquals("https://www.google.com/a/feeds/hello.world.baz/user/2.0", - $this->query->getQueryUrl()); - } - - // Test to make sure that the username accessor methods work and propogate - // to the query URI. - public function testCanSetUsernameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setUsername("foo"); - $this->assertEquals("foo", $this->query->getUsername()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/user/2.0/foo", - $this->query->getQueryUrl()); - - $this->query->setUsername("bar"); - $this->assertEquals("bar", $this->query->getUsername()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/user/2.0/bar", - $this->query->getQueryUrl()); - } - - // Test to make sure that the startUsername accessor methods work and - // propogate to the query URI. - public function testCanSetStartUsernameProperty() - { - $this->query->setDomain("my.domain.com"); - $this->query->setStartUsername("foo"); - $this->assertEquals("foo", $this->query->getStartUsername()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/user/2.0?startUsername=foo", - $this->query->getQueryUrl()); - - $this->query->setStartUsername(null); - $this->assertEquals(null, $this->query->getStartUsername()); - $this->assertEquals("https://www.google.com/a/feeds/my.domain.com/user/2.0", - $this->query->getQueryUrl()); - } - -} diff --git a/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml b/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml deleted file mode 100644 index e4ec89f42f02d9edbce94579d5100eea6c29d829..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<AppsForYourDomainErrors> - <error errorCode="1301" invalidInput="ZF-4699719c8e74c" reason="EntityDoesNotExist" /> - <error errorCode="9925" invalidInput="Foo" reason="Bar" /> - <error errorCode="5235" invalidInput="HelloWorld" reason="Blah" /> -</AppsForYourDomainErrors> diff --git a/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml b/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml deleted file mode 100644 index 09349e88f32fac05588652e2289f00563a0563b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<apps:emailList xmlns:apps="http://schemas.google.com/apps/2006" name="us-sales"/> diff --git a/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml deleted file mode 100644 index e241add76f00ff89cbfc35b1dcbe2a8bd3db8618..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:apps="http://schemas.google.com/apps/2006" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id>https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales</atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList"/> - <atom:title type="text">us-sales</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> - <atom:link rel="edit" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> - <apps:emailList name="us-sales"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#emailList.recipients" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/"/> -</atom:entry> diff --git a/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml deleted file mode 100644 index e61effbeaa6ab1df8687f11e943f09bc1a13fe48..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id> - http://www.google.com/a/feeds/example.com/emailList/2.0 - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList"/> - <atom:title type="text">EmailLists</atom:title> - <atom:link rel="next" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0?startEmailListName=john"/> - <atom:link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0"/> - <atom:link rel="http://schemas.google.com/g/2005#post" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0"/> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0"/> - <openSearch:startIndex>1</openSearch:startIndex> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList"/> - <atom:title type="text">us-sales</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> - <apps:emailList name="us-sales"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#emailList.recipients" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/"/> - </atom:entry> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/emailList/2.0/us-eng - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList"/> - <atom:title type="text">us-eng</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-eng"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-eng"/> - <apps:emailList name="us-eng"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#emailList.recipients" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-eng/recipient/"/> - </atom:entry> -</atom:feed> diff --git a/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml deleted file mode 100644 index 745b1869d576ce9d27e8e05ee47d441431706020..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:apps="http://schemas.google.com/apps/2006" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id>https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com</atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList.recipient"/> - <atom:title type="text">SusanJones</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com"/> - <atom:link rel="edit" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com"/> - <gd:who email="SusanJones@example.com"/> -</atom:entry> diff --git a/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml deleted file mode 100644 index 60ca3423cf3e74e84e9ff6e5d2875913e59be2c7..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id> - http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList.recipient"/> - <atom:title type="text">Recipients for email list us-sales</atom:title> - <atom:link rel="next" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/?startRecipient=terry@example.com"/> - <atom:link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient"/> - <atom:link rel="http://schemas.google.com/g/2005#post" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient"/> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient"/> - <openSearch:startIndex>1</openSearch:startIndex> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/joe%40example.com - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList.recipient"/> - <atom:title type="text">joe@example.com</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/joe%40example.com"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/joe%40example.com"/> - <gd:who email="joe@example.com"/> - </atom:entry> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/susan%40example.com - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#emailList.recipient"/> - <atom:title type="text">susan@example.com</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/susan%40example.com"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/susan%40example.com"/> - <gd:who email="susan@example.com"/> - </atom:entry> -</atom:feed> diff --git a/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml b/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml deleted file mode 100644 index f6971dc848b42d0b996725a35f9a385a54a3ee12..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<apps:login xmlns:apps="http://schemas.google.com/apps/2006" userName="SusanJones-1321" password="123$$abc" hashFunctionName="SHA-1" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> diff --git a/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml b/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml deleted file mode 100644 index 4b30681cb90c40d61e522fac22a0d78bf03635d4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<apps:name xmlns:apps="http://schemas.google.com/apps/2006" familyName="Jones" givenName="Susan"/> diff --git a/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml b/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml deleted file mode 100644 index a986073cfbe126aff5275ea465477f58d719874d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<apps:nickname xmlns:apps="http://schemas.google.com/apps/2006" name="Jones"/> diff --git a/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml deleted file mode 100644 index 306d51c08fd73810437ce7df97d1d345d46eb1b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:apps="http://schemas.google.com/apps/2006" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id>https://www.google.com/a/feeds/example.com/nickname/2.0/Susy</atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#nickname"/> - <atom:title type="text">Susy</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/nickname/2.0/Susy"/> - <atom:link rel="edit" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/nickname/2.0/Susy"/> - <apps:nickname name="Susy"/> - <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> -</atom:entry> diff --git a/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml deleted file mode 100644 index f93554e6f0239d3f746ec952dbf400878f7d74b7..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:apps="http://schemas.google.com/apps/2006"> - <atom:id> - http://www.google.com/a/feeds/example.com/nickname/2.0 - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#nickname"/> - <atom:title type="text">Nicknames for user SusanJones</atom:title> - <atom:link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0"/> - <atom:link rel="http://schemas.google.com/g/2005#post" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0"/> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0?username=SusanJones"/> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>2</openSearch:itemsPerPage> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/nickname/2.0/susy - </atom:id> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#nickname"/> - <atom:title type="text">susy</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0/susy"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0/susy"/> - <apps:nickname name="susy"/> - <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> - </atom:entry> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/nickname/2.0/suse - </atom:id> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#nickname"/> - <atom:title type="text">suse</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0/suse"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/nickname/2.0/suse"/> - <apps:nickname name="suse"/> - <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> - </atom:entry> -</atom:feed> diff --git a/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml b/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml deleted file mode 100644 index f516dbd7ef58fdc4b34dbf531e1fe8324fb4cddb..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<apps:quota xmlns:apps="http://schemas.google.com/apps/2006" limit="2048"/> diff --git a/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml deleted file mode 100644 index 6ef62f59b4981fba9fb4221000c04f365dd4b923..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:apps="http://schemas.google.com/apps/2006" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id>https://www.google.com/a/feeds/example.com/user/2.0/SusanJones</atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#user"/> - <atom:title type="text">SusanJones</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/user/2.0/SusanJones"/> - <atom:link rel="edit" type="application/atom+xml" - href="https://www.google.com/a/feeds/example.com/user/2.0/SusanJones"/> - <apps:login userName="SusanJones"/> - <apps:name familyName="Jones" givenName="Susan"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" - href="https://www.google.com/a/feeds/example.com/nickname/2.0?username=Susy-1321"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#user.emailLists" href="https://www.google.com/a/feeds/example.com/emailList/2.0?recipient=us-sales@example.com"/> - <apps:quota limit="2048"/> -</atom:entry> diff --git a/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml b/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml deleted file mode 100644 index 7f3fd4d626668bddf8b3559997ec638a5642c59f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:apps="http://schemas.google.com/apps/2006" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gd="http://schemas.google.com/g/2005"> - <atom:id> - http://www.google.com/a/feeds/example.com/user/2.0 - </atom:id> - <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#user"/> - <atom:title type="text">Users</atom:title> - <atom:link rel="next" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0?startUsername=john"/> - <atom:link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0"/> - <atom:link rel="http://schemas.google.com/g/2005#post" - type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0"/> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0"/> - <openSearch:startIndex>1</openSearch:startIndex> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/user/2.0/SusanJones - </atom:id> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#user"/> - <atom:title type="text">SusanJones</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0/SusanJones"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0/SusanJones"/> - <gd:who rel="http://schemas.google.com/apps/2006#user.recipient" - email="SusanJones@example.com"/> - <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> - <apps:quota limit="2048"/> - <apps:name familyName="Jones" givenName="Susan"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" - href="http://www.google.com/a/feeds/example.com/nickname/2.0?username=SusanJones"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#user.emailLists" - href="http://www.google.com/a/feeds/example.com/emailList/2.0?recipient=SusanJones@example.com"/> - </atom:entry> - <atom:entry> - <atom:id> - http://www.google.com/a/feeds/example.com/user/2.0/JohnSmith - </atom:id> - <atom:category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/apps/2006#user"/> - <atom:title type="text">JohnSmith</atom:title> - <atom:link rel="self" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0/JohnSmith"/> - <atom:link rel="edit" type="application/atom+xml" - href="http://www.google.com/a/feeds/example.com/user/2.0/JohnSmith"/> - <gd:who rel="http://schemas.google.com/apps/2006#user.recipient" - email="JohnSmith@example.com"/> - <apps:login userName="JohnSmith" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> - <apps:quota limit="2048"/> - <apps:name familyName="Smith" givenName="John"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" - href="http://www.google.com/a/feeds/example.com/nickname/2.0?username=JohnSmith"/> - <gd:feedLink rel="http://schemas.google.com/apps/2006#user.emailLists" - href="http://www.google.com/a/feeds/example.com/emailList/2.0?recipient=JohnSmith@example.com"/> - </atom:entry> -</atom:feed> diff --git a/tests/Zend/Gdata/GappsOnlineTest.php b/tests/Zend/Gdata/GappsOnlineTest.php deleted file mode 100644 index ae8290a0989f94bef36fbb70cafe3b6ce0ec7451..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/GappsOnlineTest.php +++ /dev/null @@ -1,499 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/Gapps/UserEntry.php'; -require_once 'Zend/Gdata/Gapps/UserQuery.php'; -require_once 'Zend/Gdata/ClientLogin.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_GappsOnlineTest extends PHPUnit_Framework_TestCase -{ - - const GIVEN_NAME = 'Zend_Gdata'; - const FAMILY_NAME = 'Automated Test Account'; - const PASSWORD = '4ohtladfl;'; - const PASSWORD_HASH = 'SHA-1'; - - public function setUp() - { - $this->id = uniqid('ZF-'); - $username = constant('TESTS_ZEND_GDATA_GAPPS_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_GAPPS_PASSWORD'); - $this->domain = constant('TESTS_ZEND_GDATA_GAPPS_DOMAIN'); - $client = Zend_Gdata_ClientLogin::getHttpClient($username, $pass, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); - $this->gdata = new Zend_Gdata_Gapps($client, $this->domain); - - // Container to hold users and lists created during tests. All entries in - // here will have delete() called during tear down. - // - // Failed deletions are okay, so add everying creatd in here, even if - // you plan to delete the user yourself! - $this->autoDeletePool = array(); - } - - public function tearDown() - { - // Delete all entries in $this->autoDeletePool. - foreach ($this->autoDeletePool as $x) { - try { - $x->delete(); - } catch (Exception $e) { - // Failed deletes are okay. Try and delete the rest anyway. - } - } - } - - // Schedule an entry for deletion at test tear-down. - protected function autoDelete($entry) { - $this->autoDeletePool[] = $entry; - } - - // Test Create/Read/Update/Destroy operations on a UserEntry - public function testUserCRUDOperations() { - // Create a new user - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Verify that returned values are correct - $this->assertEquals($this->id, $user->login->username); - $this->assertEquals(self::GIVEN_NAME, $user->name->givenName); - $this->assertEquals(self::FAMILY_NAME, $user->name->familyName); - - // Since we can't retrieve the password or hash function via the - // API, let's see if a ClientLogin auth request succeeds - try { - Zend_Gdata_ClientLogin::getHTTPClient($this->id . '@' . - $this->domain, self::PASSWORD, 'xapi'); - } catch (Zend_Gdata_App_AuthException $e) { - $this->fail("Unable to authenticate new user via ClientLogin."); - } - - // Check to make sure there are no extension elements/attributes - // in the retrieved user - $this->assertTrue(count($user->extensionElements) == 0); - $this->assertTrue(count($user->extensionAttributes) == 0); - - // Try searching for the same user and make sure that they're returned - $user2 = $this->gdata->retrieveUser($this->id); - $this->assertEquals($user->saveXML(), $user2->saveXML()); - - // Delete user (uses builtin delete method, convenience delete - // method tested further down) - $user->delete(); - - // Ensure that user was deleted - $deletedUser = $this->gdata->retrieveUser($this->id); - $this->assertNull($deletedUser); - } - - // Test to make sure that users with unicode characters can be created - // okay. - public function testUsersSupportUnicode() { - // Create a user - $user = $this->gdata->createUser($this->id, 'テスト', 'ユーザー', - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Make sure the user is the same as returned by the server - $this->assertEquals('テスト', $user->name->givenName); - $this->assertEquals('ユーザー', $user->name->familyName); - } - - // Test to make sure that a page of users can be retrieved. - public function testRetrievePageOfUsers() { - $feed = $this->gdata->retrievePageOfUsers(); - $this->assertTrue(count($feed->entries) > 0); - } - - // Test to make sure that a page of users can be retrieved with a - // startUsername parameter. - public function testRetrievePageOfUsersWithStartingUsername() { - $feed = $this->gdata->retrievePageOfUsers(); - $this->assertTrue(count($feed->entries) > 0); - $username = $feed->entries[0]->login->username; - $feed = $this->gdata->retrievePageOfUsers($username); - $this->assertTrue(count($feed->entries) > 0); - } - - // Test to see if all users can be retrieved - // NOTE: This test may timeout if the domain used for testing contains - // many pages of users. - public function testRetrieveAllUsers() { - // Create 35 users to make sure that there's more than one page. - for ($i = 0; $i < 25; $i++) { - $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, - self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - } - - $feed = $this->gdata->retrieveAllUsers(); - $this->assertTrue(count($feed->entry) > 0); - } - - // Test to see if a user can be manually updated by calling updateUser(). - public function testManualUserEntryUpdate() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - $user->name->givenName = "Renamed"; - $user2 = $this->gdata->updateUser($this->id, $user); - $this->assertEquals("Renamed", $user2->name->givenName); - } - - // Test to see if a user can be suspended, then un-suspended - public function testCanSuspendAndRestoreUser() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - $returned = $this->gdata->suspendUser($this->id); - $user = $this->gdata->retrieveUser($this->id); - $this->assertEquals(true, $user->login->suspended); - $this->assertEquals($this->id, $returned->login->username); - - $returned = $this->gdata->restoreUser($this->id); - $user = $this->gdata->retrieveUser($this->id); - $this->assertEquals(false, $user->login->suspended); - $this->assertEquals($this->id, $returned->login->username); - } - - // Test the convenience delete method for users - public function testCanDeleteUser() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Assert that the user exists, just in case... - $rUser = $this->gdata->retrieveUser($this->id); - $this->assertNotNull($rUser); - - // Delete user - $this->gdata->deleteUser($this->id); - - // Ensure that user was deleted - $rUser = $this->gdata->retrieveUser($this->id); - $this->assertNull($rUser); - } - - public function testNicknameCRUDOperations() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Create nickname - // Apps will convert the nickname to lowercase on the server, so - // we just make sure the generated nickname is lowercase here to start - // to avoid confusion later on. - $generatedNickname = strtolower(uniqid('zf-nick-')); - $nickname = $this->gdata->createNickname($this->id, $generatedNickname); - $this->assertEquals($generatedNickname, $nickname->nickname->name); - $this->assertEquals($this->id, $nickname->login->username); - - // Retrieve nickname - $nickname = $this->gdata->retrieveNickname($generatedNickname); - $this->assertEquals($generatedNickname, $nickname->nickname->name); - $this->assertEquals($this->id, $nickname->login->username); - - // Delete nickname (uses builtin delete method, convenience delete - // method tested further down) - $nickname->delete(); - - // Ensure that nickname was deleted - $nickname = $this->gdata->retrieveNickname($generatedNickname); - $this->assertNull($nickname); - } - - public function testRetrieveNicknames() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, - self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Create 5 nicknames - for ($i = 0; $i < 5; $i++) { - $generatedNickname[$i] = strtolower(uniqid('zf-nick-')); - $this->gdata->createNickname($this->id, $generatedNickname[$i]); - } - - // Retrieve all nicknames for the test user and see if they match - $nicknameFeed = $this->gdata->retrieveNicknames($this->id); - $this->assertEquals(count($generatedNickname), count($nicknameFeed->entry)); - foreach ($nicknameFeed as $nicknameEntry) { - $searchResult = array_search($nicknameEntry->nickname->name, - $generatedNickname); - $this->assertNotSame(false, $searchResult); - unset($generatedNickname[$searchResult]); - } - $this->assertEquals(0, count($generatedNickname)); - } - - public function testRetrievePageOfNicknames() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, - self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Create 5 nicknames - for ($i = 0; $i < 5; $i++) { - $generatedNickname[$i] = strtolower(uniqid('zf-nick-')); - $this->gdata->createNickname($this->id, $generatedNickname[$i]); - } - - // Test to make sure that we receive at least 5 nicknames back - // from the server - $results = $this->gdata->retrievePageOfNicknames(); - $this->assertTrue(count($results->entry) >= 5); - } - - public function testRetrieveAllNicknames() { - // Create 3 users, each with 10 nicknames - for ($i = 0; $i < 3; $i++) { - $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, - self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - for ($j = 0; $j < 10; $j++) { - $generatedNickname = strtolower(uniqid('zf-nick-')); - $this->gdata->createNickname($user->login->username, $generatedNickname); - } - } - - // Test to make sure that we receive at least 5 nicknames back - // from the server - $results = $this->gdata->retrieveAllNicknames(); - $this->assertTrue(count($results->entry) >= 30); - } - - // Test the convenience delete method for nicknames - public function testCanDeleteNickname() { - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - $generatedNickname = strtolower(uniqid('zf-nick-')); - $this->gdata->createNickname($this->id, $generatedNickname); - - // Assert that the nickname exists, just in case... - $rNick = $this->gdata->retrieveNickname($generatedNickname); - $this->assertNotNull($rNick); - - // Delete nickname - $this->gdata->deleteNickname($generatedNickname); - - // Ensure that nickname was deleted - $rNick = $this->gdata->retrieveNickname($generatedNickname); - $this->assertNull($rNick); - } - - public function testEmailListCRUDOperations() { - // Create email list - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - $this->assertEquals($generatedListName, $list->emailList->name); - - // Retrieve email list - $query = $this->gdata->newEmailListQuery(); - $listFeed = $this->gdata->getEmailListFeed($query); - $entryCount = count($listFeed->entry); - $this->assertTrue($entryCount > 0); - - // Delete email list (uses builtin delete method, convenience delete - // method tested further down) - $list->delete(); - - // Ensure that nickname was deleted - $listFeed = $this->gdata->getEmailListFeed($query); - $this->assertEquals($entryCount - 1, count($listFeed->entry)); - } - - public function testCanAssignMultipleEmailListsToOneUser() { - // Create a user - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - - // Create two email lists - $listCount = 2; - - for ($i = 0; $i < $listCount; $i++) { - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - $this->gdata->addRecipientToEmailList($this->id, $generatedListName); - } - - // Make sure that the user is subscribed to both lists - $subscriptions = $this->gdata->retrieveEmailLists($this->id); - $this->assertEquals($listCount, count($subscriptions->entry)); - } - - public function testCanRetrievePageOfEmailLists() { - // Create an email list - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - - // Try retrieving the email list feed - $feed = $this->gdata->retrievePageOfEmailLists(); - $this->assertTrue(count($feed->entry) > 0); - } - - public function testCanRetrieveAllEmailLists() { - // Create a couple of users to make sure we don't hit the limit - // on the max number of email lists. - for ($i = 0; $i < 3; $i++) { - $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, self::FAMILY_NAME, - sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - } - - // Create a whole bunch of email lists to make sure we trigger - // paging. - for ($i = 0; $i < 30; $i++) { - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - } - - // Try retrieving the email list feed - $feed = $this->gdata->retrieveAllEmailLists(); - $this->assertTrue(count($feed->entry) >= 30); - } - - // Test the convenience delete method for email lists - public function testCanDeleteEmailList() { - // Create an email list - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - - // Assert that the email list exists, just in case... - $query = $this->gdata->newEmailListQuery(); - $query->setEmailListName($generatedListName); - $entry = $this->gdata->getEmailListEntry($query); - $this->assertNotNull($entry); - - // Delete nickname - $this->gdata->deleteEmailList($generatedListName); - - // Ensure that nickname was deleted - try { - $query = $this->gdata->newEmailListQuery(); - $query->setEmailListName($generatedListName); - $entry = $this->gdata->getEmailListEntry($query); - // This souldn't execute - $this->fail('Retrieving a non-existant email list entry didn\'t' . - 'raise exception.'); - } catch (Zend_Gdata_Gapps_ServiceException $e) { - if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { - // Dummy assertion just to say we tested something here. - $this->assertTrue(true); - } else { - // Exception thrown for an unexpected reason - throw $e; - } - } - } - - public function testCanRetrievePageOfRecipients() { - // Create a new email list - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - - // Create two users and assign them to the email list - $userCount = 2; - for ($i = 0; $i < $userCount; $i++) { - $generatedUsername = uniqid('ZF-'); - $user = $this->gdata->createUser($generatedUsername, - self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), - self::PASSWORD_HASH); - $this->autoDelete($user); - $this->gdata->addRecipientToEmailList($generatedUsername, - $generatedListName); - } - - // Retrieve recipients - $recipientFeed = - $this->gdata->retrievePageOfRecipients($generatedListName); - $this->assertTrue(count($recipientFeed->entry) == $userCount); - } - - public function testCanRetrievAllRecipients() { - // Create a new email list - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - - // Create enough users to trigger paging and assign them to the email - // list - $userCount = 30; - for ($i = 0; $i < $userCount; $i++) { - $generatedUsername = uniqid('ZF-'); - $user = $this->gdata->createUser($generatedUsername, - self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), - self::PASSWORD_HASH); - $this->autoDelete($user); - $this->gdata->addRecipientToEmailList($generatedUsername, - $generatedListName); - } - - // Retrieve recipients - $recipientFeed = - $this->gdata->retrieveAllRecipients($generatedListName); - $this->assertTrue(count($recipientFeed->entry) == $userCount); - } - - // Test the convenience delete method for email list recipients - public function testCanDeleteEmailListRecipient() { - // Create an email list - $generatedListName = strtolower(uniqid('zf-list-')); - $list = $this->gdata->createEmailList($generatedListName); - $this->autoDelete($list); - - // Create a user for the email list - $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, - self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); - $this->autoDelete($user); - $this->gdata->addRecipientToEmailList($this->id, $generatedListName); - - // Assert that the recipient exists, just in case... - $recipients = - $this->gdata->retrieveAllRecipients($generatedListName); - $this->assertTrue(count($recipients->entry) == 1); - - // Remove the user from the list - $this->gdata->removeRecipientFromEmailList($user->login->username, - $generatedListName); - - // Ensure that user was deleted - $recipients = - $this->gdata->retrieveAllRecipients($generatedListName); - $this->assertTrue(count($recipients->entry) == 0); - } - -} diff --git a/tests/Zend/Gdata/GappsTest.php b/tests/Zend/Gdata/GappsTest.php deleted file mode 100644 index 09011041745a360dbc62295a5fd147a01ba12d2c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/GappsTest.php +++ /dev/null @@ -1,61 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'TestHelper.php'; -require_once 'Zend/Gdata/Gapps.php'; -require_once 'Zend/Gdata/ClientLogin.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_GappsTest extends PHPUnit_Framework_TestCase -{ - const TEST_DOMAIN = 'nowhere.invalid'; - - public function setUp() - { - // These tests shouldn't be doing anything online, so we can use - // bogous auth credentials. - $this->gdata = new Zend_Gdata_Gapps(null, self::TEST_DOMAIN); - } - - public function testMagicFactoryProvidesQueriesWithDomains() { - $userQ = $this->gdata->newUserQuery(); - $this->assertTrue($userQ instanceof Zend_Gdata_Gapps_UserQuery); - $this->assertEquals(self::TEST_DOMAIN, $userQ->getDomain()); - $this->assertEquals(null, $userQ->getUsername()); - - $userQ = $this->gdata->newUserQuery('foo'); - $this->assertTrue($userQ instanceof Zend_Gdata_Gapps_UserQuery); - $this->assertEquals(self::TEST_DOMAIN, $userQ->getDomain()); - $this->assertEquals('foo', $userQ->getUsername()); - } - - public function testMagicFactoryLeavesNonQueriesAlone() { - $login = $this->gdata->newLogin('blah'); - $this->assertTrue($login instanceof Zend_Gdata_Gapps_Extension_Login); - $this->assertEquals('blah', $login->username); - } - -} \ No newline at end of file diff --git a/tests/Zend/Gdata/Gbase/BaseAttributeTest.php b/tests/Zend/Gdata/Gbase/BaseAttributeTest.php deleted file mode 100644 index d02c29ec804da2e5a8518778c9ca4f1c53d7a4dd..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/BaseAttributeTest.php +++ /dev/null @@ -1,58 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_BaseAttributeTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->baseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute(); - } - - public function testToAndFromString() - { - - $this->baseAttribute->setName('price'); - $this->baseAttribute->setText('10.99 USD'); - $this->baseAttribute->setType('floatUnit'); - - $this->assertTrue($this->baseAttribute->getName() == 'price'); - $this->assertTrue($this->baseAttribute->getText() == '10.99 USD'); - $this->assertTrue($this->baseAttribute->getType() == 'floatUnit'); - - $newBaseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute(); - $doc = new DOMDocument(); - $doc->loadXML($this->baseAttribute->saveXML()); - $newBaseAttribute->transferFromDom($doc->documentElement); - - $this->assertTrue($this->baseAttribute->getName() == $newBaseAttribute->getName()); - $this->assertTrue($this->baseAttribute->getText() == $newBaseAttribute->getText()); - $this->assertTrue($this->baseAttribute->getType() == $newBaseAttribute->getType()); - } - -} diff --git a/tests/Zend/Gdata/Gbase/ItemEntryTest.php b/tests/Zend/Gdata/Gbase/ItemEntryTest.php deleted file mode 100644 index 1acfdf03d667f2fe15ba9039c53fa8c482271b6b..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/ItemEntryTest.php +++ /dev/null @@ -1,62 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_ItemEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->itemEntry = new Zend_Gdata_Gbase_ItemEntry(); - } - - public function testToAndFromString() - { - $this->itemEntry->setItemType('products'); - $this->assertEquals($this->itemEntry->getItemType()->getText(), 'products'); - - $this->itemEntry->addGbaseAttribute('price', '10.99 USD', 'floatUnit'); - $baseAttribute = $this->itemEntry->getGbaseAttribute('price'); - $this->assertEquals(count($baseAttribute), 1); - $this->assertEquals($baseAttribute[0]->getName(), 'price'); - $this->assertEquals($baseAttribute[0]->getText(), '10.99 USD'); - $this->assertEquals($baseAttribute[0]->getType(), 'floatUnit'); - - $newItemEntry = new Zend_Gdata_Gbase_ItemEntry(); - $doc = new DOMDocument(); - $doc->loadXML($this->itemEntry->saveXML()); - $newItemEntry->transferFromDom($doc->documentElement); - $rowDataFromXML = $newItemEntry->getGbaseAttribute('price'); - - $this->assertEquals($this->itemEntry->getItemType()->getText(), $newItemEntry->getItemType()->getText()); - $this->assertEquals(count($rowDataFromXML), 1); - $this->assertEquals($rowDataFromXML[0]->getName(), 'price'); - $this->assertEquals($rowDataFromXML[0]->getText(), '10.99 USD'); - $this->assertEquals($rowDataFromXML[0]->getType(), 'floatUnit'); - } - -} diff --git a/tests/Zend/Gdata/Gbase/ItemFeedTest.php b/tests/Zend/Gdata/Gbase/ItemFeedTest.php deleted file mode 100644 index 7b92c463a9b72e4ace1f99a74e93a46091e54582..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/ItemFeedTest.php +++ /dev/null @@ -1,59 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_ItemFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->itemFeed = new Zend_Gdata_Gbase_ItemFeed( - file_get_contents('Zend/Gdata/Gbase/_files/TestDataGbaseItemFeedSample1.xml'), - true); - } - - public function testToAndFromString() - { - $this->assertEquals(count($this->itemFeed->entries), 1); - foreach($this->itemFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_ItemEntry); - } - - $newItemFeed = new Zend_Gdata_Gbase_ItemFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->itemFeed->saveXML()); - $newItemFeed->transferFromDom($doc->documentElement); - - $this->assertEquals(count($newItemFeed->entries), 1); - foreach($newItemFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_ItemEntry); - } - } - -} diff --git a/tests/Zend/Gdata/Gbase/ItemQueryTest.php b/tests/Zend/Gdata/Gbase/ItemQueryTest.php deleted file mode 100644 index 5bde85a0b452621717c7944304fe1f52adbc5e86..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/ItemQueryTest.php +++ /dev/null @@ -1,86 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Gdata/Gbase/ItemQuery.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_ItemQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->itemQuery = new Zend_Gdata_Gbase_ItemQuery(); - } - - public function testBq() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setBq('[title:PHP]'); - $this->assertEquals($this->itemQuery->getBq(), '[title:PHP]'); - } - - public function testRefine() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setRefine('true'); - $this->assertEquals($this->itemQuery->getRefine(), 'true'); - } - - public function testContent() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setContent('stats'); - $this->assertEquals($this->itemQuery->getContent(), 'stats'); - } - - public function testOrderBy() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setOrderBy('relevancy'); - $this->assertEquals($this->itemQuery->getOrderBy(), 'relevancy'); - } - - public function testSortOrder() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setOrderBy('descending'); - $this->assertEquals($this->itemQuery->getOrderBy(), 'descending'); - } - - public function testCrowdBy() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setCrowdBy('attribute:5,content:2,url'); - $this->assertEquals($this->itemQuery->getCrowdBy(), 'attribute:5,content:2,url'); - } - - public function testAdjust() - { - $this->itemQuery->resetParameters(); - $this->itemQuery->setAdjust('true'); - $this->assertEquals($this->itemQuery->getAdjust(), 'true'); - } -} diff --git a/tests/Zend/Gdata/Gbase/QueryTest.php b/tests/Zend/Gdata/Gbase/QueryTest.php deleted file mode 100644 index 334975607f7f936a5d41b6d449e31c3259aa5116..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/QueryTest.php +++ /dev/null @@ -1,44 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Gdata/Gbase/Query.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_QueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->query = new Zend_Gdata_Gbase_Query(); - } - - public function testKey() - { - $this->query->setKey('xyz'); - $this->assertEquals($this->query->getKey(), 'xyz'); - } - -} diff --git a/tests/Zend/Gdata/Gbase/SnippetFeedTest.php b/tests/Zend/Gdata/Gbase/SnippetFeedTest.php deleted file mode 100644 index a1fcb91eaeba9f92af070e6bb80833e337824708..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/SnippetFeedTest.php +++ /dev/null @@ -1,59 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_SnippetFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->snippetFeed = new Zend_Gdata_Gbase_SnippetFeed( - file_get_contents('Zend/Gdata/Gbase/_files/TestDataGbaseSnippetFeedSample1.xml'), - true); - } - - public function testToAndFromString() - { - $this->assertEquals(count($this->snippetFeed->entries), 1); - foreach($this->snippetFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_SnippetEntry); - } - - $newSnippetFeed = new Zend_Gdata_Gbase_SnippetFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->snippetFeed->saveXML()); - $newSnippetFeed->transferFromDom($doc->documentElement); - - $this->assertEquals(count($newSnippetFeed->entries), 1); - foreach($newSnippetFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_SnippetEntry); - } - } - -} diff --git a/tests/Zend/Gdata/Gbase/SnippetQueryTest.php b/tests/Zend/Gdata/Gbase/SnippetQueryTest.php deleted file mode 100644 index a0b806c8e5124e992c99874f38e230bd93ad9bad..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/SnippetQueryTest.php +++ /dev/null @@ -1,87 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Gdata/Gbase/SnippetQuery.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Gbase_SnippetQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->snippetQuery = new Zend_Gdata_Gbase_SnippetQuery(); - } - - public function testBq() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setBq('[title:PHP]'); - $this->assertEquals($this->snippetQuery->getBq(), '[title:PHP]'); - } - - public function testRefine() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setRefine('true'); - $this->assertEquals($this->snippetQuery->getRefine(), 'true'); - } - - public function testContent() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setContent('stats'); - $this->assertEquals($this->snippetQuery->getContent(), 'stats'); - } - - public function testOrderBy() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setOrderBy('relevancy'); - $this->assertEquals($this->snippetQuery->getOrderBy(), 'relevancy'); - } - - public function testSortOrder() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setOrderBy('descending'); - $this->assertEquals($this->snippetQuery->getOrderBy(), 'descending'); - } - - public function testCrowdBy() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setCrowdBy('attribute:5,content:2,url'); - $this->assertEquals($this->snippetQuery->getCrowdBy(), 'attribute:5,content:2,url'); - } - - public function testAdjust() - { - $this->snippetQuery->resetParameters(); - $this->snippetQuery->setAdjust('true'); - $this->assertEquals($this->snippetQuery->getAdjust(), 'true'); - } - -} diff --git a/tests/Zend/Gdata/Gbase/_files/TestDataGbaseItemFeedSample1.xml b/tests/Zend/Gdata/Gbase/_files/TestDataGbaseItemFeedSample1.xml deleted file mode 100644 index 772a94744ede328df0c2f2f6955adf8b6e6048af..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/_files/TestDataGbaseItemFeedSample1.xml +++ /dev/null @@ -1,91 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> - <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gm='http://base.google.com/ns-metadata/1.0' xmlns:g='http://base.google.com/ns/1.0' xmlns:batch='http://schemas.google.com/gdata/batch'> - <id>http://www.google.com/base/feeds/items</id> - <updated>2007-09-15T00:08:42.580Z</updated> - <title type='text'>Items matching query: [customer id(int):1385111]</title> - <link rel='alternate' type='text/html' href='http://base.google.com'/> - <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/base/feeds/items'/> - <link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://www.google.com/base/feeds/items'/> - <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://www.google.com/base/feeds/items/batch'/> - <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/items?start-index=1&max-results=2'/> - <link rel='next' type='application/atom+xml' href='http://www.google.com/base/feeds/items?start-index=3&max-results=2'/> - <author> - <name>Google Inc.</name> - <email>base@google.com</email> - </author> - <generator version='1.0' uri='http://base.google.com'>GoogleBase</generator> - <openSearch:totalResults>9</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>2</openSearch:itemsPerPage> - <g:customer_id type='int'>1385111</g:customer_id> - <entry> - <id>http://www.google.com/base/feeds/items/1717711776806040891</id> - <published>2007-09-14T00:26:01.000Z</published> - <updated>2007-09-14T00:26:01.000Z</updated> - <category scheme='http://base.google.com/categories/itemtypes' term='Products'/> - <title type='text'>PHP Developer Handbook Second Edition</title> - <content type='html'>Essential handbook for PHP developers. This is a test item.</content> - <link rel='alternate' type='text/html' href='http://base.google.com/base/a/1385111/D1717711776806040891'/> - <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/items/1717711776806040891'/> - <link rel='edit' type='application/atom+xml' href='http://www.google.com/base/feeds/items/1717711776806040891'/> - <author> - <name>jacobm@google.com</name> - <email>anon-d2dp8lsofybp@base.google.com</email> - </author> - <g:item_type type='text'>Products</g:item_type> - <g:publisher type='text'>My Press</g:publisher> - <g:isbn type='text'>ISBN12345</g:isbn> - <g:condition type='text'>New</g:condition> - <g:published_date type='text'>Sep 2007</g:published_date> - <g:payment type='text'>Google Checkout</g:payment> - <g:upc type='text'>UPC12345</g:upc> - <g:brand type='text'>Oxford</g:brand> - <g:product_type type='text'>book</g:product_type> - <g:edition type='text'>First Edition</g:edition> - <g:year type='float'>2006.0</g:year> - <g:item_language type='text'>en</g:item_language> - <g:pages type='float'>253.0</g:pages> - <g:price type='floatUnit'>16.99 usd</g:price> - <g:target_country type='text'>US</g:target_country> - <g:customer_id type='int'>1385111</g:customer_id> - <g:customer_id type='int'>1385111</g:customer_id> - <g:quantity type='int'>10</g:quantity> - <g:author type='text'>John Doe</g:author> - <g:weight type='floatUnit'>2.2 lbs</g:weight> - <g:expiration_date type='dateTime'>2007-10-14T00:26:01.000Z</g:expiration_date> - </entry> - <entry> - <id>http://www.google.com/base/feeds/items/5366131833179111427</id> - <published>2007-09-14T00:32:03.000Z</published> - <updated>2007-09-14T00:32:04.000Z</updated> - <category scheme='http://base.google.com/categories/itemtypes' term='Products'/> - <title type='text'>PHP Developer Handbook Second Edition</title> - <content type='html'>Essential handbook for PHP developers. This is a test item.</content> - <link rel='alternate' type='text/html' href='http://base.google.com/base/a/1385111/D5366131833179111427'/> - <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/items/5366131833179111427'/> - <link rel='edit' type='application/atom+xml' href='http://www.google.com/base/feeds/items/5366131833179111427'/> - <author> - <name>jacobm@google.com</name> - <email>anon-d2dp8lsofybp@base.google.com</email> - </author> - <g:item_type type='text'>Products</g:item_type> - <g:isbn type='text'>ISBN12345</g:isbn> - <g:publisher type='text'>My Press</g:publisher> - <g:condition type='text'>New</g:condition> - <g:payment type='text'>Google Checkout</g:payment> - <g:upc type='text'>UPC12345</g:upc> - <g:edition type='text'>First Edition</g:edition> - <g:product_type type='text'>book</g:product_type> - <g:year type='float'>2006.0</g:year> - <g:item_language type='text'>en</g:item_language> - <g:pages type='float'>253.0</g:pages> - <g:price type='floatUnit'>12.99 usd</g:price> - <g:target_country type='text'>US</g:target_country> - <g:customer_id type='int'>1385111</g:customer_id> - <g:customer_id type='int'>1385111</g:customer_id> - <g:quantity type='int'>10</g:quantity> - <g:author type='text'>John Doe</g:author> - <g:weight type='floatUnit'>2.2 lbs</g:weight> - <g:expiration_date type='dateTime'>2007-10-14T00:32:03.000Z</g:expiration_date> - </entry> - </feed> \ No newline at end of file diff --git a/tests/Zend/Gdata/Gbase/_files/TestDataGbaseSnippetFeedSample1.xml b/tests/Zend/Gdata/Gbase/_files/TestDataGbaseSnippetFeedSample1.xml deleted file mode 100644 index 3422bfcc87b79575f64744cdf61bb4d5eb52742b..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Gbase/_files/TestDataGbaseSnippetFeedSample1.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> - <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gm='http://base.google.com/ns-metadata/1.0' xmlns:g='http://base.google.com/ns/1.0' xmlns:batch='http://schemas.google.com/gdata/batch'> - <id>http://www.google.com/base/feeds/snippets</id> - <updated>2007-09-15T00:09:38.999Z</updated> - <title type='text'>Items matching query: [title:PHP book]</title> - <link rel='alternate' type='text/html' href='http://base.google.com'/> - <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets'/> - <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/batch'/> - <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets?start-index=1&max-results=2&bq=%5Btitle%3APHP+book%5D'/> - <link rel='next' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets?start-index=3&max-results=2&bq=%5Btitle%3APHP+book%5D'/> - <author> - <name>Google Inc.</name> - <email>base@google.com</email> - </author> - <generator version='1.0' uri='http://base.google.com'>GoogleBase</generator> - <openSearch:totalResults>191</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>2</openSearch:itemsPerPage> - <entry> - <id>http://www.google.com/base/feeds/snippets/12314974507194001735</id> - <published>2007-06-06T07:02:31.000Z</published> - <updated>2007-09-14T07:48:53.000Z</updated> - <category scheme='http://base.google.com/categories/itemtypes' term='Products'/> - <title type='text'>The Zend PHP Certification Practice Test Book: Practice Questions for the Zend Certified Engineer Exam</title> - <content type='html'>John Coggeshall, Marco Tabini,Paperback, English-language edition,Pages:152,Pub BY Marco Tabini & Associates,</content> - <link rel='alternate' type='text/html' href='http://search.barnesandnoble.com/booksearch/isbninquiry.asp?sourceid=Q000000630&ean=9780973589887'/> - <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/12314974507194001735'/> - <author> - <name>Barnes & Noble.com</name> - <email>anon-h0z4ch9cz5h5@base.google.com</email> - </author> - <g:item_type type='text'>Products</g:item_type> - <g:image_link type='url'>http://images.barnesandnoble.com.edgesuite.net/images/8950000/8957260.gif</g:image_link> - <g:publisher type='text'>Marco Tabini & Associates,</g:publisher> - <g:isbn type='text'>0973589884</g:isbn> - <g:condition type='text'>new</g:condition> - <g:id type='text'>9780973589887</g:id> - <g:product_type type='text'>books</g:product_type> - <g:item_language type='text'>EN</g:item_language> - <g:pages type='int'>152</g:pages> - <g:price type='floatUnit'>21.99 usd</g:price> - <g:target_country type='text'>US</g:target_country> - <g:customer_id type='int'>1165992</g:customer_id> - <g:genre type='text'>Computers</g:genre> - <g:binding type='text'>paperback</g:binding> - <g:author type='text'>Marco Tabini</g:author> - <g:author type='text'>John Coggeshall</g:author> - <g:expiration_date type='dateTime'>2007-10-14T07:48:53.000Z</g:expiration_date> - </entry> - <entry> - <id>http://www.google.com/base/feeds/snippets/17983316950426332176</id> - <published>2007-09-07T04:21:51.000Z</published> - <updated>2007-09-14T04:09:34.000Z</updated> - <category scheme='http://base.google.com/categories/itemtypes' term='Products'/> - <title type='text'>PHP 5 / MYSQL PROGRAMMING FOR THE ABSOLUTE - BOOK *NEW</title> - <content type='html'>Sysqsystems includes more than two million titles in its online database, with an inventory of 1.3 Million titles available for immediate delivery.</content> - <link rel='alternate' type='text/html' href='http://adfarm.mediaplex.com/ad/ck/711-5256-8196-2?loc=http%3A%2F%2Fcgi.ebay.com%2FPHP-5-MYSQL-PROGRAMMING-FOR-THE-ABSOLUTE-BOOK-NEW_W0QQitemZ200149840989QQcmdZViewItem'/> - <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/17983316950426332176'/> - <author> - <name>eBay</name> - <email>rcross@ebay.com</email> - </author> - <g:item_type type='text'>Products</g:item_type> - <g:item_language type='text'>EN</g:item_language> - <g:price type='floatUnit'>18.42 usd</g:price> - <g:target_country type='text'>US</g:target_country> - <g:image_link type='url'>http://thumbs.ebaystatic.com/pict/200149840989_1.jpg</g:image_link> - <g:category type='text'>Books>Nonfiction Books</g:category> - <g:customer_id type='int'>11729</g:customer_id> - <g:id type='text'>200149840989</g:id> - <g:expiration_date type='dateTime'>2007-10-14T04:09:34.000Z</g:expiration_date> - </entry> - </feed> \ No newline at end of file diff --git a/tests/Zend/Gdata/GbaseOnlineTest.php b/tests/Zend/Gdata/GbaseOnlineTest.php deleted file mode 100644 index b6d2f76b5321ea09fde5d9fae30543319241bf5f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/GbaseOnlineTest.php +++ /dev/null @@ -1,161 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Gbase.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/ClientLogin.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_GbaseOnlineTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $service = Zend_Gdata_Gbase::AUTH_SERVICE_NAME; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->gdata = new Zend_Gdata_Gbase($client); - } - - public function testGetGbaseItemFeed() - { - $feed = $this->gdata->getGbaseItemFeed(); - $this->assertTrue($feed instanceof Zend_Gdata_Gbase_ItemFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_ItemEntry); - $this->assertEquals($entry->getHttpClient(), $feed->getHttpClient()); - } - - $query = new Zend_Gdata_Gbase_ItemQuery(); - $feed = $this->gdata->getGbaseItemFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Gbase_ItemFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_ItemEntry); - $this->assertEquals($entry->getHttpClient(), $feed->getHttpClient()); - } - - $uri = $query->getQueryUrl(); - $feed = $this->gdata->getGbaseItemFeed($uri); - $this->assertTrue($feed instanceof Zend_Gdata_Gbase_ItemFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_ItemEntry); - $this->assertEquals($entry->getHttpClient(), $feed->getHttpClient()); - } - } - - public function testGetGbaseItemEntry() - { - $newEntry = $this->gdata->newItemEntry(); - - $title = 'PHP Developer Handbook'; - $newEntry->title = $this->gdata->newTitle(trim($title)); - - $desc = 'This is a test item'; - $newEntry->content = $this->gdata->newContent($desc); - $newEntry->content->type = 'text'; - - $itemType = 'Products'; - $newEntry->itemType = $itemType; - $newEntry->itemType->type = 'text'; - - $newEntry->addGbaseAttribute('product_type', 'book', 'text'); - $newEntry->addGbaseAttribute('price', '12.99 usd', 'floatUnit'); - $newEntry->addGbaseAttribute('quantity', '10', 'int'); - - $createdEntry = $this->gdata->insertGbaseItem($newEntry, false); - $itemId = $createdEntry->id->text; - - $entry = $this->gdata->getGbaseItemEntry($itemId); - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_ItemEntry); - } - - public function testInsertGbaseItem() - { - $newEntry = $this->gdata->newItemEntry(); - - $title = 'PHP Developer Handbook'; - $newEntry->title = $this->gdata->newTitle(trim($title)); - - $desc = 'Essential handbook for PHP developers.'; - $newEntry->content = $this->gdata->newContent($desc); - $newEntry->content->type = 'text'; - - $itemType = 'Products'; - $newEntry->itemType = $itemType; - $newEntry->itemType->type = 'text'; - - $newEntry->addGbaseAttribute('product_type', 'book', 'text'); - $newEntry->addGbaseAttribute('price', '12.99 usd', 'floatUnit'); - $newEntry->addGbaseAttribute('quantity', '10', 'int'); - - $createdEntry = $this->gdata->insertGbaseItem($newEntry, true); - - $this->assertEquals($title, $createdEntry->title->text); - $this->assertEquals($desc, $createdEntry->content->text); - $this->assertEquals($itemType, $createdEntry->itemType->text); - - $baseAttribute = $createdEntry->getGbaseAttribute('product_type'); - $this->assertEquals('product_type', $baseAttribute[0]->name); - $this->assertEquals('book', $baseAttribute[0]->text); - $this->assertEquals('text', $baseAttribute[0]->type); - - $baseAttribute = $createdEntry->getGbaseAttribute('price'); - $this->assertEquals('price', $baseAttribute[0]->name); - $this->assertEquals('12.99 usd', $baseAttribute[0]->text); - $this->assertEquals('floatUnit', $baseAttribute[0]->type); - - $baseAttribute = $createdEntry->getGbaseAttribute('quantity'); - $this->assertEquals('quantity', $baseAttribute[0]->name); - $this->assertEquals('10', $baseAttribute[0]->text); - $this->assertEquals('int', $baseAttribute[0]->type); - } - - public function testGetGbaseSnippetFeed() - { - $feed = $this->gdata->getGbaseSnippetFeed(); - $this->assertTrue($feed instanceof Zend_Gdata_Gbase_SnippetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_SnippetEntry); - $this->assertEquals($entry->getHttpClient(), $feed->getHttpClient()); - } - - $query = new Zend_Gdata_Gbase_SnippetQuery(); - $feed = $this->gdata->getGbaseSnippetFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Gbase_SnippetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_SnippetEntry); - $this->assertEquals($entry->getHttpClient(), $feed->getHttpClient()); - } - - $uri = $query->getQueryUrl(); - $feed = $this->gdata->getGbaseSnippetFeed($uri); - $this->assertTrue($feed instanceof Zend_Gdata_Gbase_SnippetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Gbase_SnippetEntry); - $this->assertEquals($entry->getHttpClient(), $feed->getHttpClient()); - } - } - -} diff --git a/tests/Zend/Gdata/GdataOnlineTest.php b/tests/Zend/Gdata/GdataOnlineTest.php deleted file mode 100644 index ee915b13dc82e682ef25c7081209fc03932c315d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/GdataOnlineTest.php +++ /dev/null @@ -1,233 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata.php'; -require_once 'Zend/Gdata/App/MediaEntry.php'; -require_once 'Zend/Gdata/App/MediaFileSource.php'; -require_once 'Zend/Gdata/ClientLogin.php'; -require_once 'Zend/Gdata/App/InvalidArgumentException.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_GdataOnlineTest extends PHPUnit_Framework_TestCase -{ - private $blog = null; // blog ID from config - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $this->blog = constant('TESTS_ZEND_GDATA_BLOG_ID'); - $service = 'blogger'; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->gdata = new Zend_Gdata($client); - } - - public function testPostAndDeleteByEntry() - { - $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . - '/posts/default'; - $entry = $this->gdata->newEntry(); - $entry->title = $this->gdata->newTitle('PHP test blog post'); - $entry->content = $this->gdata->newContent('Blog post content...'); - $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); - $this->assertEquals('PHP test blog post', $insertedEntry->title->text); - $this->assertEquals('Blog post content...', - $insertedEntry->content->text); - $this->assertTrue( - strpos($insertedEntry->getEditLink()->href, 'http') === 0); - $this->gdata->delete($insertedEntry); - } - - public function testPostAndDeleteByUrl() - { - $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . - '/posts/default'; - $entry = $this->gdata->newEntry(); - $entry->title = $this->gdata->newTitle('PHP test blog post'); - $entry->content = $this->gdata->newContent('Blog post content...'); - $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); - $this->assertTrue( - strpos($insertedEntry->getEditLink()->href, 'http') === 0); - $this->gdata->delete($insertedEntry->getEditLink()->href); - } - - public function testPostRetrieveEntryAndDelete() - { - $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . - '/posts/default'; - $entry = $this->gdata->newEntry(); - $entry->title = $this->gdata->newTitle(' PHP test blog post '); - $this->assertTrue(isset($entry->title)); - $entry->content = $this->gdata->newContent('Blog post content...'); - - /* testing getText and __toString */ - $this->assertEquals("PHP test blog post", - $entry->title->getText()); - $this->assertEquals(" PHP test blog post ", - $entry->title->getText(false)); - $this->assertEquals($entry->title->getText(), - $entry->title->__toString()); - - $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); - $retrievedEntryQuery = $this->gdata->newQuery( - $insertedEntry->getSelfLink()->href); - $retrievedEntry = $this->gdata->getEntry($retrievedEntryQuery); - $this->assertTrue( - strpos($retrievedEntry->getEditLink()->href, 'http') === 0); - $this->gdata->delete($retrievedEntry); - } - - public function testPostUpdateAndDeleteEntry() - { - $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . - '/posts/default'; - $entry = $this->gdata->newEntry(); - $entry->title = $this->gdata->newTitle('PHP test blog post'); - $entry->content = $this->gdata->newContent('Blog post content...'); - $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); - $this->assertTrue( - strpos($insertedEntry->getEditLink()->href, 'http') === 0); - $insertedEntry->title->text = 'PHP test blog post modified'; - $updatedEntry = $this->gdata->updateEntry($insertedEntry); - $this->assertEquals('PHP test blog post modified', - $updatedEntry->title->text); - $updatedEntry->title->text = 'PHP test blog post modified twice'; - // entry->saveXML() and entry->getXML() should be the same - $this->assertEquals($updatedEntry->saveXML(), - $updatedEntry->getXML()); - $newlyUpdatedEntry = $this->gdata->updateEntry($updatedEntry); - $this->assertEquals('PHP test blog post modified twice', - $updatedEntry->title->text); - $updatedEntry->delete(); - } - - public function testFeedImplementation() - { - $blogsUrl = 'http://www.blogger.com/feeds/default/blogs'; - $blogsQuery = $this->gdata->newQuery($blogsUrl); - $retrievedFeed = $this->gdata->getFeed($blogsQuery); - - // Make sure the iterator and array impls match - $entry1 = $retrievedFeed->current(); - $entry2 = $retrievedFeed[0]; - $this->assertEquals($entry1, $entry2); - - /* - TODO: Fix these tests - // Test ArrayAccess interface - $firstBlogTitle = $retrievedFeed[0]->title->text; - $entries = $retrievedFeed->entry; - $entries[0]->title->text = $firstBlogTitle . "**"; - $retrievedFeed[0] = $entries[0]; - $this->assertEquals($retrievedFeed->entry[0]->title->text, - $retrievedFeed[0]->title->text); - $this->assertEquals($firstBlogTitle . "**", - $retrievedFeed[0]->title->text); - */ - } - - public function testBadFeedRetrieval() - { - $feed = $this->gdata->newFeed(); - try { - $returnedFeed = $this->gdata->getFeed($feed); - } catch (Zend_Gdata_App_InvalidArgumentException $e) { - // we're expecting to cause an exception here - } - } - - public function testBadEntryRetrieval() - { - $entry = $this->gdata->newEntry(); - try { - $returnedEntry = $this->gdata->getEntry($entry); - } catch (Zend_Gdata_App_InvalidArgumentException $e) { - // we're expecting to cause an exception here - } - } - - public function testMediaUpload() - { - // the standard sevice for GData testing is Blogger, due to the strong - // match to the standard GData/APP protocol. However, Blogger doesn't - // currently support media uploads, so we're using Picasa Web Albums - // for this test instead - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $this->blog = constant('TESTS_ZEND_GDATA_BLOG_ID'); - $service = 'lh2'; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $gd = new Zend_Gdata($client); - - // setup the photo content - $fs = $gd->newMediaFileSource('Zend/Gdata/_files/testImage.jpg'); - $fs->setContentType('image/jpeg'); - - - // create a new picasa album - $albumEntry = $gd->newEntry(); - $albumEntry->setTitle($gd->newTitle('My New Test Album')); - $albumEntry->setCategory(array($gd->newCategory( - 'http://schemas.google.com/photos/2007#album', - 'http://schemas.google.com/g/2005#kind' - ))); - $createdAlbumEntry = $gd->insertEntry($albumEntry, - 'http://picasaweb.google.com/data/feed/api/user/default'); - $this->assertEquals('My New Test Album', - $createdAlbumEntry->title->text); - $albumUrl = $createdAlbumEntry->getLink('http://schemas.google.com/g/2005#feed')->href; - - // post the photo to the new album, without any metadata - // other than the slug - // add a slug header to the media file source - $fs->setSlug('Going to the park'); - $createdPhotoBinaryOnly = $gd->insertEntry($fs, $albumUrl); - $this->assertEquals('Going to the park', - $createdPhotoBinaryOnly->title->text); - - // post the photo to the new album along with the entry - // remove slug header from the media file source - $fs->setSlug(null); - - // setup an entry with metadata - $mediaEntry = $gd->newMediaEntry(); - $mediaEntry->setMediaSource($fs); - - $mediaEntry->setTitle($gd->newTitle('My New Test Photo')); - $mediaEntry->setSummary($gd->newSummary('My New Test Photo Summary')); - $mediaEntry->setCategory(array($gd->newCategory( - 'http://schemas.google.com/photos/2007#photo ', - 'http://schemas.google.com/g/2005#kind' - ))); - $createdPhotoMultipart = $gd->insertEntry($mediaEntry, $albumUrl); - $this->assertEquals('My New Test Photo', - $createdPhotoMultipart->title->text); - - } - -} diff --git a/tests/Zend/Gdata/GdataTest.php b/tests/Zend/Gdata/GdataTest.php deleted file mode 100644 index cce204e636d810fec3da229f73bdcb9794541d42..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/GdataTest.php +++ /dev/null @@ -1,96 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_GdataTest extends PHPUnit_Framework_TestCase -{ - - public function testDefaultHttpClient() - { - $gdata = new Zend_Gdata(); - $client = $gdata->getHttpClient(); - $this->assertTrue($client instanceof Zend_Http_Client, - 'Expecting object of type Zend_Http_Client, got ' - . (gettype($client) == 'object' ? get_class($client) : gettype($client)) - ); - } - - public function testSpecificHttpClient() - { - $client = new Zend_Http_Client(); - $gdata = new Zend_Gdata($client); - $client2 = $gdata->getHttpClient(); - $this->assertTrue($client2 instanceof Zend_Http_Client, - 'Expecting object of type Zend_Http_Client, got ' - . (gettype($client) == 'object' ? get_class($client) : gettype($client)) - ); - $this->assertSame($client, $client2); - } - - public function testExceptionNotHttpClient() - { - $obj = new ArrayObject(); - try { - $gdata = new Zend_Gdata($obj); - $this->fail('Expecting to catch Zend_Gdata_App_HttpException'); - } catch (Exception $e) { - $this->assertThat($e, $this->isInstanceOf('Zend_Gdata_App_HttpException'), - 'Expecting Zend_Gdata_App_HttpException, got '.get_class($e)); - $this->assertEquals('Argument is not an instance of Zend_Http_Client.', $e->getMessage()); - } - } - - public function testGetFeedExceptionInvalidLocationType() - { - $gdata = new Zend_Gdata(); - try { - // give it neither a string nor a Zend_Gdata_Query object, - // and see if it throws an exception. - $feed = $gdata->getFeed(new stdClass()); - $this->fail('Expecting to catch Zend_Gdata_App_InvalidArgumentException'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Gdata_App_InvalidArgumentException', $e, - 'Expecting Zend_Gdata_App_InvalidArgumentException, got '.get_class($e)); - $this->assertEquals('You must specify the location as either a string URI or a child of Zend_Gdata_Query', $e->getMessage()); - } - } - - public function testGetEntryExceptionInvalidLocationType() - { - $gdata = new Zend_Gdata(); - try { - // give it neither a string nor a Zend_Gdata_Query object, - // and see if it throws an exception. - $feed = $gdata->getEntry(new stdClass()); - $this->fail('Expecting to catch Zend_Gdata_App_InvalidArgumentException'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Gdata_App_InvalidArgumentException', $e, - 'Expecting Zend_Gdata_App_InvalidArgumentException, got '.get_class($e)); - $this->assertEquals('You must specify the location as either a string URI or a child of Zend_Gdata_Query', $e->getMessage()); - } - } - -} diff --git a/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php b/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php deleted file mode 100644 index 217ee82fc4a0dca8ccd6b0aaed2cac26d828f86a..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/OpenSearchItemsPerPage.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_OpenSearchItemsPerPageTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->openSearchItemsPerPageText = file_get_contents( - 'Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml', - true); - $this->openSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); - } - - public function testEmptyOpenSearchItemsPerPageShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionElements)); - $this->assertTrue(count($this->openSearchItemsPerPage->extensionElements) == 0); - } - - public function testEmptyOpenSearchItemsPerPageShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionAttributes)); - $this->assertTrue(count($this->openSearchItemsPerPage->extensionAttributes) == 0); - } - - public function testSampleOpenSearchItemsPerPageShouldHaveNoExtensionElements() { - $this->openSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPageText); - $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionElements)); - $this->assertTrue(count($this->openSearchItemsPerPage->extensionElements) == 0); - } - - public function testSampleOpenSearchItemsPerPageShouldHaveNoExtensionAttributes() { - $this->openSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPageText); - $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionAttributes)); - $this->assertTrue(count($this->openSearchItemsPerPage->extensionAttributes) == 0); - } - - public function testNormalOpenSearchItemsPerPageShouldHaveNoExtensionElements() { - $this->openSearchItemsPerPage->text = "200"; - - $this->assertEquals("200", $this->openSearchItemsPerPage->text); - - $this->assertEquals(0, count($this->openSearchItemsPerPage->extensionElements)); - $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); - $newOpenSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPage->saveXML()); - $this->assertEquals(0, count($newOpenSearchItemsPerPage->extensionElements)); - $newOpenSearchItemsPerPage->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newOpenSearchItemsPerPage->extensionElements)); - $this->assertEquals("200", $newOpenSearchItemsPerPage->text); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newOpenSearchItemsPerPage2 = $gdata->newOpenSearchItemsPerPage(); - $newOpenSearchItemsPerPage2->transferFromXML($newOpenSearchItemsPerPage->saveXML()); - $this->assertEquals(1, count($newOpenSearchItemsPerPage2->extensionElements)); - $this->assertEquals("200", $newOpenSearchItemsPerPage2->text); - } - - public function testEmptyOpenSearchItemsPerPageToAndFromStringShouldMatch() { - $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML(); - $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); - $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml); - $newOpenSearchItemsPerPageXml = $newOpenSearchItemsPerPage->saveXML(); - $this->assertTrue($openSearchItemsPerPageXml == $newOpenSearchItemsPerPageXml); - } - - public function testOpenSearchItemsPerPageWithValueToAndFromStringShouldMatch() { - $this->openSearchItemsPerPage->text = "200"; - $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML(); - $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); - $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml); - $newOpenSearchItemsPerPageXml = $newOpenSearchItemsPerPage->saveXML(); - $this->assertTrue($openSearchItemsPerPageXml == $newOpenSearchItemsPerPageXml); - $this->assertEquals("200", $this->openSearchItemsPerPage->text); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->openSearchItemsPerPage->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->openSearchItemsPerPage->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->openSearchItemsPerPage->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->openSearchItemsPerPage->extensionAttributes['foo2']['value']); - $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML(); - $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); - $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml); - $this->assertEquals('bar', $newOpenSearchItemsPerPage->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newOpenSearchItemsPerPage->extensionAttributes['foo2']['value']); - } - - public function testConvertFullOpenSearchItemsPerPageToAndFromString() { - $this->openSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPageText); - $this->assertEquals("25", $this->openSearchItemsPerPage->text); - } - -} diff --git a/tests/Zend/Gdata/OpenSearchStartIndexTest.php b/tests/Zend/Gdata/OpenSearchStartIndexTest.php deleted file mode 100644 index 65175564483a0beae3482621c2b65c79af9ade77..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/OpenSearchStartIndexTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/OpenSearchStartIndex.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_OpenSearchStartIndexTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->openSearchStartIndexText = file_get_contents( - 'Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml', - true); - $this->openSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); - } - - public function testEmptyOpenSearchStartIndexShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->openSearchStartIndex->extensionElements)); - $this->assertTrue(count($this->openSearchStartIndex->extensionElements) == 0); - } - - public function testEmptyOpenSearchStartIndexShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->openSearchStartIndex->extensionAttributes)); - $this->assertTrue(count($this->openSearchStartIndex->extensionAttributes) == 0); - } - - public function testSampleOpenSearchStartIndexShouldHaveNoExtensionElements() { - $this->openSearchStartIndex->transferFromXML($this->openSearchStartIndexText); - $this->assertTrue(is_array($this->openSearchStartIndex->extensionElements)); - $this->assertTrue(count($this->openSearchStartIndex->extensionElements) == 0); - } - - public function testSampleOpenSearchStartIndexShouldHaveNoExtensionAttributes() { - $this->openSearchStartIndex->transferFromXML($this->openSearchStartIndexText); - $this->assertTrue(is_array($this->openSearchStartIndex->extensionAttributes)); - $this->assertTrue(count($this->openSearchStartIndex->extensionAttributes) == 0); - } - - public function testNormalOpenSearchStartIndexShouldHaveNoExtensionElements() { - $this->openSearchStartIndex->text = "20"; - - $this->assertEquals("20", $this->openSearchStartIndex->text); - - $this->assertEquals(0, count($this->openSearchStartIndex->extensionElements)); - $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); - $newOpenSearchStartIndex->transferFromXML($this->openSearchStartIndex->saveXML()); - $this->assertEquals(0, count($newOpenSearchStartIndex->extensionElements)); - $newOpenSearchStartIndex->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newOpenSearchStartIndex->extensionElements)); - $this->assertEquals("20", $newOpenSearchStartIndex->text); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newOpenSearchStartIndex2 = $gdata->newOpenSearchStartIndex(); - $newOpenSearchStartIndex2->transferFromXML($newOpenSearchStartIndex->saveXML()); - $this->assertEquals(1, count($newOpenSearchStartIndex2->extensionElements)); - $this->assertEquals("20", $newOpenSearchStartIndex2->text); - } - - public function testEmptyOpenSearchStartIndexToAndFromStringShouldMatch() { - $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML(); - $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); - $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml); - $newOpenSearchStartIndexXml = $newOpenSearchStartIndex->saveXML(); - $this->assertTrue($openSearchStartIndexXml == $newOpenSearchStartIndexXml); - } - - public function testOpenSearchStartIndexWithValueToAndFromStringShouldMatch() { - $this->openSearchStartIndex->text = "20"; - $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML(); - $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); - $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml); - $newOpenSearchStartIndexXml = $newOpenSearchStartIndex->saveXML(); - $this->assertTrue($openSearchStartIndexXml == $newOpenSearchStartIndexXml); - $this->assertEquals("20", $this->openSearchStartIndex->text); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->openSearchStartIndex->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->openSearchStartIndex->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->openSearchStartIndex->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->openSearchStartIndex->extensionAttributes['foo2']['value']); - $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML(); - $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); - $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml); - $this->assertEquals('bar', $newOpenSearchStartIndex->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newOpenSearchStartIndex->extensionAttributes['foo2']['value']); - } - - public function testConvertFullOpenSearchStartIndexToAndFromString() { - $this->openSearchStartIndex->transferFromXML($this->openSearchStartIndexText); - $this->assertEquals("5", $this->openSearchStartIndex->text); - } - -} diff --git a/tests/Zend/Gdata/OpenSearchTotalResultsTest.php b/tests/Zend/Gdata/OpenSearchTotalResultsTest.php deleted file mode 100644 index b047fdab8dc1cbf002402ce571a854152e9a0dd6..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/OpenSearchTotalResultsTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/OpenSearchTotalResults.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_OpenSearchTotalResultsTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->openSearchTotalResultsText = file_get_contents( - 'Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml', - true); - $this->openSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); - } - - public function testEmptyOpenSearchTotalResultsShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->openSearchTotalResults->extensionElements)); - $this->assertTrue(count($this->openSearchTotalResults->extensionElements) == 0); - } - - public function testEmptyOpenSearchTotalResultsShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->openSearchTotalResults->extensionAttributes)); - $this->assertTrue(count($this->openSearchTotalResults->extensionAttributes) == 0); - } - - public function testSampleOpenSearchTotalResultsShouldHaveNoExtensionElements() { - $this->openSearchTotalResults->transferFromXML($this->openSearchTotalResultsText); - $this->assertTrue(is_array($this->openSearchTotalResults->extensionElements)); - $this->assertTrue(count($this->openSearchTotalResults->extensionElements) == 0); - } - - public function testSampleOpenSearchTotalResultsShouldHaveNoExtensionAttributes() { - $this->openSearchTotalResults->transferFromXML($this->openSearchTotalResultsText); - $this->assertTrue(is_array($this->openSearchTotalResults->extensionAttributes)); - $this->assertTrue(count($this->openSearchTotalResults->extensionAttributes) == 0); - } - - public function testNormalOpenSearchTotalResultsShouldHaveNoExtensionElements() { - $this->openSearchTotalResults->text = "42"; - - $this->assertEquals("42", $this->openSearchTotalResults->text); - - $this->assertEquals(0, count($this->openSearchTotalResults->extensionElements)); - $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); - $newOpenSearchTotalResults->transferFromXML($this->openSearchTotalResults->saveXML()); - $this->assertEquals(0, count($newOpenSearchTotalResults->extensionElements)); - $newOpenSearchTotalResults->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newOpenSearchTotalResults->extensionElements)); - $this->assertEquals("42", $newOpenSearchTotalResults->text); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newOpenSearchTotalResults2 = $gdata->newOpenSearchTotalResults(); - $newOpenSearchTotalResults2->transferFromXML($newOpenSearchTotalResults->saveXML()); - $this->assertEquals(1, count($newOpenSearchTotalResults2->extensionElements)); - $this->assertEquals("42", $newOpenSearchTotalResults2->text); - } - - public function testEmptyOpenSearchTotalResultsToAndFromStringShouldMatch() { - $openSearchTotalResultsXml = $this->openSearchTotalResults->saveXML(); - $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); - $newOpenSearchTotalResults->transferFromXML($openSearchTotalResultsXml); - $newOpenSearchTotalResultsXml = $newOpenSearchTotalResults->saveXML(); - $this->assertTrue($openSearchTotalResultsXml == $newOpenSearchTotalResultsXml); - } - - public function testOpenSearchTotalResultsWithValueToAndFromStringShouldMatch() { - $this->openSearchTotalResults->text = "42"; - $openSearchTotalResultsXml = $this->openSearchTotalResults->saveXML(); - $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); - $newOpenSearchTotalResults->transferFromXML($openSearchTotalResultsXml); - $newOpenSearchTotalResultsXml = $newOpenSearchTotalResults->saveXML(); - $this->assertTrue($openSearchTotalResultsXml == $newOpenSearchTotalResultsXml); - $this->assertEquals("42", $this->openSearchTotalResults->text); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->openSearchTotalResults->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->openSearchTotalResults->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->openSearchTotalResults->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->openSearchTotalResults->extensionAttributes['foo2']['value']); - $openSearchTotalResultsXml = $this->openSearchTotalResults->saveXML(); - $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); - $newOpenSearchTotalResults->transferFromXML($openSearchTotalResultsXml); - $this->assertEquals('bar', $newOpenSearchTotalResults->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newOpenSearchTotalResults->extensionAttributes['foo2']['value']); - } - - public function testConvertFullOpenSearchTotalResultsToAndFromString() { - $this->openSearchTotalResults->transferFromXML($this->openSearchTotalResultsText); - $this->assertEquals("12", $this->openSearchTotalResults->text); - } - -} diff --git a/tests/Zend/Gdata/OriginalEventTest.php b/tests/Zend/Gdata/OriginalEventTest.php deleted file mode 100644 index 14ea2fa2b0ff84b79d1f20e96513f20dbedeaa9c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/OriginalEventTest.php +++ /dev/null @@ -1,131 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/OriginalEvent.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_OriginalEventTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->originalEventText = file_get_contents( - 'Zend/Gdata/_files/OriginalEventElementSample1.xml', - true); - $this->originalEvent = new Zend_Gdata_Extension_OriginalEvent(); - } - - public function testEmptyOriginalEventShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->originalEvent->extensionElements)); - $this->assertTrue(count($this->originalEvent->extensionElements) == 0); - } - - public function testEmptyOriginalEventShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->originalEvent->extensionAttributes)); - $this->assertTrue(count($this->originalEvent->extensionAttributes) == 0); - } - - public function testSampleOriginalEventShouldHaveNoExtensionElements() { - $this->originalEvent->transferFromXML($this->originalEventText); - $this->assertTrue(is_array($this->originalEvent->extensionElements)); - $this->assertTrue(count($this->originalEvent->extensionElements) == 0); - } - - public function testSampleOriginalEventShouldHaveNoExtensionAttributes() { - $this->originalEvent->transferFromXML($this->originalEventText); - $this->assertTrue(is_array($this->originalEvent->extensionAttributes)); - $this->assertTrue(count($this->originalEvent->extensionAttributes) == 0); - } - - public function testNormalOriginalEventShouldHaveNoExtensionElements() { - $this->originalEvent->href = "http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite"; - $this->originalEvent->id = "abcdef123456789"; - - $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $this->originalEvent->href); - $this->assertEquals("abcdef123456789", $this->originalEvent->id); - - $this->assertEquals(0, count($this->originalEvent->extensionElements)); - $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); - $newOriginalEvent->transferFromXML($this->originalEvent->saveXML()); - $this->assertEquals(0, count($newOriginalEvent->extensionElements)); - $newOriginalEvent->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newOriginalEvent->extensionElements)); - $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent->href); - $this->assertEquals("abcdef123456789", $newOriginalEvent->id); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newOriginalEvent2 = $gdata->newOriginalEvent(); - $newOriginalEvent2->transferFromXML($newOriginalEvent->saveXML()); - $this->assertEquals(1, count($newOriginalEvent2->extensionElements)); - $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent2->href); - $this->assertEquals("abcdef123456789", $newOriginalEvent2->id); - } - - public function testEmptyOriginalEventToAndFromStringShouldMatch() { - $originalEventXml = $this->originalEvent->saveXML(); - $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); - $newOriginalEvent->transferFromXML($originalEventXml); - $newOriginalEventXml = $newOriginalEvent->saveXML(); - $this->assertTrue($originalEventXml == $newOriginalEventXml); - } - - public function testOriginalEventWithValueToAndFromStringShouldMatch() { - $this->originalEvent->href = "http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite"; - $this->originalEvent->id = "abcdef123456789"; - $originalEventXml = $this->originalEvent->saveXML(); - $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); - $newOriginalEvent->transferFromXML($originalEventXml); - $newOriginalEventXml = $newOriginalEvent->saveXML(); - $this->assertTrue($originalEventXml == $newOriginalEventXml); - $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $this->originalEvent->href); - $this->assertEquals("abcdef123456789", $this->originalEvent->id); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->originalEvent->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->originalEvent->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->originalEvent->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->originalEvent->extensionAttributes['foo2']['value']); - $originalEventXml = $this->originalEvent->saveXML(); - $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); - $newOriginalEvent->transferFromXML($originalEventXml); - $this->assertEquals('bar', $newOriginalEvent->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newOriginalEvent->extensionAttributes['foo2']['value']); - } - - public function testConvertFullOriginalEventToAndFromString() { - $this->originalEvent->transferFromXML($this->originalEventText); - $this->assertEquals("http://www.google.com/calendar/feeds/userID/private/full/123456789", $this->originalEvent->href); - $this->assertEquals("i8fl1nrv2bl57c1qgr3f0onmgg", $this->originalEvent->id); - $this->assertTrue($this->originalEvent->when instanceof Zend_Gdata_Extension_When); - $this->assertEquals("2006-03-17T22:00:00.000Z", $this->originalEvent->when->startTime); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php b/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php deleted file mode 100755 index 3847e3360d7691bc396bd66603c02a9fdd6500b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php +++ /dev/null @@ -1,358 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/AlbumEntry.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosAlbumEntryTest extends PHPUnit_Framework_TestCase -{ - - protected $albumEntry = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $albumEntryText = file_get_contents( - '_files/TestAlbumEntry.xml', - true); - $this->albumEntry = new Zend_Gdata_Photos_AlbumEntry($albumEntryText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $entry = $this->albumEntry; - - // Assert that the entry's author is correct - $entryAuthor = $entry->getAuthor(); - $this->assertEquals($entryAuthor, $entry->author); - $this->assertEquals(1, count($entryAuthor)); - $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); - $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $entry = $this->albumEntry; - - // Assert that the entry's ID is correct - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $entry = $this->albumEntry; - - // Assert that the photo entry has an Atom Published object - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - $this->verifyProperty2($entry, "published", "text", "2007-09-05T07:00:00.000Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $entry = $this->albumEntry; - - // Assert that the entry's updated date is correct - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($entry, "updated", "text", - "2007-09-05T20:49:24.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($entry, "title", "text", "Test"); - } - - /** - * Check for the existence of an <gphoto:user> and verify that it contains - * the expected value. - */ - public function testGphotoUser() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); - $this->verifyProperty2($entry, "gphotoUser", "text", - "sample.user"); - $this->verifyProperty3($entry, "gphotoUser", "text", - "sample.user"); - } - - /** - * Check for the existence of an <gphoto:nickname> and verify that it contains - * the expected value. - */ - public function testGphotoNickname() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); - $this->verifyProperty2($entry, "gphotoNickname", "text", - "sample"); - $this->verifyProperty3($entry, "gphotoNickname", "text", - "sample"); - } - - /** - * Check for the existence of an <gphoto:name> and verify that it contains - * the expected value. - */ - public function testGphotoName() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoName() instanceof Zend_Gdata_Photos_Extension_Name); - $this->verifyProperty2($entry, "gphotoName", "text", - "Test"); - $this->verifyProperty3($entry, "gphotoName", "text", - "Test"); - } - - /** - * Check for the existence of an <gphoto:id> and verify that it contains - * the expected value. - */ - public function testGphotoId() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); - $this->verifyProperty2($entry, "gphotoId", "text", - "1"); - $this->verifyProperty3($entry, "gphotoId", "text", - "1"); - } - - /** - * Check for the existence of an <gphoto:location> and verify that it contains - * the expected value. - */ - public function testGphotoLocation() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoLocation() instanceof Zend_Gdata_Photos_Extension_Location); - $this->verifyProperty2($entry, "gphotoLocation", "text", - ""); - } - - /** - * Check for the existence of an <gphoto:access> and verify that it contains - * the expected value. - */ - public function testGphotoAccess() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoAccess() instanceof Zend_Gdata_Photos_Extension_Access); - $this->verifyProperty2($entry, "gphotoAccess", "text", - "public"); - $this->verifyProperty3($entry, "gphotoAccess", "text", - "public"); - } - - /** - * Check for the existence of an <gphoto:timestamp> and verify that it contains - * the expected value. - */ - public function testGphotoTimestamp() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); - $this->verifyProperty2($entry, "gphotoTimestamp", "text", - "1188975600000"); - $this->verifyProperty3($entry, "gphotoTimestamp", "text", - "1188975600000"); - } - - /** - * Check for the existence of an <gphoto:numphotos> and verify that it contains - * the expected value. - */ - public function testGphotoNumPhotos() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoNumPhotos() instanceof Zend_Gdata_Photos_Extension_NumPhotos); - $this->verifyProperty2($entry, "gphotoNumPhotos", "text", - "2"); - $this->verifyProperty3($entry, "gphotoNumPhotos", "text", - "2"); - } - - /** - * Check for the existence of an <gphoto:commentingEnabled> and verify that it contains - * the expected value. - */ - public function testGphotoCommentingEnabled() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); - $this->verifyProperty2($entry, "gphotoCommentingEnabled", "text", - "true"); - $this->verifyProperty3($entry, "gphotoCommentingEnabled", "text", - "true"); - } - - /** - * Check for the existence of an <gphoto:commentCount> and verify that it contains - * the expected value. - */ - public function testGphotoCommentCount() - { - $entry = $this->albumEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); - $this->verifyProperty2($entry, "gphotoCommentCount", "text", - "0"); - $this->verifyProperty3($entry, "gphotoCommentCount", "text", - "0"); - } - - /** - * Check for the existence of a <media:group> - */ - public function testMediaGroup() - { - $entry = $this->albumEntry; - - // Assert that the entry's media group exists - $this->assertTrue($entry->getMediaGroup() instanceof Zend_Gdata_Media_Extension_MediaGroup); - } - - /** - * Check for the geo data and verify that it contains the expected values - */ - public function testGeoData() - { - $geoRssWhere = $this->albumEntry->geoRssWhere; - $point = $geoRssWhere->point; - $pos = $point->pos; - $this->assertEquals("42.87194 13.56738", $pos->text); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php b/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php deleted file mode 100755 index 5c10a73d8258456e8d84c9cf3a0cc04c2e594158..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php +++ /dev/null @@ -1,463 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/AlbumFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosAlbumFeedTest extends PHPUnit_Framework_TestCase -{ - - protected $albumFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $albumFeedText = file_get_contents( - '_files/TestAlbumFeed.xml', - true); - $this->albumFeed = new Zend_Gdata_Photos_AlbumFeed($albumFeedText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of appropriate entry type and object count matches. - */ - public function testAlbumFeedToAndFromString() - { - $entryCount = 0; - foreach ($this->albumFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Photos_PhotoEntry || - $entry instanceof Zend_Gdata_Photos_TagEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->albumFeed and convert back to objects */ - $newListFeed = new Zend_Gdata_Photos_UserFeed( - $this->albumFeed->saveXML()); - $newEntryCount = 0; - foreach ($newListFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Photos_PhotoEntry || - $entry instanceof Zend_Gdata_Photos_TagEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that the number of entries equals the number - * of entries defined in the sample file. - */ - public function testEntryCount() - { - $entryCount = 0; - foreach ($this->albumFeed as $entry) { - $entryCount++; - } - $this->assertEquals(4, $entryCount); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $feed = $this->albumFeed; - - // Assert that the feed's author is correct - $feedAuthor = $feed->getAuthor(); - $this->assertEquals($feedAuthor, $feed->author); - $this->assertEquals(1, count($feedAuthor)); - $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($feedAuthor[0], "name", "text", "sample"); - $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - - // Assert that each entry has valid author data - foreach ($feed as $entry) { - if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) { - $entryAuthor = $entry->getAuthor(); - $this->assertEquals(1, count($entryAuthor)); - $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); - $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - } - } - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $feed = $this->albumFeed; - - // Assert that the feed's ID is correct - $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($feed, "id", "text", - "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"); - - // Assert that all entries have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - } - - // Assert one of the entry's IDs - $entry = $feed[0]; - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $feed = $this->albumFeed; - - // Assert that all photo entries have an Atom Published object - foreach ($feed as $entry) { - if ($entry instanceof Zend_Gdata_Photos_PhotoEntry) { - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - } - } - - // Assert one of the entry's Published dates - $entry = $feed[0]; - $this->verifyProperty2($entry, "published", "text", "2007-09-05T20:49:23.000Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $feed = $this->albumFeed; - - // Assert that the feed's updated date is correct - $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($feed, "updated", "text", - "2007-09-21T18:23:05.000Z"); - - // Assert that all entries have an Atom Updated object - foreach ($feed as $entry) { - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - } - - // Assert one of the entry's Updated dates - $entry = $feed[0]; - $this->verifyProperty2($entry, "updated", "text", "2007-09-21T18:23:05.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($feed, "title", "text", "Test"); - - // Assert that all entries have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - } - - // Assert one of the entry's Titles - $entry = $feed[0]; - $this->verifyProperty2($entry, "title", "text", "Aqua Blue.jpg"); - } - - /** - * Check for the existence of an <atom:subtitle> and verify that it contains - * the expected value. - */ - public function testSubtitle() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); - $this->verifyProperty2($feed, "subtitle", "text", - ""); - } - - /** - * Check for the existence of an <atom:generator> and verify that it contains - * the expected value. - */ - public function testGenerator() - { - $feed = $this->albumFeed; - - // Assert that the feed's generator is correct - $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); - $this->verifyProperty2($feed, "generator", "version", "1.00"); - $this->verifyProperty2($feed, "generator", "uri", "http://picasaweb.google.com/"); - $this->verifyProperty2($feed, "generator", "text", "Picasaweb"); - } - - /** - * Check for the existence of an <atom:icon> and verify that it contains - * the expected value. - */ - public function testIcon() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getIcon() instanceof Zend_Gdata_App_Extension_Icon); - $this->verifyProperty2($feed, "icon", "text", - "http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg"); - } - - /** - * Check for the existence of an <gphoto:user> and verify that it contains - * the expected value. - */ - public function testGphotoUser() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); - $this->verifyProperty2($feed, "gphotoUser", "text", - "sample.user"); - $this->verifyProperty3($feed, "gphotoUser", "text", - "sample.user"); - } - - /** - * Check for the existence of an <gphoto:nickname> and verify that it contains - * the expected value. - */ - public function testGphotoNickname() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); - $this->verifyProperty2($feed, "gphotoNickname", "text", - "sample"); - $this->verifyProperty3($feed, "gphotoNickname", "text", - "sample"); - } - - /** - * Check for the existence of an <gphoto:name> and verify that it contains - * the expected value. - */ - public function testGphotoName() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoName() instanceof Zend_Gdata_Photos_Extension_Name); - $this->verifyProperty2($feed, "gphotoName", "text", - "Test"); - } - - /** - * Check for the existence of an <gphoto:id> and verify that it contains - * the expected value. - */ - public function testGphotoId() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); - $this->verifyProperty2($feed, "gphotoId", "text", - "1"); - $this->verifyProperty3($feed, "gphotoId", "text", - "1"); - } - - /** - * Check for the existence of an <gphoto:location> and verify that it contains - * the expected value. - */ - public function testGphotoLocation() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoLocation() instanceof Zend_Gdata_Photos_Extension_Location); - $this->verifyProperty2($feed, "gphotoLocation", "text", - ""); - $this->verifyProperty3($feed, "gphotoLocation", "text", - ""); - } - - /** - * Check for the existence of an <gphoto:access> and verify that it contains - * the expected value. - */ - public function testGphotoAccess() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoAccess() instanceof Zend_Gdata_Photos_Extension_Access); - $this->verifyProperty2($feed, "gphotoAccess", "text", - "public"); - $this->verifyProperty3($feed, "gphotoAccess", "text", - "public"); - } - - /** - * Check for the existence of an <gphoto:timestamp> and verify that it contains - * the expected value. - */ - public function testGphotoTimestamp() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); - $this->verifyProperty2($feed, "gphotoTimestamp", "text", - "1188975600000"); - $this->verifyProperty3($feed, "gphotoTimestamp", "text", - "1188975600000"); - } - - /** - * Check for the existence of an <gphoto:numphotos> and verify that it contains - * the expected value. - */ - public function testGphotoNumPhotos() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoNumPhotos() instanceof Zend_Gdata_Photos_Extension_NumPhotos); - $this->verifyProperty2($feed, "gphotoNumPhotos", "text", - "2"); - $this->verifyProperty3($feed, "gphotoNumPhotos", "text", - "2"); - } - - /** - * Check for the existence of an <gphoto:commentingEnabled> and verify that it contains - * the expected value. - */ - public function testGphotoCommentingEnabled() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); - $this->verifyProperty2($feed, "gphotoCommentingEnabled", "text", - "true"); - $this->verifyProperty3($feed, "gphotoCommentingEnabled", "text", - "true"); - } - - /** - * Check for the existence of an <gphoto:commentCount> and verify that it contains - * the expected value. - */ - public function testGphotoCommentCount() - { - $feed = $this->albumFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); - $this->verifyProperty2($feed, "gphotoCommentCount", "text", - "0"); - $this->verifyProperty3($feed, "gphotoCommentCount", "text", - "0"); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php b/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php deleted file mode 100755 index a50a85c7046f6b4cd43278f15edad4fe6542dca1..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php +++ /dev/null @@ -1,192 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/AlbumQuery.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosAlbumQueryTest extends PHPUnit_Framework_TestCase -{ - - /** - * Check the consistency of an album feed request - */ - public function testSimpleAlbumQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"; - - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/album/test"; - - $query->setAlbumId(null); - $query->setAlbumName("test"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check for thrown exceptions upon improper albumname/id setting - */ - public function testAlbumQueryExceptions() - { - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - - try { - $generatedString = $query->getQueryUrl(); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - - $query->setAlbumId("1"); - $query->setAlbumName("test"); - - try { - $generatedString = $query->getQueryUrl(); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - } - - /** - * Check the consistency of an album feed request - * Projection is set to base - */ - public function testBaseAlbumQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/base/user/sample.user/albumid/1"; - - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setProjection("base"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of an album feed request filtered - * for a specific tag - */ - public function testTagFilterAlbumQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?tag=test"; - - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setTag("test"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of an album feed request for private data - */ - public function testPrivateAlbumQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?access=private"; - - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setAccess("private"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of an album feed request for specifically-sized thumbnails - */ - public function testThumbnailAlbumQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?thumbsize=72"; - - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setThumbsize("72"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the set thumbsize is correct - $this->assertEquals("72", $query->getThumbsize()); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of an album feed request for specifically-sized images - */ - public function testImgAlbumQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?imgmax=800"; - - $query = new Zend_Gdata_Photos_AlbumQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setImgMax("800"); - - // Assert that the set ImgMax is correct - $this->assertEquals("800", $query->getImgMax()); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - - // Check that ImgMax is set back to null - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"; - $query->setImgMax(null); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php b/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php deleted file mode 100755 index 61fc11f0f21dadb7b08edc23ed4024bae5390846..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php +++ /dev/null @@ -1,223 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/CommentEntry.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosCommentEntryTest extends PHPUnit_Framework_TestCase -{ - - protected $commentEntry = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $commentEntryText = file_get_contents( - '_files/TestCommentEntry.xml', - true); - $this->commentEntry = new Zend_Gdata_Photos_CommentEntry($commentEntryText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $entry = $this->commentEntry; - - // Assert that the entry's ID is correct - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5"); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $entry = $this->commentEntry; - - // Assert that the entry's author is correct - $entryAuthor = $entry->getAuthor(); - $this->assertEquals($entryAuthor, $entry->author); - $this->assertEquals(1, count($entryAuthor)); - $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); - $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $entry = $this->commentEntry; - - // Assert that the photo entry has an Atom Published object - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - $this->verifyProperty2($entry, "published", "text", "2007-09-21T18:22:53.000Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $entry = $this->commentEntry; - - // Assert that the entry's updated date is correct - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($entry, "updated", "text", - "2007-09-21T18:22:53.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $entry = $this->commentEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($entry, "title", "text", "sample"); - } - - /** - * Check for the existence of an <atom:content> and verify that it contains - * the expected value. - */ - public function testContent() - { - $entry = $this->commentEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getContent() instanceof Zend_Gdata_App_Extension_Content); - $this->verifyProperty2($entry, "content", "text", "test comment"); - } - - /** - * Check for the existence of an <gphoto:id> and verify that it contains - * the expected value. - */ - public function testGphotoId() - { - $entry = $this->commentEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); - $this->verifyProperty2($entry, "gphotoId", "text", - "5"); - $this->verifyProperty3($entry, "gphotoId", "text", - "5"); - } - - /** - * Check for the existence of an <gphoto:photoid> and verify that it contains - * the expected value. - */ - public function testGphotoPhotoId() - { - $entry = $this->commentEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoPhotoId() instanceof Zend_Gdata_Photos_Extension_PhotoId); - $this->verifyProperty2($entry, "gphotoPhotoId", "text", - "100"); - $this->verifyProperty3($entry, "gphotoPhotoId", "text", - "100"); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php b/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php deleted file mode 100755 index f005fe8d6d3f976247f1b2ac8c5c725823dc243c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php +++ /dev/null @@ -1,389 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/PhotoEntry.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosPhotoEntryTest extends PHPUnit_Framework_TestCase -{ - - protected $photoEntry = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $photoEntryText = file_get_contents( - '_files/TestPhotoEntry.xml', - true); - $this->photoEntry = new Zend_Gdata_Photos_PhotoEntry($photoEntryText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $entry = $this->photoEntry; - - // Assert that the entry's ID is correct - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $entry = $this->photoEntry; - - // Assert that the photo entry has an Atom Published object - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - $this->verifyProperty2($entry, "published", "text", "2007-09-05T20:49:24.000Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $entry = $this->photoEntry; - - // Assert that the entry's updated date is correct - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($entry, "updated", "text", - "2007-09-21T18:19:38.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $entry = $this->photoEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($entry, "title", "text", "Aqua Graphite.jpg"); - } - - /** - * Check for the existence of an <gphoto:id> and verify that it contains - * the expected value. - */ - public function testGphotoId() - { - $entry = $this->photoEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); - $this->verifyProperty2($entry, "gphotoId", "text", - "100"); - $this->verifyProperty3($entry, "gphotoId", "text", - "100"); - } - - /** - * Check for the existance of exif namespaced data and verify that it contains - * the expected value. - */ - public function testExifData() - { - $exifTags = $this->photoEntry->exifTags; - $this->assertTrue($exifTags != null); - $this->assertTrue($exifTags->flash != null); - $this->assertTrue($exifTags->fstop != null); - $this->assertTrue($exifTags->exposure != null); - $this->assertTrue($exifTags->focallength != null); - $this->assertTrue($exifTags->iso != null); - $this->assertTrue($exifTags->time != null); - $this->assertTrue($exifTags->distance != null); - $this->assertTrue($exifTags->make != null); - $this->assertTrue($exifTags->model != null); - $this->assertTrue($exifTags->imageUniqueID != null); - $this->assertEquals("true", $exifTags->flash->text); - $this->assertEquals("11.0", $exifTags->fstop->text); - $this->assertEquals("0.0040", $exifTags->exposure->text); - $this->assertEquals("22.0", $exifTags->focallength->text); - $this->assertEquals("200", $exifTags->iso->text); - $this->assertEquals("1180950900000", $exifTags->time->text); - $this->assertEquals("0.0",$exifTags->distance->text); - $this->assertEquals("Fictitious Camera Company",$exifTags->make->text); - $this->assertEquals("AMAZING-100D",$exifTags->model->text); - $this->assertEquals("a5ce2e36b9df7d3cb081511c72e73926", $exifTags->imageUniqueID->text); - } - - /** - * Check for the geo data and verify that it contains the expected values - */ - public function testGeoData() - { - $geoRssWhere = $this->photoEntry->geoRssWhere; - $point = $geoRssWhere->point; - $pos = $point->pos; - $this->assertEquals("41.87194 12.56738", $pos->text); - } - - - /** - * Check for the existence of an <gphoto:version> and verify that it contains - * the expected value. - */ - public function testGphotoVersion() - { - $entry = $this->photoEntry; - - // Assert that the entry's version is correct - $this->assertTrue($entry->getGphotoVersion() instanceof Zend_Gdata_Photos_Extension_Version); - $this->verifyProperty2($entry, "gphotoVersion", "text", - "1190398778006402"); - $this->verifyProperty3($entry, "gphotoVersion", "text", - "1190398778006402"); - } - - /** - * Check for the existence of an <gphoto:albumid> and verify that it contains - * the expected value. - */ - public function testGphotoAlbumId() - { - $entry = $this->photoEntry; - - // Assert that the entry's albumid is correct - $this->assertTrue($entry->getGphotoAlbumId() instanceof Zend_Gdata_Photos_Extension_AlbumId); - $this->verifyProperty2($entry, "gphotoAlbumId", "text", - "1"); - $this->verifyProperty3($entry, "gphotoAlbumId", "text", - "1"); - } - - /** - * Check for the existence of an <gphoto:width> and verify that it contains - * the expected value. - */ - public function testGphotoWidth() - { - $entry = $this->photoEntry; - - // Assert that the entry's width is correct - $this->assertTrue($entry->getGphotoWidth() instanceof Zend_Gdata_Photos_Extension_Width); - $this->verifyProperty2($entry, "gphotoWidth", "text", - "2560"); - $this->verifyProperty3($entry, "gphotoWidth", "text", - "2560"); - } - - /** - * Check for the existence of an <gphoto:height> and verify that it contains - * the expected value. - */ - public function testGphotoHeight() - { - $entry = $this->photoEntry; - - // Assert that the entry's height is correct - $this->assertTrue($entry->getGphotoHeight() instanceof Zend_Gdata_Photos_Extension_Height); - $this->verifyProperty2($entry, "gphotoHeight", "text", - "1600"); - $this->verifyProperty3($entry, "gphotoHeight", "text", - "1600"); - } - - /** - * Check for the existence of an <gphoto:size> and verify that it contains - * the expected value. - */ - public function testGphotoSize() - { - $entry = $this->photoEntry; - - // Assert that the entry's size is correct - $this->assertTrue($entry->getGphotoSize() instanceof Zend_Gdata_Photos_Extension_Size); - $this->verifyProperty2($entry, "gphotoSize", "text", - "798334"); - $this->verifyProperty3($entry, "gphotoSize", "text", - "798334"); - } - - /** - * Check for the existence of an <gphoto:client> and verify that it contains - * the expected value. - */ - public function testGphotoClient() - { - $entry = $this->photoEntry; - - // Assert that the entry's client is correct - $this->assertTrue($entry->getGphotoClient() instanceof Zend_Gdata_Photos_Extension_Client); - $this->verifyProperty2($entry, "gphotoClient", "text", - ""); - $this->verifyProperty3($entry, "gphotoClient", "text", - ""); - } - - /** - * Check for the existence of an <gphoto:checksum> and verify that it contains - * the expected value. - */ - public function testGphotoChecksum() - { - $entry = $this->photoEntry; - - // Assert that the entry's checksum is correct - $this->assertTrue($entry->getGphotoChecksum() instanceof Zend_Gdata_Photos_Extension_Checksum); - $this->verifyProperty2($entry, "gphotoChecksum", "text", - ""); - $this->verifyProperty3($entry, "gphotoChecksum", "text", - ""); - } - - /** - * Check for the existence of an <gphoto:timestamp> and verify that it contains - * the expected value. - */ - public function testGphotoTimestamp() - { - $entry = $this->photoEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); - $this->verifyProperty2($entry, "gphotoTimestamp", "text", - "1189025363000"); - $this->verifyProperty3($entry, "gphotoTimestamp", "text", - "1189025363000"); - } - - /** - * Check for the existence of an <gphoto:commentingEnabled> and verify that it contains - * the expected value. - */ - public function testGphotoCommentingEnabled() - { - $entry = $this->photoEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); - $this->verifyProperty2($entry, "gphotoCommentingEnabled", "text", - "true"); - $this->verifyProperty3($entry, "gphotoCommentingEnabled", "text", - "true"); - } - - /** - * Check for the existence of an <gphoto:commentCount> and verify that it contains - * the expected value. - */ - public function testGphotoCommentCount() - { - $entry = $this->photoEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); - $this->verifyProperty2($entry, "gphotoCommentCount", "text", - "0"); - $this->verifyProperty3($entry, "gphotoCommentCount", "text", - "0"); - } - - /** - * Check for the existence of a <media:group> - */ - public function testMediaGroup() - { - $entry = $this->photoEntry; - - // Assert that the entry's media group exists - $this->assertTrue($entry->getMediaGroup() instanceof Zend_Gdata_Media_Extension_MediaGroup); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php b/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php deleted file mode 100755 index e92fa2d503a7931a287ed6753c9faeee9eca482a..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php +++ /dev/null @@ -1,429 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/PhotoFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosPhotoFeedTest extends PHPUnit_Framework_TestCase -{ - - protected $photoFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $photoFeedText = file_get_contents( - '_files/TestPhotoFeed.xml', - true); - $this->photoFeed = new Zend_Gdata_Photos_PhotoFeed($photoFeedText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of appropriate entry type and object count matches. - */ - public function testPhotoFeedToAndFromString() - { - $entryCount = 0; - foreach ($this->photoFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Photos_CommentEntry || - $entry instanceof Zend_Gdata_Photos_TagEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->photoFeed and convert back to objects */ - $newListFeed = new Zend_Gdata_Photos_PhotoFeed( - $this->photoFeed->saveXML()); - $newEntryCount = 0; - foreach ($newListFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Photos_CommentEntry || - $entry instanceof Zend_Gdata_Photos_TagEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that the number of entries equals the number - * of entries defined in the sample file. - */ - public function testEntryCount() - { - $entryCount = 0; - foreach ($this->photoFeed as $entry) { - $entryCount++; - } - $this->assertEquals(3, $entryCount); - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $feed = $this->photoFeed; - - // Assert that the feed's ID is correct - $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($feed, "id", "text", - "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100"); - - // Assert that all entries have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - } - - // Assert one of the entry's IDs - $entry = $feed[0]; - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $feed = $this->photoFeed; - - // Assert that the feed's updated date is correct - $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($feed, "updated", "text", - "2007-09-21T18:23:05.000Z"); - - // Assert that all entries have an Atom Updated object - foreach ($feed as $entry) { - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - } - - // Assert one of the entry's Updated dates - $entry = $feed[0]; - $this->verifyProperty2($entry, "updated", "text", "2007-09-21T18:23:05.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $feed = $this->photoFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($feed, "title", "text", "Aqua Blue.jpg"); - - // Assert that all entries have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - } - } - - /** - * Check for the existence of an <atom:subtitle> and verify that it contains - * the expected value. - */ - public function testSubtitle() - { - $feed = $this->photoFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); - $this->verifyProperty2($feed, "subtitle", "text", - "Blue"); - } - - /** - * Check for the existence of an <atom:generator> and verify that it contains - * the expected value. - */ - public function testGenerator() - { - $feed = $this->photoFeed; - - // Assert that the feed's generator is correct - $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); - $this->verifyProperty2($feed, "generator", "version", "1.00"); - $this->verifyProperty2($feed, "generator", "uri", "http://picasaweb.google.com/"); - $this->verifyProperty2($feed, "generator", "text", "Picasaweb"); - } - - /** - * Check for the existence of an <atom:icon> and verify that it contains - * the expected value. - */ - public function testIcon() - { - $feed = $this->photoFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getIcon() instanceof Zend_Gdata_App_Extension_Icon); - $this->verifyProperty2($feed, "icon", "text", - "http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg"); - } - - /** - * Check for the existence of an <gphoto:id> and verify that it contains - * the expected value. - */ - public function testGphotoId() - { - $feed = $this->photoFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); - $this->verifyProperty2($feed, "gphotoId", "text", - "100"); - $this->verifyProperty3($feed, "gphotoId", "text", - "100"); - } - - /** - * Check for the existence of an <gphoto:version> and verify that it contains - * the expected value. - */ - public function testGphotoVersion() - { - $feed = $this->photoFeed; - - // Assert that the feed's version is correct - $this->assertTrue($feed->getGphotoVersion() instanceof Zend_Gdata_Photos_Extension_Version); - $this->verifyProperty2($feed, "gphotoVersion", "text", - "1190398985145172"); - $this->verifyProperty3($feed, "gphotoVersion", "text", - "1190398985145172"); - } - - /** - * Check for the existence of an <gphoto:albumid> and verify that it contains - * the expected value. - */ - public function testGphotoAlbumId() - { - $feed = $this->photoFeed; - - // Assert that the feed's albumid is correct - $this->assertTrue($feed->getGphotoAlbumId() instanceof Zend_Gdata_Photos_Extension_AlbumId); - $this->verifyProperty2($feed, "gphotoAlbumId", "text", - "1"); - $this->verifyProperty3($feed, "gphotoAlbumId", "text", - "1"); - } - - /** - * Check for the existence of an <gphoto:timestamp> and verify that it contains - * the expected value. - */ - public function testGphotoTimestamp() - { - $feed = $this->photoFeed; - - // Assert that the feed's timestamp is correct - $this->assertTrue($feed->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); - $this->verifyProperty2($feed, "gphotoTimestamp", "text", - "1189025362000"); - $this->verifyProperty3($feed, "gphotoTimestamp", "text", - "1189025362000"); - } - - /** - * Check for the existence of an <gphoto:width> and verify that it contains - * the expected value. - */ - public function testGphotoWidth() - { - $feed = $this->photoFeed; - - // Assert that the feed's width is correct - $this->assertTrue($feed->getGphotoWidth() instanceof Zend_Gdata_Photos_Extension_Width); - $this->verifyProperty2($feed, "gphotoWidth", "text", - "2560"); - $this->verifyProperty3($feed, "gphotoWidth", "text", - "2560"); - } - - /** - * Check for the existence of an <gphoto:height> and verify that it contains - * the expected value. - */ - public function testGphotoHeight() - { - $feed = $this->photoFeed; - - // Assert that the feed's height is correct - $this->assertTrue($feed->getGphotoHeight() instanceof Zend_Gdata_Photos_Extension_Height); - $this->verifyProperty2($feed, "gphotoHeight", "text", - "1600"); - $this->verifyProperty3($feed, "gphotoHeight", "text", - "1600"); - } - - /** - * Check for the existence of an <gphoto:size> and verify that it contains - * the expected value. - */ - public function testGphotoSize() - { - $feed = $this->photoFeed; - - // Assert that the feed's size is correct - $this->assertTrue($feed->getGphotoSize() instanceof Zend_Gdata_Photos_Extension_Size); - $this->verifyProperty2($feed, "gphotoSize", "text", - "883405"); - $this->verifyProperty3($feed, "gphotoSize", "text", - "883405"); - } - - /** - * Check for the existence of an <gphoto:client> and verify that it contains - * the expected value. - */ - public function testGphotoClient() - { - $feed = $this->photoFeed; - - // Assert that the feed's client is correct - $this->assertTrue($feed->getGphotoClient() instanceof Zend_Gdata_Photos_Extension_Client); - $this->verifyProperty2($feed, "gphotoClient", "text", - ""); - $this->verifyProperty3($feed, "gphotoClient", "text", - ""); - } - - /** - * Check for the existence of an <gphoto:checksum> and verify that it contains - * the expected value. - */ - public function testGphotoChecksum() - { - $feed = $this->photoFeed; - - // Assert that the feed's checksum is correct - $this->assertTrue($feed->getGphotoChecksum() instanceof Zend_Gdata_Photos_Extension_Checksum); - $this->verifyProperty2($feed, "gphotoChecksum", "text", - ""); - $this->verifyProperty3($feed, "gphotoChecksum", "text", - ""); - } - - /** - * Check for the existence of an <gphoto:commentingEnabled> and verify that it contains - * the expected value. - */ - public function testGphotoCommentingEnabled() - { - $feed = $this->photoFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); - $this->verifyProperty2($feed, "gphotoCommentingEnabled", "text", - "true"); - $this->verifyProperty3($feed, "gphotoCommentingEnabled", "text", - "true"); - } - - /** - * Check for the existence of an <gphoto:commentCount> and verify that it contains - * the expected value. - */ - public function testGphotoCommentCount() - { - $feed = $this->photoFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); - $this->verifyProperty2($feed, "gphotoCommentCount", "text", - "1"); - $this->verifyProperty3($feed, "gphotoCommentCount", "text", - "1"); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php b/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php deleted file mode 100755 index 4cf05be2576e44d90f6c067b1db15b5aa33f28a3..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php +++ /dev/null @@ -1,127 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/PhotoQuery.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosPhotoQueryTest extends PHPUnit_Framework_TestCase -{ - - /** - * Check the consistency of a user feed request - */ - public function testSimplePhotoQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1"; - - $query = new Zend_Gdata_Photos_PhotoQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setPhotoId("1"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of a user feed request - * Projection is set to base - */ - public function testBasePhotoQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/base/user/sample.user/albumid/1/photoid/1"; - - $query = new Zend_Gdata_Photos_PhotoQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setPhotoId("1"); - $query->setProjection("base"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check for thrown exceptions upon improper photoid setting - */ - public function testPhotoQueryExceptions() - { - $query = new Zend_Gdata_Photos_PhotoQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - - try { - $generatedString = $query->getQueryUrl(); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - } - - /** - * Check the consistency of a user feed request filtered - * for a specific tag - */ - public function testTagFilterPhotoQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?tag=test"; - - $query = new Zend_Gdata_Photos_PhotoQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setPhotoId("1"); - $query->setTag("test"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of a user feed request for private data - */ - public function testPrivatePhotoQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?access=private"; - - $query = new Zend_Gdata_Photos_PhotoQuery(); - $query->setUser("sample.user"); - $query->setAlbumId("1"); - $query->setPhotoId("1"); - $query->setAccess("private"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php b/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php deleted file mode 100755 index 92f051f8a483e7149415f9a0edb826a017a2f922..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php +++ /dev/null @@ -1,124 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/TagEntry.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosTagEntryTest extends PHPUnit_Framework_TestCase -{ - - protected $tagEntry = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $tagEntryText = file_get_contents( - '_files/TestTagEntry.xml', - true); - $this->tagEntry = new Zend_Gdata_Photos_TagEntry($tagEntryText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $entry = $this->tagEntry; - - // Assert that the entry's ID is correct - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $entry = $this->tagEntry; - - // Assert that the entry's updated date is correct - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($entry, "updated", "text", - "1970-01-01T00:01:01.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $entry = $this->tagEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($entry, "title", "text", "tag"); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php b/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php deleted file mode 100755 index cccf5d8e1c85d4a13829c1f4d89a62ad153e028d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php +++ /dev/null @@ -1,222 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/UserEntry.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosUserEntryTest extends PHPUnit_Framework_TestCase -{ - - protected $userEntry = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $userEntryText = file_get_contents( - '_files/TestUserEntry.xml', - true); - $this->userEntry = new Zend_Gdata_Photos_UserEntry($userEntryText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $entry = $this->userEntry; - - // Assert that the entry's author is correct - $entryAuthor = $entry->getAuthor(); - $this->assertEquals($entryAuthor, $entry->author); - $this->assertEquals(1, count($entryAuthor)); - $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); - $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $entry = $this->userEntry; - - // Assert that the entry's ID is correct - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $entry = $this->userEntry; - - // Assert that the photo entry has an Atom Published object - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - $this->verifyProperty2($entry, "published", "text", "2007-09-24T23:45:49.059Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $entry = $this->userEntry; - - // Assert that the entry's updated date is correct - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($entry, "updated", "text", - "2007-09-24T23:45:49.059Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $entry = $this->userEntry; - - // Assert that the entry's title is correct - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($entry, "title", "text", "sample.user"); - } - - /** - * Check for the existence of an <gphoto:user> and verify that it contains - * the expected value. - */ - public function testGphotoUser() - { - $entry = $this->userEntry; - - // Assert that the entry's user is correct - $this->assertTrue($entry->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); - $this->verifyProperty2($entry, "gphotoUser", "text", "sample.user"); - $this->verifyProperty3($entry, "gphotoUser", "text", "sample.user"); - } - - /** - * Check for the existence of an <gphoto:nickname> and verify that it contains - * the expected value. - */ - public function testGphotoNickname() - { - $entry = $this->userEntry; - - // Assert that the entry's nickname is correct - $this->assertTrue($entry->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); - $this->verifyProperty2($entry, "gphotoNickname", "text", "sample"); - $this->verifyProperty3($entry, "gphotoNickname", "text", "sample"); - } - - /** - * Check for the existence of an <gphoto:thumbnail> and verify that it contains - * the expected value. - */ - public function testGphotoThumbnail() - { - $entry = $this->userEntry; - - // Assert that the entry's thumbnail is correct - $this->assertTrue($entry->getGphotoThumbnail() instanceof Zend_Gdata_Photos_Extension_Thumbnail); - $this->verifyProperty2($entry, "gphotoThumbnail", "text", - "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); - $this->verifyProperty3($entry, "gphotoThumbnail", "text", - "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php b/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php deleted file mode 100755 index a7e7bfe1ea3e44521129859623208199756d500c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php +++ /dev/null @@ -1,354 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/UserFeed.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosUserFeedTest extends PHPUnit_Framework_TestCase -{ - - protected $userFeed = null; - - /** - * Called before each test to setup any fixtures. - */ - public function setUp() - { - $userFeedText = file_get_contents( - '_files/TestUserFeed.xml', - true); - $this->userFeed = new Zend_Gdata_Photos_UserFeed($userFeedText); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty2($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Verify that a given property is set to a specific value, - * that it keeps that value when set using the setter, - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty3($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $propSetter = "set" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - $secondSetter = "set" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $obj->$propSetter($obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - /** - * Convert sample feed to XML then back to objects. Ensure that - * all objects are instances of appropriate entry type and object count matches. - */ - public function testUserFeedToAndFromString() - { - $entryCount = 0; - foreach ($this->userFeed as $entry) { - $entryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Photos_AlbumEntry || - $entry instanceof Zend_Gdata_Photos_PhotoEntry || - $entry instanceof Zend_Gdata_Photos_TagEntry); - } - $this->assertTrue($entryCount > 0); - - /* Grab XML from $this->userFeed and convert back to objects */ - $newListFeed = new Zend_Gdata_Photos_UserFeed( - $this->userFeed->saveXML()); - $newEntryCount = 0; - foreach ($newListFeed as $entry) { - $newEntryCount++; - $this->assertTrue($entry instanceof Zend_Gdata_Photos_AlbumEntry || - $entry instanceof Zend_Gdata_Photos_PhotoEntry || - $entry instanceof Zend_Gdata_Photos_TagEntry); - } - $this->assertEquals($entryCount, $newEntryCount); - } - - /** - * Ensure that the number of entries equals the number - * of entries defined in the sample file. - */ - public function testEntryCount() - { - $entryCount = 0; - foreach ($this->userFeed as $entry) { - $entryCount++; - } - $this->assertEquals(3, $entryCount); - } - - /** - * Check for the existence of an <atom:author> and verify that they - * contain the expected values. - */ - public function testAuthor() - { - $feed = $this->userFeed; - - // Assert that the feed's author is correct - $feedAuthor = $feed->getAuthor(); - $this->assertEquals($feedAuthor, $feed->author); - $this->assertEquals(1, count($feedAuthor)); - $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); - $this->verifyProperty2($feedAuthor[0], "name", "text", "sample"); - $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); - $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - - // Assert that each entry has valid author data - foreach ($feed as $entry) { - if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) { - $entryAuthor = $entry->getAuthor(); - $this->assertEquals(1, count($entryAuthor)); - $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); - $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); - } - } - } - - /** - * Check for the existence of an <atom:id> and verify that it contains - * the expected value. - */ - public function testId() - { - $feed = $this->userFeed; - - // Assert that the feed's ID is correct - $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); - $this->verifyProperty2($feed, "id", "text", - "http://picasaweb.google.com/data/feed/api/user/sample.user"); - - // Assert that all entries have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); - } - - // Assert one of the entry's IDs - $entry = $feed[0]; - $this->verifyProperty2($entry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100"); - } - - /** - * Check for the existence of an <atom:published> and verify that it contains - * the expected value. - */ - public function testPublished() - { - $feed = $this->userFeed; - - // Assert that all entries have an Atom Published object - foreach ($feed as $entry) { - $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); - } - - // Assert one of the entry's Published dates - $entry = $feed[0]; - $this->verifyProperty2($entry, "published", "text", "2007-09-05T07:00:00.000Z"); - } - - /** - * Check for the existence of an <atom:updated> and verify that it contains - * the expected value. - */ - public function testUpdated() - { - $feed = $this->userFeed; - - // Assert that the feed's updated date is correct - $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - $this->verifyProperty2($feed, "updated", "text", - "2007-09-20T21:09:39.111Z"); - - // Assert that all entries have an Atom Updated object - foreach ($feed as $entry) { - $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); - } - - // Assert one of the entry's Updated dates - $entry = $feed[0]; - $this->verifyProperty2($entry, "updated", "text", "2007-09-05T20:49:24.000Z"); - } - - /** - * Check for the existence of an <atom:title> and verify that it contains - * the expected value. - */ - public function testTitle() - { - $feed = $this->userFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); - $this->verifyProperty2($feed, "title", "text", - "sample.user"); - - // Assert that all entries have an Atom ID object - foreach ($feed as $entry) { - $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); - } - - // Assert one of the entry's Titles - $entry = $feed[0]; - $this->verifyProperty2($entry, "title", "text", "Test"); - } - - /** - * Check for the existence of an <atom:subtitle> and verify that it contains - * the expected value. - */ - public function testSubtitle() - { - $feed = $this->userFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); - $this->verifyProperty2($feed, "subtitle", "text", - ""); - } - - /** - * Check for the existence of an <atom:generator> and verify that it contains - * the expected value. - */ - public function testGenerator() - { - $feed = $this->userFeed; - - // Assert that the feed's generator is correct - $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); - $this->verifyProperty2($feed, "generator", "version", "1.00"); - $this->verifyProperty2($feed, "generator", "uri", "http://picasaweb.google.com/"); - $this->verifyProperty2($feed, "generator", "text", "Picasaweb"); - } - - /** - * Check for the existence of an <atom:icon> and verify that it contains - * the expected value. - */ - public function testIcon() - { - $feed = $this->userFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getIcon() instanceof Zend_Gdata_App_Extension_Icon); - $this->verifyProperty2($feed, "icon", "text", - "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); - } - - /** - * Check for the existence of an <gphoto:user> and verify that it contains - * the expected value. - */ - public function testGphotoUser() - { - $feed = $this->userFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); - $this->verifyProperty2($feed, "gphotoUser", "text", - "sample.user"); - $this->verifyProperty3($feed, "gphotoUser", "text", - "sample.user"); - } - - /** - * Check for the existence of an <gphoto:nickname> and verify that it contains - * the expected value. - */ - public function testGphotoNickname() - { - $feed = $this->userFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); - $this->verifyProperty2($feed, "gphotoNickname", "text", - "sample"); - $this->verifyProperty3($feed, "gphotoNickname", "text", - "sample"); - } - - /** - * Check for the existence of an <gphoto:thumbnail> and verify that it contains - * the expected value. - */ - public function testGphotoThumbnail() - { - $feed = $this->userFeed; - - // Assert that the feed's title is correct - $this->assertTrue($feed->getGphotoThumbnail() instanceof Zend_Gdata_Photos_Extension_Thumbnail); - $this->verifyProperty2($feed, "gphotoThumbnail", "text", - "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); - $this->verifyProperty3($feed, "gphotoThumbnail", "text", - "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); - } - -} diff --git a/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php b/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php deleted file mode 100755 index ce074115e8ecfb67cc213de6692986dd807428b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php +++ /dev/null @@ -1,128 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Gdata/Photos/UserQuery.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Photos_PhotosUserQueryTest extends PHPUnit_Framework_TestCase -{ - - /** - * Check the consistency of a user feed request - */ - public function testSimpleUserQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user"; - - $query = new Zend_Gdata_Photos_UserQuery(); - $query->setUser("sample.user"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of a user feed request - * Projection is set to base - */ - public function testBaseUserQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/base/user/sample.user"; - - $query = new Zend_Gdata_Photos_UserQuery(); - $query->setUser("sample.user"); - $query->setProjection("base"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check for thrown exceptions upon improper albumname/id setting - */ - public function testUserQueryExceptions() - { - $query = new Zend_Gdata_Photos_UserQuery(); - $query->setUser("sample.user"); - $query->setProjection(null); - - try { - $generatedString = $query->getQueryUrl(); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - - $query->setProjection("api"); - $query->setUser(null); - - try { - $generatedString = $query->getQueryUrl(); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - } - - /** - * Check the consistency of a user feed request filtered - * for a specific tag - */ - public function testTagFilterUserQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user?tag=test"; - - $query = new Zend_Gdata_Photos_UserQuery(); - $query->setUser("sample.user"); - $query->setTag("test"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - - /** - * Check the consistency of a user feed request for private data - */ - public function testPrivateUserQuery() - { - $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user?access=private"; - - $query = new Zend_Gdata_Photos_UserQuery(); - $query->setUser("sample.user"); - $query->setAccess("private"); - - $generatedString = $query->getQueryUrl(); - - // Assert that the generated query matches the correct one - $this->assertEquals($queryString, $generatedString); - } - -} diff --git a/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml b/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml deleted file mode 100755 index 70bef7ad7af275bddba3e98236f307ee0409a33d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1</id> - <published>2007-09-05T07:00:00.000Z</published> - <updated>2007-09-05T20:49:24.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/> - <title type="text">Test</title> - <summary type="text"/> - <rights type="text">public</rights> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - <gphoto:id>1</gphoto:id> - <gphoto:name>Test</gphoto:name> - <gphoto:location/> - <gphoto:access>public</gphoto:access> - <gphoto:timestamp>1188975600000</gphoto:timestamp> - <gphoto:numphotos>2</gphoto:numphotos> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <media:group> - <media:title type="plain">Test</media:title> - <media:description type="plain"/> - <media:keywords/> - <media:content url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/Test.jpg" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg" height="160" width="160"/> - <media:credit>sample</media:credit> - </media:group> - <georss:where> - <gml:Point> - <gml:pos>42.87194 13.56738</gml:pos> - </gml:Point> - </georss:where> -</entry> diff --git a/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml b/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml deleted file mode 100755 index b8758a33e84ab37dba88aa374447a96f6d7d0ab4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml +++ /dev/null @@ -1,139 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1</id> - <updated>2007-09-21T18:23:05.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/> - <title type="text">Test</title> - <subtitle type="text"/> - <rights type="text">public</rights> - <icon>http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg</icon> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test"/> - <link rel="http://schemas.google.com/photos/2007#slideshow" type="application/x-shockwave-flash" href="http://picasaweb.google.com/s/c/bin/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsample.user%2Falbumid%2F1%3Falt%3Drss"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?start-index=1&max-results=500&kind=photo%2Ctag"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - <generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator> - <openSearch:totalResults>4</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>500</openSearch:itemsPerPage> - <gphoto:id>1</gphoto:id> - <gphoto:name>Test</gphoto:name> - <gphoto:location/> - <gphoto:access>public</gphoto:access> - <gphoto:timestamp>1188975600000</gphoto:timestamp> - <gphoto:numphotos>2</gphoto:numphotos> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2</id> - <published>2007-09-05T20:49:23.000Z</published> - <updated>2007-09-21T18:23:05.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> - <title type="text">Aqua Blue.jpg</title> - <summary type="text">Blue</summary> - <content type="image/jpeg" src="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/2"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#2"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2"/> - <gphoto:id>2</gphoto:id> - <gphoto:version>1190398985145172</gphoto:version> - <gphoto:position>0.0</gphoto:position> - <gphoto:albumid>1</gphoto:albumid> - <gphoto:width>2560</gphoto:width> - <gphoto:height>1600</gphoto:height> - <gphoto:size>883405</gphoto:size> - <gphoto:client/> - <gphoto:checksum/> - <gphoto:timestamp>1189025362000</gphoto:timestamp> - <exif:tags> - <exif:flash>true</exif:flash> - <exif:imageUniqueID>c041ce17aaa637eb656c81d9cf526c24</exif:imageUniqueID> - </exif:tags> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>1</gphoto:commentCount> - <media:group> - <media:title type="plain">Aqua Blue.jpg</media:title> - <media:description type="plain">Blue</media:description> - <media:keywords>tag, test</media:keywords> - <media:content url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s72/Aqua%20Blue.jpg" height="45" width="72"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s144/Aqua%20Blue.jpg" height="90" width="144"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg" height="180" width="288"/> - <media:credit>sample</media:credit> - </media:group> - <georss:where> - <gml:Point> - <gml:pos>41.87194 12.56738</gml:pos> - </gml:Point> - </georss:where> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/3</id> - <published>2007-09-05T20:49:24.000Z</published> - <updated>2007-09-21T18:19:38.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> - <title type="text">Aqua Graphite.jpg</title> - <summary type="text">Gray</summary> - <content type="image/jpeg" src="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/3"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#3"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/3"/> - <gphoto:id>3</gphoto:id> - <gphoto:version>1190398778006402</gphoto:version> - <gphoto:position>1.0</gphoto:position> - <gphoto:albumid>1</gphoto:albumid> - <gphoto:width>2560</gphoto:width> - <gphoto:height>1600</gphoto:height> - <gphoto:size>798334</gphoto:size> - <gphoto:client/> - <gphoto:checksum/> - <gphoto:timestamp>1189025363000</gphoto:timestamp> - <exif:tags> - <exif:flash>true</exif:flash> - <exif:imageUniqueID>a5ce2e36b9df7d3cb081511c72e73926</exif:imageUniqueID> - </exif:tags> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <media:group> - <media:title type="plain">Aqua Graphite.jpg</media:title> - <media:description type="plain">Gray</media:description> - <media:keywords/> - <media:content url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s72/Aqua%20Graphite.jpg" height="45" width="72"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s144/Aqua%20Graphite.jpg" height="90" width="144"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s288/Aqua%20Graphite.jpg" height="180" width="288"/> - <media:credit>sample</media:credit> - </media:group> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/tag</id> - <updated>2007-09-05T20:49:24.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> - <title type="text">tag</title> - <summary type="text">tag</summary> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=tag&psc=G&uname=sample.user&filter=0"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/tag"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/test</id> - <updated>2007-09-05T20:49:24.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> - <title type="text">test</title> - <summary type="text">test</summary> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=test&psc=G&uname=sample.user&filter=0"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/test"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - </entry> -</feed> diff --git a/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml b/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml deleted file mode 100755 index 5b3d4238f8c99e651470dba49bb08f368d884c64..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5</id> - <published>2007-09-21T18:22:53.000Z</published> - <updated>2007-09-21T18:22:53.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#comment"/> - <title type="text">sample</title> - <summary type="text">test comment</summary> - <content type="text">test comment</content> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s48-c/sample.user</gphoto:thumbnail> - </author> - <gphoto:id>5</gphoto:id> - <gphoto:photoid>100</gphoto:photoid> -</entry> diff --git a/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml b/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml deleted file mode 100755 index 2f6e4b5d038dd8719ea2a12c2086b0caa5fb1531..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100</id> - <published>2007-09-05T20:49:24.000Z</published> - <updated>2007-09-21T18:19:38.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> - <title type="text">Aqua Graphite.jpg</title> - <summary type="text">Gray</summary> - <content type="image/jpeg" src="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100"/> - <gphoto:id>100</gphoto:id> - <gphoto:version>1190398778006402</gphoto:version> - <gphoto:albumid>1</gphoto:albumid> - <gphoto:width>2560</gphoto:width> - <gphoto:height>1600</gphoto:height> - <gphoto:size>798334</gphoto:size> - <gphoto:client/> - <gphoto:checksum/> - <gphoto:timestamp>1189025363000</gphoto:timestamp> - <exif:tags> - <exif:fstop>11.0</exif:fstop> - <exif:exposure>0.0040</exif:exposure> - <exif:flash>true</exif:flash> - <exif:focallength>22.0</exif:focallength> - <exif:iso>200</exif:iso> - <exif:time>1180950900000</exif:time> - <exif:imageUniqueID>a5ce2e36b9df7d3cb081511c72e73926</exif:imageUniqueID> - <exif:distance>0.0</exif:distance> - <exif:make>Fictitious Camera Company</exif:make> - <exif:model>AMAZING-100D</exif:model> - </exif:tags> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <media:group> - <media:title type="plain">Aqua Graphite.jpg</media:title> - <media:description type="plain">Gray</media:description> - <media:keywords/> - <media:content url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s72/Aqua%20Graphite.jpg" height="45" width="72"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s144/Aqua%20Graphite.jpg" height="90" width="144"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s288/Aqua%20Graphite.jpg" height="180" width="288"/> - <media:credit>sample</media:credit> - </media:group> - <georss:where> - <gml:Point> - <gml:pos>41.87194 12.56738</gml:pos> - </gml:Point> - </georss:where> -</entry> diff --git a/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml b/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml deleted file mode 100755 index ea3fb8fbf907409e2d9a318af5bfac581b7acaa4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100</id> - <updated>2007-09-21T18:23:05.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> - <title type="text">Aqua Blue.jpg</title> - <subtitle type="text">Blue</subtitle> - <icon>http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg</icon> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100?start-index=1&max-results=500&kind=tag%2Ccomment"/> - <generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator> - <openSearch:totalResults>3</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>500</openSearch:itemsPerPage> - <gphoto:id>100</gphoto:id> - <gphoto:version>1190398985145172</gphoto:version> - <gphoto:albumid>1</gphoto:albumid> - <gphoto:width>2560</gphoto:width> - <gphoto:height>1600</gphoto:height> - <gphoto:size>883405</gphoto:size> - <gphoto:client/> - <gphoto:checksum/> - <gphoto:timestamp>1189025362000</gphoto:timestamp> - <exif:tags> - <exif:flash>true</exif:flash> - <exif:imageUniqueID>c041ce17aaa637eb656c81d9cf526c24</exif:imageUniqueID> - </exif:tags> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>1</gphoto:commentCount> - <media:group> - <media:title type="plain">Aqua Blue.jpg</media:title> - <media:description type="plain">Blue</media:description> - <media:keywords>tag, test</media:keywords> - <media:content url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s72/Aqua%20Blue.jpg" height="45" width="72"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s144/Aqua%20Blue.jpg" height="90" width="144"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg" height="180" width="288"/> - <media:credit>sample</media:credit> - </media:group> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag</id> - <updated>2007-09-21T18:23:05.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> - <title type="text">tag</title> - <summary type="text">tag</summary> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=tag&psc=G&uname=sample.user&filter=0"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/test</id> - <updated>2007-09-21T18:23:05.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> - <title type="text">test</title> - <summary type="text">test</summary> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=test&psc=G&uname=sample.user&filter=0"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/test"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5</id> - <published>2007-09-21T18:22:53.000Z</published> - <updated>2007-09-21T18:22:53.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#comment"/> - <title type="text">sample</title> - <summary type="text">test comment</summary> - <content type="text">test comment</content> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s48-c/sample.user</gphoto:thumbnail> - </author> - <gphoto:id>5</gphoto:id> - <gphoto:photoid>100</gphoto:photoid> - </entry> -</feed> diff --git a/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml b/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml deleted file mode 100755 index 6e00dd586ff74c9314f6bf7fd461ba903cc3ef6c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag</id> - <updated>1970-01-01T00:01:01.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> - <title type="text">tag</title> - <summary type="text">tag</summary> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=tag&psc=G&uname=sample.user&filter=0"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> -</entry> diff --git a/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml b/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml deleted file mode 100755 index 759818c47844ade49e3f1bc5c1e4d147869517b5..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<entry xmlns="http://www.w3.org/2005/Atom" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user</id> - <published>2007-09-24T23:45:49.059Z</published> - <updated>2007-09-24T23:45:49.059Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#user"/> - <title type="text">sample.user</title> - <summary type="text"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user</gphoto:thumbnail> -</entry> diff --git a/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml b/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml deleted file mode 100755 index 58dd6b407b350d95adb1e94b34ddb1388724759c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml +++ /dev/null @@ -1,132 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> - <id>http://picasaweb.google.com/data/feed/api/user/sample.user</id> - <updated>2007-09-20T21:09:39.111Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#user"/> - <title type="text">sample.user</title> - <subtitle type="text"/> - <icon>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user</icon> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user"/> - <link rel="http://schemas.google.com/photos/2007#slideshow" type="application/x-shockwave-flash" href="http://picasaweb.google.com/s/c/bin/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsample.user%3Falt%3Drss"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user?start-index=1&max-results=100&kind=album%2Cphoto%2Ctag"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - <generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator> - <openSearch:totalResults>4</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>100</openSearch:itemsPerPage> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user</gphoto:thumbnail> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100</id> - <published>2007-09-05T07:00:00.000Z</published> - <updated>2007-09-05T20:49:24.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/> - <title type="text">Test</title> - <summary type="text"/> - <rights type="text">public</rights> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/100"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100"/> - <author> - <name>sample</name> - <uri>http://picasaweb.google.com/sample.user</uri> - </author> - <gphoto:id>100</gphoto:id> - <gphoto:name>Test</gphoto:name> - <gphoto:location/> - <gphoto:access>public</gphoto:access> - <gphoto:timestamp>1188975600000</gphoto:timestamp> - <gphoto:numphotos>2</gphoto:numphotos> - <gphoto:user>sample.user</gphoto:user> - <gphoto:nickname>sample</gphoto:nickname> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <media:group> - <media:title type="plain">Test</media:title> - <media:description type="plain"/> - <media:keywords/> - <media:content url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/Test.jpg" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg" height="160" width="160"/> - <media:credit>sample</media:credit> - </media:group> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/2</id> - <published>2007-09-05T20:49:24.000Z</published> - <updated>2007-09-05T20:49:23.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> - <title type="text">Second.jpg</title> - <summary type="text"/> - <content type="image/jpeg" src="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/100/photoid/2"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#2"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/2"/> - <gphoto:id>2</gphoto:id> - <gphoto:version>1189025363424891</gphoto:version> - <gphoto:albumid>100</gphoto:albumid> - <gphoto:width>2560</gphoto:width> - <gphoto:height>1600</gphoto:height> - <gphoto:size>798334</gphoto:size> - <gphoto:client/> - <gphoto:checksum/> - <gphoto:timestamp>1189025363000</gphoto:timestamp> - <exif:tags xmlns:exif="http://schemas.google.com/photos/exif/2007"> - <exif:flash>true</exif:flash> - <exif:imageUniqueID>a5ce2e36b9df7d3cb081511c72e73926</exif:imageUniqueID> - </exif:tags> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <media:group> - <media:title type="plain">Second.jpg</media:title> - <media:description type="plain"/> - <media:keywords/> - <media:content url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s72/Aqua%20Graphite.jpg" height="45" width="72"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s144/Aqua%20Graphite.jpg" height="90" width="144"/> - <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s288/Aqua%20Graphite.jpg" height="180" width="288"/> - <media:credit>sample</media:credit> - </media:group> - </entry> - <entry> - <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/1</id> - <published>2007-09-05T20:49:23.000Z</published> - <updated>2007-09-05T20:49:22.000Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> - <title type="text">First.jpg</title> - <summary type="text"/> - <content type="image/jpeg" src="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/100/photoid/1"/> - <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#1"/> - <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/1"/> - <gphoto:id>1</gphoto:id> - <gphoto:version>1189025362423722</gphoto:version> - <gphoto:albumid>100</gphoto:albumid> - <gphoto:width>2560</gphoto:width> - <gphoto:height>1600</gphoto:height> - <gphoto:size>883405</gphoto:size> - <gphoto:client/> - <gphoto:checksum/> - <gphoto:timestamp>1189025362000</gphoto:timestamp> - <exif:tags xmlns:exif="http://schemas.google.com/photos/exif/2007"> - <exif:flash>true</exif:flash> - <exif:imageUniqueID>c041ce17aaa637eb656c81d9cf526c24</exif:imageUniqueID> - </exif:tags> - <gphoto:commentingEnabled>true</gphoto:commentingEnabled> - <gphoto:commentCount>0</gphoto:commentCount> - <media:group> - <media:title type="plain">First.jpg</media:title> - <media:description type="plain"/> - <media:keywords/> - <media:content url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s72/Aqua%20Blue.jpg" height="45" width="72"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s144/Aqua%20Blue.jpg" height="90" width="144"/> - <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg" height="180" width="288"/> - <media:credit>sample</media:credit> - </media:group> - </entry> -</feed> diff --git a/tests/Zend/Gdata/Photos/_files/test.jpg b/tests/Zend/Gdata/Photos/_files/test.jpg deleted file mode 100755 index d4a5a1098dfa166e24b95623f51bb125d1b2c435..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Gdata/Photos/_files/test.jpg and /dev/null differ diff --git a/tests/Zend/Gdata/PhotosOnlineTest.php b/tests/Zend/Gdata/PhotosOnlineTest.php deleted file mode 100755 index a2a1528fb366b1cf6369b65d78356148bcb925d0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/PhotosOnlineTest.php +++ /dev/null @@ -1,284 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/Photos.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; -require_once 'Zend/Gdata/ClientLogin.php'; -require_once 'Zend/Gdata/App/InvalidArgumentException.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_PhotosOnlineTest extends PHPUnit_Framework_TestCase -{ - - protected $photos = null; - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $service = 'lh2'; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->photos = new Zend_Gdata_Photos($client); - } - - /** - * Verify that a given property is set to a specific value - * and that the getter and magic variable return the same value. - * - * @param object $obj The object to be interrogated. - * @param string $name The name of the property to be verified. - * @param string $secondName 2nd level accessor function name - * @param object $value The expected value of the property. - */ - protected function verifyProperty($obj, $name, $secondName, $value) - { - $propName = $name; - $propGetter = "get" . ucfirst($name); - $secondGetter = "get" . ucfirst($secondName); - - $this->assertEquals($obj->$propGetter(), $obj->$propName); - $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); - } - - public function createAlbum() - { - $client = $this->photos; - - $album = new Zend_Gdata_Photos_AlbumEntry(); - $album->setTitle($client->newTitle("testAlbum")); - $album->setCategory(array($client->newCategory( - 'http://schemas.google.com/photos/2007#album', - 'http://schemas.google.com/g/2005#kind'))); - - $newAlbum = $client->insertAlbumEntry($album); - $this->assertEquals($album->getTitle(), $newAlbum->getTitle()); - $this->assertEquals($newAlbum->getTitle(), $client->getAlbumEntry($newAlbum->getLink('self')->href)->getTitle()); - - $albumFeedUri = $newAlbum->getLink('http://schemas.google.com/g/2005#feed')->href; - $albumFeed = $client->getAlbumFeed($albumFeedUri); - $this->verifyProperty($albumFeed, "title", "text", "testAlbum"); - - return $newAlbum; - } - - public function createPhoto($album) - { - $client = $this->photos; - - $fd = $client->newMediaFileSource('Zend/Gdata/_files/testImage.jpg'); - $fd->setContentType('image/jpeg'); - - $photo = new Zend_Gdata_Photos_PhotoEntry(); - $photo->setMediaSource($fd); - $photo->setTitle($client->newTitle("test photo")); - $photo->setCategory(array($client->newCategory( - 'http://schemas.google.com/photos/2007#photo', - 'http://schemas.google.com/g/2005#kind'))); - - $newPhoto = $client->insertPhotoEntry($photo, $album); - $this->assertEquals($photo->getTitle(), $newPhoto->getTitle()); - $this->assertEquals($newPhoto->getTitle(), $client->getPhotoEntry($newPhoto->getLink('self')->href)->getTitle()); - - $photoFeedUri = $newPhoto->getLink('http://schemas.google.com/g/2005#feed')->href; - $photoFeed = $client->getPhotoFeed($photoFeedUri); - $this->verifyProperty($photoFeed, "title", "text", "test photo"); - - return $newPhoto; - } - - public function updatePhotoMetaData() - { - $client = $this->photos; - $album = $this->createAlbum(); - $insertedEntry = $this->createPhoto($album); - - $insertedEntry->title->text = "New Photo"; - $insertedEntry->summary->text = "Photo caption"; - $keywords = new Zend_Gdata_Media_Extension_MediaKeywords(); - $keywords->setText("foo, bar, baz"); - $insertedEntry->mediaGroup->keywords = $keywords; - - $updatedEntry = $insertedEntry->save(); - return array($updatedEntry, $album); - } - - public function createComment($photo) - { - $client = $this->photos; - - $comment = new Zend_Gdata_Photos_CommentEntry(); - $comment->setTitle($client->newTitle("test comment")); - $comment->setContent($client->newContent("test comment")); - $comment->setCategory(array($client->newCategory( - 'http://schemas.google.com/photos/2007#comment', - 'http://schemas.google.com/g/2005#kind'))); - - $newComment = $client->insertCommentEntry($comment, $photo); - $this->assertEquals($comment->getContent(), $newComment->getContent()); - $this->assertEquals($newComment->getContent(), $client->getCommentEntry($newComment->getLink('self')->href)->getContent()); - - return $newComment; - } - - public function createTag($photo) - { - $client = $this->photos; - - $tag = new Zend_Gdata_Photos_TagEntry(); - $tag->setTitle($client->newTitle("test tag")); - $tag->setContent($client->newContent("test tag")); - $tag->setCategory(array($client->newCategory( - 'http://schemas.google.com/photos/2007#tag', - 'http://schemas.google.com/g/2005#kind'))); - - $newTag = $client->insertTagEntry($tag, $photo); - $this->assertEquals($tag->getTitle(), $newTag->getTitle()); - $this->assertEquals($newTag->getTitle(), $client->getTagEntry($newTag->getLink('self')->href)->getTitle()); - - return $newTag; - } - - public function testCreateAlbumAndUploadPhoto() - { - $client = $this->photos; - $album = $this->createAlbum(); - $photo = $this->createPhoto($album); - - // Clean up the mess - $client->deletePhotoEntry($photo, true); - $client->deleteAlbumEntry($album, true); - } - - public function testUpdatePhotoMetadata() - { - $client = $this->photos; - $dataArray = $this->updatePhotoMetaData(); - $updatedPhoto = $dataArray[0]; - $album = $dataArray[1]; - - $this->assertTrue($updatedPhoto instanceof Zend_Gdata_Photos_PhotoEntry); - - // Clean up the mess - $client->deletePhotoEntry($updatedPhoto, true); - $client->deleteAlbumEntry($album, true); - } - - public function testUserFeedAndEntry() - { - $client = $this->photos; - - $userEntryUri = "http://picasaweb.google.com/data/entry/api/user/" . - constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME'); - - $userEntry = $client->getUserEntry($userEntryUri); - $this->verifyProperty($userEntry, "id", "text", - "http://picasaweb.google.com/data/entry/api/user/" . - constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME')); - - - $userFeed = $client->getUserFeed(constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME')); - $this->verifyProperty($userFeed, "id", "text", - "http://picasaweb.google.com/data/feed/api/user/" . - constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME')); - } - - public function testCreatePhotoCommentAndTag() - { - $client = $this->photos; - $album = $this->createAlbum(); - $photo = $this->createPhoto($album); - $comment = $this->createComment($photo); - $tag = $this->createTag($photo); - - // Clean up the mess - $client->deleteTagEntry($tag, true); - $client->deleteCommentEntry($comment, true); - $client->deletePhotoEntry($photo, true); - $client->deleteAlbumEntry($album, true); - } - - public function testInvalidEntryFetchingAndInserting() - { - $client = $this->photos; - - try { - $userEntry = $client->getUserEntry(null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $userEntry = $client->getAlbumEntry(null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $photoEntry = $client->getPhotoEntry(null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $tagEntry = $client->getTagEntry(null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $commentEntry = $client->getCommentEntry(null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $photo = new Zend_Gdata_Photos_PhotoEntry(); - $result = $client->insertPhotoEntry($photo, null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $comment = new Zend_Gdata_Photos_CommentEntry(); - $result = $client->insertCommentEntry($comment, null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - try { - $tag = new Zend_Gdata_Photos_TagEntry(); - $result = $client->insertTagEntry($tag, null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - } - - public function testInvalidFeedFetching() - { - $client = $this->photos; - - try { - $albumFeed = $client->getAlbumFeed(null); - } catch (Exception $e) { - $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); - } - } - -} diff --git a/tests/Zend/Gdata/QueryTest.php b/tests/Zend/Gdata/QueryTest.php deleted file mode 100644 index dbf7bba4036038d9a4f2b75228c54ab7593b7cf2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/QueryTest.php +++ /dev/null @@ -1,118 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/Query.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_QueryTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - } - - public function testSetAndGetAlt() - { - $query = new Zend_Gdata_Query(); - $query->setAlt('rss'); - $this->assertEquals('rss', $query->alt); - $this->assertContains('alt=rss', $query->getQueryUrl()); - } - - public function testSetAndGetUpdatedMax() - { - $query = new Zend_Gdata_Query(); - $query->setUpdatedMax('2007-01-01'); - $this->assertEquals('2007-01-01', $query->getUpdatedMax()); - $this->assertContains('updated-max=2007-01-01', $query->getQueryUrl()); - } - - public function testSetAndGetUpdatedMin() - { - $query = new Zend_Gdata_Query(); - $query->setUpdatedMin('2007-01-01'); - $this->assertEquals('2007-01-01', $query->getUpdatedMin()); - $this->assertContains('updated-min=2007-01-01', $query->getQueryUrl()); - } - - public function testSetAndGetPublishedMax() - { - $query = new Zend_Gdata_Query(); - $query->setPublishedMax('2007-01-01'); - $this->assertEquals('2007-01-01', $query->getPublishedMax()); - $this->assertContains('published-max=2007-01-01', - $query->getQueryUrl()); - } - - public function testSetAndGetPublishedMin() - { - $query = new Zend_Gdata_Query(); - $query->setPublishedMin('2007-01-01'); - $this->assertEquals('2007-01-01', $query->getPublishedMin()); - $this->assertContains('published-min=2007-01-01', - $query->getQueryUrl()); - } - - public function testSetAndGetAuthor() - { - $query = new Zend_Gdata_Query(); - $query->setAuthor('My Name'); - $this->assertEquals('My Name', $query->getAuthor()); - $this->assertContains('author=My+Name', $query->getQueryUrl()); - } - - public function testSetAndGetMaxResults() - { - $query = new Zend_Gdata_Query(); - $query->setMaxResults('300'); - $this->assertEquals('300', $query->getMaxResults()); - $this->assertContains('max-results=300', $query->getQueryUrl()); - } - - public function testSetAndGetGenericParam() - { - $query = new Zend_Gdata_Query(); - $query->setParam('fw', 'zend'); - $this->assertEquals('zend', $query->getParam('fw')); - $this->assertContains('fw=zend', $query->getQueryUrl()); - } - - public function testSetAndGetFullTextQuery() - { - $query = new Zend_Gdata_Query(); - $query->setQuery('geek events'); - $this->assertEquals('geek events', $query->getQuery()); - $this->assertContains('q=geek+events', $query->getQueryUrl()); - } - - public function testSetAndGetStartIndex() - { - $query = new Zend_Gdata_Query(); - $query->setStartIndex(12); - $this->assertEquals(12, $query->getStartIndex()); - $this->assertContains('start-index=12', $query->getQueryUrl()); - } - -} diff --git a/tests/Zend/Gdata/RecurrenceExceptionTest.php b/tests/Zend/Gdata/RecurrenceExceptionTest.php deleted file mode 100644 index 576bb035ba4381132368dda0b506b7ad5d7bb9c7..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/RecurrenceExceptionTest.php +++ /dev/null @@ -1,126 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/RecurrenceException.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_RecurrenceExceptionTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->recurrenceExceptionText = file_get_contents( - 'Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml', - true); - $this->recurrenceException = new Zend_Gdata_Extension_RecurrenceException(); - } - - public function testEmptyRecurrenceExceptionShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->recurrenceException->extensionElements)); - $this->assertTrue(count($this->recurrenceException->extensionElements) == 0); - } - - public function testEmptyRecurrenceExceptionShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->recurrenceException->extensionAttributes)); - $this->assertTrue(count($this->recurrenceException->extensionAttributes) == 0); - } - - public function testSampleRecurrenceExceptionShouldHaveNoExtensionElements() { - $this->recurrenceException->transferFromXML($this->recurrenceExceptionText); - $this->assertTrue(is_array($this->recurrenceException->extensionElements)); - $this->assertTrue(count($this->recurrenceException->extensionElements) == 0); - } - - public function testSampleRecurrenceExceptionShouldHaveNoExtensionAttributes() { - $this->recurrenceException->transferFromXML($this->recurrenceExceptionText); - $this->assertTrue(is_array($this->recurrenceException->extensionAttributes)); - $this->assertTrue(count($this->recurrenceException->extensionAttributes) == 0); - } - - public function testNormalRecurrenceExceptionShouldHaveNoExtensionElements() { - $this->recurrenceException->specialized = "false"; - - $this->assertEquals("false", $this->recurrenceException->specialized); - - $this->assertEquals(0, count($this->recurrenceException->extensionElements)); - $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); - $newRecurrenceException->transferFromXML($this->recurrenceException->saveXML()); - $this->assertEquals(0, count($newRecurrenceException->extensionElements)); - $newRecurrenceException->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newRecurrenceException->extensionElements)); - $this->assertEquals("false", $newRecurrenceException->specialized); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newRecurrenceException2 = $gdata->newRecurrenceException(); - $newRecurrenceException2->transferFromXML($newRecurrenceException->saveXML()); - $this->assertEquals(1, count($newRecurrenceException2->extensionElements)); - $this->assertEquals("false", $newRecurrenceException2->specialized); - } - - public function testEmptyRecurrenceExceptionToAndFromStringShouldMatch() { - $recurrenceExceptionXml = $this->recurrenceException->saveXML(); - $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); - $newRecurrenceException->transferFromXML($recurrenceExceptionXml); - $newRecurrenceExceptionXml = $newRecurrenceException->saveXML(); - $this->assertTrue($recurrenceExceptionXml == $newRecurrenceExceptionXml); - } - - public function testRecurrenceExceptionWithValueToAndFromStringShouldMatch() { - $this->recurrenceException->specialized = "false"; - $recurrenceExceptionXml = $this->recurrenceException->saveXML(); - $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); - $newRecurrenceException->transferFromXML($recurrenceExceptionXml); - $newRecurrenceExceptionXml = $newRecurrenceException->saveXML(); - $this->assertTrue($recurrenceExceptionXml == $newRecurrenceExceptionXml); - $this->assertEquals("false", $this->recurrenceException->specialized); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->recurrenceException->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->recurrenceException->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->recurrenceException->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->recurrenceException->extensionAttributes['foo2']['value']); - $recurrenceExceptionXml = $this->recurrenceException->saveXML(); - $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); - $newRecurrenceException->transferFromXML($recurrenceExceptionXml); - $this->assertEquals('bar', $newRecurrenceException->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newRecurrenceException->extensionAttributes['foo2']['value']); - } - - public function testConvertFullRecurrenceExceptionToAndFromString() { - $this->recurrenceException->transferFromXML($this->recurrenceExceptionText); - $this->assertEquals("true", $this->recurrenceException->specialized); - $this->assertTrue($this->recurrenceException->entryLink instanceof Zend_Gdata_Extension_EntryLink); - $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full/hj4geu9lpkh3ebk6rvm4k8mhik", $this->recurrenceException->entryLink->href); - $this->assertTrue($this->recurrenceException->originalEvent instanceof Zend_Gdata_Extension_OriginalEvent); - $this->assertEquals("hj4geu9lpkh3ebk6rvm4k8mhik", $this->recurrenceException->originalEvent->id); - } - -} diff --git a/tests/Zend/Gdata/RecurrenceTest.php b/tests/Zend/Gdata/RecurrenceTest.php deleted file mode 100644 index 77d93f8a960bf71a8698d7c6c7e1d9544d4606c2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/RecurrenceTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Recurrence.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_RecurrenceTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->recurrenceText = file_get_contents( - 'Zend/Gdata/_files/RecurrenceElementSample1.xml', - true); - $this->recurrence = new Zend_Gdata_Extension_Recurrence(); - } - - public function testEmptyRecurrenceShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->recurrence->extensionElements)); - $this->assertTrue(count($this->recurrence->extensionElements) == 0); - } - - public function testEmptyRecurrenceShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->recurrence->extensionAttributes)); - $this->assertTrue(count($this->recurrence->extensionAttributes) == 0); - } - - public function testSampleRecurrenceShouldHaveNoExtensionElements() { - $this->recurrence->transferFromXML($this->recurrenceText); - $this->assertTrue(is_array($this->recurrence->extensionElements)); - $this->assertTrue(count($this->recurrence->extensionElements) == 0); - } - - public function testSampleRecurrenceShouldHaveNoExtensionAttributes() { - $this->recurrence->transferFromXML($this->recurrenceText); - $this->assertTrue(is_array($this->recurrence->extensionAttributes)); - $this->assertTrue(count($this->recurrence->extensionAttributes) == 0); - } - - public function testNormalRecurrenceShouldHaveNoExtensionElements() { - $this->recurrence->text = "Foo"; - - $this->assertEquals("Foo", $this->recurrence->text); - - $this->assertEquals(0, count($this->recurrence->extensionElements)); - $newRecurrence = new Zend_Gdata_Extension_Recurrence(); - $newRecurrence->transferFromXML($this->recurrence->saveXML()); - $this->assertEquals(0, count($newRecurrence->extensionElements)); - $newRecurrence->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newRecurrence->extensionElements)); - $this->assertEquals("Foo", $newRecurrence->text); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newRecurrence2 = $gdata->newRecurrence(); - $newRecurrence2->transferFromXML($newRecurrence->saveXML()); - $this->assertEquals(1, count($newRecurrence2->extensionElements)); - $this->assertEquals("Foo", $newRecurrence2->text); - } - - public function testEmptyRecurrenceToAndFromStringShouldMatch() { - $recurrenceXml = $this->recurrence->saveXML(); - $newRecurrence = new Zend_Gdata_Extension_Recurrence(); - $newRecurrence->transferFromXML($recurrenceXml); - $newRecurrenceXml = $newRecurrence->saveXML(); - $this->assertTrue($recurrenceXml == $newRecurrenceXml); - } - - public function testRecurrenceWithValueToAndFromStringShouldMatch() { - $this->recurrence->text = "Foo"; - $recurrenceXml = $this->recurrence->saveXML(); - $newRecurrence = new Zend_Gdata_Extension_Recurrence(); - $newRecurrence->transferFromXML($recurrenceXml); - $newRecurrenceXml = $newRecurrence->saveXML(); - $this->assertTrue($recurrenceXml == $newRecurrenceXml); - $this->assertEquals("Foo", $this->recurrence->text); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->recurrence->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->recurrence->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->recurrence->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->recurrence->extensionAttributes['foo2']['value']); - $recurrenceXml = $this->recurrence->saveXML(); - $newRecurrence = new Zend_Gdata_Extension_Recurrence(); - $newRecurrence->transferFromXML($recurrenceXml); - $this->assertEquals('bar', $newRecurrence->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newRecurrence->extensionAttributes['foo2']['value']); - } - - public function testConvertFullRecurrenceToAndFromString() { - $this->recurrence->transferFromXML($this->recurrenceText); - $this->assertEquals("DTSTART;VALUE=DATE:20070501\nDTEND;VALUE=DATE:20070502\nRRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904", $this->recurrence->text); - } - -} diff --git a/tests/Zend/Gdata/ReminderTest.php b/tests/Zend/Gdata/ReminderTest.php deleted file mode 100644 index 2c34b0e7e2f3d60afa2602134fffafdf3cddc845..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/ReminderTest.php +++ /dev/null @@ -1,150 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Reminder.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_ReminderTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->reminderText = file_get_contents( - 'Zend/Gdata/_files/ReminderElementSample1.xml', - true); - $this->reminder = new Zend_Gdata_Extension_Reminder(); - } - - public function testEmptyReminderShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->reminder->extensionElements)); - $this->assertTrue(count($this->reminder->extensionElements) == 0); - } - - public function testEmptyReminderShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->reminder->extensionAttributes)); - $this->assertTrue(count($this->reminder->extensionAttributes) == 0); - } - - public function testSampleReminderShouldHaveNoExtensionElements() { - $this->reminder->transferFromXML($this->reminderText); - $this->assertTrue(is_array($this->reminder->extensionElements)); - $this->assertTrue(count($this->reminder->extensionElements) == 0); - } - - public function testSampleReminderShouldHaveNoExtensionAttributes() { - $this->reminder->transferFromXML($this->reminderText); - $this->assertTrue(is_array($this->reminder->extensionAttributes)); - $this->assertTrue(count($this->reminder->extensionAttributes) == 0); - } - - public function testNormalReminderShouldHaveNoExtensionElements() { - $this->reminder->days = "12"; - $this->reminder->minutes = "64"; - $this->reminder->absoluteTime = "2007-06-19T12:42:19-06:00"; - $this->reminder->method = "email"; - $this->reminder->hours = "80"; - - $this->assertEquals("12", $this->reminder->days); - $this->assertEquals("64", $this->reminder->minutes); - $this->assertEquals("2007-06-19T12:42:19-06:00", $this->reminder->absoluteTime); - $this->assertEquals("email", $this->reminder->method); - $this->assertEquals("80", $this->reminder->hours); - - $this->assertEquals(0, count($this->reminder->extensionElements)); - $newReminder = new Zend_Gdata_Extension_Reminder(); - $newReminder->transferFromXML($this->reminder->saveXML()); - $this->assertEquals(0, count($newReminder->extensionElements)); - $newReminder->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newReminder->extensionElements)); - $this->assertEquals("12", $newReminder->days); - $this->assertEquals("64", $newReminder->minutes); - $this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder->absoluteTime); - $this->assertEquals("email", $newReminder->method); - $this->assertEquals("80", $newReminder->hours); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newReminder2 = $gdata->newReminder(); - $newReminder2->transferFromXML($newReminder->saveXML()); - $this->assertEquals(1, count($newReminder2->extensionElements)); - $this->assertEquals("12", $newReminder2->days); - $this->assertEquals("64", $newReminder2->minutes); - $this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder2->absoluteTime); - $this->assertEquals("email", $newReminder2->method); - $this->assertEquals("80", $newReminder2->hours); - } - - public function testEmptyReminderToAndFromStringShouldMatch() { - $reminderXml = $this->reminder->saveXML(); - $newReminder = new Zend_Gdata_Extension_Reminder(); - $newReminder->transferFromXML($reminderXml); - $newReminderXml = $newReminder->saveXML(); - $this->assertTrue($reminderXml == $newReminderXml); - } - - public function testReminderWithValueToAndFromStringShouldMatch() { - $this->reminder->days = "12"; - $this->reminder->minutes = "64"; - $this->reminder->absoluteTime = "2007-06-19T12:42:19-06:00"; - $this->reminder->method = "email"; - $this->reminder->hours = "80"; - $reminderXml = $this->reminder->saveXML(); - $newReminder = new Zend_Gdata_Extension_Reminder(); - $newReminder->transferFromXML($reminderXml); - $newReminderXml = $newReminder->saveXML(); - $this->assertTrue($reminderXml == $newReminderXml); - $this->assertEquals("12", $this->reminder->days); - $this->assertEquals("64", $this->reminder->minutes); - $this->assertEquals("2007-06-19T12:42:19-06:00", $this->reminder->absoluteTime); - $this->assertEquals("email", $this->reminder->method); - $this->assertEquals("80", $this->reminder->hours); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->reminder->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->reminder->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->reminder->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->reminder->extensionAttributes['foo2']['value']); - $reminderXml = $this->reminder->saveXML(); - $newReminder = new Zend_Gdata_Extension_Reminder(); - $newReminder->transferFromXML($reminderXml); - $this->assertEquals('bar', $newReminder->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newReminder->extensionAttributes['foo2']['value']); - } - - public function testConvertFullReminderToAndFromString() { - $this->reminder->transferFromXML($this->reminderText); - $this->assertEquals("42", $this->reminder->days); - $this->assertEquals("50", $this->reminder->minutes); - $this->assertEquals("2005-06-06T16:55:00-08:00", $this->reminder->absoluteTime); - $this->assertEquals("sms", $this->reminder->method); - $this->assertEquals("20", $this->reminder->hours); - } - -} diff --git a/tests/Zend/Gdata/SkipTests.php b/tests/Zend/Gdata/SkipTests.php deleted file mode 100644 index 6bce90b2000afbf43f76f6721ae7d47f93e9e3f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/SkipTests.php +++ /dev/null @@ -1,56 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_SkipOnlineTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped("Zend_Gdata online tests are not enabled in TestConfiguration.php"); - } - - public function testOnline() - { - // this is here only so we have at least one test - } -} - -class Zend_Gdata_SkipClientLoginTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped("Zend_Gdata authenticated tests are not enabled in TestConfiguration.php"); - } - - public function testClientLogin() - { - // this is here only so we have at least one test - } -} diff --git a/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php b/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php deleted file mode 100644 index 578a0c91504471185439e3cf0569ad0627322a33..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php +++ /dev/null @@ -1,58 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_CellEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->cellEntry = new Zend_Gdata_Spreadsheets_CellEntry(); - } - - public function testToAndFromString() - { - $this->cellEntry->setCell(new Zend_Gdata_Spreadsheets_Extension_Cell('my cell', '1', '2', 'input value', 'numeric value')); - $this->assertTrue($this->cellEntry->getCell()->getText() == 'my cell'); - $this->assertTrue($this->cellEntry->getCell()->getRow() == '1'); - $this->assertTrue($this->cellEntry->getCell()->getColumn() == '2'); - $this->assertTrue($this->cellEntry->getCell()->getInputValue() == 'input value'); - $this->assertTrue($this->cellEntry->getCell()->getNumericValue() == 'numeric value'); - - $newCellEntry = new Zend_Gdata_Spreadsheets_CellEntry(); - $doc = new DOMDocument(); - $doc->loadXML($this->cellEntry->saveXML()); - $newCellEntry->transferFromDom($doc->documentElement); - - $this->assertTrue($this->cellEntry->getCell()->getText() == $newCellEntry->getCell()->getText()); - $this->assertTrue($this->cellEntry->getCell()->getRow() == $newCellEntry->getCell()->getRow()); - $this->assertTrue($this->cellEntry->getCell()->getColumn() == $newCellEntry->getCell()->getColumn()); - $this->assertTrue($this->cellEntry->getCell()->getInputValue() == $newCellEntry->getCell()->getInputValue()); - $this->assertTrue($this->cellEntry->getCell()->getNumericValue() == $newCellEntry->getCell()->getNumericValue()); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php b/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php deleted file mode 100644 index b031b37f1484cd786dcaac90313aa673508ed598..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php +++ /dev/null @@ -1,81 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_CellFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->cellFeed = new Zend_Gdata_Spreadsheets_CellFeed( - file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml', true), - true); - } - - public function testToAndFromString() - { - $this->assertTrue(count($this->cellFeed->entries) == 1); - foreach($this->cellFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - } - $this->assertTrue($this->cellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount); - $this->assertTrue($this->cellFeed->getRowCount()->getText() == '100'); - $this->assertTrue($this->cellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount); - $this->assertTrue($this->cellFeed->getColumnCount()->getText() == '20'); - - $newCellFeed = new Zend_Gdata_Spreadsheets_CellFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->cellFeed->saveXML()); - $newCellFeed->transferFromDom($doc->documentElement); - - $this->assertTrue(count($newCellFeed->entries) == 1); - foreach($newCellFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - } - $this->assertTrue($newCellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount); - $this->assertTrue($newCellFeed->getRowCount()->getText() == '100'); - $this->assertTrue($newCellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount); - $this->assertTrue($newCellFeed->getColumnCount()->getText() == '20'); - } - - public function testGetSetCounts() - { - $newRowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); - $newRowCount->setText("20"); - $newColCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); - $newColCount->setText("50"); - - $this->cellFeed->setRowCount($newRowCount); - $this->cellFeed->setColumnCount($newColCount); - - $this->assertTrue($this->cellFeed->getRowCount()->getText() == "20"); - $this->assertTrue($this->cellFeed->getColumnCount()->getText() == "50"); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php b/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php deleted file mode 100644 index ff8097ccb84f04980558e12d09641aceb739c16c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php +++ /dev/null @@ -1,132 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_CellQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->docQuery = new Zend_Gdata_Spreadsheets_CellQuery(); - } - - public function testMinRow() - { - $this->assertTrue($this->docQuery->getMinRow() == null); - $this->docQuery->setMinRow('1'); - $this->assertTrue($this->docQuery->getMinRow() == '1'); - $this->assertTrue($this->docQuery->getQueryString() == '?min-row=1'); - $this->docQuery->setMinRow(null); - $this->assertTrue($this->docQuery->getMinRow() == null); - } - - public function testMaxRow() - { - $this->assertTrue($this->docQuery->getMaxRow() == null); - $this->docQuery->setMaxRow('2'); - $this->assertTrue($this->docQuery->getMaxRow() == '2'); - $this->assertTrue($this->docQuery->getQueryString() == '?max-row=2'); - $this->docQuery->setMaxRow(null); - $this->assertTrue($this->docQuery->getMaxRow() == null); - } - - public function testMinCol() - { - $this->assertTrue($this->docQuery->getMinCol() == null); - $this->docQuery->setMinCol('3'); - $this->assertTrue($this->docQuery->getMinCol() == '3'); - $this->assertTrue($this->docQuery->getQueryString() == '?min-col=3'); - $this->docQuery->setMinCol(null); - $this->assertTrue($this->docQuery->getMinCol() == null); - } - - public function testMaxCol() - { - $this->assertTrue($this->docQuery->getMaxCol() == null); - $this->docQuery->setMaxCol('4'); - $this->assertTrue($this->docQuery->getMaxCol() == '4'); - $this->assertTrue($this->docQuery->getQueryString() == '?max-col=4'); - $this->docQuery->setMaxCol(null); - $this->assertTrue($this->docQuery->getMaxCol() == null); - } - - public function testRange() - { - $this->assertTrue($this->docQuery->getRange() == null); - $this->docQuery->setRange('A1:B4'); - $this->assertTrue($this->docQuery->getRange() == 'A1:B4'); - $this->assertTrue($this->docQuery->getQueryString() == '?range=A1%3AB4'); - $this->docQuery->setRange(null); - $this->assertTrue($this->docQuery->getRange() == null); - } - - public function testReturnEmpty() - { - $this->assertTrue($this->docQuery->getReturnEmpty() == null); - $this->docQuery->setReturnEmpty('false'); - $this->assertTrue($this->docQuery->getReturnEmpty() == 'false'); - $this->assertTrue($this->docQuery->getQueryString() == '?return-empty=false'); - $this->docQuery->setReturnEmpty(null); - $this->assertTrue($this->docQuery->getReturnEmpty() == null); - } - - public function testWorksheetId() - { - $this->assertTrue($this->docQuery->getWorksheetId() == 'default'); - $this->docQuery->setWorksheetId('123'); - $this->assertTrue($this->docQuery->getWorksheetId() == '123'); - } - - public function testSpreadsheetKey() - { - $this->assertTrue($this->docQuery->getSpreadsheetKey() == null); - $this->docQuery->setSpreadsheetKey('abc'); - $this->assertTrue($this->docQuery->getSpreadsheetKey() == 'abc'); - } - - public function testCellId() - { - $this->assertTrue($this->docQuery->getCellId() == null); - $this->docQuery->setCellId('xyz'); - $this->assertTrue($this->docQuery->getCellId() == 'xyz'); - } - - public function testProjection() - { - $this->assertTrue($this->docQuery->getProjection() == 'full'); - $this->docQuery->setProjection('abc'); - $this->assertTrue($this->docQuery->getProjection() == 'abc'); - } - - public function testVisibility() - { - $this->assertTrue($this->docQuery->getVisibility() == 'private'); - $this->docQuery->setVisibility('xyz'); - $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/CellTest.php b/tests/Zend/Gdata/Spreadsheets/CellTest.php deleted file mode 100644 index 095e172f0c41ca20e796228f5541dd1fce335cc2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/CellTest.php +++ /dev/null @@ -1,61 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_CellTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->cell = new Zend_Gdata_Spreadsheets_Extension_Cell(); - } - - public function testToAndFromString() - { - $this->cell->setText('test cell'); - $this->assertTrue($this->cell->getText() == 'test cell'); - $this->cell->setRow('1'); - $this->assertTrue($this->cell->getRow() == '1'); - $this->cell->setColumn('2'); - $this->assertTrue($this->cell->getColumn() == '2'); - $this->cell->setInputValue('test input value'); - $this->assertTrue($this->cell->getInputValue() == 'test input value'); - $this->cell->setNumericValue('test numeric value'); - $this->assertTrue($this->cell->getNumericValue() == 'test numeric value'); - - $newCell = new Zend_Gdata_Spreadsheets_Extension_Cell(); - $doc = new DOMDocument(); - $doc->loadXML($this->cell->saveXML()); - $newCell->transferFromDom($doc->documentElement); - $this->assertTrue($this->cell->getText() == $newCell->getText()); - $this->assertTrue($this->cell->getRow() == $newCell->getRow()); - $this->assertTrue($this->cell->getColumn() == $newCell->getColumn()); - $this->assertTrue($this->cell->getInputValue() == $newCell->getInputValue()); - $this->assertTrue($this->cell->getNumericValue() == $newCell->getNumericValue()); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/ColCountTest.php b/tests/Zend/Gdata/Spreadsheets/ColCountTest.php deleted file mode 100644 index 96d35e00606078e0931787a473a585758d55fef8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/ColCountTest.php +++ /dev/null @@ -1,48 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_ColCountTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); - } - - public function testToAndFromString() - { - $this->colCount->setText('20'); - $this->assertTrue($this->colCount->getText() == '20'); - $newColCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); - $doc = new DOMDocument(); - $doc->loadXML($this->colCount->saveXML()); - $newColCount->transferFromDom($doc->documentElement); - $this->assertTrue($this->colCount->getText() == $newColCount->getText()); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/CustomTest.php b/tests/Zend/Gdata/Spreadsheets/CustomTest.php deleted file mode 100644 index ea0aa8ad182bbdd53c42d3be1756be4b73f64060..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/CustomTest.php +++ /dev/null @@ -1,51 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_CustomTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->custom = new Zend_Gdata_Spreadsheets_Extension_Custom(); - } - - public function testToAndFromString() - { - $this->custom->setText('value'); - $this->assertTrue($this->custom->getText() == 'value'); - $this->custom->setColumnName('column_name'); - $this->assertTrue($this->custom->getColumnName() == 'column_name'); - $newCustom = new Zend_Gdata_Spreadsheets_Extension_Custom(); - $doc = new DOMDocument(); - $doc->loadXML($this->custom->saveXML()); - $newCustom->transferFromDom($doc->documentElement); - $this->assertTrue($this->custom->getText() == $newCustom->getText()); - $this->assertTrue($this->custom->getColumnName() == $newCustom->getColumnName()); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php b/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php deleted file mode 100644 index 663d6152dee2315e0b97b69c866aa828effc1a42..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php +++ /dev/null @@ -1,85 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_DocumentQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->docQuery = new Zend_Gdata_Spreadsheets_DocumentQuery(); - } - - public function testTitle() - { - $this->assertTrue($this->docQuery->getTitle() == null); - $this->docQuery->setTitle('test title'); - $this->assertTrue($this->docQuery->getTitle() == 'test title'); - $this->assertTrue($this->docQuery->getQueryString() == '?title=test+title'); - $this->docQuery->setTitle(null); - $this->assertTrue($this->docQuery->getTitle() == null); - } - - public function testTitleExact() - { - $this->assertTrue($this->docQuery->getTitleExact() == null); - $this->docQuery->setTitleExact('test title'); - $this->assertTrue($this->docQuery->getTitleExact() == 'test title'); - $this->assertTrue($this->docQuery->getQueryString() == '?title-exact=test+title'); - $this->docQuery->setTitleExact(null); - $this->assertTrue($this->docQuery->getTitleExact() == null); - } - - public function testWorksheetId() - { - $this->assertTrue($this->docQuery->getWorksheetId() == null); - $this->docQuery->setWorksheetId('123'); - $this->assertTrue($this->docQuery->getWorksheetId() == '123'); - } - - public function testSpreadsheetKey() - { - $this->assertTrue($this->docQuery->getSpreadsheetKey() == null); - $this->docQuery->setSpreadsheetKey('abc'); - $this->assertTrue($this->docQuery->getSpreadsheetKey() == 'abc'); - } - - public function testProjection() - { - $this->assertTrue($this->docQuery->getProjection() == 'full'); - $this->docQuery->setProjection('abc'); - $this->assertTrue($this->docQuery->getProjection() == 'abc'); - } - - public function testVisibility() - { - $this->assertTrue($this->docQuery->getVisibility() == 'private'); - $this->docQuery->setVisibility('xyz'); - $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php b/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php deleted file mode 100644 index 0ad4aec9945ade8c936809323b4250552b63c7b5..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php +++ /dev/null @@ -1,219 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_ListEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->listEntry = new Zend_Gdata_Spreadsheets_ListEntry(); - $this->rowData = array(); - $this->rowData[] = new Zend_Gdata_Spreadsheets_Extension_Custom( - 'column_1', 'value 1'); - $this->rowData[] = new Zend_Gdata_Spreadsheets_Extension_Custom( - 'column_2', 'value 2'); - } - - public function testToAndFromString() - { - $this->listEntry->setCustom($this->rowData); - $rowDataOut = $this->listEntry->getCustom(); - - $this->assertEquals(count($this->rowData), count($rowDataOut)); - for ($i = 0; $i < count($this->rowData); $i++) { - $this->assertEquals($this->rowData[$i]->getText(), - $rowDataOut[$i]->getText()); - $this->assertEquals($this->rowData[$i]->getColumnName(), - $rowDataOut[$i]->getColumnName()); - } - - $newListEntry = new Zend_Gdata_Spreadsheets_ListEntry(); - $doc = new DOMDocument(); - $doc->loadXML($this->listEntry->saveXML()); - $newListEntry->transferFromDom($doc->documentElement); - $rowDataFromXML = $newListEntry->getCustom(); - - $this->assertEquals(count($this->rowData), count($rowDataFromXML)); - for ($i = 0; $i < count($this->rowData); $i++) { - $this->assertEquals($this->rowData[$i]->getText(), - $rowDataFromXML[$i]->getText()); - $this->assertEquals($this->rowData[$i]->getColumnName(), - $rowDataFromXML[$i]->getColumnName()); - } - } - - public function testCustomElementOrderingPreserved() - { - $this->listEntry->setCustom($this->rowData); - - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - for ($i = 0; $i < count($this->rowData); $i++) { - $this->assertEquals($this->rowData[$i], - $this->listEntry->custom[$i]); - } - } - - public function testCustomElementsCanBeRetrievedByName() - { - $this->listEntry->setCustom($this->rowData); - - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - for ($i = 0; $i < count($this->rowData); $i++) { - $this->assertEquals($this->rowData[$i], - $this->listEntry->getCustomByName( - $this->rowData[$i]->getColumnName())); - } - } - - public function testCustomElementsCanBeRetrievedByNameUsingArrayNotation() - { - $this->listEntry->setCustom($this->rowData); - - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - for ($i = 0; $i < count($this->rowData); $i++) { - $this->assertEquals($this->rowData[$i], - $this->listEntry->getCustomByName( - $this->rowData[$i]->getColumnName())); - } - } - - public function testCanAddIndividualCustomElements() - { - for ($i = 0; $i < count($this->rowData); $i++) { - $this->listEntry->addCustom($this->rowData[$i]); - } - - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - for ($i = 0; $i < count($this->rowData); $i++) { - $this->assertEquals($this->rowData[$i], - $this->listEntry->custom[$i]); - } - } - - public function testRetrievingNonexistantCustomElementReturnsNull() - { - $this->assertNull($this->listEntry->getCustomByName('nonexistant')); - } - - public function testCanReplaceAllCustomElements() - { - $this->listEntry->setCustom($this->rowData); - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - $this->listEntry->setCustom(array()); - $this->assertEquals(0, count($this->listEntry->getCustom())); - } - - public function testCanDeleteCustomElementById() - { - $this->listEntry->setCustom($this->rowData); - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - $this->assertEquals($this->rowData[0], $this->listEntry->custom[0]); - - $this->listEntry->removeCustom(0); - $this->assertEquals(count($this->rowData) - 1, - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - $this->assertEquals($this->rowData[1], $this->listEntry->custom[0]); - } - - public function testCanDeleteCustomElementByName() - { - $this->listEntry->setCustom($this->rowData); - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - $this->assertEquals($this->rowData[0], - $this->listEntry->getCustomByName( - $this->rowData[0]->getColumnName())); - - $this->listEntry->removeCustomByName('column_1'); - $this->assertEquals(count($this->rowData) - 1, - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - $this->assertNull($this->listEntry->getCustomByName( - $this->rowData[0]->getColumnName())); - } - - public function testDeletingNonexistantElementByIdThrowsException() - { - $this->listEntry->setCustom($this->rowData); - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - - $exceptionCaught = false; - try { - $this->listEntry->removeCustom(9999); - } catch (Zend_Gdata_App_InvalidArgumentException $e) { - $exceptionCaught = true; - $this->assertEquals('Element does not exist.', $e->getMessage()); - } - $this->assertTrue($exceptionCaught); - } - - public function testDeletingNonexistantElementByNameThrowsException() - { - $this->listEntry->setCustom($this->rowData); - $this->assertEquals(count($this->rowData), - count($this->listEntry->getCustom())); - $this->assertEquals(count($this->listEntry->getCustom()), - count($this->listEntry->getCustomByName())); - - $exceptionCaught = false; - try { - $this->listEntry->removeCustomByName('nonexistant'); - } catch (Zend_Gdata_App_InvalidArgumentException $e) { - $exceptionCaught = true; - $this->assertEquals('Element does not exist.', $e->getMessage()); - } - $this->assertTrue($exceptionCaught); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php b/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php deleted file mode 100644 index c783af8dcefcf37caee0710e95257afad8d2502e..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php +++ /dev/null @@ -1,60 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_ListFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->listFeed = new Zend_Gdata_Spreadsheets_ListFeed( - file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml'), - true); - } - - public function testToAndFromString() - { - $this->assertTrue(count($this->listFeed->entries) == 1); - foreach($this->listFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); - } - - $newListFeed = new Zend_Gdata_Spreadsheets_ListFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->listFeed->saveXML()); - $newListFeed->transferFromDom($doc->documentElement); - - $this->assertTrue(count($newListFeed->entries) == 1); - foreach($newListFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); - } - - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php b/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php deleted file mode 100644 index f4303f5cf15931616175b05b1483a8d8ac14a851..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php +++ /dev/null @@ -1,103 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_ListQueryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->docQuery = new Zend_Gdata_Spreadsheets_ListQuery(); - } - - public function testWorksheetId() - { - $this->assertTrue($this->docQuery->getWorksheetId() == 'default'); - $this->docQuery->setWorksheetId('123'); - $this->assertTrue($this->docQuery->getWorksheetId() == '123'); - } - - public function testSpreadsheetKey() - { - $this->assertTrue($this->docQuery->getSpreadsheetKey() == null); - $this->docQuery->setSpreadsheetKey('abc'); - $this->assertTrue($this->docQuery->getSpreadsheetKey() == 'abc'); - } - - public function testRowId() - { - $this->assertTrue($this->docQuery->getRowId() == null); - $this->docQuery->setRowId('xyz'); - $this->assertTrue($this->docQuery->getRowId() == 'xyz'); - } - - public function testProjection() - { - $this->assertTrue($this->docQuery->getProjection() == 'full'); - $this->docQuery->setProjection('abc'); - $this->assertTrue($this->docQuery->getProjection() == 'abc'); - } - - public function testVisibility() - { - $this->assertTrue($this->docQuery->getVisibility() == 'private'); - $this->docQuery->setVisibility('xyz'); - $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); - } - - public function testSpreadsheetQuery() - { - $this->assertTrue($this->docQuery->getSpreadsheetQuery() == null); - $this->docQuery->setSpreadsheetQuery('first=john&last=smith'); - $this->assertTrue($this->docQuery->getSpreadsheetQuery() == 'first=john&last=smith'); - $this->assertTrue($this->docQuery->getQueryString() == '?sq=first%3Djohn%26last%3Dsmith'); - $this->docQuery->setSpreadsheetQuery(null); - $this->assertTrue($this->docQuery->getSpreadsheetQuery() == null); - } - - - public function testOrderBy() - { - $this->assertTrue($this->docQuery->getOrderBy() == null); - $this->docQuery->setOrderBy('column:first'); - $this->assertTrue($this->docQuery->getOrderBy() == 'column:first'); - $this->assertTrue($this->docQuery->getQueryString() == '?orderby=column%3Afirst'); - $this->docQuery->setOrderBy(null); - $this->assertTrue($this->docQuery->getOrderBy() == null); - } - - public function testReverse() - { - $this->assertTrue($this->docQuery->getReverse() == null); - $this->docQuery->setReverse('true'); - $this->assertTrue($this->docQuery->getReverse() == 'true'); - $this->assertTrue($this->docQuery->getQueryString() == '?reverse=true'); - $this->docQuery->setReverse(null); - $this->assertTrue($this->docQuery->getReverse() == null); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/RowCountTest.php b/tests/Zend/Gdata/Spreadsheets/RowCountTest.php deleted file mode 100644 index cb287e445d6d61b6a3b7208b754a6d1e460361f5..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/RowCountTest.php +++ /dev/null @@ -1,48 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_RowCountTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); - } - - public function testToAndFromString() - { - $this->rowCount->setText('20'); - $this->assertTrue($this->rowCount->getText() == '20'); - $newRowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); - $doc = new DOMDocument(); - $doc->loadXML($this->rowCount->saveXML()); - $newRowCount->transferFromDom($doc->documentElement); - $this->assertTrue($this->rowCount->getText() == $newRowCount->getText()); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php b/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php deleted file mode 100644 index 34704620579a95d87242b80960e386e2606c68b4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php +++ /dev/null @@ -1,59 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_SpreadsheetFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->sprFeed = new Zend_Gdata_Spreadsheets_SpreadsheetFeed( - file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml'), - true); - } - - public function testToAndFromString() - { - $this->assertTrue(count($this->sprFeed->entries) == 1); - foreach($this->sprFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - } - - $newSprFeed = new Zend_Gdata_Spreadsheets_SpreadsheetFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->sprFeed->saveXML()); - $newSprFeed->transferFromDom($doc->documentElement); - - $this->assertTrue(count($newSprFeed->entries) == 1); - foreach($newSprFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - } - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php b/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php deleted file mode 100644 index c0de022818470808f6805e763aa48dd0fabc08d5..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php +++ /dev/null @@ -1,51 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_WorksheetEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->wksEntry = new Zend_Gdata_Spreadsheets_WorksheetEntry(); - } - - public function testToAndFromString() - { - $this->wksEntry->setRowCount(new Zend_Gdata_Spreadsheets_Extension_RowCount('20')); - $this->assertTrue($this->wksEntry->getRowCount()->getText() == '20'); - $this->wksEntry->setColumnCount(new Zend_Gdata_Spreadsheets_Extension_ColCount('40')); - $this->assertTrue($this->wksEntry->getColumnCount()->getText() == '40'); - $newWksEntry = new Zend_Gdata_Spreadsheets_WorksheetEntry(); - $doc = new DOMDocument(); - $doc->loadXML($this->wksEntry->saveXML()); - $newWksEntry->transferFromDom($doc->documentElement); - $this->assertTrue($this->wksEntry->getRowCount()->getText() == $newWksEntry->getRowCount()->getText()); - $this->assertTrue($this->wksEntry->getColumnCount()->getText() == $newWksEntry->getColumnCount()->getText()); - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php b/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php deleted file mode 100644 index 60d8d27e062fb336010fb676b6986a883ebfb7a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php +++ /dev/null @@ -1,59 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_Spreadsheets_WorksheetFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->wksFeed = new Zend_Gdata_Spreadsheets_WorksheetFeed( - file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml'), - true); - } - - public function testToAndFromString() - { - $this->assertTrue(count($this->wksFeed->entries) == 1); - foreach($this->wksFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); - } - - $newWksFeed = new Zend_Gdata_Spreadsheets_WorksheetFeed(); - $doc = new DOMDocument(); - $doc->loadXML($this->wksFeed->saveXML()); - $newWksFeed->transferFromDom($doc->documentElement); - - $this->assertTrue(count($newWksFeed->entries) == 1); - foreach($newWksFeed->entries as $entry) - { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); - } - } - -} diff --git a/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml b/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml deleted file mode 100644 index e40a0c3cd61ba0462903e640aa7fa17dffa5d113..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml +++ /dev/null @@ -1,49 +0,0 @@ -<feed xmlns="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gs="http://schemas.google.com/spreadsheets/2006"> - <id>http://spreadsheets.google.com/feeds/cells/key/od6/private/full</id> - <updated>2006-11-17T18:27:32.543Z</updated> - <title type="text">Sheet1</title> - <link rel="alternate" type="text/html" - href="http://spreadsheets.google.com/ccc?key=key"/> - <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/> - <link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/> - <author> - <name>Fitzwilliam Darcy</name> - <email>fitz@gmail.com</email> - </author> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>1</openSearch:itemsPerPage> - <gs:rowCount>100</gs:rowCount> - <gs:colCount>20</gs:colCount> - <entry> - <id>http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1</id> - <updated>2006-11-17T18:27:32.543Z</updated> - <category scheme="http://schemas.google.com/spreadsheets/2006" - term="http://schemas.google.com/spreadsheets/2006#cell"/> - <title type="text">A1</title> - <content type="text">Name</content> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1"/> - <link rel="edit" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1/bgvjf"/> - <gs:cell row="1" col="1" inputValue="Name">Name</gs:cell> - </entry> - <entry> - <id>http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2</id> - <updated>2006-11-17T18:27:32.543Z</updated> - <category scheme="http://schemas.google.com/spreadsheets/2006" - term="http://schemas.google.com/spreadsheets/2006#cell"/> - <title type="text">B1</title> - <content type="text">Hours</content> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2"/> - <link rel="edit" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2/1pn567"/> - <gs:cell row="1" col="2" inputValue="Hours">Hours</gs:cell> - </entry> -</feed> \ No newline at end of file diff --git a/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml b/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml deleted file mode 100644 index 1f8212b9bf1aa17a43e4e119c374e9144a50d6d2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml +++ /dev/null @@ -1,56 +0,0 @@ -<feed xmlns="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"> - <id>http://spreadsheets.google.com/feeds/list/key/od6/private/full</id> - <updated>2006-11-17T18:23:45.173Z</updated> - <title type="text">Sheet1</title> - <link rel="alternate" type="text/html" - href="http://spreadsheets.google.com/ccc?key=key"/> - <link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/> - <link rel="http://schemas.google.com/g/2005#post" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/> - <author> - <name>Fitzwilliam Darcy</name> - <email>fitz@gmail.com</email> - </author> - <openSearch:totalResults>2</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>2</openSearch:itemsPerPage> - <entry> - <id>http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr</id> - <updated>2006-11-17T18:23:45.173Z</updated> - <category scheme="http://schemas.google.com/spreadsheets/2006" - term="http://schemas.google.com/spreadsheets/2006#list"/> - <title type="text">Bingley</title> - <content type="text">Hours: 10, Items: 2, IPM: 0.0033</content> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr"/> - <link rel="edit" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr/2ehkc2oh7d"/> - <gsx:name>Bingley</gsx:name> - <gsx:hours>10</gsx:hours> - <gsx:items>2</gsx:items> - <gsx:ipm>0.0033</gsx:ipm> - </entry> - <entry> - <id>http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm</id> - <updated>2006-11-17T18:23:45.173Z</updated> - <category scheme="http://schemas.google.com/spreadsheets/2006" - term="http://schemas.google.com/spreadsheets/2006#list"/> - <title type="text">Charlotte</title> - <content type="text">Hours: 60, Items: 18000, IPM: 5</content> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm"/> - <link rel="edit" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm/64rl27px3zyn"/> - <gsx:name>Charlotte</gsx:name> - <gsx:hours>60</gsx:hours> - <gsx:items>18000</gsx:items> - <gsx:ipm>5</gsx:ipm> - </entry> -</feed> \ No newline at end of file diff --git a/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml b/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml deleted file mode 100644 index b069efc1e22f4cdc85b6fabd634273327b72fc84..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml +++ /dev/null @@ -1,38 +0,0 @@ -<feed xmlns="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gs="http://schemas.google.com/spreadsheets/2006"> - <id>http://spreadsheets.google.com/feeds/spreadsheets/private/full</id> - <updated>2006-11-17T18:23:45.173Z</updated> - <title type="text">Available Spreadsheets</title> - <link rel="alternate" type="text/html" - href="http://spreadsheets.google.com/ccc?key=key"/> - <link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/> - <author> - <name>Fitzwilliam Darcy</name> - <email>fitz@gmail.com</email> - </author> - <openSearch:totalResults>1</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>1</openSearch:itemsPerPage> - <entry> - <id>http://spreadsheets.google.com/feeds/spreadsheets/private/full/key</id> - <updated>2006-11-17T18:24:18.231Z</updated> - <title type="text">Groceries R Us</title> - <content type="text">Groceries R Us</content> - <link rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/> - <link rel="alternate" type="text/html" - href="http://spreadsheets.google.com/ccc?key=key"/> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/spreadsheets/private/full/key"/> - <author> - <name>Fitzwilliam Darcy</name> - <email>fitz@gmail.com</email> - </author> - </entry> -</feed> \ No newline at end of file diff --git a/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml b/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml deleted file mode 100644 index d86afca4cf0f38f5d43f8cd50097f3cdac5f83d4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml +++ /dev/null @@ -1,37 +0,0 @@ -<feed xmlns="http://www.w3.org/2005/Atom" - xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" - xmlns:gs="http://schemas.google.com/spreadsheets/2006"> - <id>http://spreadsheets.google.com/feeds/worksheets/key/private/full</id> - <updated>2006-11-17T18:23:45.173Z</updated> - <title type="text">Groceries R Us</title> - <link rel="alternate" type="text/html" - href="http://spreadsheets.google.com/ccc?key=key"/> - <link rel="http://schemas.google.com/g/2005#feed" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/> - <author> - <name>Fitzwilliam Darcy</name> - <email>fitz@gmail.com</email> - </author> - <openSearch:totalResults>1</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>1</openSearch:itemsPerPage> - <entry> - <id>http://spreadsheets.google.com/feeds/worksheets/key/private/full/od6</id> - <updated>2006-11-17T18:23:45.173Z</updated> - <title type="text">Sheet1</title> - <content type="text">Sheet1</content> - <link rel="http://schemas.google.com/spreadsheets/2006#listfeed" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/> - <link rel="http://schemas.google.com/spreadsheets/2006#cellsfeed" - type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/> - <link rel="self" type="application/atom+xml" - href="http://spreadsheets.google.com/feeds/worksheets/key/private/full/od6"/> - <gs:rowCount>100</gs:rowCount> - <gs:colCount>20</gs:colCount> - </entry> -</feed> \ No newline at end of file diff --git a/tests/Zend/Gdata/SpreadsheetsOnlineTest.php b/tests/Zend/Gdata/SpreadsheetsOnlineTest.php deleted file mode 100644 index 4196b3a95aeadee418984baa7f97c7619dcf0735..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/SpreadsheetsOnlineTest.php +++ /dev/null @@ -1,291 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Gdata/ClientLogin.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_SpreadsheetsOnlineTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); - $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); - $this->sprKey = constant('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY'); - $this->wksId = constant('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID'); - $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); - $this->gdata = new Zend_Gdata_Spreadsheets($client); - } - - public function testGetSpreadsheetsAndWorksheetsAndData() - { - $spreadsheetCount = 0; - - $spreadsheets = $this->gdata->getSpreadsheets(); - $testedContents = false; - foreach($spreadsheets as $spreadsheet) { - $spreadsheetCount++; - $worksheetCount = 0; - $this->assertTrue($spreadsheet instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry, 'not instance of SpreadsheetEntry'); - foreach($spreadsheet->getWorksheets() as $worksheet) { - $this->assertTrue($worksheet instanceof Zend_Gdata_Spreadsheets_WorksheetEntry, 'not instance of WorksheetEntry'); - $worksheetCount++; - if ($spreadsheet->getTitle()->getText() == 'PHP Unit Test Sheet') { - $testedContents = true; - $contentAsCells = $worksheet->getContentsAsCells(); - $this->assertEquals('a1', $contentAsCells['A1']['value']); - $this->assertEquals('new', $contentAsCells['A2']['value']); - $this->assertEquals('row', $contentAsCells['B2']['value']); - $contentAsRows = $worksheet->getContentsAsRows(); - $this->assertEquals('new', $contentAsRows[0]['a1']); - $this->assertEquals('data', $contentAsRows[0]['c1']); - $this->assertEquals('here', $contentAsRows[0]['d1']); - } - } - $this->assertTrue($worksheetCount >= 1, 'didn\'t get >= 1 worksheet'); - } - $this->assertTrue($spreadsheetCount > 1, 'didn\'t get >1 spreadsheet'); - $this->assertTrue($testedContents, 'didn\'t test the contents of the worksheet'); - } - - public function testGetSpreadsheetFeed() - { - $feed = $this->gdata->getSpreadsheetFeed(); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_SpreadsheetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); - $feed = $this->gdata->getSpreadsheetFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_SpreadsheetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $uri = $query->getQueryUrl(); - $feed = $this->gdata->getSpreadsheetFeed($uri); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_SpreadsheetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - } - - public function testGetWorksheetFeed() - { - $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); - $query->setSpreadsheetKey($this->sprKey); - $feed = $this->gdata->getWorksheetFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_WorksheetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $uri = $query->getQueryUrl(); - $feed = $this->gdata->getWorksheetFeed($uri); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_WorksheetFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - } - - public function testGetCellFeed() - { - $query = new Zend_Gdata_Spreadsheets_CellQuery(); - $query->setSpreadsheetKey($this->sprKey); - $query->setWorksheetId($this->wksId); - $feed = $this->gdata->getCellFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_CellFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $feed = $this->gdata->getCellFeed($query->getQueryUrl()); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_CellFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - } - - public function testGetListFeed() - { - $query = new Zend_Gdata_Spreadsheets_ListQuery(); - $query->setSpreadsheetKey($this->sprKey); - $query->setWorksheetId($this->wksId); - $feed = $this->gdata->getListFeed($query); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_ListFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - - $feed = $this->gdata->getListFeed($query->getQueryUrl()); - $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_ListFeed); - foreach ($feed->entries as $entry) { - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); - $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); - } - } - - public function testGetSpreadsheetEntry() - { - $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); - $query->setSpreadsheetKey($this->sprKey); - $entry = $this->gdata->getSpreadsheetEntry($query); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - - $entry = $this->gdata->getSpreadsheetEntry($query->getQueryUrl()); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); - } - - public function testGetWorksheetEntry() - { - $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); - $query->setSpreadsheetKey($this->sprKey); - $query->setWorksheetId($this->wksId); - $entry = $this->gdata->getWorksheetEntry($query); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); - - $entry = $this->gdata->getWorksheetEntry($query->getQueryUrl()); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); - } - - public function testGetCellEntry() - { - $query = new Zend_Gdata_Spreadsheets_CellQuery(); - $query->setSpreadsheetKey($this->sprKey); - $query->setCellId('R1C1'); - $entry = $this->gdata->getCellEntry($query); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - - $entry = $this->gdata->getCellEntry($query->getQueryUrl()); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - } - - public function testGetListEntry() - { - $query = new Zend_Gdata_Spreadsheets_ListQuery(); - $query->setSpreadsheetKey($this->sprKey); - $query->setStartIndex('1'); - $query->setMaxResults('1'); - $entry = $this->gdata->getListEntry($query); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); - - $entry = $this->gdata->getListEntry($query->getQueryUrl()); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); - } - - public function testUpdateCell() - { - $this->gdata->updateCell(5, 1, 'updated data', $this->sprKey, $this->wksId); - - $query = new Zend_Gdata_Spreadsheets_CellQuery(); - $query->setSpreadsheetKey($this->sprKey); - $query->setCellId('R5C1'); - $entry = $this->gdata->getCellEntry($query); - $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); - $this->assertTrue($entry->cell->getText() == 'updated data'); - - $this->gdata->updateCell(5, 1, '', $this->sprKey, $this->wksId); - } - - public function testInsertUpdateDeleteRow() - { - $rowData = array(); - $rowData['a1'] = 'new'; - $rowData['b1'] = 'row'; - $rowData['c1'] = 'data'; - $rowData['d1'] = 'here'; - $entry = $this->gdata->insertRow($rowData, $this->sprKey); - $rowData['a1'] = 'newer'; - $entry = $this->gdata->updateRow($entry, $rowData); - $this->gdata->deleteRow($entry); - } - - public function testInsertUpdateDeleteRow2() - { - $rowData = array(); - $rowData['a1'] = 'new'; - $rowData['b1'] = 'row'; - $rowData['c1'] = 'data'; - $rowData['d1'] = 'here'; - $entry = $this->gdata->insertRow($rowData, $this->sprKey); - $rowData['a1'] = 'newer'; - $entry = $this->gdata->updateRow($entry, $rowData); - $ssTest = new Zend_Gdata_Spreadsheets($entry->getHttpClient()); - $ssTest->delete($entry->getEditLink()->href); - } - - public function testInsertUpdateDeleteRow3() - { - $rowData = array(); - $rowData['a1'] = 'new'; - $rowData['b1'] = 'row'; - $rowData['c1'] = 'data'; - $rowData['d1'] = 'here'; - $entry = $this->gdata->insertRow($rowData, $this->sprKey); - $rowData['a1'] = 'newer'; - $entry = $this->gdata->updateRow($entry, $rowData); - $ssTest = new Zend_Gdata_Spreadsheets($entry->getHttpClient()); - $ssTest->delete($entry); - } - - public function testCustomElementsCollected() { - $rowData = array(); - $rowData['a1'] = 'new'; - $rowData['b1'] = 'row'; - $rowData['c1'] = 'data'; - $rowData['d1'] = 'here'; - $entry = $this->gdata->insertRow($rowData, $this->sprKey); - - $this->assertEquals(4, count($entry->custom)); - $this->assertEquals(4, count($entry->customByName)); - - $this->assertEquals('new', $entry->custom[0]->getText()); - $this->assertEquals('row', $entry->custom[1]->getText()); - $this->assertEquals('data', $entry->custom[2]->getText()); - $this->assertEquals('here', $entry->custom[3]->getText()); - - $this->assertEquals('new', $entry->customByName['a1']->getText()); - $this->assertEquals('row', $entry->customByName['b1']->getText()); - $this->assertEquals('data', $entry->customByName['c1']->getText()); - $this->assertEquals('here', $entry->customByName['d1']->getText()); - - $ssTest = new Zend_Gdata_Spreadsheets($entry->getHttpClient()); - $ssTest->delete($entry); - } - -} diff --git a/tests/Zend/Gdata/SpreadsheetsTest.php b/tests/Zend/Gdata/SpreadsheetsTest.php deleted file mode 100644 index 560a2f2b4ab441df55778c2e618d7827fa85f5a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/SpreadsheetsTest.php +++ /dev/null @@ -1,42 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Spreadsheets.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_SpreadsheetsTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->gdata = new Zend_Gdata_Spreadsheets(new Zend_Http_Client()); - } - - public function testSpreadsheets() - { - $this->assertTrue(true); - } - -} diff --git a/tests/Zend/Gdata/TransparencyTest.php b/tests/Zend/Gdata/TransparencyTest.php deleted file mode 100644 index c3be69daffb7d81551c9b90c3167d96c0b4b69c7..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/TransparencyTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Transparency.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_TransparencyTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->transparencyText = file_get_contents( - 'Zend/Gdata/_files/TransparencyElementSample1.xml', - true); - $this->transparency = new Zend_Gdata_Extension_Transparency(); - } - - public function testEmptyTransparencyShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->transparency->extensionElements)); - $this->assertTrue(count($this->transparency->extensionElements) == 0); - } - - public function testEmptyTransparencyShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->transparency->extensionAttributes)); - $this->assertTrue(count($this->transparency->extensionAttributes) == 0); - } - - public function testSampleTransparencyShouldHaveNoExtensionElements() { - $this->transparency->transferFromXML($this->transparencyText); - $this->assertTrue(is_array($this->transparency->extensionElements)); - $this->assertTrue(count($this->transparency->extensionElements) == 0); - } - - public function testSampleTransparencyShouldHaveNoExtensionAttributes() { - $this->transparency->transferFromXML($this->transparencyText); - $this->assertTrue(is_array($this->transparency->extensionAttributes)); - $this->assertTrue(count($this->transparency->extensionAttributes) == 0); - } - - public function testNormalTransparencyShouldHaveNoExtensionElements() { - $this->transparency->value = "http://schemas.google.com/g/2005#event.opaque"; - - $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $this->transparency->value); - - $this->assertEquals(0, count($this->transparency->extensionElements)); - $newTransparency = new Zend_Gdata_Extension_Transparency(); - $newTransparency->transferFromXML($this->transparency->saveXML()); - $this->assertEquals(0, count($newTransparency->extensionElements)); - $newTransparency->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newTransparency->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $newTransparency->value); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newTransparency2 = $gdata->newTransparency(); - $newTransparency2->transferFromXML($newTransparency->saveXML()); - $this->assertEquals(1, count($newTransparency2->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $newTransparency2->value); - } - - public function testEmptyTransparencyToAndFromStringShouldMatch() { - $transparencyXml = $this->transparency->saveXML(); - $newTransparency = new Zend_Gdata_Extension_Transparency(); - $newTransparency->transferFromXML($transparencyXml); - $newTransparencyXml = $newTransparency->saveXML(); - $this->assertTrue($transparencyXml == $newTransparencyXml); - } - - public function testTransparencyWithValueToAndFromStringShouldMatch() { - $this->transparency->value = "http://schemas.google.com/g/2005#event.opaque"; - $transparencyXml = $this->transparency->saveXML(); - $newTransparency = new Zend_Gdata_Extension_Transparency(); - $newTransparency->transferFromXML($transparencyXml); - $newTransparencyXml = $newTransparency->saveXML(); - $this->assertTrue($transparencyXml == $newTransparencyXml); - $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $this->transparency->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->transparency->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->transparency->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->transparency->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->transparency->extensionAttributes['foo2']['value']); - $transparencyXml = $this->transparency->saveXML(); - $newTransparency = new Zend_Gdata_Extension_Transparency(); - $newTransparency->transferFromXML($transparencyXml); - $this->assertEquals('bar', $newTransparency->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newTransparency->extensionAttributes['foo2']['value']); - } - - public function testConvertFullTransparencyToAndFromString() { - $this->transparency->transferFromXML($this->transparencyText); - $this->assertEquals("http://schemas.google.com/g/2005#event.transparent", $this->transparency->value); - } - -} diff --git a/tests/Zend/Gdata/VisibilityTest.php b/tests/Zend/Gdata/VisibilityTest.php deleted file mode 100644 index a545ab92d04693db9f5b36e5aac4d160e0573e90..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/VisibilityTest.php +++ /dev/null @@ -1,122 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Visibility.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_VisibilityTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->visibilityText = file_get_contents( - 'Zend/Gdata/_files/VisibilityElementSample1.xml', - true); - $this->visibility = new Zend_Gdata_Extension_Visibility(); - } - - public function testEmptyVisibilityShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->visibility->extensionElements)); - $this->assertTrue(count($this->visibility->extensionElements) == 0); - } - - public function testEmptyVisibilityShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->visibility->extensionAttributes)); - $this->assertTrue(count($this->visibility->extensionAttributes) == 0); - } - - public function testSampleVisibilityShouldHaveNoExtensionElements() { - $this->visibility->transferFromXML($this->visibilityText); - $this->assertTrue(is_array($this->visibility->extensionElements)); - $this->assertTrue(count($this->visibility->extensionElements) == 0); - } - - public function testSampleVisibilityShouldHaveNoExtensionAttributes() { - $this->visibility->transferFromXML($this->visibilityText); - $this->assertTrue(is_array($this->visibility->extensionAttributes)); - $this->assertTrue(count($this->visibility->extensionAttributes) == 0); - } - - public function testNormalVisibilityShouldHaveNoExtensionElements() { - $this->visibility->value = "http://schemas.google.com/g/2005#event.private"; - - $this->assertEquals("http://schemas.google.com/g/2005#event.private", $this->visibility->value); - - $this->assertEquals(0, count($this->visibility->extensionElements)); - $newVisibility = new Zend_Gdata_Extension_Visibility(); - $newVisibility->transferFromXML($this->visibility->saveXML()); - $this->assertEquals(0, count($newVisibility->extensionElements)); - $newVisibility->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newVisibility->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.private", $newVisibility->value); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newVisibility2 = $gdata->newVisibility(); - $newVisibility2->transferFromXML($newVisibility->saveXML()); - $this->assertEquals(1, count($newVisibility2->extensionElements)); - $this->assertEquals("http://schemas.google.com/g/2005#event.private", $newVisibility2->value); - } - - public function testEmptyVisibilityToAndFromStringShouldMatch() { - $visibilityXml = $this->visibility->saveXML(); - $newVisibility = new Zend_Gdata_Extension_Visibility(); - $newVisibility->transferFromXML($visibilityXml); - $newVisibilityXml = $newVisibility->saveXML(); - $this->assertTrue($visibilityXml == $newVisibilityXml); - } - - public function testVisibilityWithValueToAndFromStringShouldMatch() { - $this->visibility->value = "http://schemas.google.com/g/2005#event.private"; - $visibilityXml = $this->visibility->saveXML(); - $newVisibility = new Zend_Gdata_Extension_Visibility(); - $newVisibility->transferFromXML($visibilityXml); - $newVisibilityXml = $newVisibility->saveXML(); - $this->assertTrue($visibilityXml == $newVisibilityXml); - $this->assertEquals("http://schemas.google.com/g/2005#event.private", $this->visibility->value); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->visibility->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->visibility->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->visibility->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->visibility->extensionAttributes['foo2']['value']); - $visibilityXml = $this->visibility->saveXML(); - $newVisibility = new Zend_Gdata_Extension_Visibility(); - $newVisibility->transferFromXML($visibilityXml); - $this->assertEquals('bar', $newVisibility->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newVisibility->extensionAttributes['foo2']['value']); - } - - public function testConvertFullVisibilityToAndFromString() { - $this->visibility->transferFromXML($this->visibilityText); - $this->assertEquals("http://schemas.google.com/g/2005#event.confidential", $this->visibility->value); - } - -} diff --git a/tests/Zend/Gdata/WhenTest.php b/tests/Zend/Gdata/WhenTest.php deleted file mode 100644 index bfdf2b4ee46855701aa425278348ca34aae64075..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/WhenTest.php +++ /dev/null @@ -1,136 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/When.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_WhenTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->whenText = file_get_contents( - 'Zend/Gdata/_files/WhenElementSample1.xml', - true); - $this->when = new Zend_Gdata_Extension_When(); - } - - public function testEmptyWhenShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->when->extensionElements)); - $this->assertTrue(count($this->when->extensionElements) == 0); - } - - public function testEmptyWhenShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->when->extensionAttributes)); - $this->assertTrue(count($this->when->extensionAttributes) == 0); - } - - public function testSampleWhenShouldHaveNoExtensionElements() { - $this->when->transferFromXML($this->whenText); - $this->assertTrue(is_array($this->when->extensionElements)); - $this->assertTrue(count($this->when->extensionElements) == 0); - } - - public function testSampleWhenShouldHaveNoExtensionAttributes() { - $this->when->transferFromXML($this->whenText); - $this->assertTrue(is_array($this->when->extensionAttributes)); - $this->assertTrue(count($this->when->extensionAttributes) == 0); - } - - public function testNormalWhenShouldHaveNoExtensionElements() { - $this->when->valueString = "Later"; - $this->when->endTime = "2007-06-21T21:31:56-07:00"; - $this->when->startTime = "2007-06-19T05:42:19-06:00"; - - $this->assertEquals("Later", $this->when->valueString); - $this->assertEquals("2007-06-21T21:31:56-07:00", $this->when->endTime); - $this->assertEquals("2007-06-19T05:42:19-06:00", $this->when->startTime); - - $this->assertEquals(0, count($this->when->extensionElements)); - $newWhen = new Zend_Gdata_Extension_When(); - $newWhen->transferFromXML($this->when->saveXML()); - $this->assertEquals(0, count($newWhen->extensionElements)); - $newWhen->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newWhen->extensionElements)); - $this->assertEquals("Later", $newWhen->valueString); - $this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen->endTime); - $this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen->startTime); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newWhen2 = $gdata->newWhen(); - $newWhen2->transferFromXML($newWhen->saveXML()); - $this->assertEquals(1, count($newWhen2->extensionElements)); - $this->assertEquals("Later", $newWhen2->valueString); - $this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen2->endTime); - $this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen2->startTime); - } - - public function testEmptyWhenToAndFromStringShouldMatch() { - $whenXml = $this->when->saveXML(); - $newWhen = new Zend_Gdata_Extension_When(); - $newWhen->transferFromXML($whenXml); - $newWhenXml = $newWhen->saveXML(); - $this->assertTrue($whenXml == $newWhenXml); - } - - public function testWhenWithValueToAndFromStringShouldMatch() { - $this->when->valueString = "Later"; - $this->when->endTime = "2007-06-21T21:31:56-07:00"; - $this->when->startTime = "2007-06-19T05:42:19-06:00"; - $whenXml = $this->when->saveXML(); - $newWhen = new Zend_Gdata_Extension_When(); - $newWhen->transferFromXML($whenXml); - $newWhenXml = $newWhen->saveXML(); - $this->assertTrue($whenXml == $newWhenXml); - $this->assertEquals("Later", $this->when->valueString); - $this->assertEquals("2007-06-21T21:31:56-07:00", $this->when->endTime); - $this->assertEquals("2007-06-19T05:42:19-06:00", $this->when->startTime); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->when->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->when->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->when->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->when->extensionAttributes['foo2']['value']); - $whenXml = $this->when->saveXML(); - $newWhen = new Zend_Gdata_Extension_When(); - $newWhen->transferFromXML($whenXml); - $this->assertEquals('bar', $newWhen->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newWhen->extensionAttributes['foo2']['value']); - } - - public function testConvertFullWhenToAndFromString() { - $this->when->transferFromXML($this->whenText); - $this->assertEquals("Tomorrow @ 5 PM", $this->when->valueString); - $this->assertEquals("2005-06-06T18:00:00-08:00", $this->when->endTime); - $this->assertEquals("2005-06-06T17:00:00-08:00", $this->when->startTime); - } - -} diff --git a/tests/Zend/Gdata/WhereTest.php b/tests/Zend/Gdata/WhereTest.php deleted file mode 100644 index a626bf636468204650ef5511c61a9887aac68cfe..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/WhereTest.php +++ /dev/null @@ -1,138 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Where.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_WhereTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->whereText = file_get_contents( - 'Zend/Gdata/_files/WhereElementSample1.xml', - true); - $this->where = new Zend_Gdata_Extension_Where(); - } - - public function testEmptyWhereShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->where->extensionElements)); - $this->assertTrue(count($this->where->extensionElements) == 0); - } - - public function testEmptyWhereShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->where->extensionAttributes)); - $this->assertTrue(count($this->where->extensionAttributes) == 0); - } - - public function testSampleWhereShouldHaveNoExtensionElements() { - $this->where->transferFromXML($this->whereText); - $this->assertTrue(is_array($this->where->extensionElements)); - $this->assertTrue(count($this->where->extensionElements) == 0); - } - - public function testSampleWhereShouldHaveNoExtensionAttributes() { - $this->where->transferFromXML($this->whereText); - $this->assertTrue(is_array($this->where->extensionAttributes)); - $this->assertTrue(count($this->where->extensionAttributes) == 0); - } - - public function testNormalWhereShouldHaveNoExtensionElements() { - $this->where->valueString = "Test Value String"; - $this->where->rel = "http://schemas.google.com/g/2005#event.alternate"; - $this->where->label = "Test Label"; - - $this->assertEquals("Test Value String", $this->where->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $this->where->rel); - $this->assertEquals("Test Label", $this->where->label); - - $this->assertEquals(0, count($this->where->extensionElements)); - $newWhere = new Zend_Gdata_Extension_Where(); - $newWhere->transferFromXML($this->where->saveXML()); - $this->assertEquals(0, count($newWhere->extensionElements)); - $newWhere->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newWhere->extensionElements)); - $this->assertEquals("Test Value String", $newWhere->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere->rel); - $this->assertEquals("Test Label", $newWhere->label); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newWhere2 = $gdata->newWhere(); - $newWhere2->transferFromXML($newWhere->saveXML()); - $this->assertEquals(1, count($newWhere2->extensionElements)); - $this->assertEquals("Test Value String", $newWhere2->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere2->rel); - $this->assertEquals("Test Label", $newWhere2->label); - } - - public function testEmptyWhereToAndFromStringShouldMatch() { - $whereXml = $this->where->saveXML(); - $newWhere = new Zend_Gdata_Extension_Where(); - $newWhere->transferFromXML($whereXml); - $newWhereXml = $newWhere->saveXML(); - $this->assertTrue($whereXml == $newWhereXml); - } - - public function testWhereWithValueToAndFromStringShouldMatch() { - $this->where->valueString = "Test Value String"; - $this->where->rel = "http://schemas.google.com/g/2005#event.alternate"; - $this->where->label = "Test Label"; - $whereXml = $this->where->saveXML(); - $newWhere = new Zend_Gdata_Extension_Where(); - $newWhere->transferFromXML($whereXml); - $newWhereXml = $newWhere->saveXML(); - $this->assertTrue($whereXml == $newWhereXml); - $this->assertEquals("Test Value String", $this->where->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $this->where->rel); - $this->assertEquals("Test Label", $this->where->label); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->where->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->where->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->where->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->where->extensionAttributes['foo2']['value']); - $whereXml = $this->where->saveXML(); - $newWhere = new Zend_Gdata_Extension_Where(); - $newWhere->transferFromXML($whereXml); - $this->assertEquals('bar', $newWhere->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newWhere->extensionAttributes['foo2']['value']); - } - - public function testConvertFullWhereToAndFromString() { - $this->where->transferFromXML($this->whereText); - $this->assertEquals("Joe's Pub", $this->where->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event", $this->where->rel); - $this->assertEquals("1234 Anywhere Ln., New York, NY", $this->where->label); - $this->assertTrue($this->where->entryLink instanceof Zend_Gdata_Extension_EntryLink); - $this->assertEquals("http://local.example.com/10018/JoesPub", $this->where->entryLink->href); - } - -} diff --git a/tests/Zend/Gdata/WhoTest.php b/tests/Zend/Gdata/WhoTest.php deleted file mode 100644 index 89fe7cbf5bdaa6d68885845c0437a486fba52aae..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/WhoTest.php +++ /dev/null @@ -1,142 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'Zend/Gdata/Extension/Who.php'; -require_once 'Zend/Gdata.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_WhoTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->whoText = file_get_contents( - 'Zend/Gdata/_files/WhoElementSample1.xml', - true); - $this->who = new Zend_Gdata_Extension_Who(); - } - - public function testEmptyWhoShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->who->extensionElements)); - $this->assertTrue(count($this->who->extensionElements) == 0); - } - - public function testEmptyWhoShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->who->extensionAttributes)); - $this->assertTrue(count($this->who->extensionAttributes) == 0); - } - - public function testSampleWhoShouldHaveNoExtensionElements() { - $this->who->transferFromXML($this->whoText); - $this->assertTrue(is_array($this->who->extensionElements)); - $this->assertTrue(count($this->who->extensionElements) == 0); - } - - public function testSampleWhoShouldHaveNoExtensionAttributes() { - $this->who->transferFromXML($this->whoText); - $this->assertTrue(is_array($this->who->extensionAttributes)); - $this->assertTrue(count($this->who->extensionAttributes) == 0); - } - - public function testNormalWhoShouldHaveNoExtensionElements() { - $this->who->valueString = "Test Value String"; - $this->who->rel = "http://schemas.google.com/g/2005#event.speaker"; - $this->who->email = "testemail@somewhere.domain.invalid"; - - $this->assertEquals("Test Value String", $this->who->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $this->who->rel); - $this->assertEquals("testemail@somewhere.domain.invalid", $this->who->email); - - $this->assertEquals(0, count($this->who->extensionElements)); - $newWho = new Zend_Gdata_Extension_Who(); - $newWho->transferFromXML($this->who->saveXML()); - $this->assertEquals(0, count($newWho->extensionElements)); - $newWho->extensionElements = array( - new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); - $this->assertEquals(1, count($newWho->extensionElements)); - $this->assertEquals("Test Value String", $newWho->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho->rel); - $this->assertEquals("testemail@somewhere.domain.invalid", $newWho->email); - - /* try constructing using magic factory */ - $gdata = new Zend_Gdata(); - $newWho2 = $gdata->newWho(); - $newWho2->transferFromXML($newWho->saveXML()); - $this->assertEquals(1, count($newWho2->extensionElements)); - $this->assertEquals("Test Value String", $newWho2->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho2->rel); - $this->assertEquals("testemail@somewhere.domain.invalid", $newWho2->email); - } - - public function testEmptyWhoToAndFromStringShouldMatch() { - $whoXml = $this->who->saveXML(); - $newWho = new Zend_Gdata_Extension_Who(); - $newWho->transferFromXML($whoXml); - $newWhoXml = $newWho->saveXML(); - $this->assertTrue($whoXml == $newWhoXml); - } - - public function testWhoWithValueToAndFromStringShouldMatch() { - $this->who->valueString = "Test Value String"; - $this->who->rel = "http://schemas.google.com/g/2005#event.speaker"; - $this->who->email = "testemail@somewhere.domain.invalid"; - $whoXml = $this->who->saveXML(); - $newWho = new Zend_Gdata_Extension_Who(); - $newWho->transferFromXML($whoXml); - $newWhoXml = $newWho->saveXML(); - $this->assertTrue($whoXml == $newWhoXml); - $this->assertEquals("Test Value String", $this->who->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $this->who->rel); - $this->assertEquals("testemail@somewhere.domain.invalid", $this->who->email); - } - - public function testExtensionAttributes() { - $extensionAttributes = $this->who->extensionAttributes; - $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); - $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); - $this->who->extensionAttributes = $extensionAttributes; - $this->assertEquals('bar', $this->who->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $this->who->extensionAttributes['foo2']['value']); - $whoXml = $this->who->saveXML(); - $newWho = new Zend_Gdata_Extension_Who(); - $newWho->transferFromXML($whoXml); - $this->assertEquals('bar', $newWho->extensionAttributes['foo1']['value']); - $this->assertEquals('rab', $newWho->extensionAttributes['foo2']['value']); - } - - public function testConvertFullWhoToAndFromString() { - $this->who->transferFromXML($this->whoText); - $this->assertEquals("Jo", $this->who->valueString); - $this->assertEquals("http://schemas.google.com/g/2005#event.attendee", $this->who->rel); - $this->assertEquals("jo@nowhere.invalid", $this->who->email); - $this->assertTrue($this->who->attendeeStatus instanceof Zend_Gdata_Extension_AttendeeStatus); - $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $this->who->attendeeStatus->value); - $this->assertTrue($this->who->attendeeType instanceof Zend_Gdata_Extension_AttendeeType); - $this->assertEquals("http://schemas.google.com/g/2005#event.required", $this->who->attendeeType->value); - $this->assertTrue($this->who->entryLink instanceof Zend_Gdata_Extension_EntryLink); - $this->assertEquals("http://gmail.com/jo/contacts/Jo", $this->who->entryLink->href); - } - -} diff --git a/tests/Zend/Gdata/YouTube/CommentEntryTest.php b/tests/Zend/Gdata/YouTube/CommentEntryTest.php deleted file mode 100644 index 2996b5ab398aab13e9e203c5ae96a8f1b78e2c79..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/CommentEntryTest.php +++ /dev/null @@ -1,107 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/CommentEntry.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_CommentEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_YouTube_CommentEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($commentEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052', - $commentEntry->id->text); - $this->assertEquals('2007-09-02T18:00:04.000-07:00', $commentEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $commentEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#comment', $commentEntry->category[0]->term); - $this->assertEquals('text', $commentEntry->title->type); - $this->assertEquals('how to turn ...', $commentEntry->title->text);; - $this->assertEquals('text', $commentEntry->content->type); - $this->assertEquals('how to turn rejection and heartbreak into something positive is the big mystery of life but you\'re managed to turn it to your advantage with a beautiful song. Who was she?', $commentEntry->content->text);; - $this->assertEquals('self', $commentEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $commentEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052', $commentEntry->getLink('self')->href); - $this->assertEquals('reneemathome', $commentEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/reneemathome', $commentEntry->author[0]->uri->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyCommentEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newCommentEntry = new Zend_Gdata_YouTube_CommentEntry(); - $newCommentEntry->transferFromXML($entryXml); - $newCommentEntryXml = $newCommentEntry->saveXML(); - $this->assertTrue($entryXml == $newCommentEntryXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertCommentEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newCommentEntry = new Zend_Gdata_YouTube_CommentEntry(); - $newCommentEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newCommentEntry); - $newCommentEntryXml = $newCommentEntry->saveXML(); - $this->assertEquals($entryXml, $newCommentEntryXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/CommentFeedTest.php b/tests/Zend/Gdata/YouTube/CommentFeedTest.php deleted file mode 100644 index ae75f270345a419ed8b13529d89636adb387ab96..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/CommentFeedTest.php +++ /dev/null @@ -1,109 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/CommentFeed.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_CommentFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml', - true); - $this->feed = new Zend_Gdata_YouTube_CommentFeed(); - } - - private function verifyAllSamplePropertiesAreCorrect ($commentFeed) { - $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments', - $commentFeed->id->text); - $this->assertEquals('2007-09-21T02:32:55.032Z', $commentFeed->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $commentFeed->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#comment', $commentFeed->category[0]->term); - $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $commentFeed->logo->text); - $this->assertEquals('text', $commentFeed->title->type); - $this->assertEquals('Comments on \'"That Girl" - Original Song - Acoustic Version\'', $commentFeed->title->text);; - $this->assertEquals('self', $commentFeed->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $commentFeed->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments?start-index=1&max-results=4', $commentFeed->getLink('self')->href); - $this->assertEquals('YouTube', $commentFeed->author[0]->name->text); - $this->assertEquals('http://www.youtube.com/', $commentFeed->author[0]->uri->text); - $this->assertEquals(100, $commentFeed->totalResults->text); - $this->assertEquals(1, $commentFeed->startIndex->text); - $this->assertEquals(4, $commentFeed->itemsPerPage->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testEmptyCommentFeedToAndFromStringShouldMatch() { - $entryXml = $this->feed->saveXML(); - $newCommentFeed = new Zend_Gdata_YouTube_CommentFeed(); - $newCommentFeed->transferFromXML($entryXml); - $newCommentFeedXml = $newCommentFeed->saveXML(); - $this->assertTrue($entryXml == $newCommentFeedXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->feed->transferFromXML($this->feedText); - $this->verifyAllSamplePropertiesAreCorrect($this->feed); - } - - public function testConvertCommentFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $entryXml = $this->feed->saveXML(); - $newCommentFeed = new Zend_Gdata_YouTube_CommentFeed(); - $newCommentFeed->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newCommentFeed); - $newCommentFeedXml = $newCommentFeed->saveXML(); - $this->assertEquals($entryXml, $newCommentFeedXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/ContactEntryTest.php b/tests/Zend/Gdata/YouTube/ContactEntryTest.php deleted file mode 100644 index c20d81902e3b8418cb7c777f59115abe92b961cb..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/ContactEntryTest.php +++ /dev/null @@ -1,109 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/ContactEntry.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_ContactEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_YouTube_ContactEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($contactEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser', - $contactEntry->id->text); - $this->assertEquals('2007-09-21T02:44:41.134Z', $contactEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $contactEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#friend', $contactEntry->category[0]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/contact.cat', $contactEntry->category[1]->scheme); - $this->assertEquals('Friends', $contactEntry->category[1]->term); - $this->assertEquals('text', $contactEntry->title->type); - $this->assertEquals('testuser', $contactEntry->title->text);; - $this->assertEquals('self', $contactEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $contactEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser', $contactEntry->getLink('self')->href); - $this->assertEquals('davidchoimusic', $contactEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $contactEntry->author[0]->uri->text); - $this->assertEquals('testuser', $contactEntry->username->text); - $this->assertEquals('accepted', $contactEntry->status->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyContactEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newContactEntry = new Zend_Gdata_YouTube_ContactEntry(); - $newContactEntry->transferFromXML($entryXml); - $newContactEntryXml = $newContactEntry->saveXML(); - $this->assertTrue($entryXml == $newContactEntryXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertContactEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newContactEntry = new Zend_Gdata_YouTube_ContactEntry(); - $newContactEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newContactEntry); - $newContactEntryXml = $newContactEntry->saveXML(); - $this->assertEquals($entryXml, $newContactEntryXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/ContactFeedTest.php b/tests/Zend/Gdata/YouTube/ContactFeedTest.php deleted file mode 100644 index f265601f2b9fcdb412c8950502cd5f01b953c56b..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/ContactFeedTest.php +++ /dev/null @@ -1,109 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/ContactFeed.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_ContactFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml', - true); - $this->feed = new Zend_Gdata_YouTube_ContactFeed(); - } - - private function verifyAllSamplePropertiesAreCorrect ($contactFeed) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts', - $contactFeed->id->text); - $this->assertEquals('2007-09-21T02:44:41.135Z', $contactFeed->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $contactFeed->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#friend', $contactFeed->category[0]->term); - $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $contactFeed->logo->text); - $this->assertEquals('text', $contactFeed->title->type); - $this->assertEquals('davidchoimusic\'s Contacts', $contactFeed->title->text);; - $this->assertEquals('self', $contactFeed->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $contactFeed->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts?start-index=1&max-results=5', $contactFeed->getLink('self')->href); - $this->assertEquals('davidchoimusic', $contactFeed->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $contactFeed->author[0]->uri->text); - $this->assertEquals(1558, $contactFeed->totalResults->text); - $this->assertEquals(1, $contactFeed->startIndex->text); - $this->assertEquals(5, $contactFeed->itemsPerPage->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testEmptyContactFeedToAndFromStringShouldMatch() { - $entryXml = $this->feed->saveXML(); - $newContactFeed = new Zend_Gdata_YouTube_ContactFeed(); - $newContactFeed->transferFromXML($entryXml); - $newContactFeedXml = $newContactFeed->saveXML(); - $this->assertTrue($entryXml == $newContactFeedXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->feed->transferFromXML($this->feedText); - $this->verifyAllSamplePropertiesAreCorrect($this->feed); - } - - public function testConvertContactFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $entryXml = $this->feed->saveXML(); - $newContactFeed = new Zend_Gdata_YouTube_ContactFeed(); - $newContactFeed->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newContactFeed); - $newContactFeedXml = $newContactFeed->saveXML(); - $this->assertEquals($entryXml, $newContactFeedXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php b/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php deleted file mode 100644 index c88b6074b335228f767e59b8f04dfb8404d5b7f3..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php +++ /dev/null @@ -1,144 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/PlaylistListEntry.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_PlaylistListEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_YouTube_PlaylistListEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($playlistListEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7', - $playlistListEntry->id->text); - $this->assertEquals('2007-09-20T13:42:19.000-07:00', $playlistListEntry->updated->text); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/tags.cat', $playlistListEntry->category[0]->scheme); - $this->assertEquals('music', $playlistListEntry->category[0]->term); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistListEntry->category[1]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlistLink', $playlistListEntry->category[1]->term); - $this->assertEquals('text', $playlistListEntry->title->type); - $this->assertEquals('YouTube Musicians', $playlistListEntry->title->text);; - $this->assertEquals('text', $playlistListEntry->content->type); - $this->assertEquals('Music from talented people on YouTube.', $playlistListEntry->content->text);; - $this->assertEquals('self', $playlistListEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $playlistListEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7', $playlistListEntry->getLink('self')->href); - $this->assertEquals('testuser', $playlistListEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $playlistListEntry->author[0]->uri->text); - $this->assertEquals('Music from talented people on YouTube.', $playlistListEntry->description->text); - $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7', $playlistListEntry->getPlaylistVideoFeedUrl()); - $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7', $playlistListEntry->feedLink[0]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', $playlistListEntry->feedLink[0]->rel); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyPlaylistListEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newPlaylistListEntry = new Zend_Gdata_YouTube_PlaylistListEntry(); - $newPlaylistListEntry->transferFromXML($entryXml); - $newPlaylistListEntryXml = $newPlaylistListEntry->saveXML(); - $this->assertTrue($entryXml == $newPlaylistListEntryXml); - } - - public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals(2, count($this->entry->feedLink)); - } - - public function testGetFeedLinkCanReturnEntriesByRelValue() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals($entry1, $this->entry->getFeedLink('first')); - $this->assertEquals($entry2, $this->entry->getFeedLink('second')); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertPlaylistListEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newPlaylistListEntry = new Zend_Gdata_YouTube_PlaylistListEntry(); - $newPlaylistListEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newPlaylistListEntry); - $newPlaylistListEntryXml = $newPlaylistListEntry->saveXML(); - $this->assertEquals($entryXml, $newPlaylistListEntryXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php b/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php deleted file mode 100644 index bf1673e762bc07fe50ced1e6466dffd0e339d53f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php +++ /dev/null @@ -1,107 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/PlaylistListFeed.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_PlaylistListFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml', - true); - $this->feed = new Zend_Gdata_YouTube_PlaylistListFeed(); - } - - private function verifyAllSamplePropertiesAreCorrect ($playlistListEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists', - $playlistListEntry->id->text); - $this->assertEquals('2007-09-20T20:59:47.530Z', $playlistListEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistListEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlistLink', $playlistListEntry->category[0]->term); - $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $playlistListEntry->logo->text); - $this->assertEquals('text', $playlistListEntry->title->type); - $this->assertEquals('testuser\'s Playlists', $playlistListEntry->title->text);; - $this->assertEquals('self', $playlistListEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $playlistListEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists?start-index=1&max-results=25', $playlistListEntry->getLink('self')->href); - $this->assertEquals('testuser', $playlistListEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $playlistListEntry->author[0]->uri->text); - $this->assertEquals(2, $playlistListEntry->totalResults->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testEmptyPlaylistListFeedToAndFromStringShouldMatch() { - $entryXml = $this->feed->saveXML(); - $newPlaylistListFeed = new Zend_Gdata_YouTube_PlaylistListFeed(); - $newPlaylistListFeed->transferFromXML($entryXml); - $newPlaylistListFeedXml = $newPlaylistListFeed->saveXML(); - $this->assertTrue($entryXml == $newPlaylistListFeedXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->feed->transferFromXML($this->feedText); - $this->verifyAllSamplePropertiesAreCorrect($this->feed); - } - - public function testConvertPlaylistListFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $entryXml = $this->feed->saveXML(); - $newPlaylistListFeed = new Zend_Gdata_YouTube_PlaylistListFeed(); - $newPlaylistListFeed->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newPlaylistListFeed); - $newPlaylistListFeedXml = $newPlaylistListFeed->saveXML(); - $this->assertEquals($entryXml, $newPlaylistListFeedXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php b/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php deleted file mode 100644 index b18896a4989f5144f0b68f30a732d3ed1c307748..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php +++ /dev/null @@ -1,148 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/PlaylistVideoEntry.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_PlaylistVideoEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($playlistVideoEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21', - $playlistVideoEntry->id->text); - $this->assertEquals('2007-09-20T22:56:57.061Z', $playlistVideoEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistVideoEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', $playlistVideoEntry->category[0]->term); - $this->assertEquals('text', $playlistVideoEntry->title->type); - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $playlistVideoEntry->title->text);; - $this->assertEquals('html', $playlistVideoEntry->content->type); - $this->assertEquals('self', $playlistVideoEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $playlistVideoEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21', $playlistVideoEntry->getLink('self')->href); - $this->assertEquals('davidchoimusic', $playlistVideoEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $playlistVideoEntry->author[0]->uri->text); - $mediaGroup = $playlistVideoEntry->mediaGroup; - - $this->assertEquals('plain', $mediaGroup->title->type); - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); - $this->assertEquals('plain', $mediaGroup->description->type); - $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); - $this->assertEquals('music, singing, gnarls, barkley, acoustic, cover', $mediaGroup->keywords->text); - $this->assertEquals(255, $mediaGroup->duration->seconds); - $this->assertEquals('Music', $mediaGroup->category[0]->label); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[0]->scheme); - $this->assertEquals('video', $mediaGroup->content[0]->medium); - $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $mediaGroup->content[0]->url); - $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); - $this->assertEquals('true', $mediaGroup->content[0]->isDefault); - $this->assertEquals('full', $mediaGroup->content[0]->expression); - $this->assertEquals(255, $mediaGroup->content[0]->duration); - $this->assertEquals(5, $mediaGroup->content[0]->format); - - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); - $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); - $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); - $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); - $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); - $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); - $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); - - $this->assertEquals(113321, $playlistVideoEntry->statistics->viewCount); - $this->assertEquals(1, $playlistVideoEntry->rating->min); - $this->assertEquals(5, $playlistVideoEntry->rating->max); - $this->assertEquals(1005, $playlistVideoEntry->rating->numRaters); - $this->assertEquals(4.77, $playlistVideoEntry->rating->average); - $this->assertEquals(1, $playlistVideoEntry->position->text); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments', $playlistVideoEntry->comments->feedLink->href); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyPlaylistVideoEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newPlaylistVideoEntry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); - $newPlaylistVideoEntry->transferFromXML($entryXml); - $newPlaylistVideoEntryXml = $newPlaylistVideoEntry->saveXML(); - $this->assertTrue($entryXml == $newPlaylistVideoEntryXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertPlaylistVideoEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newPlaylistVideoEntry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); - $newPlaylistVideoEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newPlaylistVideoEntry); - $newPlaylistVideoEntryXml = $newPlaylistVideoEntry->saveXML(); - $this->assertEquals($entryXml, $newPlaylistVideoEntryXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php b/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php deleted file mode 100644 index 960ec0fe26a9fc2d78c8805d23f23dc705ac0bd4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php +++ /dev/null @@ -1,112 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/PlaylistVideoFeed.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_PlaylistVideoFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml', - true); - $this->feed = new Zend_Gdata_YouTube_PlaylistVideoFeed(); - } - - private function verifyAllSamplePropertiesAreCorrect ($playlistVideoFeed) { - $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7', - $playlistVideoFeed->id->text); - $this->assertEquals('2007-09-20T13:42:19.000-07:00', $playlistVideoFeed->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistVideoFeed->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', $playlistVideoFeed->category[0]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/tags.cat', $playlistVideoFeed->category[1]->scheme); - $this->assertEquals('music', $playlistVideoFeed->category[1]->term); - $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $playlistVideoFeed->logo->text); - $this->assertEquals('text', $playlistVideoFeed->title->type); - $this->assertEquals('YouTube Musicians', $playlistVideoFeed->title->text);; - $this->assertEquals('self', $playlistVideoFeed->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $playlistVideoFeed->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7?start-index=1&max-results=25', $playlistVideoFeed->getLink('self')->href); - $this->assertEquals('testuser', $playlistVideoFeed->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $playlistVideoFeed->author[0]->uri->text); - $this->assertEquals(13, $playlistVideoFeed->totalResults->text); - $this->assertEquals(13, count($playlistVideoFeed->entry)); - $entries = $playlistVideoFeed->entry; - $this->assertEquals(1, $entries[0]->getPosition()->getText()); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testEmptyPlaylistVideoFeedToAndFromStringShouldMatch() { - $entryXml = $this->feed->saveXML(); - $newPlaylistVideoFeed = new Zend_Gdata_YouTube_PlaylistVideoFeed(); - $newPlaylistVideoFeed->transferFromXML($entryXml); - $newPlaylistVideoFeedXml = $newPlaylistVideoFeed->saveXML(); - $this->assertTrue($entryXml == $newPlaylistVideoFeedXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->feed->transferFromXML($this->feedText); - $this->verifyAllSamplePropertiesAreCorrect($this->feed); - } - - public function testConvertPlaylistVideoFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $feedXml = $this->feed->saveXML(); - $newPlaylistVideoFeed = new Zend_Gdata_YouTube_PlaylistVideoFeed(); - $newPlaylistVideoFeed->transferFromXML($feedXml); - $this->verifyAllSamplePropertiesAreCorrect($newPlaylistVideoFeed); - $newPlaylistVideoFeedXml = $newPlaylistVideoFeed->saveXML(); - $this->assertEquals($feedXml, $newPlaylistVideoFeedXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php b/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php deleted file mode 100644 index b598bddc287044e65a386fc6ba54c7a42fc18e47..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php +++ /dev/null @@ -1,141 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/SubscriptionEntry.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_SubscriptionEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_YouTube_SubscriptionEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($subscriptionListEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db', - $subscriptionListEntry->id->text); - $this->assertEquals('2007-03-02T11:58:22.000-08:00', $subscriptionListEntry->updated->text); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat', $subscriptionListEntry->category[1]->scheme); - $this->assertEquals('publisher', $subscriptionListEntry->category[1]->term); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $subscriptionListEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#subscription', $subscriptionListEntry->category[0]->term); - $this->assertEquals('text', $subscriptionListEntry->title->type); - $this->assertEquals('Videos published by : BBC', $subscriptionListEntry->title->text);; - $this->assertEquals('self', $subscriptionListEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $subscriptionListEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db', $subscriptionListEntry->getLink('self')->href); - $this->assertEquals('testuser', $subscriptionListEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $subscriptionListEntry->author[0]->uri->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/BBC/uploads', $subscriptionListEntry->feedLink[0]->href); - $this->assertEquals('697', $subscriptionListEntry->feedLink[0]->countHint); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.uploads', $subscriptionListEntry->feedLink[0]->rel); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptySubscriptionEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newSubscriptionEntry = new Zend_Gdata_YouTube_SubscriptionEntry(); - $newSubscriptionEntry->transferFromXML($entryXml); - $newSubscriptionEntryXml = $newSubscriptionEntry->saveXML(); - $this->assertTrue($entryXml == $newSubscriptionEntryXml); - } - - public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals(2, count($this->entry->feedLink)); - } - - public function testGetFeedLinkCanReturnEntriesByRelValue() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals($entry1, $this->entry->getFeedLink('first')); - $this->assertEquals($entry2, $this->entry->getFeedLink('second')); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertSubscriptionEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newSubscriptionEntry = new Zend_Gdata_YouTube_SubscriptionEntry(); - $newSubscriptionEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newSubscriptionEntry); - $newSubscriptionEntryXml = $newSubscriptionEntry->saveXML(); - $this->assertEquals($entryXml, $newSubscriptionEntryXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php b/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php deleted file mode 100644 index a3b987d63adf60be183556959f2a6b0a7326adf0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php +++ /dev/null @@ -1,107 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/SubscriptionFeed.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_SubscriptionFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml', - true); - $this->feed = new Zend_Gdata_YouTube_SubscriptionFeed(); - } - - private function verifyAllSamplePropertiesAreCorrect ($subscriptionFeed) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/subscriptions', - $subscriptionFeed->id->text); - $this->assertEquals('2007-09-20T22:12:45.193Z', $subscriptionFeed->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $subscriptionFeed->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#subscription', $subscriptionFeed->category[0]->term); - $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $subscriptionFeed->logo->text); - $this->assertEquals('text', $subscriptionFeed->title->type); - $this->assertEquals('testuser\'s Subscriptions', $subscriptionFeed->title->text);; - $this->assertEquals('self', $subscriptionFeed->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $subscriptionFeed->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/subscriptions?start-index=1&max-results=25', $subscriptionFeed->getLink('self')->href); - $this->assertEquals('testuser', $subscriptionFeed->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $subscriptionFeed->author[0]->uri->text); - $this->assertEquals(3, $subscriptionFeed->totalResults->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testEmptySubscriptionFeedToAndFromStringShouldMatch() { - $entryXml = $this->feed->saveXML(); - $newSubscriptionFeed = new Zend_Gdata_YouTube_SubscriptionFeed(); - $newSubscriptionFeed->transferFromXML($entryXml); - $newSubscriptionFeedXml = $newSubscriptionFeed->saveXML(); - $this->assertTrue($entryXml == $newSubscriptionFeedXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->feed->transferFromXML($this->feedText); - $this->verifyAllSamplePropertiesAreCorrect($this->feed); - } - - public function testConvertSubscriptionFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $entryXml = $this->feed->saveXML(); - $newSubscriptionFeed = new Zend_Gdata_YouTube_SubscriptionFeed(); - $newSubscriptionFeed->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newSubscriptionFeed); - $newSubscriptionFeedXml = $newSubscriptionFeed->saveXML(); - $this->assertEquals($entryXml, $newSubscriptionFeedXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php b/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php deleted file mode 100644 index 45843d6aaacbea842fa2f1cf2fd1213b468322a6..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php +++ /dev/null @@ -1,162 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/UserProfileEntry.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_UserProfileEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml', - true); - $this->entry = new Zend_Gdata_YouTube_UserProfileEntry(); - } - - private function verifyAllSamplePropertiesAreCorrect ($userProfileEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy', - $userProfileEntry->id->text); - $this->assertEquals('2007-08-13T12:37:03.000-07:00', $userProfileEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $userProfileEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#userProfile', $userProfileEntry->category[0]->term); - $this->assertEquals('text', $userProfileEntry->title->type); - $this->assertEquals('Darcy', $userProfileEntry->title->text);; - $this->assertEquals('self', $userProfileEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $userProfileEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy', $userProfileEntry->getLink('self')->href); - $this->assertEquals('Fitzwilliam Darcy', $userProfileEntry->author[0]->name->text); - $this->assertEquals(32, $userProfileEntry->age->text); - $this->assertEquals('darcy', $userProfileEntry->username->text); - $this->assertEquals('A person of great interest', $userProfileEntry->description->text); - $this->assertEquals('Pride and Prejudice', $userProfileEntry->books->text); - $this->assertEquals('Self employed', $userProfileEntry->company->text); - $this->assertEquals('Reading, arguing with Liz', $userProfileEntry->hobbies->text); - $this->assertEquals('Steventon', $userProfileEntry->hometown->text); - $this->assertEquals('Longbourn in Hertfordshire, Pemberley in Derbyshire', $userProfileEntry->location->text); - $this->assertEquals('Pride and Prejudice, 2005', $userProfileEntry->movies->text); - $this->assertEquals('Air Con Varizzioni, The Pleasure of the Town', $userProfileEntry->music->text); - $this->assertEquals('Gentleman', $userProfileEntry->occupation->text); - $this->assertEquals('Home schooling', $userProfileEntry->school->text); - $this->assertEquals('m', $userProfileEntry->gender->text); - $this->assertEquals('taken', $userProfileEntry->relationship->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy', $userProfileEntry->author[0]->uri->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/favorites', $userProfileEntry->feedLink[0]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.favorites', $userProfileEntry->feedLink[0]->rel); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/contacts', $userProfileEntry->feedLink[1]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.contacts', $userProfileEntry->feedLink[1]->rel); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/inbox', $userProfileEntry->feedLink[2]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.inbox', $userProfileEntry->feedLink[2]->rel); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/playlists', $userProfileEntry->feedLink[3]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.playlists', $userProfileEntry->feedLink[3]->rel); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/subscriptions', $userProfileEntry->feedLink[4]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.subscriptions', $userProfileEntry->feedLink[4]->rel); - $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/uploads', $userProfileEntry->feedLink[5]->href); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.uploads', $userProfileEntry->feedLink[5]->rel); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyUserProfileEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newUserProfileEntry = new Zend_Gdata_YouTube_UserProfileEntry(); - $newUserProfileEntry->transferFromXML($entryXml); - $newUserProfileEntryXml = $newUserProfileEntry->saveXML(); - $this->assertTrue($entryXml == $newUserProfileEntryXml); - } - - public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals(2, count($this->entry->feedLink)); - } - - public function testGetFeedLinkCanReturnEntriesByRelValue() { - // Prepare test data - $entry1 = new Zend_Gdata_Extension_FeedLink(); - $entry1->rel = "first"; - $entry1->href= "foo"; - $entry2 = new Zend_Gdata_Extension_FeedLink(); - $entry2->rel = "second"; - $entry2->href= "bar"; - $data = array($entry1, $entry2); - - // Load test data and run test - $this->entry->feedLink = $data; - $this->assertEquals($entry1, $this->entry->getFeedLink('first')); - $this->assertEquals($entry2, $this->entry->getFeedLink('second')); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testConvertUserProfileEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newUserProfileEntry = new Zend_Gdata_YouTube_UserProfileEntry(); - $newUserProfileEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newUserProfileEntry); - $newUserProfileEntryXml = $newUserProfileEntry->saveXML(); - $this->assertEquals($entryXml, $newUserProfileEntryXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/VideoEntryTest.php b/tests/Zend/Gdata/YouTube/VideoEntryTest.php deleted file mode 100644 index a8c345b1aff398953bbd9cb92d8d403bfebffc74..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/VideoEntryTest.php +++ /dev/null @@ -1,574 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: VideoEntryTest.php 9361 2008-05-05 14:55:29Z jhartmann $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/VideoEntry.php'; -require_once 'Zend/Gdata/YouTube/Extension/State.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @category Zend - * @package Zend_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Gdata_YouTube_VideoEntryTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->entryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml', - true); - $this->privateEntryText = file_get_contents( - 'Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml', - true); - $this->entry = new Zend_Gdata_YouTube_VideoEntry(); - } - - private function createRandomString() { - $randomString = ''; - for ($x = 0; $x < 10; $x++) { - $randomCharacter = chr(rand(97,122)); - $randomString .= $randomCharacter; - } - return $randomString; - } - - private function verifyAllSamplePropertiesAreCorrect ($videoEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', - $videoEntry->id->text); - $this->assertEquals('UMFI1hdm96E', $videoEntry->getVideoId()); - $this->assertEquals('2007-01-07T01:50:15.000Z', $videoEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoEntry->category[0]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[1]->scheme); - $this->assertEquals('barkley', $videoEntry->category[1]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[2]->scheme); - $this->assertEquals('singing', $videoEntry->category[2]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[3]->scheme); - $this->assertEquals('acoustic', $videoEntry->category[3]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[4]->scheme); - $this->assertEquals('cover', $videoEntry->category[4]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $videoEntry->category[5]->scheme); - $this->assertEquals('Music', $videoEntry->category[5]->term); - $this->assertEquals('Music', $videoEntry->category[5]->label); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[6]->scheme); - $this->assertEquals('gnarls', $videoEntry->category[6]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[7]->scheme); - $this->assertEquals('music', $videoEntry->category[7]->term); - - $this->assertEquals('text', $videoEntry->title->type); - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->title->text);; - $this->assertEquals('html', $videoEntry->content->type); - $this->assertEquals('self', $videoEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $videoEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', $videoEntry->getLink('self')->href); - $this->assertEquals('text/html', $videoEntry->getLink('alternate')->type); - $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getLink('alternate')->href); - $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->href); - $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->href); - $this->assertEquals('davidchoimusic', $videoEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $videoEntry->author[0]->uri->text); - $mediaGroup = $videoEntry->mediaGroup; - - $this->assertEquals('plain', $mediaGroup->title->type); - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); - $this->assertEquals('plain', $mediaGroup->description->type); - $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); - $this->assertEquals('music, singing, gnarls, barkley, acoustic, cover', $mediaGroup->keywords->text); - $this->assertEquals(255, $mediaGroup->duration->seconds); - $this->assertEquals('Music', $mediaGroup->category[0]->label); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/developertags.cat', $mediaGroup->category[1]->scheme); - $this->assertEquals('DeveloperTag1', $mediaGroup->category[1]->text); - $this->assertEquals('video', $mediaGroup->content[0]->medium); - $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $mediaGroup->content[0]->url); - $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); - $this->assertEquals('true', $mediaGroup->content[0]->isDefault); - $this->assertEquals('full', $mediaGroup->content[0]->expression); - $this->assertEquals(255, $mediaGroup->content[0]->duration); - $this->assertEquals(5, $mediaGroup->content[0]->format); - $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $mediaGroup->player[0]->url); - - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); - $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); - $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); - $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); - $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); - $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); - $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); - $this->assertNull($mediaGroup->private); - - $this->assertEquals(113321, $videoEntry->statistics->viewCount); - $this->assertEquals(1, $videoEntry->rating->min); - $this->assertEquals(5, $videoEntry->rating->max); - $this->assertEquals(1005, $videoEntry->rating->numRaters); - $this->assertEquals(4.77, $videoEntry->rating->average); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments', $videoEntry->comments->feedLink->href); - - $this->assertEquals('37.398529052734375 -122.0635986328125', $videoEntry->where->point->pos->text); - } - - private function verifyAllPrivateSamplePropertiesAreCorrect ($videoEntry) { - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', - $videoEntry->id->text); - $this->assertEquals('UMFI1hdm96E', $videoEntry->getVideoId()); - $this->assertEquals('2007-01-07T01:50:15.000Z', $videoEntry->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoEntry->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoEntry->category[0]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[1]->scheme); - $this->assertEquals('barkley', $videoEntry->category[1]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[2]->scheme); - $this->assertEquals('singing', $videoEntry->category[2]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[3]->scheme); - $this->assertEquals('acoustic', $videoEntry->category[3]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[4]->scheme); - $this->assertEquals('cover', $videoEntry->category[4]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $videoEntry->category[5]->scheme); - $this->assertEquals('Music', $videoEntry->category[5]->term); - $this->assertEquals('Music', $videoEntry->category[5]->label); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[6]->scheme); - $this->assertEquals('gnarls', $videoEntry->category[6]->term); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[7]->scheme); - $this->assertEquals('music', $videoEntry->category[7]->term); - - $this->assertEquals('text', $videoEntry->title->type); - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->title->text);; - $this->assertEquals('html', $videoEntry->content->type); - $this->assertEquals('self', $videoEntry->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $videoEntry->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', $videoEntry->getLink('self')->href); - $this->assertEquals('text/html', $videoEntry->getLink('alternate')->type); - $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getLink('alternate')->href); - $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->href); - $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->href); - $this->assertEquals('davidchoimusic', $videoEntry->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $videoEntry->author[0]->uri->text); - $mediaGroup = $videoEntry->mediaGroup; - - $this->assertEquals('plain', $mediaGroup->title->type); - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); - $this->assertEquals('plain', $mediaGroup->description->type); - $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); - $this->assertEquals('music, singing, gnarls, barkley, acoustic, cover', $mediaGroup->keywords->text); - $this->assertEquals(255, $mediaGroup->duration->seconds); - - $this->assertEquals('Music', $mediaGroup->category[0]->label); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007/developertags.cat', $mediaGroup->category[1]->scheme); - $this->assertEquals('DeveloperTag1', $mediaGroup->category[1]->text); - $this->assertEquals('video', $mediaGroup->content[0]->medium); - $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $mediaGroup->content[0]->url); - $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); - $this->assertEquals('true', $mediaGroup->content[0]->isDefault); - $this->assertEquals('full', $mediaGroup->content[0]->expression); - $this->assertEquals(255, $mediaGroup->content[0]->duration); - $this->assertEquals(5, $mediaGroup->content[0]->format); - $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $mediaGroup->player[0]->url); - - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); - $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); - $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); - $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); - $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); - $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); - $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); - $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); - $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); - $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); - $this->assertTrue($mediaGroup->private instanceof Zend_Gdata_YouTube_Extension_Private); - - $this->assertEquals(113321, $videoEntry->statistics->viewCount); - $this->assertEquals(1, $videoEntry->rating->min); - $this->assertEquals(5, $videoEntry->rating->max); - $this->assertEquals(1005, $videoEntry->rating->numRaters); - $this->assertEquals(4.77, $videoEntry->rating->average); - $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments', $videoEntry->comments->feedLink->href); - - $this->assertEquals('37.398529052734375 -122.0635986328125', $videoEntry->where->point->pos->text); - } - - public function testGetVideoId() { - $videoEntry = new Zend_Gdata_YouTube_VideoEntry(); - - // assert valid ID - $videoEntry->id = new Zend_Gdata_App_Extension_Id('http://gdata.youtube.com/feeds/videos/ABCDEFG12AB'); - $this->assertEquals('ABCDEFG12AB', $videoEntry->getVideoId()); - } - - /** - * @expectedException Zend_Gdata_App_Exception - */ - public function testGetVideoIdException() { - $videoEntry = new Zend_Gdata_YouTube_VideoEntry(); - - // assert invalid ID - $videoEntry->id = new Zend_Gdata_App_Extension_Id('adfadfasf'); - $this->assertEquals('adfadfasf', $videoEntry->getVideoId()); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionElements)); - $this->assertTrue(count($this->entry->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->entry->transferFromXML($this->entryText); - $this->assertTrue(is_array($this->entry->extensionAttributes)); - $this->assertTrue(count($this->entry->extensionAttributes) == 0); - } - - public function testEmptyVideoEntryToAndFromStringShouldMatch() { - $entryXml = $this->entry->saveXML(); - $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); - $newVideoEntry->transferFromXML($entryXml); - $newVideoEntryXml = $newVideoEntry->saveXML(); - $this->assertTrue($entryXml == $newVideoEntryXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->entryText); - $this->verifyAllSamplePropertiesAreCorrect($this->entry); - } - - public function testPrivateSamplePropertiesAreCorrect () { - $this->entry->transferFromXML($this->privateEntryText); - $this->verifyAllPrivateSamplePropertiesAreCorrect($this->entry); - } - - public function testGetVideoTitle() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->getVideoTitle()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoTitle()); - } - - public function testSetVideoTitle() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $newTitle = 'My New Title'; - $videoEntry->setVideoTitle($newTitle); - $this->assertEquals($videoEntry->getVideoTitle(), $newTitle); - } - - public function testGetVideoDescription() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $videoEntry->getVideoDescription()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoDescription()); - } - - public function testSetVideoDescription() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $newDescription = 'My New Description'; - $videoEntry->setVideoDescription($newDescription); - $this->assertEquals($videoEntry->getVideoDescription(), $newDescription); - } - - public function testGetVideoWatchPageUrl() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getVideoWatchPageUrl()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoWatchPageUrl()); - } - - public function testGetVideoThumbnails() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $mediaThumbnails1 = $videoEntry->getMediaGroup()->getThumbnail(); - $mediaThumbnails2 = $videoEntry->getVideoThumbnails(); - $this->assertEquals(count($mediaThumbnails1), count($mediaThumbnails2)); - - $foundThumbnail = false; - foreach ($mediaThumbnails2 as $thumbnail) { - if ($thumbnail['url'] == 'http://img.youtube.com/vi/UMFI1hdm96E/1.jpg') { - $foundThumbnail = true; - $this->assertEquals(97, $thumbnail['height']); - $this->assertEquals(130, $thumbnail['width']); - $this->assertEquals('00:01:03.750', $thumbnail['time']); - } - } - $this->assertTrue($foundThumbnail); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(array(), $newEntry->getVideoThumbnails()); - } - - public function testGetVideoTags() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - - $keywords = $videoEntry->getMediaGroup()->getKeywords(); - - $keywordsString = (string) $keywords; - - if (strlen(trim($keywordsString)) > 0) { - $keywordArray = split('(, *)|,', $keywordsString); - } - - $tagArray = $videoEntry->getVideoTags(); - $this->assertEquals(count($keywordArray), count($tagArray)); - foreach ($keywordArray as $keyword) { - $this->assertTrue(in_array($keyword, $tagArray)); - } - foreach ($tagArray as $tag) { - $this->assertTrue(in_array($tag, $keywordArray)); - } - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(array(), $newEntry->getVideoTags()); - } - - public function testSetVideoTags() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - - $newKeywordsString = $this->createRandomString() - . ', ' . $this->createRandomString(); - $videoEntry->setVideoTags($newKeywordsString); - - if (strlen(trim($newKeywordsString)) > 0) { - $keywordArray = split('(, *)|,', $newKeywordsString); - } - - $tagArray = $videoEntry->getVideoTags(); - $this->assertEquals(count($keywordArray), count($tagArray)); - - foreach ($keywordArray as $keyword) { - $this->assertTrue(in_array($keyword, $tagArray)); - } - - foreach ($tagArray as $tag) { - $this->assertTrue(in_array($tag, $keywordArray)); - } - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(array(), $newEntry->getVideoTags()); - } - - public function testGetVideoDeveloperTags() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - - $categories = $videoEntry->getMediaGroup()->getCategory(); - $developerTagsArrayFromMediaGroup = null; - foreach($categories as $category) { - if ($category->getScheme() == 'http://gdata.youtube.com/schemas/2007/developertags.cat') { - $developerTagsArrayFromMediaGroup[] = $category->getText(); - } - } - - $developerTagsArray = $videoEntry->getVideoDeveloperTags(); - - $this->assertEquals(count($developerTagsArrayFromMediaGroup), count($developerTagsArray)); - foreach ($developerTagsArrayFromMediaGroup as $devTagMG) { - $this->assertTrue(in_array($devTagMG, $developerTagsArrayFromMediaGroup)); - } - foreach ($developerTagsArray as $devTag) { - $this->assertTrue(in_array($devTag, $developerTagsArray)); - } - } - - public function testSetVideoDeveloperTags() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $existingDevTags = $videoEntry->getVideoDeveloperTags(); - - $newDeveloperTags = array( - $this->createRandomString(), - $this->createRandomString()); - - $videoEntry->setVideoDeveloperTags($newDeveloperTags); - $newAndOldDeveloperTags = array_merge($newDeveloperTags, $existingDevTags); - $developerTagsArray = $videoEntry->getVideoDeveloperTags(); - $this->assertEquals(count($newAndOldDeveloperTags), count($developerTagsArray)); - - foreach($developerTagsArray as $developerTagOnEntry) { - $this->assertTrue(in_array($developerTagOnEntry, $newAndOldDeveloperTags)); - } - } - - public function testGetFlashPlayerUrl() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $videoEntry->getFlashPlayerUrl()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getFlashPlayerUrl()); - } - - public function testGetVideoDuration() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals(255, $videoEntry->getVideoDuration()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoDuration()); - } - - public function testGetVideoViewCount() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals(113321, $videoEntry->getVideoViewCount()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoViewCount()); - } - - public function testGetVideoGeoLocation() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $geoLocation = $videoEntry->getVideoGeoLocation(); - $this->assertEquals('37.398529052734375', $geoLocation['latitude']); - $this->assertEquals('-122.0635986328125', $geoLocation['longitude']); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoGeoLocation()); - } - - public function testGetVideoRatingInfo() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - - $ratingInfo = $videoEntry->getVideoRatingInfo(); - - $this->assertEquals(4.77, $ratingInfo['average']); - $this->assertEquals(1005, $ratingInfo['numRaters']); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoRatingInfo()); - } - - public function testGetVideoCategory() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertEquals('Music', $videoEntry->getVideoCategory()); - - $newEntry = new Zend_Gdata_YouTube_VideoEntry(); - $this->assertEquals(null, $newEntry->getVideoCategory()); - } - - public function testSetVideoCategory() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $newCategory = 'Comedy'; - $videoEntry->setVideoCategory($newCategory); - $this->assertEquals($videoEntry->getVideoCategory(), $newCategory); - } - - public function testConvertVideoEntryToAndFromString() { - $this->entry->transferFromXML($this->entryText); - $entryXml = $this->entry->saveXML(); - $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); - $newVideoEntry->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newVideoEntry); - $newVideoEntryXml = $newVideoEntry->saveXML(); - $this->assertEquals($entryXml, $newVideoEntryXml); - } - - public function testNoEmbed() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - $this->assertNotEquals(null, $videoEntry->getNoEmbed()); - } - - public function testVideoState() { - $this->entry->transferFromXML($this->entryText); - $videoEntry = $this->entry; - - $videoState = $videoEntry->getVideoState(); - $this->assertTrue($videoState instanceof Zend_Gdata_YouTube_Extension_State); - - $this->assertEquals('rejected', $videoState->getName()); - $this->assertEquals('inappropriate', $videoState->getReasonCode()); - $this->assertEquals('http://www.youtube.com/t/community_guidelines', $videoState->getHelpUrl()); - $this->assertEquals('The content of this video may violate the terms of use.', - $videoState->getText()); - } - - public function testVideoPrivate() { - $this->entry->transferFromXml($this->privateEntryText); - $videoEntry = $this->entry; - - $this->assertTrue($videoEntry->isVideoPrivate()); - } - - public function testSetVideoPrivate() { - $this->entry->transferFromXml($this->entryText); - $videoEntry = $this->entry; - $videoEntry->setVideoPrivate(); - - $this->assertTrue($videoEntry->isVideoPrivate()); - } - - public function testSetVideoPublic() { - $this->entry->transferFromXml($this->privateEntryText); - $videoEntry = $this->entry; - $videoEntry->setVideoPublic(); - - $this->assertFalse($videoEntry->isVideoPrivate()); - } - -} diff --git a/tests/Zend/Gdata/YouTube/VideoFeedTest.php b/tests/Zend/Gdata/YouTube/VideoFeedTest.php deleted file mode 100644 index f2bb0e10aeeb3bf3d708a9daefa32c7178519059..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/VideoFeedTest.php +++ /dev/null @@ -1,109 +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_Gdata_YouTube - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com); - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube/VideoFeed.php'; -require_once 'Zend/Gdata/YouTube.php'; - -/** - * @package Zend_Gdata_App - * @subpackage UnitTests - */ -class Zend_Gdata_YouTube_VideoFeedTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() { - $this->feedText = file_get_contents( - 'Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml', - true); - $this->feed = new Zend_Gdata_YouTube_VideoFeed(); - } - - private function verifyAllSamplePropertiesAreCorrect ($videoFeed) { - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/uploads', - $videoFeed->id->text); - $this->assertEquals('2007-09-21T02:27:22.638Z', $videoFeed->updated->text); - $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoFeed->category[0]->scheme); - $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoFeed->category[0]->term); - $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $videoFeed->logo->text); - $this->assertEquals('text', $videoFeed->title->type); - $this->assertEquals('Davidchoimusic\'s Videos', $videoFeed->title->text);; - $this->assertEquals('self', $videoFeed->getLink('self')->rel); - $this->assertEquals('application/atom+xml', $videoFeed->getLink('self')->type); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/uploads?start-index=1&max-results=5', $videoFeed->getLink('self')->href); - $this->assertEquals('davidchoimusic', $videoFeed->author[0]->name->text); - $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $videoFeed->author[0]->uri->text); - $this->assertEquals(54, $videoFeed->totalResults->text); - $this->assertEquals(1, $videoFeed->startIndex->text); - $this->assertEquals(5, $videoFeed->itemsPerPage->text); - } - - public function testEmptyEntryShouldHaveNoExtensionElements() { - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testEmptyEntryShouldHaveNoExtensionAttributes() { - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionElements() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionElements)); - $this->assertTrue(count($this->feed->extensionElements) == 0); - } - - public function testSampleEntryShouldHaveNoExtensionAttributes() { - $this->feed->transferFromXML($this->feedText); - $this->assertTrue(is_array($this->feed->extensionAttributes)); - $this->assertTrue(count($this->feed->extensionAttributes) == 0); - } - - public function testEmptyVideoFeedToAndFromStringShouldMatch() { - $entryXml = $this->feed->saveXML(); - $newVideoFeed = new Zend_Gdata_YouTube_VideoFeed(); - $newVideoFeed->transferFromXML($entryXml); - $newVideoFeedXml = $newVideoFeed->saveXML(); - $this->assertTrue($entryXml == $newVideoFeedXml); - } - - public function testSamplePropertiesAreCorrect () { - $this->feed->transferFromXML($this->feedText); - $this->verifyAllSamplePropertiesAreCorrect($this->feed); - } - - public function testConvertVideoFeedToAndFromString() { - $this->feed->transferFromXML($this->feedText); - $entryXml = $this->feed->saveXML(); - $newVideoFeed = new Zend_Gdata_YouTube_VideoFeed(); - $newVideoFeed->transferFromXML($entryXml); - $this->verifyAllSamplePropertiesAreCorrect($newVideoFeed); - $newVideoFeedXml = $newVideoFeed->saveXML(); - $this->assertEquals($entryXml, $newVideoFeedXml); - } - -} diff --git a/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml deleted file mode 100644 index f36f905e3d3b1afe744cdbee8924402e5ba83ff0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom'> - <id>http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052</id> - <published>2007-09-02T18:00:04.000-07:00</published> - <updated>2007-09-02T18:00:04.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#comment' /> - <title type='text'>how to turn ...</title> - <content type='text'>how to turn rejection and heartbreak into something positive is the big mystery of life but you're managed to turn it to your advantage with a beautiful song. Who was she?</content> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052' /> - <author> - <name>reneemathome</name> - <uri>http://gdata.youtube.com/feeds/users/reneemathome</uri> - </author> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml deleted file mode 100644 index d865ed08d2e64b566e8b47204de90a001e5f86e0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml +++ /dev/null @@ -1,112 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'> - <id>http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments</id> - <updated>2007-09-21T02:32:55.032Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#comment' /> - <title type='text'>Comments on '"That Girl" - Original Song - Acoustic Version'</title> - <logo> http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments?start-index=1&max-results=4' /> - <link rel='next' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments?start-index=6&max-results=4' /> - <author> - <name>YouTube</name> - <uri>http://www.youtube.com/</uri> - </author> - <generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator> - <openSearch:totalResults>100</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>4</openSearch:itemsPerPage> - <entry> - <id> - http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052</id> - <published>2007-09-02T18:00:04.000-07:00</published> - <updated>2007-09-02T18:00:04.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#comment' /> - <title type='text'>how to turn ...</title> - <content type='text'>how to turn rejection and heartbreak into - something positive is the big mystery of life but you're - managed to turn it to your advantage with a beautiful song. Who - was she?</content> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052' /> - <author> - <name>reneemathome</name> - <uri>http://gdata.youtube.com/feeds/users/reneemathome</uri> - </author> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/405F5D8E73538763</id> - <published>2007-09-02T20:51:52.000-07:00</published> - <updated>2007-09-02T20:51:52.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#comment' /> - <title type='text'>The stars are ...</title> - <content type='text'>The stars are flying... Make something - with this!!!:)</content> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/405F5D8E73538763' /> - <author> - <name>minoujill</name> - <uri>http://gdata.youtube.com/feeds/users/minoujill</uri> - </author> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/DA7550644FFCF2EC</id> - <published>2007-09-02T22:22:27.000-07:00</published> - <updated>2007-09-02T22:22:27.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#comment' /> - <title type='text'>awesome song!</title> - <content type='text'>awesome song!</content> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/DA7550644FFCF2EC' /> - <author> - <name>beeGoaTee</name> - <uri>http://gdata.youtube.com/feeds/users/beeGoaTee</uri> - </author> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/B99ACB2520430E90</id> - <published>2007-09-03T10:46:45.000-07:00</published> - <updated>2007-09-03T10:46:45.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#comment' /> - <title type='text'>This is GOOD!!</title> - <content type='text'>This is GOOD!!</content> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/B99ACB2520430E90' /> - <author> - <name>Grosh62</name> - <uri>http://gdata.youtube.com/feeds/users/Grosh62</uri> - </author> - </entry> -</feed> diff --git a/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml deleted file mode 100644 index e375401acd65ea3209b502e4e58479e8666b6ba0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id>http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser</id> - <published>1970-01-14T04:17:17.804-08:00</published> - <updated>2007-09-21T02:44:41.134Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#friend' /> - <category scheme='http://gdata.youtube.com/schemas/2007/contact.cat' - term='Friends' /> - <title type='text'>testuser</title> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile?user=testuser' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <yt:username>testuser</yt:username> - <yt:status>accepted</yt:status> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml deleted file mode 100644 index 23c9010be5e8789a6837380cd3558187b643b150..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id>http://gdata.youtube.com/feeds/users/davidchoimusic/contacts</id> - <updated>2007-09-21T02:44:41.135Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#friend' /> - <title type='text'>davidchoimusic's Contacts</title> - <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_friends?user=davidchoimusic' /> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts?start-index=1&max-results=5' /> - <link rel='next' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts?start-index=6&max-results=5' /> - <author> - <name>davidchoimusic</name> - <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator> - <openSearch:totalResults>1558</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>5</openSearch:itemsPerPage> - <entry> - <id>http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser</id> - <published>1970-01-14T04:17:17.804-08:00</published> - <updated>2007-09-21T02:44:41.134Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#friend' /> - <category scheme='http://gdata.youtube.com/schemas/2007/contact.cat' - term='Friends' /> - <title type='text'>testuser</title> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile?user=testuser' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <yt:username>testuser</yt:username> - <yt:status>accepted</yt:status> - </entry> -</feed> diff --git a/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml b/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml deleted file mode 100644 index 5dfb1f8d91604227b23cfff31f45df34d045ea03..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml +++ /dev/null @@ -1 +0,0 @@ -<response><url>http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbF1_JjEQ9cGTjEAd5FKwV42SeNWJexmc5y7XR-eFj24uqbqU6NRcxKJW_4R-sYISLxQ</url><token>AIwbFAQ21fImpR2iYPaFnfuCvfbCB3qBxl5qXiZlpH3lfkungiSPoyw1iOM1gFB6Nx-wmY-kjprNT3qtdp7LJCLfngn11Ne_X9Jd44Vz8AzygtEtaDGyib5tnri0O0-V5pwcAPCHIJurOMsOpA2zInW8V8qHk2S2LheXfTXVbqc0Li9iCBpsoBGbykYU0moNoyGAaKRbSBD0oPnCv6v9Rll5Zjvivi2hQt-Br2JDb9wVeLv3qyAFaeyN6X6k32RyaAHs_n8d8d_oSriQmvS8g1HxSCS4dnoGL7tafQ4SBqnrQEb-hxFeu1ZrAwCLv</token></response> diff --git a/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml deleted file mode 100644 index 2beed6c13ab8ca2b5865a107943b51cbe1c85199..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id> - http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7</id> - <published>2007-01-29T22:42:12.000-08:00</published> - <updated>2007-09-20T13:42:19.000-07:00</updated> - <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' - term='music' /> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlistLink' /> - <title type='text'>YouTube Musicians</title> - <content type='text'>Music from talented people on YouTube.</content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/view_play_list?p=46A2F8C9B36B6FE7' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <yt:description>Music from talented people on YouTube.</yt:description> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7' /> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml deleted file mode 100644 index e18908e76b23f179999be4da70565a7210b77436..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id>http://gdata.youtube.com/feeds/users/testuser/playlists</id> - <updated>2007-09-20T20:59:47.530Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlistLink' /> - <title type='text'>testuser's Playlists</title> - <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_play_list?user=testuser' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/playlists' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/playlists?start-index=1&max-results=25' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <generator version='beta' uri='http://gdata.youtube.com/'>YouTube - data API</generator> - <openSearch:totalResults>2</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>25</openSearch:itemsPerPage> - <entry> - <id> - http://gdata.youtube.com/feeds/users/testuser/playlists/A0F668D93B388F99</id> - <published>2007-01-17T14:13:22.000-08:00</published> - <updated>2007-02-04T21:56:42.000-08:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlistLink' /> - <title type='text'>Korean/Chinese Playlist</title> - <content type='text'>Testing characters</content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/view_play_list?p=A0F668D93B388F99' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/playlists/A0F668D93B388F99' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <yt:description>Testing characters</yt:description> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist' - href='http://gdata.youtube.com/feeds/playlists/A0F668D93B388F99' /> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7</id> - <published>2007-01-29T22:42:12.000-08:00</published> - <updated>2007-09-20T13:42:19.000-07:00</updated> - <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' - term='music' /> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlistLink' /> - <title type='text'>YouTube Musicians</title> - <content type='text'>Music from talented people on YouTube.</content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/view_play_list?p=46A2F8C9B36B6FE7' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <yt:description>Music from talented people on YouTube.</yt:description> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7' /> - </entry> -</feed> diff --git a/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml deleted file mode 100644 index 544937455c8e67be617c1baf5f0ff5eb40c06227..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21</id> - <updated>2007-09-20T22:56:57.061Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img - alt="" - src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy - (Gnarles Barkley)&quot; - Acoustic Cover</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Gnarles Barkley acoustic cover - http://www.myspace.com/davidchoimusic</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; - padding-left: 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 113321</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">1005 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:15</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> - <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> - <media:keywords>music, singing, gnarls, barkley, acoustic, cover</media:keywords> - <yt:duration seconds='255' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/UMFI1hdm96E' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='255' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' - height='97' width='130' time='00:02:07.500' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' - height='97' width='130' time='00:01:03.750' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' - height='97' width='130' time='00:03:11.250' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' - height='240' width='320' time='00:02:07.500' /> - </media:group> - <yt:statistics viewCount='113321' /> - <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> - </gd:comments> - <yt:position>1</yt:position> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml deleted file mode 100644 index 3c47b3e008a539476f1c94d3788d46fb493cdfcf..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml +++ /dev/null @@ -1,1495 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7</id> - <updated>2007-09-20T13:42:19.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' - term='music' /> - <title type='text'>YouTube Musicians</title> - <subtitle type='text'>Music from talented people on YouTube.</subtitle> - <logo> - http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/view_play_list?p=46A2F8C9B36B6FE7' /> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7?start-index=1&max-results=25' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <generator version='beta' uri='http://gdata.youtube.com/'>YouTube - data API</generator> - <openSearch:totalResults>13</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>25</openSearch:itemsPerPage> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21</id> - <updated>2007-09-20T22:56:57.061Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic - Cover</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img - alt="" - src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy - (Gnarles Barkley)&quot; - Acoustic Cover</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Gnarles Barkley acoustic cover - http://www.myspace.com/davidchoimusic</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; - padding-left: 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 113321</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">1005 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:15</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"Crazy (Gnarles Barkley)" - - Acoustic Cover</media:title> - <media:description type='plain'>Gnarles Barkley acoustic - cover - http://www.myspace.com/davidchoimusic</media:description> - <media:keywords>music, singing, gnarls, barkley, acoustic, - cover</media:keywords> - <yt:duration seconds='255' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/UMFI1hdm96E' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='255' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' - height='97' width='130' time='00:02:07.500' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' - height='97' width='130' time='00:01:03.750' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' - height='97' width='130' time='00:03:11.250' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' - height='240' width='320' time='00:02:07.500' /> - </media:group> - <yt:statistics viewCount='113321' /> - <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> - </gd:comments> - <yt:position>1</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/c9d8e923d586c337</id> - <updated>2007-09-20T22:56:57.061Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>gnals barkley</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=waQuw1P7VU8"><img - alt="" - src="http://img.youtube.com/vi/waQuw1P7VU8/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=waQuw1P7VU8">gnals - barkley</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>Me - singing Crazy by gnarls - barkley</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=esmeedenters">esmeedenters</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 219224</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">1753 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">02:59</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=waQuw1P7VU8' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/c9d8e923d586c337' /> - <author> - <name>esmeedenters</name> - <uri>http://gdata.youtube.com/feeds/users/esmeedenters</uri> - </author> - <media:group> - <media:title type='plain'>gnals barkley</media:title> - <media:description type='plain'>Me singing Crazy by gnarls - barkley</media:description> - <media:keywords>music, singing, gnarls, - barkley</media:keywords> - <yt:duration seconds='179' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/waQuw1P7VU8' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='179' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=waQuw1P7VU8' /> - <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/2.jpg' - height='97' width='130' time='00:01:29.500' /> - <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/1.jpg' - height='97' width='130' time='00:00:44.750' /> - <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/3.jpg' - height='97' width='130' time='00:02:14.250' /> - <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/0.jpg' - height='240' width='320' time='00:01:29.500' /> - </media:group> - <yt:statistics viewCount='219224' /> - <gd:rating min='1' max='5' numRaters='1753' average='4.73' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8/comments' /> - </gd:comments> - <yt:position>2</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/8574b0cf3b5045b9</id> - <updated>2007-09-20T22:56:57.061Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>Can't take my eyes off of you</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=xjidkN6kleU"><img - alt="" - src="http://img.youtube.com/vi/xjidkN6kleU/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=xjidkN6kleU">Can&#39;t - take my eyes off of you</a> <br></div> - <div style="font-size: 12px; margin: 3px - 0px;"><span>Lauryn Hill Cover - Can&#39;t take my - eyes off of you. my way--- a good - way?</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=munilicious">munilicious</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 12968</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> - <div style="font-size: 11px;">34 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">02:18</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=xjidkN6kleU' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/8574b0cf3b5045b9' /> - <author> - <name>munilicious</name> - <uri>http://gdata.youtube.com/feeds/users/munilicious</uri> - </author> - <media:group> - <media:title type='plain'>Can't take my eyes off of - you</media:title> - <media:description type='plain'>Lauryn Hill Cover - Can't - take my eyes off of you. my way--- a good - way?</media:description> - <media:keywords>Lauryn, Hill, Can't, take, my, eyes, off, of, - you</media:keywords> - <yt:duration seconds='138' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:player url='http://www.youtube.com/watch?v=xjidkN6kleU' /> - <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/2.jpg' - height='97' width='130' time='00:01:09' /> - <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/1.jpg' - height='97' width='130' time='00:00:34.500' /> - <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/3.jpg' - height='97' width='130' time='00:01:43.500' /> - <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/0.jpg' - height='240' width='320' time='00:01:09' /> - </media:group> - <yt:statistics viewCount='12968' /> - <yt:noembed /> - <gd:rating min='1' max='5' numRaters='34' average='3.85' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU/comments' /> - </gd:comments> - <yt:position>3</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/6d42a26a97a53c78</id> - <updated>2007-09-20T22:56:57.062Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>hanging by a moment (cover)</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=MOxExzhhW0c"><img - alt="" - src="http://img.youtube.com/vi/MOxExzhhW0c/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=MOxExzhhW0c">hanging by - a moment (cover)</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>my - sister(guitar) and me jamming - lifehouse</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=lauwarm">lauwarm</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 7186</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> - <div style="font-size: 11px;">24 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">00:30</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=MOxExzhhW0c' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/6d42a26a97a53c78' /> - <author> - <name>lauwarm</name> - <uri>http://gdata.youtube.com/feeds/users/lauwarm</uri> - </author> - <media:group> - <media:title type='plain'>hanging by a moment - (cover)</media:title> - <media:description type='plain'>my sister(guitar) and me - jamming lifehouse</media:description> - <media:keywords>lifehouse, hanging, by, moment, cover, - acoustic</media:keywords> - <yt:duration seconds='30' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/MOxExzhhW0c' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='30' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=MOxExzhhW0c' /> - <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/2.jpg' - height='97' width='130' time='00:00:15' /> - <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/1.jpg' - height='97' width='130' time='00:00:07.500' /> - <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/3.jpg' - height='97' width='130' time='00:00:22.500' /> - <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/0.jpg' - height='240' width='320' time='00:00:15' /> - </media:group> - <yt:statistics viewCount='7186' /> - <gd:rating min='1' max='5' numRaters='24' average='4.21' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c/comments' /> - </gd:comments> - <yt:position>4</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/f78779d50b24db79</id> - <updated>2007-09-20T22:56:57.062Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>I'LL BE-MEN'S OCTET (ACAPELLA)</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=_KHqQc1nn_0"><img - alt="" - src="http://img.youtube.com/vi/_KHqQc1nn_0/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=_KHqQc1nn_0">I&#39;LL - BE-MEN&#39;S OCTET (ACAPELLA)</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>UC BERKELEY&#39;S MEN&#39;S - OCTET (ACAPELLA)</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=boredom">boredom</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 46416</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">116 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:06</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=_KHqQc1nn_0' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/f78779d50b24db79' /> - <author> - <name>boredom</name> - <uri>http://gdata.youtube.com/feeds/users/boredom</uri> - </author> - <media:group> - <media:title type='plain'>I'LL BE-MEN'S OCTET - (ACAPELLA)</media:title> - <media:description type='plain'>UC BERKELEY'S MEN'S OCTET - (ACAPELLA)</media:description> - <media:keywords>ACAPELLA, berkeley, octet</media:keywords> - <yt:duration seconds='246' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/_KHqQc1nn_0' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='246' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=_KHqQc1nn_0' /> - <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/2.jpg' - height='97' width='130' time='00:02:03' /> - <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/1.jpg' - height='97' width='130' time='00:01:01.500' /> - <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/3.jpg' - height='97' width='130' time='00:03:04.500' /> - <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/0.jpg' - height='240' width='320' time='00:02:03' /> - </media:group> - <yt:statistics viewCount='46416' /> - <gd:rating min='1' max='5' numRaters='116' average='4.65' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0/comments' /> - </gd:comments> - <yt:position>5</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/d5fead6a034eb51c</id> - <updated>2007-09-20T22:56:57.062Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>Kiss the Girl</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=EV1_qPBuDt8"><img - alt="" - src="http://img.youtube.com/vi/EV1_qPBuDt8/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=EV1_qPBuDt8">Kiss the - Girl</a> <br></div> <div style="font-size: - 12px; margin: 3px 0px;"><span>Alma College&#39;s - Scots on the Rocks sing their acapella rendition of Kiss the - Girl from the Little - Mermaid</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=cmorris">cmorris</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 37218</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">312 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">03:16</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=EV1_qPBuDt8' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/d5fead6a034eb51c' /> - <author> - <name>cmorris</name> - <uri>http://gdata.youtube.com/feeds/users/cmorris</uri> - </author> - <media:group> - <media:title type='plain'>Kiss the Girl</media:title> - <media:description type='plain'>Alma College's Scots on the - Rocks sing their acapella rendition of Kiss the Girl from the - Little Mermaid</media:description> - <media:keywords>acapella</media:keywords> - <yt:duration seconds='196' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/EV1_qPBuDt8' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='196' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=EV1_qPBuDt8' /> - <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/2.jpg' - height='97' width='130' time='00:01:38' /> - <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/1.jpg' - height='97' width='130' time='00:00:49' /> - <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/3.jpg' - height='97' width='130' time='00:02:27' /> - <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/0.jpg' - height='240' width='320' time='00:01:38' /> - </media:group> - <yt:statistics viewCount='37218' /> - <gd:rating min='1' max='5' numRaters='312' average='4.77' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8/comments' /> - </gd:comments> - <yt:position>6</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/618d7dba982c0d7e</id> - <updated>2007-09-20T22:56:57.063Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>Oasis "Wonderwall" Acoustic Cover by - ortoPilot</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=t4EaHIpjTTY"><img - alt="" - src="http://img.youtube.com/vi/t4EaHIpjTTY/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=t4EaHIpjTTY">Oasis - &quot;Wonderwall&quot; Acoustic Cover by - ortoPilot</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>Oasis - &quot;Wonderwall&quot; Acoustic Cover by ortoPilot - acoustic version of wonderwall influenced by RYAN ADAMS mp3 - download and TABS @ www.ortoPilot.com enjoy! if you like this - vid, SUBSCRIBE to my vids, - cheers!</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=ortoPilot">ortoPilot</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 92395</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">521 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:01</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=t4EaHIpjTTY' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/618d7dba982c0d7e' /> - <author> - <name>ortoPilot</name> - <uri>http://gdata.youtube.com/feeds/users/ortoPilot</uri> - </author> - <media:group> - <media:title type='plain'>Oasis "Wonderwall" Acoustic Cover - by ortoPilot</media:title> - <media:description type='plain'>Oasis "Wonderwall" Acoustic - Cover by ortoPilot acoustic version of wonderwall influenced - by RYAN ADAMS mp3 download and TABS @ www.ortoPilot.com - enjoy! if you like this vid, SUBSCRIBE to my vids, - cheers!</media:description> - <media:keywords>acoustic, guitar, cover, oasis, wonderwall, - ortopilot, matt, hutchison, live, tab, tabs, - tutorial</media:keywords> - <yt:duration seconds='241' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/t4EaHIpjTTY' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='241' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=t4EaHIpjTTY' /> - <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/2.jpg' - height='97' width='130' time='00:02:00.500' /> - <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/1.jpg' - height='97' width='130' time='00:01:00.250' /> - <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/3.jpg' - height='97' width='130' time='00:03:00.750' /> - <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/0.jpg' - height='240' width='320' time='00:02:00.500' /> - </media:group> - <yt:statistics viewCount='92395' /> - <gd:rating min='1' max='5' numRaters='521' average='4.66' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY/comments' /> - </gd:comments> - <yt:position>7</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/4bfaab0ffb00dfdd</id> - <updated>2007-09-20T22:56:57.063Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>Pancakes!</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=PnCVZozHTG8"><img - alt="" - src="http://img.youtube.com/vi/PnCVZozHTG8/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=PnCVZozHTG8">Pancakes!</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>A short music video about making - pancakes =) This video has been on ABC&#39;s &quot;Good - Morning America&quot; show, 16th August. - http://abcnews.go.com/Video/playerIndex?id=2318825 It has also - been aired on Fox news in America, Sky News, and Five News in - Britain and on ABC (Austrailain Broadcasting Company) in - Australia. I live in Scotland, these are British pancakes which - are like Crépes, to clear up the confusion. Lemon - and Sugar is very popular on pacakes here. It took over a week - to make this, it&#39;s the most heavily editied project I - have done yet, and it was not easy at all, but I have created - something that I&#39;m very proud of =) Song written, - performed and produced by me, video written, edited and filmed - by me. MP3 available on my website! James Provan Thanks to - Yukeh for the the voice that says &quot;GiR - it&#39;s - time for pancakes!&quot; at the - start.</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=GiR2007">GiR2007</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 2249048</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">17754 <span - style="color: #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">02:22</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=1">Film - &amp; - Animation</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=PnCVZozHTG8' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/4bfaab0ffb00dfdd' /> - <author> - <name>GiR2007</name> - <uri>http://gdata.youtube.com/feeds/users/GiR2007</uri> - </author> - <media:group> - <media:title type='plain'>Pancakes!</media:title> - <media:description type='plain'>A short music video about - making pancakes =) This video has been on ABC's "Good Morning - America" show, 16th August. - http://abcnews.go.com/Video/playerIndex?id=2318825 It has - also been aired on Fox news in America, Sky News, and Five - News in Britain and on ABC (Austrailain Broadcasting Company) - in Australia. I live in Scotland, these are British pancakes - which are like Crépes, to clear up the confusion. - Lemon and Sugar is very popular on pacakes here. It took over - a week to make this, it's the most heavily editied project I - have done yet, and it was not easy at all, but I have created - something that I'm very proud of =) Song written, performed - and produced by me, video written, edited and filmed by me. - MP3 available on my website! James Provan Thanks to Yukeh for - the the voice that says "GiR - it's time for pancakes!" at - the start.</media:description> - <media:keywords>stop, motion, pancakes, GiR2007, food, tasty, - nutella, jam, maple, syrup, animation, GMA, good, morning, - america, goodmorning</media:keywords> - <yt:duration seconds='142' /> - <media:category label='Film & Animation' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Film</media:category> - <media:content url='http://www.youtube.com/v/PnCVZozHTG8' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='142' - yt:format='5' /> - <media:content url='rtsp://rtsp.youtube.com/youtube/videos/PnCVZozHTG8/video.3gp' - type='video/3gpp' medium='video' expression='full' - duration='142' yt:format='1' /> - <media:player url='http://www.youtube.com/watch?v=PnCVZozHTG8' /> - <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/2.jpg' - height='97' width='130' time='00:01:11' /> - <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/1.jpg' - height='97' width='130' time='00:00:35.500' /> - <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/3.jpg' - height='97' width='130' time='00:01:46.500' /> - <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/0.jpg' - height='240' width='320' time='00:01:11' /> - </media:group> - <yt:statistics viewCount='2249048' /> - <gd:rating min='1' max='5' numRaters='17754' average='4.59' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8/comments' /> - </gd:comments> - <yt:position>8</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/46632a732cae0cbc</id> - <updated>2007-09-20T22:56:57.063Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>Ana Free - Chained</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=_6ceUy9lVdM"><img - alt="" - src="http://img.youtube.com/vi/_6ceUy9lVdM/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=_6ceUy9lVdM">Ana Free - - Chained</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>The - second upload of the day.. :) All is explained in the video, no - point in writing it here! Take care *** - Ana</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=anafree">anafree</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 688963</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> - <div style="font-size: 11px;">4530 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">03:11</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=_6ceUy9lVdM' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/46632a732cae0cbc' /> - <author> - <name>anafree</name> - <uri>http://gdata.youtube.com/feeds/users/anafree</uri> - </author> - <media:group> - <media:title type='plain'>Ana Free - Chained</media:title> - <media:description type='plain'>The second upload of the - day.. :) All is explained in the video, no point in writing - it here! Take care *** Ana</media:description> - <media:keywords>anafree, ana, free, chained, original, - acoustic, love</media:keywords> - <yt:duration seconds='191' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/_6ceUy9lVdM' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='191' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=_6ceUy9lVdM' /> - <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/2.jpg' - height='97' width='130' time='00:01:35.500' /> - <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/1.jpg' - height='97' width='130' time='00:00:47.750' /> - <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/3.jpg' - height='97' width='130' time='00:02:23.250' /> - <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/0.jpg' - height='240' width='320' time='00:01:35.500' /> - </media:group> - <yt:statistics viewCount='688963' /> - <gd:rating min='1' max='5' numRaters='4530' average='4.48' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM/comments' /> - </gd:comments> - <yt:position>9</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/e67d5bf916676e20</id> - <updated>2007-09-20T22:56:57.064Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>Ana Free (Bic Runga - Sway</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=ihQW-pWlkJw"><img - alt="" - src="http://img.youtube.com/vi/ihQW-pWlkJw/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=ihQW-pWlkJw">Ana Free - (Bic Runga - Sway</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>This - is Sway by Bic Runga, difficult to sing and I guess to play - aswell..:) Hope you enjoy - it!</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=anafree">anafree</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 282936</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">2224 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">03:24</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=ihQW-pWlkJw' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/e67d5bf916676e20' /> - <author> - <name>anafree</name> - <uri>http://gdata.youtube.com/feeds/users/anafree</uri> - </author> - <media:group> - <media:title type='plain'>Ana Free (Bic Runga - - Sway</media:title> - <media:description type='plain'>This is Sway by Bic Runga, - difficult to sing and I guess to play aswell..:) Hope you - enjoy it!</media:description> - <media:keywords>bic, runga, sway, ana, free, anafree, - acoustic, singing</media:keywords> - <yt:duration seconds='204' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/ihQW-pWlkJw' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='204' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=ihQW-pWlkJw' /> - <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/2.jpg' - height='97' width='130' time='00:01:42' /> - <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/1.jpg' - height='97' width='130' time='00:00:51' /> - <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/3.jpg' - height='97' width='130' time='00:02:33' /> - <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/0.jpg' - height='240' width='320' time='00:01:42' /> - </media:group> - <yt:statistics viewCount='282936' /> - <gd:rating min='1' max='5' numRaters='2224' average='4.74' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw/comments' /> - </gd:comments> - <yt:position>10</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/a3011180d79eff53</id> - <updated>2007-09-20T22:56:57.064Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>I'm falling in love (u can buy the mp3 at - justinsteere.com)</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=oXjInYHk2j0"><img - alt="" - src="http://img.youtube.com/vi/oXjInYHk2j0/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=oXjInYHk2j0">I&#39;m - falling in love (u can buy the mp3 at - justinsteere.com)</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>this - is an original acoustic song. to purchase this song and others - check out justinsteere.com VOTE FOR THIS VIDEO AT famecast.com - (just search my name and click on vote for artist) - myspace.com/jsteere subscribe for instant video updates. more - videos coming soon. all the money i make from the mp3 downloads - is going towards making my real cd in november. enjoy - :)</span></div></td> <td style="font-size: - 11px; line-height: 1.4em; padding-left: 20px; padding-top: - 1px;" width="146" valign="top"><div><span - style="color: #666666; font-size: 11px;">From:</span> - <a - href="http://www.youtube.com/profile?user=bunetaybaz">bunetaybaz</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 653489</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">4654 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">03:17</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=oXjInYHk2j0' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/a3011180d79eff53' /> - <author> - <name>bunetaybaz</name> - <uri>http://gdata.youtube.com/feeds/users/bunetaybaz</uri> - </author> - <media:group> - <media:title type='plain'>I'm falling in love (u can buy the - mp3 at justinsteere.com)</media:title> - <media:description type='plain'>this is an original acoustic - song. to purchase this song and others check out - justinsteere.com VOTE FOR THIS VIDEO AT famecast.com (just - search my name and click on vote for artist) - myspace.com/jsteere subscribe for instant video updates. more - videos coming soon. all the money i make from the mp3 - downloads is going towards making my real cd in november. - enjoy :)</media:description> - <media:keywords>justin, steere, jason, mraz, im, yours, dax, - flame, brookers, david, gray, josh, groban, you, and, I, - both, right, kind, of, phrase, better</media:keywords> - <yt:duration seconds='197' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/oXjInYHk2j0' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='197' - yt:format='5' /> - <media:content url='rtsp://rtsp.youtube.com/youtube/videos/oXjInYHk2j0/video.3gp' - type='video/3gpp' medium='video' expression='full' - duration='197' yt:format='1' /> - <media:player url='http://www.youtube.com/watch?v=oXjInYHk2j0' /> - <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/2.jpg' - height='97' width='130' time='00:01:38.500' /> - <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/1.jpg' - height='97' width='130' time='00:00:49.250' /> - <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/3.jpg' - height='97' width='130' time='00:02:27.750' /> - <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/0.jpg' - height='240' width='320' time='00:01:38.500' /> - </media:group> - <yt:statistics viewCount='653489' /> - <gd:rating min='1' max='5' numRaters='4654' average='4.59' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0/comments' /> - </gd:comments> - <yt:position>11</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/798565c7d1c75453</id> - <updated>2007-09-20T22:56:57.064Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>When I Loved You</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=KjMRf4egAyA"><img - alt="" - src="http://img.youtube.com/vi/KjMRf4egAyA/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=KjMRf4egAyA">When I - Loved You</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>As - promised a new song EVERY Sunday...another original (just a - sample) I promise I&#39;ll get Sex Machine up as soon as I - can! - www.myspace.com/mishalmmoore</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; - padding-left: 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=mishalmooremusic">mishalmooremusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 715030</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> - <div style="font-size: 11px;">2988 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">02:38</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=KjMRf4egAyA' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/798565c7d1c75453' /> - <author> - <name>mishalmooremusic</name> - <uri> - http://gdata.youtube.com/feeds/users/mishalmooremusic</uri> - </author> - <media:group> - <media:title type='plain'>When I Loved You</media:title> - <media:description type='plain'>As promised a new song EVERY - Sunday...another original (just a sample) I promise I'll get - Sex Machine up as soon as I can! - www.myspace.com/mishalmmoore</media:description> - <media:keywords>mishal, moore, when, i, loved, - you</media:keywords> - <yt:duration seconds='158' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/KjMRf4egAyA' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='158' - yt:format='5' /> - <media:content url='rtsp://rtsp.youtube.com/youtube/videos/KjMRf4egAyA/video.3gp' - type='video/3gpp' medium='video' expression='full' - duration='158' yt:format='1' /> - <media:player url='http://www.youtube.com/watch?v=KjMRf4egAyA' /> - <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/2.jpg' - height='97' width='130' time='00:01:19' /> - <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/1.jpg' - height='97' width='130' time='00:00:39.500' /> - <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/3.jpg' - height='97' width='130' time='00:01:58.500' /> - <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/0.jpg' - height='240' width='320' time='00:01:19' /> - </media:group> - <yt:statistics viewCount='715030' /> - <gd:rating min='1' max='5' numRaters='2988' average='4.48' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA/comments' /> - </gd:comments> - <yt:position>12</yt:position> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/2c0c020593e15124</id> - <updated>2007-09-20T22:56:57.065Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#playlist' /> - <title type='text'>CONCEIT- Scissors & Glue ON THE RISE - CONTEST WINNER</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=R_ruSmFFdAY"><img - alt="" - src="http://img.youtube.com/vi/R_ruSmFFdAY/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=R_ruSmFFdAY">CONCEIT- - Scissors &amp; Glue ON THE RISE CONTEST WINNER</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Conceit - Scissors &amp; Glue - Prod. Memo of the Molemen from the WASTED TALENT MIXTAPE - straight out the SAN FRANCISCO BAY AREA!!! Machete Vox - Gurp - City - Strangeface - Kill Technology Much love 2 LORDS CREW UM - 86&#39;in Promo Download: - http://www.zshare.net/audio/3603976e3994ff/ Wasted Talent - Mixtape available @ myspace.com/conceit - gurpcity.net</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=conceit">conceit</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 188729</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> - <div style="font-size: 11px;">680 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">02:22</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=R_ruSmFFdAY' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY/related' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/2c0c020593e15124' /> - <author> - <name>conceit</name> - <uri>http://gdata.youtube.com/feeds/users/conceit</uri> - </author> - <media:group> - <media:title type='plain'>CONCEIT- Scissors & Glue ON THE - RISE CONTEST WINNER</media:title> - <media:description type='plain'>Conceit - Scissors & Glue - Prod. Memo of the Molemen from the WASTED TALENT MIXTAPE - straight out the SAN FRANCISCO BAY AREA!!! Machete Vox - Gurp - City - Strangeface - Kill Technology Much love 2 LORDS CREW - UM 86'in Promo Download: - http://www.zshare.net/audio/3603976e3994ff/ Wasted Talent - Mixtape available @ myspace.com/conceit - gurpcity.net</media:description> - <media:keywords>rap, music, contest, 50, cent, conceit, sf, - bay, area, ontherise, wasted, talent, gurp, city, machete, - vox</media:keywords> - <yt:duration seconds='142' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/R_ruSmFFdAY' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='142' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=R_ruSmFFdAY' /> - <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/2.jpg' - height='97' width='130' time='00:01:11' /> - <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/1.jpg' - height='97' width='130' time='00:00:35.500' /> - <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/3.jpg' - height='97' width='130' time='00:01:46.500' /> - <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/0.jpg' - height='240' width='320' time='00:01:11' /> - </media:group> - <yt:statistics viewCount='188729' /> - <gd:rating min='1' max='5' numRaters='680' average='3.84' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY/comments' /> - </gd:comments> - <yt:position>13</yt:position> - </entry> -</feed> diff --git a/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml deleted file mode 100644 index b2db6ec5bf87ab64b540ab4256c9617f3ddaf796..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id> - http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db</id> - <published>2007-03-02T11:58:22.000-08:00</published> - <updated>2007-03-02T11:58:22.000-08:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#subscription' /> - <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' - term='publisher' /> - <title type='text'>Videos published by : BBC</title> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_videos?user=BBC' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' - href='http://gdata.youtube.com/feeds/users/BBC/uploads' - countHint='697' /> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml deleted file mode 100644 index 6200054d3d5081892ab657247487e369ec4c54b0..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id> - http://gdata.youtube.com/feeds/users/testuser/subscriptions</id> - <updated>2007-09-20T22:12:45.193Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#subscription' /> - <title type='text'>testuser's Subscriptions</title> - <logo> - http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_subscriptions?user=testuser' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/subscriptions' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/subscriptions?start-index=1&max-results=25' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <generator version='beta' uri='http://gdata.youtube.com/'>YouTube - data API</generator> - <openSearch:totalResults>3</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>25</openSearch:itemsPerPage> - <entry> - <id> - http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db</id> - <published>2007-03-02T11:58:22.000-08:00</published> - <updated>2007-03-02T11:58:22.000-08:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#subscription' /> - <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' - term='publisher' /> - <title type='text'>Videos published by : BBC</title> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_videos?user=BBC' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' - href='http://gdata.youtube.com/feeds/users/BBC/uploads' - countHint='697' /> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/users/testuser/subscriptions/742853a3468b2418</id> - <published>2007-09-18T21:39:36.000-07:00</published> - <updated>2007-09-18T21:39:36.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#subscription' /> - <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' - term='publisher' /> - <title type='text'>Videos published by : communitychannel</title> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_videos?user=communitychannel' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/742853a3468b2418' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' - href='http://gdata.youtube.com/feeds/users/communitychannel/uploads' - countHint='49' /> - </entry> - <entry> - <id> - http://gdata.youtube.com/feeds/users/testuser/subscriptions/98263c1ed3e31828</id> - <published>2007-09-20T13:45:29.000-07:00</published> - <updated>2007-09-20T13:45:29.000-07:00</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#subscription' /> - <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' - term='publisher' /> - <title type='text'>Videos published by : ucberkeley</title> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_videos?user=ucberkeley' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/98263c1ed3e31828' /> - <author> - <name>testuser</name> - <uri>http://gdata.youtube.com/feeds/users/testuser</uri> - </author> - <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' - href='http://gdata.youtube.com/feeds/users/ucberkeley/uploads' - countHint='201' /> - </entry> -</feed> diff --git a/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml deleted file mode 100644 index 384ac3f07c0b7fafa931cda745191e6c400296c4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns="http://www.w3.org/2005/Atom" - xmlns:gd="http://schemas.google.com/g/2005" - xmlns:yt="http://gdata.youtube.com/schemas/2007"> - <id>http://gdata.youtube.com/feeds/users/darcy</id> - <published>2006-03-19T11:35:56.000-08:00</published> - <updated>2007-08-13T12:37:03.000-07:00</updated> - <category scheme="http://schemas.google.com/g/2005#kind" - term="http://gdata.youtube.com/schemas/2007#userProfile"/> - <title type="text">Darcy</title> - <link rel="alternate" type="text/html" - href="http://www.youtube.com/profile?user=darcy"/> - <link rel="self" type="application/atom+xml" - href="http://gdata.youtube.com/feeds/users/darcy"/> - <author> - <name>Fitzwilliam Darcy</name> - <uri>http://gdata.youtube.com/feeds/users/darcy</uri> - </author> - - <yt:age>32</yt:age> - <yt:description>A person of great interest</yt:description> - <yt:username>darcy</yt:username> - <yt:books>Pride and Prejudice</yt:books> - <yt:company>Self employed</yt:company> - <yt:hobbies>Reading, arguing with Liz</yt:hobbies> - <yt:hometown>Steventon</yt:hometown> - <yt:location>Longbourn in Hertfordshire, Pemberley in Derbyshire</yt:location> - <yt:movies>Pride and Prejudice, 2005</yt:movies> - <yt:music>Air Con Varizzioni, The Pleasure of the Town</yt:music> - <yt:occupation>Gentleman</yt:occupation> - <yt:school>Home schooling</yt:school> - <yt:gender>m</yt:gender> - <yt:relationship>taken</yt:relationship> - - <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.favorites" - href="http://gdata.youtube.com/feeds/users/darcy/favorites"/> - <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.contacts" - href="http://gdata.youtube.com/feeds/users/darcy/contacts"/> - <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.inbox" - href="http://gdata.youtube.com/feeds/users/darcy/inbox"/> - <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.playlists" - href="http://gdata.youtube.com/feeds/users/darcy/playlists"/> - <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.subscriptions" - href="http://gdata.youtube.com/feeds/users/darcy/subscriptions"/> - <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.uploads" - href="http://gdata.youtube.com/feeds/users/darcy/uploads"/> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml deleted file mode 100644 index 91fc0cc6e21d669fbf90d8ae5fa05c9c62969a5a..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007' -xmlns:gml='http://www.opengis.net/gml' -xmlns:georss='http://www.georss.org/georss' -xmlns:app='http://purl.org/atom/app#'> - <id>http://gdata.youtube.com/feeds/videos/UMFI1hdm96E</id> - <published>2007-01-07T01:50:15.000Z</published> - <updated>2007-01-07T01:50:15.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='barkley' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='singing' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='acoustic' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='cover' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='gnarls' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='music' /> - <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img - alt="" - src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy - (Gnarles Barkley)&quot; - Acoustic Cover</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Gnarles Barkley acoustic cover - http://www.myspace.com/davidchoimusic</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; padding-left: - 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 113321</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">1005 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:15</span></td> <td style="font-size: - 11px; padding-left: 20px;"><span style="color: #666666; - font-size: 11px;">More in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> - <author> - <name>davidchoimusic</name> - <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> - <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> - <media:keywords>music, singing, gnarls, barkley, acoustic, cover</media:keywords> - <yt:duration seconds='255' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:category - scheme='http://gdata.youtube.com/schemas/2007/developertags.cat'> - DeveloperTag1</media:category> - <media:content url='http://www.youtube.com/v/UMFI1hdm96E' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='255' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' - height='97' width='130' time='00:02:07.500' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' - height='97' width='130' time='00:01:03.750' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' - height='97' width='130' time='00:03:11.250' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' - height='240' width='320' time='00:02:07.500' /> - </media:group> - <yt:statistics viewCount='113321' /> - <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> - <georss:where> - <gml:Point> - <gml:pos>37.398529052734375 -122.0635986328125</gml:pos> - </gml:Point> - </georss:where> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> - </gd:comments> - <yt:noembed /> - <app:control> - <app:draft>yes</app:draft> - <yt:state - name="rejected" - reasonCode="inappropriate" - helpUrl="http://www.youtube.com/t/community_guidelines"> - The content of this video may violate the terms of use.</yt:state> - </app:control> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml b/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml deleted file mode 100755 index 86a3e2f396c8ae382fd25f71ac92b7c5abb64cb2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml +++ /dev/null @@ -1,138 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<entry xmlns='http://www.w3.org/2005/Atom' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007' -xmlns:gml='http://www.opengis.net/gml' -xmlns:georss='http://www.georss.org/georss' -xmlns:app='http://purl.org/atom/app#'> - <id>http://gdata.youtube.com/feeds/videos/UMFI1hdm96E</id> - <published>2007-01-07T01:50:15.000Z</published> - <updated>2007-01-07T01:50:15.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='barkley' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='singing' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='acoustic' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='cover' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='gnarls' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='music' /> - <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img - alt="" - src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy - (Gnarles Barkley)&quot; - Acoustic Cover</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Gnarles Barkley acoustic cover - http://www.myspace.com/davidchoimusic</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; padding-left: - 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 113321</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">1005 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:15</span></td> <td style="font-size: - 11px; padding-left: 20px;"><span style="color: #666666; - font-size: 11px;">More in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> - <author> - <name>davidchoimusic</name> - <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> - <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> - <media:keywords>music, singing, gnarls, barkley, acoustic, cover</media:keywords> - <yt:duration seconds='255' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:category - scheme='http://gdata.youtube.com/schemas/2007/developertags.cat'> - DeveloperTag1</media:category> - <media:content url='http://www.youtube.com/v/UMFI1hdm96E' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='255' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' - height='97' width='130' time='00:02:07.500' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' - height='97' width='130' time='00:01:03.750' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' - height='97' width='130' time='00:03:11.250' /> - <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' - height='240' width='320' time='00:02:07.500' /> - <yt:private /> - </media:group> - <yt:statistics viewCount='113321' /> - <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> - <georss:where> - <gml:Point> - <gml:pos>37.398529052734375 -122.0635986328125</gml:pos> - </gml:Point> - </georss:where> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> - </gd:comments> - <yt:noembed /> - <app:control> - <app:draft>yes</app:draft> - <yt:state - name="rejected" - reasonCode="inappropriate" - helpUrl="http://www.youtube.com/t/community_guidelines"> - The content of this video may violate the terms of use.</yt:state> - </app:control> -</entry> diff --git a/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml b/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml deleted file mode 100644 index 33ec9c79ac86dce7c8b782a1ee4e92f1fc53f5d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml +++ /dev/null @@ -1,743 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<feed xmlns='http://www.w3.org/2005/Atom' -xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' -xmlns:media='http://search.yahoo.com/mrss/' -xmlns:gd='http://schemas.google.com/g/2005' -xmlns:yt='http://gdata.youtube.com/schemas/2007'> - <id>http://gdata.youtube.com/feeds/users/davidchoimusic/uploads</id> - <updated>2007-09-21T02:27:22.638Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <title type='text'>Davidchoimusic's Videos</title> - <logo> http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/profile_videos?user=davidchoimusic' /> - <link rel='related' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic' /> - <link rel='http://schemas.google.com/g/2005#feed' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/uploads' /> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/uploads?start-index=1&max-results=5' /> - <link rel='next' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/users/davidchoimusic/uploads?start-index=6&max-results=5' /> - <author> - <name>davidchoimusic</name> - <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator> - <openSearch:totalResults>54</openSearch:totalResults> - <openSearch:startIndex>1</openSearch:startIndex> - <openSearch:itemsPerPage>5</openSearch:itemsPerPage> - <entry> - <id>http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg</id> - <published>2007-01-11T00:17:31.000Z</published> - <updated>2007-01-11T00:17:31.000Z</updated> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Song' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Version' /> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Original' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Girl' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='That' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Acoustic' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='davidchoimusic' /> - <title type='text'>"That Girl" - Original Song - Acoustic - Version</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=Lnio-pqLPgg"><img - alt="" - src="http://img.youtube.com/vi/Lnio-pqLPgg/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=Lnio-pqLPgg">&quot;That - Girl&quot; - Original Song - Acoustic Version</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>For the full version, check out - http://www.myspace.com/musicchester mp3 - http://www.broadjam.com/davidchoi That Girl Oh tonight - I&#39;m feeling fine I&#39;m alone just wasting time no - Friday movie nights or romantic candlelight I&#39;m just - having conversations with the thoughts in my head all I hear - are angels crying oh won&#39;t they just sing instead It - would be wrong for me to say I don&#39;t need that girl by - my side I don&#39;t need that girl in my life I - don&#39;t want to talk it out or hold her when she cries I - don&#39;t want to say she&#39;s my kind I don&#39;t - want to say that she&#39;s mine I don&#39;t want to - tell her that I love her more than life more than life, love - her more than life Honestly, this won&#39;t do how is she - doing? I tell myself I&#39;m feeling swell but I know - I&#39;m such a fool I&#39;ll just take it as a new - beginning but you know I don&#39;t feel that way who will - take all this pain away? I know it&#39;s wrong for me to - say Chorus Talk about a sin was the day I walked into the other - side I would run back in I wouldn&#39;t waste no time I - know it&#39;s wrong for me to say Chorus - www.myspace.com/davidchoimusic</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; - padding-left: 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 437209</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">2981 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">03:40</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/related' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"That Girl" - Original Song - - Acoustic Version</media:title> - <media:description type='plain'>For the full version, check - out http://www.myspace.com/musicchester mp3 - http://www.broadjam.com/davidchoi That Girl Oh tonight I'm - feeling fine I'm alone just wasting time no Friday movie - nights or romantic candlelight I'm just having conversations - with the thoughts in my head all I hear are angels crying oh - won't they just sing instead It would be wrong for me to say - I don't need that girl by my side I don't need that girl in - my life I don't want to talk it out or hold her when she - cries I don't want to say she's my kind I don't want to say - that she's mine I don't want to tell her that I love her more - than life more than life, love her more than life Honestly, - this won't do how is she doing? I tell myself I'm feeling - swell but I know I'm such a fool I'll just take it as a new - beginning but you know I don't feel that way who will take - all this pain away? I know it's wrong for me to say Chorus - Talk about a sin was the day I walked into the other side I - would run back in I wouldn't waste no time I know it's wrong - for me to say Chorus - www.myspace.com/davidchoimusic</media:description> - <media:keywords>That, Girl, Original, Song, Acoustic, - Version, davidchoimusic</media:keywords> - <yt:duration seconds='220' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/Lnio-pqLPgg' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='220' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> - <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/2.jpg' - height='97' width='130' time='00:01:50' /> - <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/1.jpg' - height='97' width='130' time='00:00:55' /> - <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/3.jpg' - height='97' width='130' time='00:02:45' /> - <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/0.jpg' - height='240' width='320' time='00:01:50' /> - </media:group> - <yt:statistics viewCount='437209' /> - <gd:rating min='1' max='5' numRaters='2981' average='4.89' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments' /> - </gd:comments> - </entry> - <entry> - <id>http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g</id> - <published>2006-12-30T23:20:14.000Z</published> - <updated>2006-12-30T23:20:14.000Z</updated> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Song' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Song)' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Version' /> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Love' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Tube' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Original' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='You' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='(A' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Acoustic' /> - <title type='text'>"You Tube" (A Love Song) - Original Song - - Acoustic Version</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=FWPzxVMQU8g"><img - alt="" - src="http://img.youtube.com/vi/FWPzxVMQU8g/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=FWPzxVMQU8g">&quot;You - Tube&quot; (A Love Song) - Original Song - Acoustic - Version</a> <br></div> <div - style="font-size: 12px; margin: 3px - 0px;"><span>http://www.youtube.com/subscription_center?add_user=davidchoimusic - http://www.myspace.com/davidchoimusic If you want to be updated - on new videos, hit the orange &quot;subscribe&quot; - button on the top right corner! - ================================ &quot;You Tube&quot; - (A Love Song) When I wake up in the morning youtube when I - dream at night, youtube in the middle of the day, youtube you - consume my life, youtube I can&#39;t help, but think of you - I just love the things you do allow the people, to post our - videos, we love you youtube I like the founders some Asian and - some white dude but more than you I love youtube When I wake up - in the morning youtube when I dream at night, youtube in the - middle of the day, youtube you consume my life, youtube - youtube, you can comment all over me youtube, will you make - passionate love to me you can respond to my video if - you&#39;d like I&#39;ll post one right back, oh I think - I might could you add me to your favorites and I&#39;ll - post on your bulletin maybe send you a message if you promise - to write me back I&#39;ll log in and out to please you oh - you know the things I&#39;ll do oh youtube, oh youtube When - I wake up in the morning youtube when I dream at night, youtube - in the middle of the day, youtube you consume my life, - youtube</span></div></td> <td - style="font-size: 11px; line-height: 1.4em; padding-left: 20px; - padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 1495035</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">10995 <span - style="color: #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">02:57</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=FWPzxVMQU8g' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g/related' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"You Tube" (A Love Song) - Original - Song - Acoustic Version</media:title> - <media:description type='plain'> - http://www.youtube.com/subscription_center?add_user=davidchoimusic - http://www.myspace.com/davidchoimusic If you want to be - updated on new videos, hit the orange "subscribe" button on - the top right corner! ================================ "You - Tube" (A Love Song) When I wake up in the morning youtube - when I dream at night, youtube in the middle of the day, - youtube you consume my life, youtube I can't help, but think - of you I just love the things you do allow the people, to - post our videos, we love you youtube I like the founders some - Asian and some white dude but more than you I love youtube - When I wake up in the morning youtube when I dream at night, - youtube in the middle of the day, youtube you consume my - life, youtube youtube, you can comment all over me youtube, - will you make passionate love to me you can respond to my - video if you'd like I'll post one right back, oh I think I - might could you add me to your favorites and I'll post on - your bulletin maybe send you a message if you promise to - write me back I'll log in and out to please you oh you know - the things I'll do oh youtube, oh youtube When I wake up in - the morning youtube when I dream at night, youtube in the - middle of the day, youtube you consume my life, - youtube</media:description> - <media:keywords>You, Tube, (A, Love, Song), Original, Song, - Acoustic, Version</media:keywords> - <yt:duration seconds='177' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/FWPzxVMQU8g' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='177' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=FWPzxVMQU8g' /> - <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/2.jpg' - height='97' width='130' time='00:01:28.500' /> - <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/1.jpg' - height='97' width='130' time='00:00:44.250' /> - <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/3.jpg' - height='97' width='130' time='00:02:12.750' /> - <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/0.jpg' - height='240' width='320' time='00:01:28.500' /> - </media:group> - <yt:statistics viewCount='1495035' /> - <gd:rating min='1' max='5' numRaters='10995' average='4.64' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g/comments' /> - </gd:comments> - </entry> - <entry> - <id>http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo</id> - <published>2007-07-13T06:28:11.000Z</published> - <updated>2007-07-13T06:28:11.000Z</updated> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='kingston' /> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='beautiful' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='acoustic' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='cover' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='sean' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='girls' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='suicidal' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='davidchoimusic' /> - <title type='text'>"Beautiful Girls" - Sean Kingston - Acoustic - Cover</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=uWVuAl_aFRo"><img - alt="" - src="http://img.youtube.com/vi/uWVuAl_aFRo/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=uWVuAl_aFRo">&quot;Beautiful - Girls&quot; - Sean Kingston - Acoustic Cover</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Click Link to Subscribe! - http://www.youtube.com/subscription_center?add_user=davidchoimusic - http://www.myspace.com/davidchoimusic I really like this song - so I covered it. I will not smile for you - :)</span></div></td> <td style="font-size: - 11px; line-height: 1.4em; padding-left: 20px; padding-top: - 1px;" width="146" valign="top"><div><span - style="color: #666666; font-size: 11px;">From:</span> - <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 124571</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">1201 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">04:23</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=uWVuAl_aFRo' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo/related' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>"Beautiful Girls" - Sean Kingston - - Acoustic Cover</media:title> - <media:description type='plain'>Click Link to Subscribe! - http://www.youtube.com/subscription_center?add_user=davidchoimusic - http://www.myspace.com/davidchoimusic I really like this song - so I covered it. I will not smile for you - :)</media:description> - <media:keywords>davidchoimusic, beautiful, girls, sean, - kingston, acoustic, cover, video, suicidal</media:keywords> - <yt:duration seconds='263' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/uWVuAl_aFRo' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='263' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=uWVuAl_aFRo' /> - <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/2.jpg' - height='97' width='130' time='00:02:11.500' /> - <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/1.jpg' - height='97' width='130' time='00:01:05.750' /> - <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/3.jpg' - height='97' width='130' time='00:03:17.250' /> - <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/0.jpg' - height='240' width='320' time='00:02:11.500' /> - </media:group> - <yt:statistics viewCount='124571' /> - <gd:rating min='1' max='5' numRaters='1201' average='4.71' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo/comments' /> - </gd:comments> - </entry> - <entry> - <id>http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo</id> - <published>2007-02-15T20:40:24.000Z</published> - <updated>2007-02-15T20:40:24.000Z</updated> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Chords' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Girl' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Vlog' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='That' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Guitar' /> - <title type='text'>Vlog - "That Girl" - Guitar Chords</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=_PCgDBIgPbo"><img - alt="" - src="http://img.youtube.com/vi/_PCgDBIgPbo/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=_PCgDBIgPbo">Vlog - - &quot;That Girl&quot; - Guitar Chords</a> - <br></div> <div style="font-size: 12px; margin: - 3px 0px;"><span>Vlog - &quot;That Girl&quot; - - Guitar Chords Finally here! Enjoy! - http://www.myspace.com/davidchoimusic - http://www.broadjam.com/davidchoi</span></div></td> - <td style="font-size: 11px; line-height: 1.4em; - padding-left: 20px; padding-top: 1px;" width="146" - valign="top"><div><span style="color: #666666; - font-size: 11px;">From:</span> <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 76681</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">384 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">05:38</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=_PCgDBIgPbo' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo/related' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>Vlog - "That Girl" - Guitar - Chords</media:title> - <media:description type='plain'>Vlog - "That Girl" - Guitar - Chords Finally here! Enjoy! - http://www.myspace.com/davidchoimusic - http://www.broadjam.com/davidchoi</media:description> - <media:keywords>Vlog, That, Girl, Guitar, - Chords</media:keywords> - <yt:duration seconds='338' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/_PCgDBIgPbo' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='338' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=_PCgDBIgPbo' /> - <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/2.jpg' - height='97' width='130' time='00:02:49' /> - <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/1.jpg' - height='97' width='130' time='00:01:24.500' /> - <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/3.jpg' - height='97' width='130' time='00:04:13.500' /> - <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/0.jpg' - height='240' width='320' time='00:02:49' /> - </media:group> - <yt:statistics viewCount='76681' /> - <gd:rating min='1' max='5' numRaters='384' average='4.79' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo/comments' /> - </gd:comments> - </entry> - <entry> - <id>http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng</id> - <published>2007-08-12T00:59:18.000Z</published> - <updated>2007-08-12T00:59:18.000Z</updated> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Choi' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='David' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Making' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='with' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='to' /> - <category scheme='http://schemas.google.com/g/2005#kind' - term='http://gdata.youtube.com/schemas/2007#video' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='how' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='Beat' /> - <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' - term='Music' label='Music' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='tools' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='pro' /> - <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' - term='davidchoimusic' /> - <title type='text'>Beat Making with David Choi</title> - <content type='html'><div style="color: #000000;font-family: - Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; - width: 555px;"><table cellspacing="0" cellpadding="0" - border="0"><tbody><tr><td width="140" - valign="top" rowspan="2"><div style="border: 1px solid - #999999; margin: 0px 10px 5px 0px;"><a - href="http://www.youtube.com/watch?v=DdGyPZ0v7Ng"><img - alt="" - src="http://img.youtube.com/vi/DdGyPZ0v7Ng/2.jpg"></a></div></td> - <td width="256" valign="top"><div style="font-size: - 12px; font-weight: bold;"><a style="font-size: 15px; - font-weight: bold; font-decoration: none;" - href="http://www.youtube.com/watch?v=DdGyPZ0v7Ng">Beat - Making with David Choi</a> <br></div> <div - style="font-size: 12px; margin: 3px 0px;"><span>Click - Link to Subscribe! - http://www.youtube.com/subscription_center?add_user=davidchoimusic - http://www.myspace.com/davidchoimusic Just a quick little beat - I made to show you guys the general idea behind beat making. - And yes, the skin is real - :)</span></div></td> <td style="font-size: - 11px; line-height: 1.4em; padding-left: 20px; padding-top: - 1px;" width="146" valign="top"><div><span - style="color: #666666; font-size: 11px;">From:</span> - <a - href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> - <div><span style="color: #666666; font-size: - 11px;">Views:</span> 22559</div> <div - style="white-space: nowrap;text-align: left"><img - style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> - <img style="border: 0px none; margin: 0px; padding: 0px; - vertical-align: middle; font-size: 11px;" align="top" alt="" - src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> - <div style="font-size: 11px;">371 <span style="color: - #666666; font-size: - 11px;">ratings</span></div></td></tr> - <tr><td><span style="color: #666666; font-size: - 11px;">Time:</span> <span style="color: #000000; - font-size: 11px; font-weight: - bold;">09:51</span></td> <td - style="font-size: 11px; padding-left: 20px;"><span - style="color: #666666; font-size: 11px;">More - in</span> <a - href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div></content> - <link rel='self' type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng' /> - <link rel='alternate' type='text/html' - href='http://www.youtube.com/watch?v=DdGyPZ0v7Ng' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.responses' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng/responses' /> - <link rel='http://gdata.youtube.com/schemas/2007#video.related' - type='application/atom+xml' - href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng/related' /> - <author> - <name>davidchoimusic</name> - <uri> - http://gdata.youtube.com/feeds/users/davidchoimusic</uri> - </author> - <media:group> - <media:title type='plain'>Beat Making with David - Choi</media:title> - <media:description type='plain'>Click Link to Subscribe! - http://www.youtube.com/subscription_center?add_user=davidchoimusic - http://www.myspace.com/davidchoimusic Just a quick little - beat I made to show you guys the general idea behind beat - making. And yes, the skin is real :)</media:description> - <media:keywords>how, to, Beat, Making, with, David, Choi, - davidchoimusic, pro, tools</media:keywords> - <yt:duration seconds='591' /> - <media:category label='Music' - scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> - Music</media:category> - <media:content url='http://www.youtube.com/v/DdGyPZ0v7Ng' - type='application/x-shockwave-flash' medium='video' - isDefault='true' expression='full' duration='591' - yt:format='5' /> - <media:player url='http://www.youtube.com/watch?v=DdGyPZ0v7Ng' /> - <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/2.jpg' - height='97' width='130' time='00:04:55.500' /> - <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/1.jpg' - height='97' width='130' time='00:02:27.750' /> - <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/3.jpg' - height='97' width='130' time='00:07:23.250' /> - <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/0.jpg' - height='240' width='320' time='00:04:55.500' /> - </media:group> - <yt:statistics viewCount='22559' /> - <gd:rating min='1' max='5' numRaters='371' average='4.74' /> - <gd:comments> - <gd:feedLink href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng/comments' /> - </gd:comments> - </entry> -</feed> diff --git a/tests/Zend/Gdata/YouTubeOnlineTest.php b/tests/Zend/Gdata/YouTubeOnlineTest.php deleted file mode 100644 index c74d7254675c78ebcde6e23dd803c526b4e197f7..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTubeOnlineTest.php +++ /dev/null @@ -1,183 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Gdata/YouTube.php'; -require_once 'Zend/Gdata/YouTube/VideoQuery.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_YouTubeOnlineTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->ytAccount = constant('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT'); - $this->gdata = new Zend_Gdata_YouTube(); - } - - public function tearDown() - { - } - - public function testRetrieveSubScriptionFeed() - { - $feed = $this->gdata->getSubscriptionFeed($this->ytAccount); - $this->assertTrue($feed->totalResults->text > 0); - $this->assertEquals('Subscriptions of zfgdata', $feed->title->text); - $this->assertTrue(count($feed->entry) > 0); - foreach ($feed->entry as $entry) { - $this->assertTrue($entry->title->text != ''); - } - } - - public function testRetrieveContactFeed() - { - $feed = $this->gdata->getContactFeed($this->ytAccount); - $this->assertTrue($feed->totalResults->text > 0); - $this->assertEquals('Contacts of zfgdata', $feed->title->text); - $this->assertTrue(count($feed->entry) > 0); - foreach ($feed->entry as $entry) { - $this->assertTrue($entry->title->text != ''); - } - $this->assertEquals('ytgdatatest1', $feed->entry[0]->username->text); - } - - public function testRetrieveUserVideos() - { - $feed = $this->gdata->getUserUploads($this->ytAccount); - $this->assertEquals('Videos of zfgdata', $feed->title->text); - $this->assertTrue(count($feed->entry) === 1); - } - - public function testRetrieveVideoFeed() - { - $feed = $this->gdata->getVideoFeed(); - - $query = new Zend_Gdata_YouTube_VideoQuery(); - $query->setVideoQuery('puppy'); - $feed = $this->gdata->getVideoFeed($query); - foreach ($feed as $videoEntry) { - $videoResponsesLink = $videoEntry->getVideoResponsesLink(); - $videoRatingsLink = $videoEntry->getVideoRatingsLink(); - $videoComplaintsLink = $videoEntry->getVideoComplaintsLink(); - } - - $feed = $this->gdata->getVideoFeed($query->getQueryUrl()); - } - - public function testRetrieveVideoEntry() - { - $entry = $this->gdata->getVideoEntry('66wj2g5yz0M'); - $this->assertEquals('TestMovie', $entry->title->text); - - $entry = $this->gdata->getVideoEntry(null, 'http://gdata.youtube.com/feeds/videos/66wj2g5yz0M'); - $this->assertEquals('TestMovie', $entry->title->text); - } - - public function testRetrieveOtherFeeds() - { - $feed = $this->gdata->getRelatedVideoFeed('66wj2g5yz0M'); - $feed = $this->gdata->getVideoResponseFeed('66wj2g5yz0M'); - $feed = $this->gdata->getVideoCommentFeed('66wj2g5yz0M'); - $feed = $this->gdata->getWatchOnMobileVideoFeed(); - $feed = $this->gdata->getUserFavorites('zfgdata'); - } - - public function testRetrieveUserProfile() - { - $entry = $this->gdata->getUserProfile($this->ytAccount); - $this->assertEquals('zfgdata Channel', $entry->title->text); - $this->assertEquals('zfgdata', $entry->username->text); - $this->assertEquals('I\'m a lonely test account, with little to do but sit around and wait for people to use me. I get bored in between releases and often sleep to pass the time. Please use me more often, as I love to show off my talent in breaking your code.', - $entry->description->text); - $this->assertEquals(32, $entry->age->text); - $this->assertEquals('crime and punishment, ps i love you, the stand', $entry->books->text); - $this->assertEquals('Google', $entry->company->text); - $this->assertEquals('software engineering, information architecture, photography, travel', $entry->hobbies->text); - $this->assertEquals('Mountain View, CA', $entry->hometown->text); - $this->assertEquals('San Francisco, CA, US', $entry->location->text); - $this->assertEquals('monk, heroes, law and order, top gun', $entry->movies->text); - $this->assertEquals('imogen heap, frou frou, thievory corp, morcheeba, barenaked ladies', $entry->music->text); - $this->assertEquals('Developer Programs', $entry->occupation->text); - $this->assertEquals('University of the World', $entry->school->text); - $this->assertEquals('f', $entry->gender->text); - $this->assertEquals('taken', $entry->relationship->text); - } - - public function testRetrievePlaylistList() - { - $feed = $this->gdata->getPlaylistListFeed($this->ytAccount); - $this->assertTrue($feed->totalResults->text > 0); - $this->assertEquals('Playlists of zfgdata', $feed->title->text); - $this->assertTrue(count($feed->entry) > 0); - foreach ($feed->entry as $entry) { - $this->assertTrue($entry->title->text != ''); - } - $this->assertEquals('test playlist', $feed->entry[0]->description->text); - } - - public function testRetrievePlaylistVideoFeed() - { - $listFeed = $this->gdata->getPlaylistListFeed($this->ytAccount); - - $feed = $this->gdata->getPlaylistVideoFeed($listFeed->entry[0]->feedLink[0]->href); - $this->assertTrue($feed->totalResults->text > 0); - $this->assertEquals('test playlist', $feed->title->text); - $this->assertTrue(count($feed->entry) > 0); - foreach ($feed->entry as $entry) { - $this->assertTrue($entry->title->text != ''); - } - } - - public function testRetrieveTopRatedVideos() - { - $feed = $this->gdata->getTopRatedVideoFeed(); - $this->assertTrue($feed->totalResults->text > 10); - $this->assertEquals('Top Rated', $feed->title->text); - $this->assertTrue(count($feed->entry) > 0); - foreach ($feed->entry as $entry) { - $this->assertTrue($entry->rating->average > 3); - $this->assertEquals(1, $entry->rating->min); - $this->assertEquals(5, $entry->rating->max); - $this->assertTrue($entry->rating->numRaters > 2); - } - } - - public function testRetrieveMostViewedVideos() - { - $feed = $this->gdata->getMostViewedVideoFeed(); - $this->assertTrue($feed->totalResults->text > 10); - $this->assertEquals('Most Viewed', $feed->title->text); - $this->assertTrue(count($feed->entry) > 0); - foreach ($feed->entry as $entry) { - if ($entry->rating) { - $this->assertEquals(1, $entry->rating->min); - $this->assertEquals(5, $entry->rating->max); - } - } - } - -} diff --git a/tests/Zend/Gdata/YouTubeTest.php b/tests/Zend/Gdata/YouTubeTest.php deleted file mode 100644 index 7d13178f5aadeccf44250e89f20ef693a96ab580..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/YouTubeTest.php +++ /dev/null @@ -1,67 +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_Gdata - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once 'TestHelper.php'; -require_once 'Zend/Gdata/YouTube.php'; -require_once 'Zend/Http/Client.php'; - -/** - * @package Zend_Gdata - * @subpackage UnitTests - */ -class Zend_Gdata_YouTubeTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - // These tests shouldn't be doing anything online, so we can use - // bogus authentication credentials. - $this->gdata = new Zend_Gdata_YouTube(null); - $this->responseText = file_get_contents( - 'Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml', - true); - } - - public function testGetFormUploadTokenResponseHandler() - { - $responseArray = Zend_Gdata_YouTube::parseFormUploadTokenResponse($this->responseText); - $this->assertEquals('http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbF1_JjEQ9cGTjEAd5FKwV42SeNWJexmc5y7XR-eFj24uqbqU6NRcxKJW_4R-sYISLxQ', - $responseArray['url']); - $this->assertEquals('AIwbFAQ21fImpR2iYPaFnfuCvfbCB3qBxl5qXiZlpH3lfkungiSPoyw1iOM1gFB6Nx-wmY-kjprNT3qtdp7LJCLfngn11Ne_X9Jd44Vz8AzygtEtaDGyib5tnri0O0-V5pwcAPCHIJurOMsOpA2zInW8V8qHk2S2LheXfTXVbqc0Li9iCBpsoBGbykYU0moNoyGAaKRbSBD0oPnCv6v9Rll5Zjvivi2hQt-Br2JDb9wVeLv3qyAFaeyN6X6k32RyaAHs_n8d8d_oSriQmvS8g1HxSCS4dnoGL7tafQ4SBqnrQEb-hxFeu1ZrAwCLv', - $responseArray['token']); - } - - public function testSetClientIDAndDeveloperKeyHeader() - { - $applicationId = 'MyTestCompany-MyTestApp-0.1'; - $clientId = 'MyClientId'; - $developerKey = 'MyDeveloperKey'; - $httpClient = new Zend_Http_Client(); - $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey); - - $this->assertTrue($yt instanceOf Zend_Gdata_YouTube); - $client = $yt->getHttpClient(); - - $this->assertEquals($client->getHeader('X-Gdata-Key'), 'key='. $developerKey); - $this->assertEquals($client->getHeader('X-Gdata-Client'), $clientId); - } -} diff --git a/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml b/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml deleted file mode 100644 index 3ffc5e50761cfecabcd6d262826e35fb29916771..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<attendeeStatus xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.invited"/> diff --git a/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml b/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml deleted file mode 100644 index 547f1eeaaaf30905537b70931b718bc1d08c8dc3..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<attendeeType xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.required"/> diff --git a/tests/Zend/Gdata/_files/CommentsElementSample1.xml b/tests/Zend/Gdata/_files/CommentsElementSample1.xml deleted file mode 100644 index 67ffd1d5e9092529413465c76690ab00e8ad5760..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/CommentsElementSample1.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<comments xmlns="http://schemas.google.com/g/2005" rel="http://schemas.google.com/g/2005#reviews"> - <feedLink href="http://example.com/restaurants/SanFrancisco/432432/reviews"> - </feedLink> -</comments> diff --git a/tests/Zend/Gdata/_files/DocsTest.csv b/tests/Zend/Gdata/_files/DocsTest.csv deleted file mode 100755 index d83012da7266a362a4d95c536fd20b54b0f88384..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/DocsTest.csv +++ /dev/null @@ -1,4 +0,0 @@ -name,favoriteColor -fred,blue -john,red -doug,green diff --git a/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml b/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml deleted file mode 100644 index d5ba1384f4097c346e109872cc58d36c474caa1f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<gd:entryLink xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" href="http://gmail.com/jo/contacts/Jo" readOnly="true" rel="via"> - <entry> - <category scheme="http://schemas.google.com/g/2005#kind" - term="http://schemas.google.com/g/2005#contact"/> - <id>http://gmail.com/jo/contacts/Jo</id> - <category term="user-tag" label="Google"/> - <title>Jo March</title> - </entry> -</gd:entryLink> diff --git a/tests/Zend/Gdata/_files/EventStatusElementSample1.xml b/tests/Zend/Gdata/_files/EventStatusElementSample1.xml deleted file mode 100644 index e59159543695fdf0552fee4c80ccb20ebdc808d4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/EventStatusElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<eventStatus xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.confirmed"/> diff --git a/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml b/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml deleted file mode 100644 index 3acb8210a2848cb0efe99aff690f56348b45d8f2..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<extendedProperty xmlns="http://schemas.google.com/g/2005" name="http://www.example.com/schemas/2007#mycal.id" - value="1234" /> \ No newline at end of file diff --git a/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml b/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml deleted file mode 100644 index d56687ad687ff67215bde7e1ab2a0114fd9c7d9c..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<gd:feedLink xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" href="http://www.google.com/calendar/feeds/default/private/full/3tsi3ag1q40bnsik88k25sgpss/comments" countHint="0" readOnly="true" rel="http://schemas.google.com/g/2005#feed"> - <feed> - <updated>2007-06-19T00:48:41.230Z</updated> - <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> - <title type="text">Comments for: Sample Event</title> - <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/3tsi3ag1q40bnsik88k25sgpss/comments" title="alternate"/> - </feed> -</gd:feedLink> diff --git a/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml b/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml deleted file mode 100644 index 6c7aa60171af76a1720bba3e1955b25b7104d202..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<itemsPerPage xmlns="http://a9.com/-/spec/opensearchrss/1.0/">25</itemsPerPage> diff --git a/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml b/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml deleted file mode 100644 index 4fd667380acc33fde57dcb1d46924736c418d5f4..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<startIndex xmlns="http://a9.com/-/spec/opensearchrss/1.0/">5</startIndex> diff --git a/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml b/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml deleted file mode 100644 index b3f0a0c25169c5f50422cfdd3131ed3b9f97ed45..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<totalResults xmlns="http://a9.com/-/spec/opensearchrss/1.0/">12</totalResults> diff --git a/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml b/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml deleted file mode 100644 index 7955fd513f5cb2dcadf5f9fa8fe7ad21050a5a7d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<originalEvent xmlns="http://schemas.google.com/g/2005" id="i8fl1nrv2bl57c1qgr3f0onmgg" href="http://www.google.com/calendar/feeds/userID/private/full/123456789"> - <when startTime="2006-03-17T22:00:00.000Z"/> -</originalEvent> diff --git a/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml b/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml deleted file mode 100644 index d252ec79873bd25e6fdf638ebb38cb6336a1d3db..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<recurrence xmlns="http://schemas.google.com/g/2005"> -DTSTART;VALUE=DATE:20070501 -DTEND;VALUE=DATE:20070502 -RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904 -</recurrence> diff --git a/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml b/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml deleted file mode 100644 index 768993c10548310c3ab0b58b0f3852685ab12003..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<recurrenceException xmlns="http://schemas.google.com/g/2005" specialized="true"> - <entryLink href="http://www.google.com/calendar/feeds/default/private/full/hj4geu9lpkh3ebk6rvm4k8mhik"> - </entryLink> - <originalEvent id="hj4geu9lpkh3ebk6rvm4k8mhik" href="http://www.google.com/calendar/feeds/default/private/composite/hj4geu9lpkh3ebk6rvm4k8mhik" /> -</recurrenceException> diff --git a/tests/Zend/Gdata/_files/ReminderElementSample1.xml b/tests/Zend/Gdata/_files/ReminderElementSample1.xml deleted file mode 100644 index aaa4961b83f33efc4c40af3a89bdd22d1b01221f..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/ReminderElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<reminder xmlns="http://schemas.google.com/g/2005" absoluteTime="2005-06-06T16:55:00-08:00" days="42" hours="20" minutes="50" method="sms"/> diff --git a/tests/Zend/Gdata/_files/RsaCert.pem b/tests/Zend/Gdata/_files/RsaCert.pem deleted file mode 100644 index 445542cb33a6e44763ee38a3bc2359b2b63d4355..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/RsaCert.pem +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICxTCCAi6gAwIBAgIJALIWLob1fh/YMA0GCSqGSIb3DQEBBQUAMEwxCzAJBgNV -BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEYMBYG -A1UEAxMPd3d3LmV4YW1wbGUuY29tMB4XDTA4MDYyOTIwMDEyMVoXDTA5MDYyOTIw -MDEyMVowTDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3Vu -dGFpbiBWaWV3MRgwFgYDVQQDEw93d3cuZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcN -AQEBBQADgY0AMIGJAoGBAN8jNUSm/KkypB2sTIRIob/GPVJAeDUSFOQ+HOT0sruM -lf0RzY8wLBQdVshLfq1PsdE49jPavnOR9+CBI4f1LUC24XUcDQ0W1MTltdOrx1Rr -FWQHrNE6R19N2eYLC0o0VBJhp4o6VERr8MhKiQT4GqtZjJpycF/G0M5ysDZCvaA9 -AgMBAAGjga4wgaswHQYDVR0OBBYEFH3/umQGqQAzS6zm8Vi29FKuk9K/MHwGA1Ud -IwR1MHOAFH3/umQGqQAzS6zm8Vi29FKuk9K/oVCkTjBMMQswCQYDVQQGEwJVUzEL -MAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxGDAWBgNVBAMTD3d3 -dy5leGFtcGxlLmNvbYIJALIWLob1fh/YMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN -AQEFBQADgYEAwBPAqlfAM0prZ7GNfVkFjxZv5/HALtcd54CYIiSk0FHFMmRrQbDr -DgaMcB4TVVF9ldVoRqvP4MpB4/SzYlEHMctjrJwbdVLZl7zACuTElsl4yr+Dzv6h -zVj1cIz9+lzwPZ8e0HJRRWmdEe+zoCed5iUigtEViMUvhszLzLcGmEc= ------END CERTIFICATE----- diff --git a/tests/Zend/Gdata/_files/RsaKey.pem b/tests/Zend/Gdata/_files/RsaKey.pem deleted file mode 100644 index b2deeca62d76a31b2a3eeaa352080ee00d48426d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/RsaKey.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXwIBAAKBgQDfIzVEpvypMqQdrEyESKG/xj1SQHg1EhTkPhzk9LK7jJX9Ec2P -MCwUHVbIS36tT7HROPYz2r5zkffggSOH9S1AtuF1HA0NFtTE5bXTq8dUaxVkB6zR -OkdfTdnmCwtKNFQSYaeKOlREa/DISokE+BqrWYyacnBfxtDOcrA2Qr2gPQIDAQAB -AoGBAMetwyJvaJSk67ZeFI8gTBbIeOGdLbUYPDfP2Z2N2E/7S9GO1+u2CQvrAVj2 -LiM7uP1owvG+Y0Yarr5p8fjdj6K4FBFZIsv7ugm9+lhwHMQXBMT8RdnPUtAupzRT -YuNlJgBluFyV2C6JZakmHKbn+RJxTnBAiWAMe+8zXQTNlhXBAkEA/0yk2o6q4yTR -hMg9REHyA8mNlZYgFm41tJmNIoshK+xWEyx+mvKEt3VHdkz0kDqzZo5XR/PoqH8P -FTsVntGyTQJBAN+/+Ckiw5XCBkeJMVmuynSP+PXXViczzBZiTJQeMf+ja+uL9XXH -cf2Y1Hg+0YGdr+NzGb3EKxH+CzLaaz3ZPbECQQDmFXUdZCauv6f0O2K7+ZLbxvJL -NhmFHZ5ZPWntD+a9ZynL7fXMP3VMwe29uG1Q7xZv/yi6OCAeeyRkxfMeR26hAkEA -y80hjuZ5W/kkmxgdeWC6S72vuM1xTbfiVykmM2vlgsIp1Jzg8Wy/KYyBSx182yD0 -SqpWcgEycesB7EoCkI1FoQJBALU/zXYUn0Jmh/qKruPo+7PwyQqgiO+muWoYxVC2 -vYdtqvvIAKUhERjA8vkbPdqp4zzjjzs6hjTeOmGqmmrFhxk= ------END RSA PRIVATE KEY----- diff --git a/tests/Zend/Gdata/_files/TransparencyElementSample1.xml b/tests/Zend/Gdata/_files/TransparencyElementSample1.xml deleted file mode 100644 index fe9028df9c623da07a6cc2e46de83766fd2693b9..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/TransparencyElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<transparency xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.transparent"/> diff --git a/tests/Zend/Gdata/_files/VisibilityElementSample1.xml b/tests/Zend/Gdata/_files/VisibilityElementSample1.xml deleted file mode 100644 index 5c9c4b836b391e7b5cb1bd66b267bcbc48082d7e..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/VisibilityElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<visibility xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.confidential"/> diff --git a/tests/Zend/Gdata/_files/WhenElementSample1.xml b/tests/Zend/Gdata/_files/WhenElementSample1.xml deleted file mode 100644 index 2ecf824de1ffcf8d1940a15230ae2761680e9f21..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/WhenElementSample1.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<when xmlns="http://schemas.google.com/g/2005" startTime="2005-06-06T17:00:00-08:00" endTime="2005-06-06T18:00:00-08:00" valueString="Tomorrow @ 5 PM"/> diff --git a/tests/Zend/Gdata/_files/WhereElementSample1.xml b/tests/Zend/Gdata/_files/WhereElementSample1.xml deleted file mode 100644 index 1b01f15b5d18fce5d8712e11d65e3e8e9b451969..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/WhereElementSample1.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<where xmlns="http://schemas.google.com/g/2005" rel="http://schemas.google.com/g/2005#event" valueString="Joe's Pub" label="1234 Anywhere Ln., New York, NY"> - <entryLink href="http://local.example.com/10018/JoesPub"> - </entryLink> -</where> diff --git a/tests/Zend/Gdata/_files/WhoElementSample1.xml b/tests/Zend/Gdata/_files/WhoElementSample1.xml deleted file mode 100644 index 8df48804b404f68fdac69510d060ed803524643d..0000000000000000000000000000000000000000 --- a/tests/Zend/Gdata/_files/WhoElementSample1.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<who xmlns="http://schemas.google.com/g/2005" rel="http://schemas.google.com/g/2005#event.attendee" valueString="Jo" email="jo@nowhere.invalid"> - <attendeeType value="http://schemas.google.com/g/2005#event.required"/> - <attendeeStatus value="http://schemas.google.com/g/2005#event.tentative"/> - <entryLink href="http://gmail.com/jo/contacts/Jo"> - </entryLink> -</who> diff --git a/tests/Zend/Gdata/_files/testImage.jpg b/tests/Zend/Gdata/_files/testImage.jpg deleted file mode 100644 index b378f7a3931af368e3249ceeceb68b445dca065e..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Gdata/_files/testImage.jpg and /dev/null differ diff --git a/tests/Zend/Http/AllTests.php b/tests/Zend/Http/AllTests.php deleted file mode 100644 index 63ae4879b8f57258ff0377eaac82648589294cda..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/AllTests.php +++ /dev/null @@ -1,63 +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_Http - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Http_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Http/ResponseTest.php'; -require_once 'Zend/Http/CookieTest.php'; -require_once 'Zend/Http/CookieJarTest.php'; -require_once 'Zend/Http/Client/AllTests.php'; - -class Zend_Http_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend'); - - $suite->addTestSuite('Zend_Http_ResponseTest'); - $suite->addTestSuite('Zend_Http_CookieTest'); - $suite->addTestSuite('Zend_Http_CookieJarTest'); - $suite->addTest(Zend_Http_Client_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Http_AllTests::main') { - Zend_Http_AllTests::main(); -} diff --git a/tests/Zend/Http/Client/AllTests.php b/tests/Zend/Http/Client/AllTests.php deleted file mode 100644 index 75b053680125ef73b65e292cd68aa6ab1ce4a516..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/AllTests.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Http_Client_AllTests::main'); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -// Read local configuration -if (! defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - is_readable('TestConfiguration.php')) { - - require_once 'TestConfiguration.php'; -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Http/Client/StaticTest.php'; -require_once 'Zend/Http/Client/SocketTest.php'; -require_once 'Zend/Http/Client/SocketKeepaliveTest.php'; -require_once 'Zend/Http/Client/SocketPersistentTest.php'; -require_once 'Zend/Http/Client/TestAdapterTest.php'; -require_once 'Zend/Http/Client/ProxyAdapterTest.php'; -require_once 'Zend/Http/Client/SkipTests.php'; -//require_once 'Zend/Http/Client/CurlTest.php'; - -class Zend_Http_Client_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend'); - - $suite->addTestSuite('Zend_Http_Client_StaticTest'); - if (defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && Zend_Uri_Http::check(TESTS_ZEND_HTTP_CLIENT_BASEURI)) { - $suite->addTestSuite('Zend_Http_Client_SocketTest'); - $suite->addTestSuite('Zend_Http_Client_SocketKeepaliveTest'); - $suite->addTestSuite('Zend_Http_Client_SocketPersistentTest'); - } else { - $suite->addTestSuite('Zend_Http_Client_Skip_SocketTest'); - } - $suite->addTestSuite('Zend_Http_Client_TestAdapterTest'); - if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') && TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) { - $suite->addTestSuite('Zend_Http_Client_ProxyAdapterTest'); - } else { - $suite->addTestSuite('Zend_Http_Client_Skip_ProxyAdapterTest'); - } - //$suite->addTestSuite('Zend_Http_Client_CurlTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Http_Client_AllTests::main') { - Zend_Http_Client_AllTests::main(); -} diff --git a/tests/Zend/Http/Client/CurlTest.php b/tests/Zend/Http/Client/CurlTest.php deleted file mode 100644 index 4f17123bd3f4819022e25d64d26a46df5de2e63d..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/CurlTest.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -// Read local configuration -if (! defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - is_readable('TestConfiguration.php')) { - - require_once 'TestConfiguration.php'; -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'SocketTest.php'; - -/** - * This Testsuite includes all Zend_Http_Client that require a working web - * server to perform. It was designed to be extendable, so that several - * test suites could be run against several servers, with different client - * adapters and configurations. - * - * Note that $this->baseuri must point to a directory on a web server - * containing all the files under the _files directory. You should symlink - * or copy these files and set 'baseuri' properly. - * - * You can also set the proper constand in your test configuration file to - * point to the right place. - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: CurlTest.php 11915 2008-10-12 18:29:09Z alexander $ - * @copyright - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Client_CurlTest extends Zend_Http_Client_SocketTest -{ - /** - * Configuration array - * - * @var array - */ - protected $config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Curl' - ); -} diff --git a/tests/Zend/Http/Client/ProxyAdapterTest.php b/tests/Zend/Http/Client/ProxyAdapterTest.php deleted file mode 100644 index 7b0e017f1ddded8f874d115064ee86dbdb4be8ef..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/ProxyAdapterTest.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php - -// Read local configuration -if (! defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - is_readable('TestConfiguration.php')) { - - require_once 'TestConfiguration.php'; -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'SocketTest.php'; - -/** - * Zend_Http_Client_Adapter_Proxy test suite. - * - * In order to run, TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY must point to a working - * proxy server, which can access TESTS_ZEND_HTTP_CLIENT_BASEURI. - * - * See TestConfiguration.php.dist for more information. - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: ProxyAdapterTest.php 11915 2008-10-12 18:29:09Z alexander $ - * @copyright - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Client_ProxyAdapterTest extends Zend_Http_Client_SocketTest -{ - /** - * Configuration array - * - * @var array - */ - protected function setUp() - { - if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') && - TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) { - - list($host, $port) = split(':', TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY, 2); - - if (! $host) - $this->markTestSkipped("No valid proxy host name or address specified."); - - $port = (int) $port; - if ($port == 0) { - $port = 8080; - } else { - if (($port < 1 || $port > 65535)) - $this->markTestSkipped("$port is not a valid proxy port number. Should be between 1 and 65535."); - } - - $user = ''; - $pass = ''; - if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') && - TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER) - $user = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER; - - if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') && - TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS) - $pass = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS; - - - $this->config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Proxy', - 'proxy_host' => $host, - 'proxy_port' => $port, - 'proxy_user' => $user, - 'proxy_pass' => $pass, - ); - - parent::setUp(); - - } else { - $this->markTestSkipped("Zend_Http_Client proxy server tests are not enabled in TestConfiguration.php"); - } - } - - public function testGetLastRequest() - { - // Overriding, this one will not work and is not required for the - // proxy test - } -} diff --git a/tests/Zend/Http/Client/SkipTests.php b/tests/Zend/Http/Client/SkipTests.php deleted file mode 100644 index 0137f74bfe54550f6b3e6936d437dc86872a3a7e..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/SkipTests.php +++ /dev/null @@ -1,58 +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_Http_Client - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Http_Client - * @subpackage UnitTests - */ -class Zend_Http_Client_Skip_SocketTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped("Zend_Http_Client dynamic tests are not enabled in TestConfiguration.php"); - } - - public function testSocket() - { - // this is here only so we have at least one test - } -} - -class Zend_Http_Client_Skip_ProxyAdapterTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped("Zend_Http_Client proxy server tests are not enabled in TestConfiguration.php"); - } - - public function testProxyAdapter() - { - // this is here only so we have at least one test - } -} diff --git a/tests/Zend/Http/Client/SocketKeepaliveTest.php b/tests/Zend/Http/Client/SocketKeepaliveTest.php deleted file mode 100644 index 6fe897c25da931d2dee6bef627fc872458e33290..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/SocketKeepaliveTest.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -// Read local configuration -if (! defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - is_readable('TestConfiguration.php')) { - - require_once 'TestConfiguration.php'; -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'SocketTest.php'; - -/** - * This Testsuite includes all Zend_Http_Client that require a working web - * server to perform. It was designed to be extendable, so that several - * test suites could be run against several servers, with different client - * adapters and configurations. - * - * Note that $this->baseuri must point to a directory on a web server - * containing all the files under the _files directory. You should symlink - * or copy these files and set 'baseuri' properly. - * - * You can also set the proper constand in your test configuration file to - * point to the right place. - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: SocketKeepaliveTest.php 11915 2008-10-12 18:29:09Z alexander $ - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Client_SocketKeepaliveTest extends Zend_Http_Client_SocketTest -{ - /** - * Configuration array - * - * @var array - */ - protected $config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Socket', - 'keepalive' => true - ); -} diff --git a/tests/Zend/Http/Client/SocketPersistentTest.php b/tests/Zend/Http/Client/SocketPersistentTest.php deleted file mode 100644 index f5f6d5e878512cb8f0a9f884837fda5ca9a41e0f..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/SocketPersistentTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -// Read local configuration -if (! defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - is_readable('TestConfiguration.php')) { - - require_once 'TestConfiguration.php'; -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'SocketTest.php'; - -/** - * This Testsuite includes all Zend_Http_Client that require a working web - * server to perform. It was designed to be extendable, so that several - * test suites could be run against several servers, with different client - * adapters and configurations. - * - * Note that $this->baseuri must point to a directory on a web server - * containing all the files under the _files directory. You should symlink - * or copy these files and set 'baseuri' properly. - * - * You can also set the proper constand in your test configuration file to - * point to the right place. - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: SocketPersistentTest.php 11915 2008-10-12 18:29:09Z alexander $ - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Client_SocketPersistentTest extends Zend_Http_Client_SocketTest -{ - /** - * Configuration array - * - * @var array - */ - protected $config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Socket', - 'persistent' => true, - 'keepalive' => true - ); -} diff --git a/tests/Zend/Http/Client/SocketTest.php b/tests/Zend/Http/Client/SocketTest.php deleted file mode 100644 index 3bc29b7b62ae0fbed5a9f823c958280bfb71afc9..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/SocketTest.php +++ /dev/null @@ -1,793 +0,0 @@ -<?php - -// Read local configuration -if (! defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - is_readable('TestConfiguration.php')) { - - require_once 'TestConfiguration.php'; -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'Zend/Uri/Http.php'; - -/** - * This Testsuite includes all Zend_Http_Client that require a working web - * server to perform. It was designed to be extendable, so that several - * test suites could be run against several servers, with different client - * adapters and configurations. - * - * Note that $this->baseuri must point to a directory on a web server - * containing all the files under the _files directory. You should symlink - * or copy these files and set 'baseuri' properly. - * - * You can also set the proper constant in your test configuration file to - * point to the right place. - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: SocketTest.php 11915 2008-10-12 18:29:09Z alexander $ - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Client_SocketTest extends PHPUnit_Framework_TestCase -{ - /** - * The bast URI for this test, containing all files in the _files directory - * Should be set in TestConfiguration.php or TestConfiguration.php.dist - * - * @var string - */ - protected $baseuri; - - /** - * Common HTTP client - * - * @var Zend_Http_Client - */ - protected $client = null; - - /** - * Configuration array - * - * @var array - */ - protected $config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Socket' - ); - - /** - * Set up the test case - * - */ - protected function setUp() - { - if (defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') && - Zend_Uri_Http::check(TESTS_ZEND_HTTP_CLIENT_BASEURI)) { - - $this->baseuri = TESTS_ZEND_HTTP_CLIENT_BASEURI; - if (substr($this->baseuri, -1) != '/') $this->baseuri .= '/'; - $uri = $this->baseuri . $this->getName() . '.php'; - $this->client = new Zend_Http_Client($uri, $this->config); - - } else { - // Skip tests - $this->markTestSkipped("Zend_Http_Client dynamic tests are not enabled in TestConfiguration.php"); - } - } - - /** - * Simple request tests - */ - - /** - * Test simple requests - * - */ - public function testSimpleRequests() - { - $methods = array('GET', 'POST', 'OPTIONS', 'PUT', 'DELETE'); - - foreach ($methods as $method) { - $res = $this->client->request($method); - $this->assertEquals('Success', $res->getBody(), "HTTP {$method} request failed."); - } - } - - /** - * Test we can get the last request as string - * - */ - public function testGetLastRequest() - { - $this->client->setUri($this->baseuri . 'testHeaders.php'); - $this->client->setParameterGet('someinput', 'somevalue'); - $this->client->setHeaders(array( - 'X-Powered-By' => 'My Glorious Golden Ass', - )); - - $res = $this->client->request(Zend_Http_Client::TRACE); - - $this->assertEquals($this->client->getLastRequest(), $res->getBody(), 'Response body should be exactly like the last request'); - } - - /** - * Test the getLastResponse() method actually returns the last response - * - */ - public function testGetLastResponse() - { - // First, make sure we get null before the request - $this->assertEquals(null, $this->client->getLastResponse(), 'getLastResponse() is still expected to return null'); - - // Now, test we get a proper response after the request - $this->client->setUri($this->baseuri . 'testHeaders.php'); - $response = $this->client->request(); - - $this->assertTrue(($response === $this->client->getLastResponse()), 'Response is expected to be identical to the result of getLastResponse()'); - } - - /** - * Test that getLastResponse returns null when not storing - * - */ - public function testGetLastResponseWhenNotStoring() - { - $this->client->setUri($this->baseuri . 'testHeaders.php'); - $this->client->setConfig(array('storeresponse' => false)); - $response = $this->client->request(); - - $this->assertEquals(null, $this->client->getLastResponse(), 'getLastResponse is expected to be null when not storing'); - } - - /** - * GET and POST parameters tests - */ - - /** - * Test we can properly send GET parameters - * - */ - public function testGetData() - { - $params = array( - 'quest' => 'To seek the holy grail', - 'YourMother' => 'Was a hamster', - 'specialChars' => '<>$+ &?=[]^%', - 'array' => array('firstItem', 'secondItem', '3rdItem') - ); - - $this->client->setUri($this->client->getUri(true) . '?name=Arthur'); - - $this->client->setParameterGet($params); - $res = $this->client->request('GET'); - $this->assertEquals(serialize(array_merge(array('name' => 'Arthur'), $params)), $res->getBody()); - } - - /** - * Test that setting the same parameter twice in the query string does not - * get reduced to a single value only. - * - */ - public function testDoubleGetParameter() - { - $qstr = 'foo=bar&foo=baz'; - $this->client->setUri($this->baseuri . 'testGetData.php?' . $qstr); - $res = $this->client->request('GET'); - $this->assertContains($qstr, $this->client->getLastRequest(), 'Request is expected to contain the entire query string'); - } - - /** - * Test we can properly send POST parameters with - * application/x-www-form-urlencoded content type - * - */ - public function testPostDataUrlEncoded() - { - $this->client->setUri($this->baseuri . 'testPostData.php'); - $params = array( - 'quest' => 'To seek the holy grail', - 'YourMother' => 'Was a hamster', - 'specialChars' => '<>$+ &?=[]^%', - 'array' => array('firstItem', 'secondItem', '3rdItem') - ); - - $this->client->setEncType(Zend_Http_Client::ENC_URLENCODED); - $this->client->setParameterPost($params); - $res = $this->client->request('POST'); - $this->assertEquals(serialize($params), $res->getBody(), "POST data integrity test failed"); - } - - /** - * Test we can properly send POST parameters with - * multipart/form-data content type - * - */ - public function testPostDataMultipart() - { - $this->client->setUri($this->baseuri . 'testPostData.php'); - $params = array( - 'quest' => 'To seek the holy grail', - 'YourMother' => 'Was a hamster', - 'specialChars' => '<>$+ &?=[]^%', - 'array' => array('firstItem', 'secondItem', '3rdItem') - ); - - $this->client->setEncType(Zend_Http_Client::ENC_FORMDATA); - $this->client->setParameterPost($params); - $res = $this->client->request('POST'); - $this->assertEquals(serialize($params), $res->getBody(), "POST data integrity test failed"); - } - - /** - * Test using raw HTTP POST data - * - */ - public function testRawPostData() - { - $data = "Chuck Norris never wet his bed as a child. The bed wet itself out of fear."; - - $res = $this->client->setRawData($data, 'text/html')->request('POST'); - $this->assertEquals($data, $res->getBody(), 'Response body does not contain the expected data'); - } - - /** - * Make sure we can reset the parameters between consecutive requests - * - */ - public function testResetParameters() - { - $params = array( - 'quest' => 'To seek the holy grail', - 'YourMother' => 'Was a hamster', - 'specialChars' => '<>$+ &?=[]^%', - 'array' => array('firstItem', 'secondItem', '3rdItem') - ); - - $this->client->setParameterPost($params); - $this->client->setParameterGet($params); - - $res = $this->client->request('POST'); - - $this->assertContains(serialize($params) . "\n" . serialize($params), - $res->getBody(), "returned body does not contain all GET and POST parameters (it should!)"); - - $this->client->resetParameters(); - $res = $this->client->request('POST'); - - $this->assertNotContains(serialize($params), $res->getBody(), - "returned body contains GET or POST parameters (it shouldn't!)"); - } - - /** - * Test parameters get reset when we unset them - * - */ - public function testParameterUnset() - { - $this->client->setUri($this->baseuri . 'testResetParameters.php'); - - $gparams = array ( - 'cheese' => 'camambert', - 'beer' => 'jever pilnsen', - ); - - $pparams = array ( - 'from' => 'bob', - 'to' => 'alice' - ); - - $this->client->setParameterGet($gparams)->setParameterPost($pparams); - - // Remove some parameters - $this->client->setParameterGet('cheese', null)->setParameterPost('to', null); - $res = $this->client->request('POST'); - - $this->assertNotContains('cheese', $res->getBody(), 'The "cheese" GET parameter was expected to be unset'); - $this->assertNotContains('alice', $res->getBody(), 'The "to" POST parameter was expected to be unset'); - } - - /** - * Header Tests - */ - - /** - * Make sure we can set a single header - * - */ - public function testHeadersSingle() - { - $this->client->setUri($this->baseuri . 'testHeaders.php'); - - $headers = array( - 'Accept-encoding' => 'gzip,deflate', - 'X-baz' => 'Foo', - 'X-powered-by' => 'A large wooden badger' - ); - - foreach ($headers as $key => $val) { - $this->client->setHeaders($key, $val); - } - - $acceptHeader = "Accept: text/xml,text/html,*/*"; - $this->client->setHeaders($acceptHeader); - - $res = $this->client->request('TRACE'); - $body = strtolower($res->getBody()); - - foreach ($headers as $key => $val) - $this->assertContains(strtolower("$key: $val"), $body); - - $this->assertContains(strtolower($acceptHeader), $body); - } - - /** - * Test we can set an array of headers - * - */ - public function testHeadersArray() - { - $this->client->setUri($this->baseuri . 'testHeaders.php'); - - $headers = array( - 'Accept-encoding' => 'gzip,deflate', - 'X-baz' => 'Foo', - 'X-powered-by' => 'A large wooden badger', - 'Accept: text/xml,text/html,*/*' - ); - - $this->client->setHeaders($headers); - - $res = $this->client->request('TRACE'); - $body = strtolower($res->getBody()); - - foreach ($headers as $key => $val) { - if (is_string($key)) { - $this->assertContains(strtolower("$key: $val"), $body); - } else { - $this->assertContains(strtolower($val), $body); - } - } - } - - /** - * Test we can set a set of values for one header - * - */ - public function testMultipleHeader() - { - $this->client->setUri($this->baseuri . 'testHeaders.php'); - $headers = array( - 'Accept-encoding' => 'gzip,deflate', - 'X-baz' => 'Foo', - 'X-powered-by' => array( - 'A large wooden badger', - 'My Shiny Metal Ass', - 'Dark Matter' - ), - 'Cookie' => array( - 'foo=bar', - 'baz=waka' - ) - ); - - $this->client->setHeaders($headers); - $res = $this->client->request('TRACE'); - $body = strtolower($res->getBody()); - - foreach ($headers as $key => $val) { - if (is_array($val)) - $val = implode(', ', $val); - - $this->assertContains(strtolower("$key: $val"), $body); - } - } - - /** - * Redirection tests - */ - - /** - * Test the client properly redirects in default mode - * - */ - public function testRedirectDefault() - { - $this->client->setUri($this->baseuri . 'testRedirections.php'); - - // Set some parameters - $this->client->setParameterGet('swallow', 'african'); - $this->client->setParameterPost('Camelot', 'A silly place'); - - // Request - $res = $this->client->request('POST'); - - $this->assertEquals(3, $this->client->getRedirectionsCount(), 'Redirection counter is not as expected'); - - // Make sure the body does *not* contain the set parameters - $this->assertNotContains('swallow', $res->getBody()); - $this->assertNotContains('Camelot', $res->getBody()); - } - - /** - * Make sure the client properly redirects in strict mode - * - */ - public function testRedirectStrict() - { - $this->client->setUri($this->baseuri . 'testRedirections.php'); - - // Set some parameters - $this->client->setParameterGet('swallow', 'african'); - $this->client->setParameterPost('Camelot', 'A silly place'); - - // Set strict redirections - $this->client->setConfig(array('strictredirects' => true)); - - // Request - $res = $this->client->request('POST'); - - $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()); - } - - /** - * Make sure redirections stop when limit is exceeded - * - */ - public function testMaxRedirectsExceeded() - { - $this->client->setUri($this->baseuri . 'testRedirections.php'); - - // Set some parameters - $this->client->setParameterGet('swallow', 'african'); - $this->client->setParameterPost('Camelot', 'A silly place'); - - // Set lower max redirections - // Try with strict redirections first - $this->client->setConfig(array('strictredirects' => true, 'maxredirects' => 2)); - - $res = $this->client->request('POST'); - $this->assertTrue($res->isRedirect(), - "Last response was not a redirection as expected. Response code: {$res->getStatus()}. Redirections counter: {$this->client->getRedirectionsCount()} (when strict redirects are on)"); - - // Then try with normal redirections - $this->client->setParameterGet('redirection', '0'); - $this->client->setConfig(array('strictredirects' => false)); - $res = $this->client->request('POST'); - $this->assertTrue($res->isRedirect(), - "Last response was not a redirection as expected. Response code: {$res->getStatus()}. Redirections counter: {$this->client->getRedirectionsCount()} (when strict redirects are off)"); - } - - /** - * Test we can properly redirect to an absolute path (not full URI) - * - */ - public function testAbsolutePathRedirect() - { - $this->client->setUri($this->baseuri . 'testRelativeRedirections.php'); - $this->client->setParameterGet('redirect', 'abpath'); - $this->client->setConfig(array('maxredirects' => 1)); - - // Get the host and port part of our baseuri - $uri = $this->client->getUri()->getScheme() . '://' . $this->client->getUri()->getHost() . ':' . - $this->client->getUri()->getPort(); - - $res = $this->client->request('GET'); - - $this->assertEquals("{$uri}/path/to/fake/file.ext?redirect=abpath", $this->client->getUri(true), - "The new location is not as expected: {$this->client->getUri(true)}"); - } - - /** - * Test we can properly redirect to a relative path - * - */ - public function testRelativePathRedirect() - { - $this->client->setUri($this->baseuri . 'testRelativeRedirections.php'); - $this->client->setParameterGet('redirect', 'relpath'); - $this->client->setConfig(array('maxredirects' => 1)); - - // Set the new expected URI - $uri = clone $this->client->getUri(); -// $uri->setPort(80); - $uri->setPath(dirname($uri->getPath()) . '/path/to/fake/file.ext'); - $uri = $uri->__toString(); - - $res = $this->client->request('GET'); - - $this->assertEquals("{$uri}?redirect=relpath", $this->client->getUri(true), - "The new location is not as expected: {$this->client->getUri(true)}"); - } - - /** - * HTTP Authentication Tests - * - */ - - /** - * Test we can properly use Basic HTTP authentication - * - */ - public function testHttpAuthBasic() - { - $this->client->setUri($this->baseuri. 'testHttpAuth.php'); - $this->client->setParameterGet(array( - 'user' => 'alice', - 'pass' => 'secret', - 'method' => 'Basic' - )); - - // First - fail password - $this->client->setAuth('alice', 'wrong'); - $res = $this->client->request(); - $this->assertEquals(401, $res->getStatus(), 'Expected HTTP 401 response was not recieved'); - - // Now use good password - $this->client->setAuth('alice', 'secret'); - $res = $this->client->request(); - $this->assertEquals(200, $res->getStatus(), 'Expected HTTP 200 response was not recieved'); - } - - /** - * Test we can unset HTTP authentication - * - */ - public function testCancelAuth() - { - $this->client->setUri($this->baseuri. 'testHttpAuth.php'); - - // Set auth and cancel it - $this->client->setAuth('alice', 'secret'); - $this->client->setAuth(false); - $res = $this->client->request(); - - $this->assertEquals(401, $res->getStatus(), 'Expected HTTP 401 response was not recieved'); - $this->assertNotContains('alice', $res->getBody(), "Body contains the user name, but it shouldn't"); - $this->assertNotContains('secret', $res->getBody(), "Body contains the password, but it shouldn't"); - } - - /** - * Cookie and CookieJar Tests - * - */ - - /** - * Test we can set string cookies with no jar - * - */ - public function testCookiesStringNoJar() - { - $this->client->setUri($this->baseuri. 'testCookies.php'); - - $cookies = array( - 'name' => 'value', - 'cookie' => 'crumble' - ); - - foreach ($cookies as $k => $v) { - $this->client->setCookie($k, $v); - } - - $res = $this->client->request(); - - $this->assertEquals($res->getBody(), serialize($cookies), 'Response body does not contain the expected cookies'); - } - - /** - * Make sure we can set object cookies with no jar - * - */ - public function testSetCookieObjectNoJar() - { - $this->client->setUri($this->baseuri. 'testCookies.php'); - $refuri = $this->client->getUri(); - - $cookies = array( - Zend_Http_Cookie::fromString('chocolate=chips', $refuri), - Zend_Http_Cookie::fromString('crumble=apple', $refuri) - ); - - $strcookies = array(); - foreach ($cookies as $c) { - $this->client->setCookie($c); - $strcookies[$c->getName()] = $c->getValue(); - } - - $res = $this->client->request(); - $this->assertEquals($res->getBody(), serialize($strcookies), 'Response body does not contain the expected cookies'); - } - - /** - * Make sure we can set an array of object cookies - * - */ - public function testSetCookieObjectArray() - { - $this->client->setUri($this->baseuri. 'testCookies.php'); - $refuri = $this->client->getUri(); - - $cookies = array( - Zend_Http_Cookie::fromString('chocolate=chips', $refuri), - Zend_Http_Cookie::fromString('crumble=apple', $refuri), - Zend_Http_Cookie::fromString('another=cookie', $refuri) - ); - - $this->client->setCookie($cookies); - - $strcookies = array(); - foreach ($cookies as $c) { - $strcookies[$c->getName()] = $c->getValue(); - } - - $res = $this->client->request(); - $this->assertEquals($res->getBody(), serialize($strcookies), 'Response body does not contain the expected cookies'); - } - - /** - * Make sure we can set an array of string cookies - * - */ - public function testSetCookieStringArray() - { - $this->client->setUri($this->baseuri. 'testCookies.php'); - - $cookies = array( - 'chocolate' => 'chips', - 'crumble' => 'apple', - 'another' => 'cookie' - ); - - $this->client->setCookie($cookies); - - $res = $this->client->request(); - $this->assertEquals($res->getBody(), serialize($cookies), 'Response body does not contain the expected cookies'); - } - - /** - * Make sure we can set cookie objects with a jar - * - */ - public function testSetCookieObjectJar() - { - $this->client->setUri($this->baseuri. 'testCookies.php'); - $this->client->setCookieJar(); - $refuri = $this->client->getUri(); - - $cookies = array( - Zend_Http_Cookie::fromString('chocolate=chips', $refuri), - Zend_Http_Cookie::fromString('crumble=apple', $refuri) - ); - - $strcookies = array(); - foreach ($cookies as $c) { - $this->client->setCookie($c); - $strcookies[$c->getName()] = $c->getValue(); - } - - $res = $this->client->request(); - $this->assertEquals($res->getBody(), serialize($strcookies), 'Response body does not contain the expected cookies'); - } - - /** - * File Upload Tests - * - */ - - /** - * Test we can upload raw data as a file - * - */ - public function testUploadRawData() - { - $this->client->setUri($this->baseuri. 'testUploads.php'); - - $rawdata = file_get_contents(__FILE__); - $this->client->setFileUpload('myfile.txt', 'uploadfile', $rawdata, 'text/plain'); - $res = $this->client->request('POST'); - - $body = 'uploadfile myfile.txt text/plain ' . strlen($rawdata) . "\n"; - $this->assertEquals($body, $res->getBody(), 'Response body does not include expected upload parameters'); - } - - /** - * Test we can upload an existing file - * - */ - public function testUploadLocalFile() - { - $this->client->setUri($this->baseuri. 'testUploads.php'); - $this->client->setFileUpload(__FILE__, 'uploadfile', null, 'text/x-foo-bar'); - $res = $this->client->request('POST'); - - $size = filesize(__FILE__); - - $body = "uploadfile " . basename(__FILE__) . " text/x-foo-bar $size\n"; - $this->assertEquals($body, $res->getBody(), 'Response body does not include expected upload parameters'); - } - - public function testUploadLocalDetectMime() - { - $detect = null; - if (function_exists('finfo_file')) { - $f = @finfo_open(FILEINFO_MIME); - if ($f) $detect = 'finfo'; - - } elseif (function_exists('mime_content_type')) { - if (mime_content_type(__FILE__)) { - $detect = 'mime_magic'; - } - } - - if (! $detect) { - $this->markTestSkipped('No MIME type detection capability (fileinfo or mime_magic extensions) is available'); - } - - $file = dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'staticFile.jpg'; - - $this->client->setUri($this->baseuri. 'testUploads.php'); - $this->client->setFileUpload($file, 'uploadfile'); - $res = $this->client->request('POST'); - - $size = filesize($file); - $body = "uploadfile " . basename($file) . " image/jpeg $size\n"; - $this->assertEquals($body, $res->getBody(), 'Response body does not include expected upload parameters (detect: ' . $detect . ')'); - } - - public function testUploadNameWithSpecialChars() - { - $this->client->setUri($this->baseuri. 'testUploads.php'); - - $rawdata = file_get_contents(__FILE__); - $this->client->setFileUpload('/some strage/path%/with[!@#$&]/myfile.txt', 'uploadfile', $rawdata, 'text/plain'); - $res = $this->client->request('POST'); - - $body = 'uploadfile myfile.txt text/plain ' . strlen($rawdata) . "\n"; - $this->assertEquals($body, $res->getBody(), 'Response body does not include expected upload parameters'); - } - - public function testStaticLargeFileDownload() - { - $this->client->setUri($this->baseuri . 'staticFile.jpg'); - - $got = $this->client->request()->getBody(); - $expected = $this->_getTestFileContents('staticFile.jpg'); - - $this->assertEquals($expected, $got, 'Downloaded file does not seem to match!'); - } - - /** - * Test that lines that might be evaluated as boolean false do not break - * the reading prematurely. - * - * @see http://framework.zend.com/issues/browse/ZF-4238 - * - */ - public function testZF4238FalseLinesInResponse() - { - $this->client->setUri($this->baseuri . 'ZF4238-zerolineresponse.txt'); - - $got = $this->client->request()->getBody(); - $expected = $this->_getTestFileContents('ZF4238-zerolineresponse.txt'); - $this->assertEquals($expected, $got); - } - - /** - * Internal helpder function to get the contents of test files - * - * @param string $file - * @return string - */ - protected function _getTestFileContents($file) - { - return file_get_contents(dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR . - '_files' . DIRECTORY_SEPARATOR . $file); - } -} diff --git a/tests/Zend/Http/Client/StaticTest.php b/tests/Zend/Http/Client/StaticTest.php deleted file mode 100644 index e3ddb0a2fa65427d22fbab82584056fcbae0dfd6..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/StaticTest.php +++ /dev/null @@ -1,348 +0,0 @@ -<?php - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * This Testsuite includes all Zend_Http_Client tests that do not rely - * on performing actual requests to an HTTP server. These tests can be - * executed once, and do not need to be tested with different servers / - * client setups. - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: StaticTest.php 11915 2008-10-12 18:29:09Z alexander $ - * @copyright - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase -{ - /** - * Common HTTP client - * - * @var Zend_Http_Client - */ - protected $client = null; - - /** - * Set up the test suite before each test - * - */ - public function setUp() - { - $this->client = new Zend_Http_Client('http://www.example.com'); - } - - /** - * URI Tests - */ - - /** - * Test we can SET and GET a URI as string - * - */ - public function testSetGetUriString() - { - $uristr = 'http://www.zend.com:80/'; - - $this->client->setUri($uristr); - - $uri = $this->client->getUri(); - $this->assertTrue($uri instanceof Zend_Uri_Http, 'Returned value is not a Uri object as expected'); - $this->assertEquals($uri->__toString(), $uristr, 'Returned Uri object does not hold the expected URI'); - - $uri = $this->client->getUri(true); - $this->assertTrue(is_string($uri), 'Returned value expected to be a string, ' . gettype($uri) . ' returned'); - $this->assertEquals($uri, $uristr, 'Returned string is not the expected URI'); - } - - /** - * Test we can SET and GET a URI as object - * - */ - public function testSetGetUriObject() - { - $uriobj = Zend_Uri::factory('http://www.zend.com:80/'); - - $this->client->setUri($uriobj); - - $uri = $this->client->getUri(); - $this->assertTrue($uri instanceof Zend_Uri_Http, 'Returned value is not a Uri object as expected'); - $this->assertEquals($uri, $uriobj, 'Returned object is not the excepted Uri object'); - } - - /** - * Test that passing an invalid URI string throws an exception - * - */ - public function testInvalidUriStringException() - { - try { - $this->client->setUri('http://__invalid__.com'); - $this->fail('Excepted invalid URI string exception was not thrown'); - } catch (Zend_Uri_Exception $e) { - // We're good - } - } - - /** - * Test that passing an invalid URI object throws an exception - * - */ - public function testInvalidUriObjectException() - { - try { - $uri = Zend_Uri::factory('mailto:nobody@example.com'); - $this->client->setUri($uri); - $this->fail('Excepted invalid URI object exception was not thrown'); - } catch (Zend_Http_Client_Exception $e) { - // We're good - } catch (Zend_Uri_Exception $e) { - // URI is currently unimplemented - $this->markTestIncomplete('Zend_Uri_Mailto is not implemented yet'); - } - - } - - /** - * Header Tests - */ - - /** - * Make sure an exception is thrown if an invalid header name is used - * - */ - public function testInvalidHeaderExcept() - { - try { - $this->client->setHeaders('Ina_lid* Hea%der', 'is not good'); - $this->fail('Expected invalid header name exception was not thrown'); - } catch (Zend_Http_Client_Exception $e) { - // We're good - } - } - - /** - * Make sure non-strict mode disables header name validation - * - */ - public function testInvalidHeaderNonStrictMode() - { - // Disable strict validation - $this->client->setConfig(array('strict' => false)); - - try { - $this->client->setHeaders('Ina_lid* Hea%der', 'is not good'); - } catch (Zend_Http_Client_Exception $e) { - $this->fail('Invalid header names should be allowed in non-strict mode'); - } - } - - /** - * Test we can get already set headers - * - */ - public function testGetHeader() - { - $this->client->setHeaders(array( - 'Accept-encoding' => 'gzip,deflate', - 'Accept-language' => 'en,de,*', - )); - - $this->assertEquals($this->client->getHeader('Accept-encoding'), 'gzip,deflate', 'Returned value of header is not as expected'); - $this->assertEquals($this->client->getHeader('X-Fake-Header'), null, 'Non-existing header should not return a value'); - } - - public function testUnsetHeader() - { - $this->client->setHeaders('Accept-Encoding', 'gzip,deflate'); - $this->client->setHeaders('Accept-Encoding', null); - $this->assertNull($this->client->getHeader('Accept-encoding'), 'Returned value of header is expected to be null'); - } - - /** - * Authentication tests - */ - - /** - * Test setAuth (dynamic method) fails when trying to use an unsupported - * authentication scheme - * - */ - public function testExceptUnsupportedAuthDynamic() - { - try { - $this->client->setAuth('shahar', '1234', 'SuperStrongAlgo'); - $this->fail('Trying to use unknown authentication method, setAuth should throw an exception but it didn\'t'); - } catch (Zend_Http_Client_Exception $e) { - // We're good! - } - } - - /** - * Test encodeAuthHeader (static method) fails when trying to use an - * unsupported authentication scheme - * - */ - public function testExceptUnsupportedAuthStatic() - { - try { - Zend_Http_Client::encodeAuthHeader('shahar', '1234', 'SuperStrongAlgo'); - $this->fail('Trying to use unknown authentication method, encodeAuthHeader should throw an exception but it didn\'t'); - } catch (Zend_Http_Client_Exception $e) { - // We're good! - } - } - - /** - * Cookie and Cookie Jar tests - */ - - /** - * Test we can properly set a new cookie jar - * - */ - public function testSetNewCookieJar() - { - $this->client->setCookieJar(); - $this->client->setCookie('cookie', 'value'); - $this->client->setCookie('chocolate', 'chips'); - $jar = $this->client->getCookieJar(); - - // Check we got the right cookiejar - $this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of Zend_Http_CookieJar as expected'); - $this->assertEquals(count($jar->getAllCookies()), 2, '$jar does not contain 2 cookies as expected'); - } - - /** - * Test we can properly set an existing cookie jar - * - */ - public function testSetReadyCookieJar() - { - $jar = new Zend_Http_CookieJar(); - $jar->addCookie('cookie=value', 'http://www.example.com'); - $jar->addCookie('chocolate=chips; path=/foo', 'http://www.example.com'); - - $this->client->setCookieJar($jar); - - // Check we got the right cookiejar - $this->assertEquals($jar, $this->client->getCookieJar(), '$jar is not the client\'s cookie jar as expected'); - } - - /** - * Test we can unset a cookie jar - * - */ - public function testUnsetCookieJar() - { - // Set the cookie jar just like in testSetNewCookieJar - $this->client->setCookieJar(); - $this->client->setCookie('cookie', 'value'); - $this->client->setCookie('chocolate', 'chips'); - $jar = $this->client->getCookieJar(); - - // Try unsetting the cookiejar - $this->client->setCookieJar(null); - - $this->assertNull($this->client->getCookieJar(), 'Cookie jar is expected to be null but it is not'); - } - - /** - * Make sure using an invalid cookie jar object throws an exception - * - */ - public function testSetInvalidCookieJar() - { - try { - $this->client->setCookieJar('cookiejar'); - $this->fail('Invalid cookiejar exception was not thrown'); - } catch (Exception $e) { - // We're good - } - } - - /** - * Other Tests - */ - - /** - * Check we get an exception when trying to send a POST request with an - * invalid content-type header - */ - public function testInvalidPostContentType() - { - $this->client->setEncType('x-foo/something-fake'); - $this->client->setParameterPost('parameter', 'value'); - - try { - $this->client->request('POST'); - $this->fail('Building the body with an unknown content-type for POST values should have failed, it didn\'t'); - } catch (Zend_Http_Client_Exception $e) { - // We are ok! - } - } - - /** - * Check we get an exception if there's an error in the socket - * - */ - public function testSocketErrorException() { - // Try to connect to an invalid host - $this->client->setUri('http://255.255.255.255'); - // Reduce timeout to 3 seconds to avoid waiting - $this->client->setConfig(array('timeout' => 3)); - - try { - $this->client->request(); - $this->fail('Expected connection error exception was not thrown'); - } catch (Zend_Http_Client_Adapter_Exception $e) { - // We're good! - } - } - - /** - * Check that we can set methods which are not documented in the RFC. - * Also, check that an exception is thrown if non-word characters are - * used in the request method. - * - */ - public function testSettingExtendedMethod() - { - $goodMethods = array( - 'OPTIONS', - 'POST', - 'DOSOMETHING', - 'PROPFIND', - 'Some_Characters', - 'X-MS-ENUMATTS' - ); - - foreach ($goodMethods as $method) { - try { - $this->client->setMethod($method); - } catch (Exception $e) { - $this->fail("An unexpected exception was thrown when setting request method to '{$method}'"); - } - } - - $badMethods = array( - 'N@5TYM3T#0D', - 'TWO WORDS', - 'GET http://foo.com/?', - "Injected\nnewline" - ); - - foreach ($badMethods as $method) { - try { - $this->client->setMethod($method); - $this->fail("A Zend_Http_Client_Exception was expected but was not thrown when setting request method to '{$method}'"); - } catch (Zend_Http_Client_Exception $e) { - // We're ok! - } - } - } -} diff --git a/tests/Zend/Http/Client/TestAdapterTest.php b/tests/Zend/Http/Client/TestAdapterTest.php deleted file mode 100644 index d1820cbfd911473c448a9a13ec268f28dc55e4bf..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/TestAdapterTest.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Http/Client.php'; -require_once 'Zend/Http/Client/Adapter/Test.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Exercises Zend_Http_Client_Adapter_Test - * - * @category Zend - * @package Zend_Http_Client - * @subpackage UnitTests - * @version $Id: TestAdapterTest.php 11915 2008-10-12 18:29:09Z alexander $ - */ -class Zend_Http_Client_TestAdapterTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->adapter = new Zend_Http_Client_Adapter_Test(); - } - - public function testSetConfigThrowsOnInvalidConfig() - { - try { - $this->adapter->setConfig('foo'); - } catch (Exception $e) { - $class = 'Zend_Http_Client_Adapter_Exception'; - $this->assertType($class, $e); - $this->assertRegexp('/expects an array/i', $e->getMessage()); - } - } - - public function testSetConfigReturnsQuietly() - { - $this->adapter->setConfig(array('foo' => 'bar')); - } - - public function testConnectReturnsQuietly() - { - $this->adapter->connect('http://foo'); - } - - public function testCloseReturnsQuietly() - { - $this->adapter->close(); - } - - public function testReadDefaultResponse() - { - $expected = "HTTP/1.1 400 Bad Request\r\n\r\n"; - $this->assertEquals($expected, $this->adapter->read()); - } - - public function testReadingSingleResponse() - { - $expected = "HTTP/1.1 200 OK\r\n\r\n"; - $this->adapter->setResponse($expected); - $this->assertEquals($expected, $this->adapter->read()); - $this->assertEquals($expected, $this->adapter->read()); - } - - public function testReadingResponseCycles() - { - $expected = array("HTTP/1.1 200 OK\r\n\r\n", - "HTTP/1.1 302 Moved Temporarily\r\n\r\n"); - - $this->adapter->setResponse($expected[0]); - $this->adapter->addResponse($expected[1]); - - $this->assertEquals($expected[0], $this->adapter->read()); - $this->assertEquals($expected[1], $this->adapter->read()); - $this->assertEquals($expected[0], $this->adapter->read()); - } - - public function testReadingResponseCyclesWhenSetByArray() - { - $expected = array("HTTP/1.1 200 OK\r\n\r\n", - "HTTP/1.1 302 Moved Temporarily\r\n\r\n"); - - $this->adapter->setResponse($expected); - - $this->assertEquals($expected[0], $this->adapter->read()); - $this->assertEquals($expected[1], $this->adapter->read()); - $this->assertEquals($expected[0], $this->adapter->read()); - } - - public function testSettingNextResponseByIndex() - { - $expected = array("HTTP/1.1 200 OK\r\n\r\n", - "HTTP/1.1 302 Moved Temporarily\r\n\r\n", - "HTTP/1.1 404 Not Found\r\n\r\n"); - - $this->adapter->setResponse($expected); - $this->assertEquals($expected[0], $this->adapter->read()); - - foreach ($expected as $i => $expected) { - $this->adapter->setResponseIndex($i); - $this->assertEquals($expected, $this->adapter->read()); - } - } - - public function testSettingNextResponseToAnInvalidIndex() - { - $indexes = array(-1, 1); - foreach ($indexes as $i) { - try { - $this->adapter->setResponseIndex($i); - $this->fail(); - } catch (Exception $e) { - $class = 'Zend_Http_Client_Adapter_Exception'; - $this->assertType($class, $e); - $this->assertRegexp('/out of range/i', $e->getMessage()); - } - } - } -} diff --git a/tests/Zend/Http/Client/_files/ZF4238-zerolineresponse.txt b/tests/Zend/Http/Client/_files/ZF4238-zerolineresponse.txt deleted file mode 100644 index 7ac8e5fbc94c86453f3a97d98ca15f74a806f38a..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/ZF4238-zerolineresponse.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 - -some text here diff --git a/tests/Zend/Http/Client/_files/staticFile.jpg b/tests/Zend/Http/Client/_files/staticFile.jpg deleted file mode 100644 index 708d090372ddf144b426aebbe91553b8b23a3ee5..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Http/Client/_files/staticFile.jpg and /dev/null differ diff --git a/tests/Zend/Http/Client/_files/testCookies.php b/tests/Zend/Http/Client/_files/testCookies.php deleted file mode 100644 index c59eae29eabda4d02771611ffb720aa4c7c70a4a..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testCookies.php +++ /dev/null @@ -1,22 +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_Http - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: testCookies.php 9354 2008-05-04 21:26:53Z thomas $ - */ - -echo serialize($_COOKIE); diff --git a/tests/Zend/Http/Client/_files/testGetData.php b/tests/Zend/Http/Client/_files/testGetData.php deleted file mode 100644 index 5dc5b1e610abd50ab6f7512969815c824110997c..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testGetData.php +++ /dev/null @@ -1,22 +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_Http - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: testGetData.php 9354 2008-05-04 21:26:53Z thomas $ - */ - -echo serialize($_GET); diff --git a/tests/Zend/Http/Client/_files/testHeaders.php b/tests/Zend/Http/Client/_files/testHeaders.php deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/Zend/Http/Client/_files/testHttpAuth.php b/tests/Zend/Http/Client/_files/testHttpAuth.php deleted file mode 100644 index 6e01f5f734ab732e1296decd2d04cd96adc85459..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testHttpAuth.php +++ /dev/null @@ -1,33 +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_Http - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: testHttpAuth.php 9354 2008-05-04 21:26:53Z thomas $ - */ - -$user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null; -$pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null; -$guser = isset($_GET['user']) ? $_GET['user'] : null; -$gpass = isset($_GET['pass']) ? $_GET['pass'] : null; -$method = isset($_GET['method']) ? $_GET['method'] : 'Basic'; - -if (! $user || ! $pass || $user != $guser || $pass != $gpass) { - header('WWW-Authenticate: ' . $method . ' realm="ZendTest"'); - header('HTTP/1.0 401 Unauthorized'); -} - -echo serialize($_GET), "\n", $user, "\n", $pass, "\n"; \ No newline at end of file diff --git a/tests/Zend/Http/Client/_files/testPostData.php b/tests/Zend/Http/Client/_files/testPostData.php deleted file mode 100644 index e621307266400183ab8a22e2c44961c3b250c0a9..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testPostData.php +++ /dev/null @@ -1,2 +0,0 @@ -<?php - echo serialize($_POST); diff --git a/tests/Zend/Http/Client/_files/testRawPostData.php b/tests/Zend/Http/Client/_files/testRawPostData.php deleted file mode 100644 index 990f73601e42f6e766267608336d19d0893273de..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testRawPostData.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -readfile('php://input'); \ No newline at end of file diff --git a/tests/Zend/Http/Client/_files/testRedirections.php b/tests/Zend/Http/Client/_files/testRedirections.php deleted file mode 100644 index 4128889a3e2adf96c38256b9a1da49a8e539b002..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testRedirections.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -if (! isset($_GET['redirection'])) $_GET['redirection'] = 0; -$_GET['redirection']++; -$https = isset($_SERVER['HTTPS']); - -if ($_GET['redirection'] < 4) { - $target = 'http' . ($https ? 's://' : '://') . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; - header('Location: ' . $target . '?redirection=' . $_GET['redirection']); -} else { - var_dump($_GET); - var_dump($_POST); -} \ No newline at end of file diff --git a/tests/Zend/Http/Client/_files/testRelativeRedirections.php b/tests/Zend/Http/Client/_files/testRelativeRedirections.php deleted file mode 100644 index b43ba7591f4031ed47163b80e1884380d061610f..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testRelativeRedirections.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -if (! isset($_GET['redirect'])) $_GET['redirect'] = null; - -switch ($_GET['redirect']) { - case 'abpath': - header("Location: /path/to/fake/file.ext?redirect=abpath"); - break; - - case 'relpath': - header("Location: path/to/fake/file.ext?redirect=relpath"); - break; - - default: - echo "Redirections done."; - break; -} diff --git a/tests/Zend/Http/Client/_files/testResetParameters.php b/tests/Zend/Http/Client/_files/testResetParameters.php deleted file mode 100644 index e413eddf1ce94729851ad8c9edaf5ff758075dc6..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testResetParameters.php +++ /dev/null @@ -1,2 +0,0 @@ -<?php -echo serialize($_GET) . "\n" . serialize($_POST); \ No newline at end of file diff --git a/tests/Zend/Http/Client/_files/testSimpleRequests.php b/tests/Zend/Http/Client/_files/testSimpleRequests.php deleted file mode 100644 index 51da4200abb928986170b996f71fb3dbeba71c1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testSimpleRequests.php +++ /dev/null @@ -1 +0,0 @@ -Success \ No newline at end of file diff --git a/tests/Zend/Http/Client/_files/testUploads.php b/tests/Zend/Http/Client/_files/testUploads.php deleted file mode 100644 index 7c11e3a64144e7a29b183d8c7f996684a06d20dc..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/Client/_files/testUploads.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -if (! empty($_FILES)) { - foreach ($_FILES as $name => $file) { - echo $name . " " . $file['name'] . " " . $file['type'] . " " . $file['size'] . "\n"; - } -} \ No newline at end of file diff --git a/tests/Zend/Http/CookieJarTest.php b/tests/Zend/Http/CookieJarTest.php deleted file mode 100644 index 29afbe9889cb720a5230699b72af86d0bf4b7180..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/CookieJarTest.php +++ /dev/null @@ -1,437 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Http - * @subpackage UnitTests - * @version $Id: CookieJarTest.php 7366 2008-01-09 13:48:52Z shahar $ - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -// require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'Zend/Http/CookieJar.php'; - -/** - * Zend_Http_CookieJar unit tests - * - * @category Zend - * @package Zend_Http - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase -{ - /** - * Test we can add cookies to the jar - * - */ - public function testAddCookie() - { - $jar = new Zend_Http_CookieJar(); - $this->assertEquals(0, count($jar->getAllCookies()), 'Cookie jar is expected to contain 0 cookies'); - - $jar->addCookie('foo=bar; domain=example.com'); - $cookie = $jar->getCookie('http://example.com/', 'foo'); - $this->assertTrue($cookie instanceof Zend_Http_Cookie, '$cookie is expected to be a Cookie object'); - $this->assertEquals('bar', $cookie->getValue(), 'Cookie value is expected to be "bar"'); - - $jar->addCookie('cookie=brownie; domain=geekz.co.uk;'); - $this->assertEquals(2, count($jar->getAllCookies()), 'Cookie jar is expected to contain 2 cookies'); - } - - /** - * Check we get an expection if a non-valid cookie is passed to addCookie - * - */ - public function testExceptAddInvalidCookie() - { - $jar = new Zend_Http_CookieJar(); - - try { - $jar->addCookie('garbage'); - $this->fail('Expected exception was not thrown'); - } catch (Zend_Http_Exception $e) { - // We are ok - } - - try { - $jar->addCookie(new Zend_Http_Cookiejar()); - $this->fail('Expected exception was not thrown'); - } catch (Zend_Http_Exception $e) { - // We are ok - } - } - - /** - * Test we can read cookies from a Response object - * - */ - public function testAddCookiesFromResponse() - { - $jar = new Zend_Http_Cookiejar(); - $res_str = file_get_contents(dirname(realpath(__FILE__)) . - DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'response_with_cookies'); - $response = Zend_Http_Response::fromString($res_str); - - $jar->addCookiesFromResponse($response, 'http://www.example.com'); - - $this->assertEquals(3, count($jar->getAllCookies())); - - $cookie_str = 'foo=bar;BOFH=Feature+was+not+beta+tested;time=1164234700;'; - $this->assertEquals($cookie_str, $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT)); - } - - public function testExceptAddCookiesInvalidResponse() - { - $jar = new Zend_Http_Cookiejar(); - - try { - $jar->addCookiesFromResponse('somestring', 'http://www.example.com'); - $this->fail('Excepted exception was not thrown'); - } catch (Zend_Http_Exception $e) { - // We are ok - } - - try { - $jar->addCookiesFromResponse(new stdClass(), 'http://www.example.com'); - $this->fail('Excepted exception was not thrown'); - } catch (Zend_Http_Exception $e) { - // We are ok - } - } - - /** - * Test we can get all cookies as an array of Cookie objects - * - */ - public function testGetAllCookies() - { - $jar = new Zend_Http_CookieJar(); - - $cookies = array( - 'name=Arthur; domain=camelot.gov.uk', - 'quest=holy+grail; domain=forest.euwing.com', - 'swallow=african; domain=bridge-of-death.net' - ); - - foreach ($cookies as $cookie) { - $jar->addCookie($cookie); - } - - $cobjects = $jar->getAllCookies(); - - foreach ($cobjects as $id => $cookie) { - $this->assertContains($cookie->__toString(), $cookies[$id]); - } - } - - /** - * Test we can get all cookies as a concatenated string - * - */ - public function testGetAllCookiesAsConcat() - { - $jar = new Zend_Http_CookieJar(); - - $cookies = array( - 'name=Arthur; domain=camelot.gov.uk', - 'quest=holy+grail; domain=forest.euwing.com', - 'swallow=african; domain=bridge-of-death.net' - ); - - foreach ($cookies as $cookie) { - $jar->addCookie($cookie); - } - - $expected = 'name=Arthur;quest=holy+grail;swallow=african;'; - $real = $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT ); - - $this->assertEquals($expected, $real, 'Concatenated string is not as expected'); - } - - /** - * Test we can get a single cookie as an object - * - */ - public function testGetCookieAsObject() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests'); - $jar = new Zend_Http_CookieJar(); - $jar->addCookie($cookie->__toString(), 'http://www.example.com/tests/'); - - $cobj = $jar->getCookie('http://www.example.com/tests/', 'foo'); - - $this->assertTrue($cobj instanceof Zend_Http_Cookie, '$cobj is not a Cookie object'); - $this->assertEquals($cookie->getName(), $cobj->getName(), 'Cookie name is not as expected'); - $this->assertEquals($cookie->getValue(), $cobj->getValue(), 'Cookie value is not as expected'); - $this->assertEquals($cookie->getDomain(), $cobj->getDomain(), 'Cookie domain is not as expected'); - $this->assertEquals($cookie->getPath(), $cobj->getPath(), 'Cookie path is not as expected'); - } - - /** - * Check we can get a cookie as a string - */ - public function testGetCookieAsString() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests'); - $jar = new Zend_Http_CookieJar(); - $jar->addCookie($cookie); - - $cstr = $jar->getCookie('http://www.example.com/tests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_ARRAY); - $this->assertEquals($cookie->__toString(), $cstr, 'Cookie string is not the expected string'); - - $cstr = $jar->getCookie('http://www.example.com/tests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_CONCAT); - $this->assertEquals($cookie->__toString(), $cstr, 'Cookie string is not the expected string'); - } - - /** - * Check we can get false when trying to get a non-existant cookie - */ - public function testGetCookieReturnFalse() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests'); - $jar = new Zend_Http_CookieJar(); - $jar->addCookie($cookie); - - $cstr = $jar->getCookie('http://www.example.com/tests/', 'otherfoo', Zend_Http_CookieJar::COOKIE_STRING_ARRAY); - $this->assertFalse($cstr, 'getCookie was expected to return false, no such cookie'); - - $cstr = $jar->getCookie('http://www.otherexample.com/tests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_CONCAT); - $this->assertFalse($cstr, 'getCookie was expected to return false, no such domain'); - - $cstr = $jar->getCookie('http://www.example.com/othertests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_CONCAT); - $this->assertFalse($cstr, 'getCookie was expected to return false, no such path'); - } - - /** - * Test we get a proper exception when an invalid URI is passed - */ - public function testExceptGetCookieInvalidUri() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests'); - $jar = new Zend_Http_CookieJar(); - $jar->addCookie($cookie); - - try { - $jar->getCookie('foo.com', 'foo'); - $this->fail('Expected getCookie to throw exception, invalid URI string passed'); - } catch (Zend_Exception $e) { - // We are ok! - } - - try { - $jar->getCookie(Zend_Uri::factory('mailto:nobody@dev.null.com'), 'foo'); - $this->fail('Expected getCookie to throw exception, invalid URI object passed'); - } catch (Zend_Exception $e) { - // We are ok! - } - } - - /** - * Test we get a proper exception when an invalid return constant is passed - * - */ - public function testExceptGetCookieInvalidReturnType() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=example.com;'); - $jar = new Zend_Http_CookieJar(); - $jar->addCookie($cookie); - - try { - $jar->getCookie('http://example.com/', 'foo', 5); - $this->fail('Expected getCookie to throw exception, invalid return type'); - } catch (Zend_Http_Exception $e) { - // We are ok! - } - } - - /** - * Test we can get all matching cookies for a request, with session cookies - */ - public function testGetMatchingCookies() - { - $jar = new Zend_Http_CookieJar(); - $cookies = array( - Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), - Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), - Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - ); - - foreach ($cookies as $cookie) $jar->addCookie($cookie); - - $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8'); - - $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt'); - $this->assertEquals(4, count($cookies), 'Cookie count is expected to be 4'); - - $cookies = $jar->getMatchingCookies('https://www.foo.com/path/file.txt'); - $this->assertEquals(5, count($cookies), 'Cookie count is expected to be 5'); - } - - /** - * Test we can get all matching cookies for a request, without session cookies - */ - public function testGetMatchingCookiesNoSession() - { - $jar = new Zend_Http_CookieJar(); - $cookies = array( - Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), - Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), - Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - ); - - foreach ($cookies as $cookie) $jar->addCookie($cookie); - - $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8'); - - $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', false); - $this->assertEquals(3, count($cookies), 'Cookie count is expected to be 3'); - - $cookies = $jar->getMatchingCookies('https://www.foo.com/path/file.txt', false); - $this->assertEquals(4, count($cookies), 'Cookie count is expected to be 4'); - } - - /** - * Test we can get all matching cookies for a request, when we set a different time for now - */ - public function testGetMatchingCookiesWithTime() - { - $jar = new Zend_Http_CookieJar(); - $cookies = array( - Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 7200)), - Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), - Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), - Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() - 7200)), - Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - ); - - foreach ($cookies as $cookie) $jar->addCookie($cookie); - - $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8'); - - $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_OBJECT, time() + 3700); - $this->assertEquals(2, count($cookies), 'Cookie count is expected to be 2'); - - $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_OBJECT, time() - 3700); - $this->assertEquals(5, count($cookies), 'Cookie count is expected to be 5'); - } - - /** - * Test we can get all matching cookies for a request, and return as strings array / concat - */ - public function testGetMatchingCookiesAsStrings() - { - $jar = new Zend_Http_CookieJar(); - $cookies = array( - Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), - Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), - Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), - ); - - foreach ($cookies as $cookie) $jar->addCookie($cookie); - - $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8'); - - $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY); - $this->assertType('array', $cookies, '$cookies is expected to be an array, but it is not'); - $this->assertType('string', $cookies[0], '$cookies[0] is expected to be a string');; - - $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT); - $this->assertType('string', $cookies, '$cookies is expected to be a string'); - } - - /** - * Test we get a proper exception when an invalid URI is passed - */ - public function testExceptGetMatchingCookiesInvalidUri() - { - $jar = new Zend_Http_CookieJar(); - - try { - $cookies = $jar->getMatchingCookies('invalid.com', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY); - $this->fail('Expected getMatchingCookies to throw exception, invalid URI string passed'); - } catch (Zend_Exception $e) { - // We are ok! - } - - try { - $cookies = $jar->getMatchingCookies(new stdClass(), true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY); - $this->fail('Expected getCookie to throw exception, invalid URI object passed'); - } catch (Zend_Exception $e) { - // We are ok! - } - } - - /** - * Test we can build a new object from a response object (single cookie header) - */ - public function testFromResponse() - { - $res_str = file_get_contents(dirname(realpath(__FILE__)) . - DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'response_with_single_cookie'); - $response = Zend_Http_Response::fromString($res_str); - - $jar = Zend_Http_CookieJar::fromResponse($response, 'http://www.example.com'); - - $this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of CookieJar as expected'); - $this->assertEquals(1, count($jar->getAllCookies()), 'CookieJar expected to contain 1 cookie'); - } - - /** - * Test we can build a new object from a response object (multiple cookie headers) - */ - public function testFromResponseMultiHeader() - { - $res_str = file_get_contents(dirname(realpath(__FILE__)) . - DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'response_with_cookies'); - $response = Zend_Http_Response::fromString($res_str); - - $jar = Zend_Http_CookieJar::fromResponse($response, 'http://www.example.com'); - - $this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of CookieJar as expected'); - $this->assertEquals(3, count($jar->getAllCookies()), 'CookieJar expected to contain 3 cookies'); - } - - /** - * Make sure that paths with trailing slashes are matched as well as paths with no trailing slashes - */ - public function testMatchPathWithTrailingSlash() - { - $jar = new Zend_Http_CookieJar(); - $cookies = array( - Zend_Http_Cookie::fromString('foo1=bar1; domain=.example.com; path=/a/b'), - Zend_Http_Cookie::fromString('foo2=bar2; domain=.example.com; path=/a/b/') - ); - - foreach ($cookies as $cookie) $jar->addCookie($cookie); - $cookies = $jar->getMatchingCookies('http://www.example.com/a/b/file.txt'); - - $this->assertType('array', $cookies); - $this->assertEquals(2, count($cookies)); - } -} diff --git a/tests/Zend/Http/CookieTest.php b/tests/Zend/Http/CookieTest.php deleted file mode 100644 index 5fb734e7dfe906943d44d35d98b97439ff2c410a..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/CookieTest.php +++ /dev/null @@ -1,406 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Http - * @subpackage UnitTests - * @version $Id: CookieTest.php 2073 2006-12-03 17:34:25Z shahar $ - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// // // require_once "PHPUnit/Framework/TestCase.php"; -require_once 'Zend/Http/Cookie.php'; - -/** - * Zend_Http_Cookie unit tests - * - * @category Zend - * @package Zend_Http - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase -{ - /** - * Make sure we can't set invalid names - */ - public function testSetInvalidName() - { - $invalidcharacters = "=,; \t\r\n\013\014"; - $l = strlen($invalidcharacters) - 1; - for ($i = 0; $i < $l; $i++) { - $name = 'cookie_' . $invalidcharacters[$i]; - try { - $cookie = new Zend_Http_Cookie($name, 'foo', 'example.com'); - $this->fail('Expected invalid cookie name exception was not thrown for "' . $name . '"'); - } catch (Zend_Http_Exception $e) { - // We're good! - } - } - } - - /** - * Test we get the cookie name properly - */ - public function testGetName() - { - // Array of cookies and their names. We need to test each 'keyword' in - // a cookie string - $cookies = array( - 'justacookie' => 'justacookie=foo; domain=example.com', - 'expires' => 'expires=tomorrow; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com', - 'domain' => 'domain=unittests; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com', - 'path' => 'path=indexAction; path=/; domain=.foo.com', - 'secure' => 'secure=sha1; secure; domain=.foo.com', - 'PHPSESSID' => 'PHPSESSID=1234567890abcdef; secure; domain=.foo.com; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT;' - ); - - foreach ($cookies as $name => $cstr) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Cookie ' . $name . ' is not a proper Cookie object'); - $this->assertEquals($name, $cookie->getName(), 'Cookie name is not as expected'); - } - } - - /** - * Make sure we get the correct value if it was set through the constructor - * - */ - public function testGetValueConstructor() - { - $values = array( - 'simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks" - ); - - foreach ($values as $val) { - $cookie = new Zend_Http_Cookie('cookie', $val, 'example.com', time(), '/', true); - $this->assertEquals($val, $cookie->getValue()); - } - } - - /** - * Make sure we get the correct value if it was set through fromString() - * - */ - public function testGetValueFromString() - { - $values = array( - 'simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks" - ); - - foreach ($values as $val) { - $cookie = Zend_Http_Cookie::fromString('cookie=' . urlencode($val) . '; domain=example.com'); - $this->assertEquals($val, $cookie->getValue()); - } - } - - /** - * Make sure we get the correct domain when it's set in the cookie string - * - */ - public function testGetDomainInStr() - { - $domains = array( - 'cookie=foo; domain=example.com' => 'example.com', - 'cookie=foo; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => '.example.com', - 'cookie=foo; domain=some.really.deep.domain.com; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT;' => 'some.really.deep.domain.com' - ); - - foreach ($domains as $cstr => $domain) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie instanceof Zend_Http_Cookie) $this->fail('We didn\'t get a valid Cookie object'); - $this->assertEquals($domain, $cookie->getDomain()); - } - } - - /** - * Make sure we get the correct domain when it's set in a reference URL - * - */ - public function testGetDomainInRefUrl() - { - $domains = array( - 'example.com', 'www.example.com', 'some.really.deep.domain.com' - ); - - foreach ($domains as $domain) { - $cookie = Zend_Http_Cookie::fromString('foo=baz; path=/', 'http://' . $domain); - if (! $cookie instanceof Zend_Http_Cookie) $this->fail('We didn\'t get a valid Cookie object'); - $this->assertEquals($domain, $cookie->getDomain()); - } - } - - /** - * Make sure we get the correct path when it's set in the cookie string - */ - public function testGetPathInStr() - { - $cookies = array( - 'cookie=foo; domain=example.com' => '/', - 'cookie=foo; path=/foo/baz; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => '/foo/baz', - 'cookie=foo; domain=some.really.deep.domain.com; path=/Space Out/; expires=Tue, 21-Nov-2006 08:33:44 GMT;' => '/Space Out/' - ); - - foreach ($cookies as $cstr => $path) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Failed generatic a valid cookie object'); - $this->assertEquals($path, $cookie->getPath(), 'Cookie path is not as expected'); - } - } - - /** - * Make sure we get the correct path when it's set a reference URL - */ - public function testGetPathInRefUrl() - { - $refUrls = array( - 'http://www.example.com/foo/bar/' => '/foo/bar', - 'http://foo.com' => '/', - 'http://qua.qua.co.uk/path/to/very/deep/file.php' => '/path/to/very/deep' - ); - - foreach ($refUrls as $url => $path) { - $cookie = Zend_Http_Cookie::fromString('foo=bar', $url); - if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Failed generating a valid cookie object'); - $this->assertEquals($path, $cookie->getPath(), 'Cookie path is not as expected'); - } - } - - /** - * Test we get the correct expiry time - * - */ - public function testGetExpiryTime() - { - $now = time(); - $yesterday = $now - (3600 * 24); - $cookies = array( - 'cookie=bar; domain=example.com; expires=' . date(DATE_COOKIE, $now) . ';' => $now, - 'cookie=foo; expires=' . date(DATE_COOKIE, $yesterday) . '; domain=some.really.deep.domain.com; path=/;' => $yesterday, - 'cookie=baz; domain=foo.com; path=/some/path; secure' => null - ); - - foreach ($cookies as $cstr => $exp) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertEquals($exp, $cookie->getExpiryTime(), 'Expiry time is not as expected'); - } - } - - /** - * Make sure the "is secure" flag is correctly set - */ - public function testIsSecure() - { - $cookies = array( - 'cookie=foo; path=/foo/baz; secure; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => true, - 'cookie=foo; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => false, - 'cookie=foo; path=/; SECURE; domain=.example.com;' => true, - 'cookie=foo; path=/; domain=.example.com; SECURE' => true - ); - - foreach ($cookies as $cstr => $secure) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertEquals($secure, $cookie->isSecure(), 'isSecure is not as expected'); - } - - } - - /** - * Make sure we get the correct value for 'isExpired' - */ - public function testIsExpired() - { - $notexpired = time() + 3600; - $expired = time() - 3600; - - $cookies = array( - 'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired) => false, - 'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired) => true, - 'cookie=foo; domain=example.com;' => false - ); - - foreach ($cookies as $cstr => $isexp) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertEquals($isexp, $cookie->isExpired(), 'Got the wrong value for isExpired()'); - } - } - - /** - * Make sure we get the correct value for 'isExpired', when time is manually set - */ - public function testIsExpiredDifferentTime() - { - $notexpired = time() + 3600; - $expired = time() - 3600; - $now = time() + 7200; - - $cookies = array( - 'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired), - 'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired) - ); - - // Make sure all cookies are expired - foreach ($cookies as $cstr) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertTrue($cookie->isExpired($now), 'Cookie is expected to be expired'); - } - - // Make sure all cookies are not expired - $now = time() - 7200; - foreach ($cookies as $cstr) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertFalse($cookie->isExpired($now), 'Cookie is expected not to be expired'); - } - } - - /** - * Test we can properly check if a cookie is a session cookie (has no expiry time) - */ - public function testIsSessionCookie() - { - $cookies = array( - 'cookie=foo; path=/foo/baz; secure; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => false, - 'cookie=foo; path=/; domain=.example.com;' => true, - 'cookie=foo; path=/; secure; domain=.example.com;' => true, - 'cookie=foo; path=/; domain=.example.com; secure; expires=' . date(DATE_COOKIE) => false - ); - - foreach ($cookies as $cstr => $issession) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertEquals($issession, $cookie->isSessionCookie(), 'isSessionCookie is not as expected'); - } - } - - /** - * Make sure cookies are properly converted back to strings - */ - public function testToString() - { - $cookies = array( - 'name=value;', - 'blank=;', - 'urlencodedstuff=' . urlencode('!@#$)(@$%_+{} !@#?^&') . ';', - ); - - foreach ($cookies as $cstr) { - $cookie = Zend_Http_Cookie::fromString($cstr, 'http://example.com'); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertEquals($cstr, $cookie->__toString(), 'Cookie is not converted back to the expected string'); - } - - } - - public function testGarbageInStrIsIgnored() - { - $cookies = array( - 'name=value; domain=foo.com; silly=place; secure', - 'foo=value; someCrap; secure; domain=foo.com; ', - 'anothercookie=value; secure; has some crap; ignore=me; domain=foo.com; ' - ); - - foreach ($cookies as $cstr) { - $cookie = Zend_Http_Cookie::fromString($cstr); - if (! $cookie) $this->fail('Got no cookie object from a valid cookie string'); - $this->assertEquals('value', $cookie->getValue(), 'Value is not as expected'); - $this->assertEquals('foo.com', $cookie->getDomain(), 'Domain is not as expected'); - $this->assertTrue($cookie->isSecure(), 'Cookie is expected to be secure'); - } - } - - /** - * Test the match() method against a domain - * - */ - public function testMatchDomain() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;'); - $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t'); - $this->assertFalse($cookie->match('http://www.somexample.com/foo/bar.php'), 'Cookie expected not to match, but did'); - - $uri = Zend_Uri::factory('http://www.foo.com/some/file.txt'); - $cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com'); - $this->assertTrue($cookie->match($uri), 'Cookie expected to match, but didn\'t'); - $this->assertTrue($cookie->match('http://il.www.foo.com'), 'Cookie expected to match, but didn\'t'); - $this->assertFalse($cookie->match('http://bar.foo.com'), 'Cookie expected not to match, but did'); - } - - /** - * Test the match() method against a domain - * - */ - public function testMatchPath() - { - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; path=/foo'); - $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t'); - $this->assertFalse($cookie->match('http://www.example.com/bar.php'), 'Cookie expected not to match, but did'); - - $cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com; path=/some/long/path'); - $this->assertTrue($cookie->match('http://www.foo.com/some/long/path/file.txt'), 'Cookie expected to match, but didn\'t'); - $this->assertTrue($cookie->match('http://www.foo.com/some/long/path/and/even/more'), 'Cookie expected to match, but didn\'t'); - $this->assertFalse($cookie->match('http://www.foo.com/some/long/file.txt'), 'Cookie expected not to match, but did'); - $this->assertFalse($cookie->match('http://www.foo.com/some/different/path/file.txt'), 'Cookie expected not to match, but did'); - } - - /** - * Test the match() method against secure / non secure connections - * - */ - public function testMatchSecure() - { - // A non secure cookie, should match both - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;'); - $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t'); - $this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t'); - - // A secure cookie, should match secure connections only - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; secure'); - $this->assertFalse($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected not to match, but it did'); - $this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t'); - } - - /** - * Test the match() method against different expiry times - * - */ - public function testMatchExpire() - { - // A session cookie - should always be valid - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;'); - $this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t'); - $this->assertTrue($cookie->match('http://www.example.com/', true, time() + 3600), 'Cookie expected to match, but didn\'t'); - - // A session cookie, should not match - $this->assertFalse($cookie->match('https://www.example.com/', false), 'Cookie expected not to match, but it did'); - $this->assertFalse($cookie->match('https://www.example.com/', false, time() - 3600), 'Cookie expected not to match, but it did'); - - // A cookie with expiry time in the future - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() + 3600)); - $this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t'); - $this->assertFalse($cookie->match('https://www.example.com/', true, time() + 7200), 'Cookie expected not to match, but it did'); - - // A cookie with expiry time in the past - $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() - 3600)); - $this->assertFalse($cookie->match('http://www.example.com/'), 'Cookie expected not to match, but it did'); - $this->assertTrue($cookie->match('https://www.example.com/', true, time() - 7200), 'Cookie expected to match, but didn\'t'); - } - - public function testFromStringFalse() - { - $cookie = Zend_Http_Cookie::fromString('foo; domain=www.exmaple.com'); - $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false'); - - $cookie = Zend_Http_Cookie::fromString('=bar; secure; domain=foo.nl'); - $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false'); - - $cookie = Zend_Http_Cookie::fromString('fo;o=bar; secure; domain=foo.nl'); - $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false'); - } -} diff --git a/tests/Zend/Http/ResponseTest.php b/tests/Zend/Http/ResponseTest.php deleted file mode 100644 index 86e49cffd674e30dfe330f5905f17862ef4d5b1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/ResponseTest.php +++ /dev/null @@ -1,274 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Http - * @subpackage UnitTests - * @version $Id: ResponseTest.php 7366 2008-01-09 13:48:52Z shahar $ - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * Zend_Http_Response - */ -require_once 'Zend/Http/Response.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Zend_Http_Response unit tests - * - * @category Zend - * @package Zend_Http - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Http_ResponseTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { } - - public function testGzipResponse () - { - $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_gzip'); - - $res = Zend_Http_Response::fromString($response_text); - - $this->assertEquals('gzip', $res->getHeader('Content-encoding')); - $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody())); - $this->assertEquals('f24dd075ba2ebfb3bf21270e3fdc5303', md5($res->getRawBody())); - } - - public function testDeflateResponse () - { - $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_deflate'); - - $res = Zend_Http_Response::fromString($response_text); - - $this->assertEquals('deflate', $res->getHeader('Content-encoding')); - $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody())); - $this->assertEquals('ad62c21c3aa77b6a6f39600f6dd553b8', md5($res->getRawBody())); - } - - public function testChunkedResponse () - { - $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_chunked'); - - $res = Zend_Http_Response::fromString($response_text); - - $this->assertEquals('chunked', $res->getHeader('Transfer-encoding')); - $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody())); - $this->assertEquals('c0cc9d44790fa2a58078059bab1902a9', md5($res->getRawBody())); - } - - public function testLineBreaksCompatibility() - { - $response_text_lf = $this->readResponse('response_lfonly'); - $res_lf = Zend_Http_Response::fromString($response_text_lf); - - $response_text_crlf = $this->readResponse('response_crlf'); - $res_crlf = Zend_Http_Response::fromString($response_text_crlf); - - $this->assertEquals($res_lf->getHeadersAsString(true), $res_crlf->getHeadersAsString(true), 'Responses headers do not match'); - $this->assertEquals($res_lf->getBody(), $res_crlf->getBody(), 'Response bodies do not match'); - } - - public function testExtractMessageCrlf() - { - $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_crlf'); - $this->assertEquals("OK", Zend_Http_Response::extractMessage($response_text), "Response message is not 'OK' as expected"); - } - - public function testExtractMessageLfonly() - { - $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_lfonly'); - $this->assertEquals("OK", Zend_Http_Response::extractMessage($response_text), "Response message is not 'OK' as expected"); - } - - public function test404IsError() - { - $response_text = $this->readResponse('response_404'); - $response = Zend_Http_Response::fromString($response_text); - - $this->assertEquals(404, $response->getStatus(), 'Response code is expected to be 404, but it\'s not.'); - $this->assertTrue($response->isError(), 'Response is an error, but isError() returned false'); - $this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true'); - $this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true'); - } - - public function test500isError() - { - $response_text = $this->readResponse('response_500'); - $response = Zend_Http_Response::fromString($response_text); - - $this->assertEquals(500, $response->getStatus(), 'Response code is expected to be 500, but it\'s not.'); - $this->assertTrue($response->isError(), 'Response is an error, but isError() returned false'); - $this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true'); - $this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true'); - } - - public function test300isRedirect() - { - $response = Zend_Http_Response::fromString($this->readResponse('response_302')); - - $this->assertEquals(302, $response->getStatus(), 'Response code is expected to be 302, but it\'s not.'); - $this->assertTrue($response->isRedirect(), 'Response is a redirection, but isRedirect() returned false'); - $this->assertFalse($response->isError(), 'Response is a redirection, but isError() returned true'); - $this->assertFalse($response->isSuccessful(), 'Response is a redirection, but isSuccessful() returned true'); - } - - public function test200Ok() - { - $response = Zend_Http_Response::fromString($this->readResponse('response_deflate')); - - $this->assertEquals(200, $response->getStatus(), 'Response code is expected to be 200, but it\'s not.'); - $this->assertFalse($response->isError(), 'Response is OK, but isError() returned true'); - $this->assertTrue($response->isSuccessful(), 'Response is OK, but isSuccessful() returned false'); - $this->assertFalse($response->isRedirect(), 'Response is OK, but isRedirect() returned true'); - } - - public function test100Continue() - { - $this->markTestIncomplete(); - } - - public function testAutoMessageSet() - { - $response = Zend_Http_Response::fromString($this->readResponse('response_403_nomessage')); - - $this->assertEquals(403, $response->getStatus(), 'Response status is expected to be 403, but it isn\'t'); - $this->assertEquals('Forbidden', $response->getMessage(), 'Response is 403, but message is not "Forbidden" as expected'); - - // While we're here, make sure it's classified as error... - $this->assertTrue($response->isError(), 'Response is an error, but isError() returned false'); - $this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true'); - $this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true'); - } - - public function testAsString() - { - $response_str = $this->readResponse('response_404'); - $response = Zend_Http_Response::fromString($response_str); - - $this->assertEquals(strtolower($response_str), strtolower($response->asString()), 'Response convertion to string does not match original string'); - } - - public function testGetHeaders() - { - $response = Zend_Http_Response::fromString($this->readResponse('response_deflate')); - $headers = $response->getHeaders(); - - $this->assertEquals(8, count($headers), 'Header count is not as expected'); - $this->assertEquals('Apache', $headers['Server'], 'Server header is not as expected'); - $this->assertEquals('deflate', $headers['Content-encoding'], 'Content-type header is not as expected'); - } - - public function testGetVersion() - { - $response = Zend_Http_Response::fromString($this->readResponse('response_chunked')); - $this->assertEquals(1.1, $response->getVersion(), 'Version is expected to be 1.1'); - } - - public function testResponseCodeAsText() - { - // This is an entirely static test - - // Test some response codes - $this->assertEquals('Continue', Zend_Http_Response::responseCodeAsText(100)); - $this->assertEquals('OK', Zend_Http_Response::responseCodeAsText(200)); - $this->assertEquals('Multiple Choices', Zend_Http_Response::responseCodeAsText(300)); - $this->assertEquals('Bad Request', Zend_Http_Response::responseCodeAsText(400)); - $this->assertEquals('Internal Server Error', Zend_Http_Response::responseCodeAsText(500)); - - // Make sure that invalid codes return 'Unkown' - $this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText(600)); - - // Check HTTP/1.0 value for 302 - $this->assertEquals('Found', Zend_Http_Response::responseCodeAsText(302)); - $this->assertEquals('Moved Temporarily', Zend_Http_Response::responseCodeAsText(302, false)); - - // Check we get an array if no code is passed - $codes = Zend_Http_Response::responseCodeAsText(); - $this->assertType('array', $codes); - $this->assertEquals('OK', $codes[200]); - } - - public function testUnknownCode() - { - $response_str = $this->readResponse('response_unknown'); - $response = Zend_Http_Response::fromString($response_str); - - // Check that dynamically the message is parsed - $this->assertEquals(550, $response->getStatus(), 'Status is expected to be a non-standard 550'); - $this->assertEquals('Printer On Fire', $response->getMessage(), 'Message is expected to be extracted'); - - // Check that statically, an Unknown string is returned for the 550 code - $this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText($response_str)); - } - - public function testMultilineHeader() - { - $response = Zend_Http_Response::fromString($this->readResponse('response_multiline_header')); - - // Make sure we got the corrent no. of headers - $this->assertEquals(6, count($response->getHeaders()), 'Header count is expected to be 6'); - - // Check header integrity - $this->assertEquals('timeout=15, max=100', $response->getHeader('keep-alive')); - $this->assertEquals('text/html; charset=iso-8859-1', $response->getHeader('content-type')); - } - - public function testExceptInvalidChunkedBody() - { - try { - Zend_Http_Response::decodeChunkedBody($this->readResponse('response_deflate')); - $this->fail('An expected exception was not thrown'); - } catch (Zend_Http_Exception $e) { - // We are ok! - } - } - - public function testExtractorsOnInvalidString() - { - // Try with an empty string - $response_str = ''; - - $this->assertTrue(Zend_Http_Response::extractCode($response_str) === false); - $this->assertTrue(Zend_Http_Response::extractMessage($response_str) === false); - $this->assertTrue(Zend_Http_Response::extractVersion($response_str) === false); - $this->assertTrue(Zend_Http_Response::extractBody($response_str) === ''); - $this->assertTrue(Zend_Http_Response::extractHeaders($response_str) === array()); - } - - /** - * Make sure a response with some leading whitespace in the response body - * does not get modified (see ZF-1924) - * - */ - public function testLeadingWhitespaceBody() - { - $body = Zend_Http_Response::extractBody($this->readResponse('response_leadingws')); - $this->assertEquals($body, "\r\n\t \n\r\tx", 'Extracted body is not identical to expected body'); - } - - /** - * Helper function: read test response from file - * - * @param string $response - * @return string - */ - protected function readResponse($response) - { - return file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $response); - } -} \ No newline at end of file diff --git a/tests/Zend/Http/_files/body b/tests/Zend/Http/_files/body deleted file mode 100644 index b5406c451e8214919b942d4b0fad0bb7615e4f0b..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/body +++ /dev/null @@ -1,158 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta name="keywords" content="Paamayim Nekudotayim,Colon (punctuation),Dot,Dual grammatical number,Hebrew language,International Phonetic Alphabet,Name resolution,Niqqud,PHP,Scope (programming),Suffix" /> -<link rel="shortcut icon" href="/favicon.ico" /> -<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" /> - <title>Paamayim Nekudotayim - Wikipedia, the free encyclopedia</title> - <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins-1.5/monobook/main.css?9"; /*]]>*/</style> - <link rel="stylesheet" type="text/css" media="print" href="/skins-1.5/common/commonPrint.css" /> - <!--[if lt IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE50Fixes.css";</style><![endif]--> - <!--[if IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE55Fixes.css";</style><![endif]--> - <!--[if IE 6]><style type="text/css">@import "/skins-1.5/monobook/IE60Fixes.css";</style><![endif]--> - <!--[if IE 7]><style type="text/css">@import "/skins-1.5/monobook/IE70Fixes.css?1";</style><![endif]--> - <!--[if lt IE 7]><script type="text/javascript" src="/skins-1.5/common/IEFixes.js"></script> - <meta http-equiv="imagetoolbar" content="no" /><![endif]--> - <script type="text/javascript">var skin = 'monobook';var stylepath = '/skins-1.5';</script> - <script type="text/javascript" src="/skins-1.5/common/wikibits.js?1"><!-- wikibits js --></script> - <script type="text/javascript" src="/w/index.php?title=-&action=raw&gen=js"><!-- site js --></script> - <style type="text/css">/*<![CDATA[*/ -@import "/w/index.php?title=MediaWiki:Common.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=MediaWiki:Monobook.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=-&action=raw&gen=css&maxage=2678400"; -/*]]>*/</style> - <!-- Head Scripts --> - </head> -<body class="ns-0 ltr"> - <div id="globalWrapper"> - <div id="column-content"> - <div id="content"> - <a name="top" id="top"></a> - <div id="siteNotice"><div style="text-align:right; font-size:80%">Your <b><a href="http://wikimediafoundation.org/wiki/Fundraising" class="extiw" title="wikimedia:Fundraising">continued donations</a></b> keep Wikipedia running! </div> -</div> <h1 class="firstHeading">Paamayim Nekudotayim</h1> - <div id="bodyContent"> - <h3 id="siteSub">From Wikipedia, the free encyclopedia</h3> - <div id="contentSub"></div> - <div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content --> - <p>The <a href="/w/index.php?title=Scope_Resolution_Operator&action=edit" class="new" title="Scope Resolution Operator">Scope Resolution Operator</a> (::) in <a href="/wiki/PHP" title="PHP">PHP</a> is officially called <b>Paamayim Nekudotayim</b> (<a href="/wiki/International_Phonetic_Alphabet" title="International Phonetic Alphabet">IPA</a>: <span title="Pronunciation in IPA" class="IPA">[paÊ”amajim nÉ™kudotajim]</span>). It means 'twice <a href="/wiki/Colon_%28punctuation%29" title="Colon (punctuation)">colon</a>' or 'double colon' in <a href="/wiki/Hebrew_language" title="Hebrew language">Hebrew</a>.</p> -<p><br /></p> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=1" title="Edit section: Etymology">edit</a>]</div> -<p><a name="Etymology" id="Etymology"></a></p> -<h2>Etymology</h2> -<p><i>Nekudotayim</i> (× ×§×•×“×ª×™×™×) means 'colon'; it comes from <i>nekuda</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[nÉ™kuda]</span>), 'point' or '<a href="/wiki/Dot" title="Dot">dot</a>', and the <a href="/wiki/Dual_grammatical_number" title="Dual grammatical number">dual</a> <a href="/wiki/Suffix" title="Suffix">suffix</a> <i>ayim</i> (×™×™×-), hence 'two points'. Similarly, the word <i>paamayim</i> (פעמיי×) is derived by attaching the dual suffix to <i>paam</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[paÊ”am]</span>) ('one time' or 'once'), thus yielding 'twice'.</p> -<p>The name was introduced in the Zend Engine 0.5 used in PHP 3. Although it has been confusing to many developers, it is still being used in PHP 5, as in this sample error message:</p> -<pre> -Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in... -</pre> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=2" title="Edit section: See also">edit</a>]</div> -<p><a name="See_also" id="See_also"></a></p> -<h2>See also</h2> -<ul> -<li><a href="/wiki/PHP" title="PHP">PHP</a></li> -<li><a href="/wiki/Scope_%28programming%29" title="Scope (programming)">Scope (programming)</a></li> -<li><a href="/wiki/Name_resolution" title="Name resolution">Name resolution</a>, which includes a discussion of scope resolution</li> -<li><a href="/wiki/Niqqud" title="Niqqud">Niqqud</a> on the vowel points used in Hebrew writing</li> -</ul> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=3" title="Edit section: References">edit</a>]</div> -<p><a name="References" id="References"></a></p> -<h2>References</h2> -<ul> -<li><a href="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php" class="external autonumber" title="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php">[1]</a> PHP5 OOP Manual chapter that explains the Paamayim Nekudotayim</li> -</ul> - - -<!-- Saved in parser cache with key enwiki:pcache:idhash:1794050-0!1!0!0!!en!2 and timestamp 20060629024631 --> -<div class="printfooter"> -Retrieved from "<a href="http://en.wikipedia.org/wiki/Paamayim_Nekudotayim">http://en.wikipedia.org/wiki/Paamayim_Nekudotayim</a>"</div> - <div id="catlinks"><p class='catlinks'><a href="/w/index.php?title=Special:Categories&article=Paamayim_Nekudotayim" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="/wiki/Category:PHP_programming_language" title="Category:PHP programming language">PHP programming language</a></span> | <span dir='ltr'><a href="/wiki/Category:Hebrew_language" title="Category:Hebrew language">Hebrew language</a></span> | <span dir='ltr'><a href="/wiki/Category:Pages_containing_IPA" title="Category:Pages containing IPA">Pages containing IPA</a></span></p></div> <!-- end content --> - <div class="visualClear"></div> - </div> - </div> - </div> - <div id="column-one"> - <div id="p-cactions" class="portlet"> - <h5>Views</h5> - <ul> - <li id="ca-nstab-main" class="selected"><a href="/wiki/Paamayim_Nekudotayim">Article</a></li> - <li id="ca-talk"><a href="/wiki/Talk:Paamayim_Nekudotayim">Discussion</a></li> - <li id="ca-edit"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit">Edit this page</a></li> - <li id="ca-history"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=history">History</a></li> - </ul> - </div> - <div class="portlet" id="p-personal"> - <h5>Personal tools</h5> - <div class="pBody"> - <ul> - <li id="pt-login"><a href="/w/index.php?title=Special:Userlogin&returnto=Paamayim_Nekudotayim">Sign in / create account</a></li> - </ul> - </div> - </div> - <div class="portlet" id="p-logo"> - <a style="background-image: url(/images/wiki-en.png);" href="/wiki/Main_Page" title="Main Page"></a> - </div> - <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> - <div class='portlet' id='p-navigation'> - <h5>Navigation</h5> - <div class='pBody'> - <ul> - <li id="n-mainpage"><a href="/wiki/Main_Page">Main Page</a></li> - <li id="n-portal"><a href="/wiki/Wikipedia:Community_Portal">Community Portal</a></li> - <li id="n-Featured-articles"><a href="/wiki/Wikipedia:Featured_articles">Featured articles</a></li> - <li id="n-currentevents"><a href="/wiki/Portal:Current_events">Current events</a></li> - <li id="n-recentchanges"><a href="/wiki/Special:Recentchanges">Recent changes</a></li> - <li id="n-randompage"><a href="/wiki/Special:Random">Random article</a></li> - <li id="n-help"><a href="/wiki/Help:Contents">Help</a></li> - <li id="n-contact"><a href="/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> - <li id="n-sitesupport"><a href="http://wikimediafoundation.org/wiki/Fundraising#Donation_methods">Donations</a></li> - </ul> - </div> - </div> - <div id="p-search" class="portlet"> - <h5><label for="searchInput">Search</label></h5> - <div id="searchBody" class="pBody"> - <form action="/wiki/Special:Search" id="searchform"><div> - <input id="searchInput" name="search" type="text" accesskey="f" value="" /> - <input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" /> - <input type='submit' name="fulltext" class="searchButton" value="Search" /> - </div></form> - </div> - </div> - <div class="portlet" id="p-tb"> - <h5>Toolbox</h5> - <div class="pBody"> - <ul> - <li id="t-whatlinkshere"><a href="/w/index.php?title=Special:Whatlinkshere&target=Paamayim_Nekudotayim">What links here</a></li> - <li id="t-recentchangeslinked"><a href="/w/index.php?title=Special:Recentchangeslinked&target=Paamayim_Nekudotayim">Related changes</a></li> -<li id="t-upload"><a href="/wiki/Special:Upload">Upload file</a></li> -<li id="t-specialpages"><a href="/wiki/Special:Specialpages">Special pages</a></li> - <li id="t-print"><a href="/w/index.php?title=Paamayim_Nekudotayim&printable=yes">Printable version</a></li> <li id="t-permalink"><a href="/w/index.php?title=Paamayim_Nekudotayim&oldid=54444918">Permanent link</a></li><li id="t-cite"><a href="/w/index.php?title=Special:Cite&page=Paamayim_Nekudotayim&id=54444918">Cite this article</a></li> </ul> - </div> - </div> - <div id="p-lang" class="portlet"> - <h5>In other languages</h5> - <div class="pBody"> - <ul> - <li class="interwiki-de"><a href="http://de.wikipedia.org/wiki/Paamayim_Nekudotayim">Deutsch</a></li> - <li class="interwiki-fr"><a href="http://fr.wikipedia.org/wiki/Paamayim_Nekudotayim">Français</a></li> - </ul> - </div> - </div> - </div><!-- end of the left (by default at least) column --> - <div class="visualClear"></div> - <div id="footer"> - <div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/skins-1.5/common/images/poweredby_mediawiki_88x31.png" alt="MediaWiki" /></a></div> - <div id="f-copyrightico"><a href="http://wikimediafoundation.org/"><img src="/images/wikimedia-button.png" border="0" alt="Wikimedia Foundation"/></a></div> - <ul id="f-list"> - <li id="lastmod"> This page was last modified 00:52, 22 May 2006.</li> - <li id="copyright">All text is available under the terms of the <a class='internal' href="/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License" title="Wikipedia:Text of the GNU Free Documentation License">GNU Free Documentation License</a>. (See <b><a class='internal' href="/wiki/Wikipedia:Copyrights" title="Wikipedia:Copyrights">Copyrights</a></b> for details.) <br /> Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.<br /></li> - <li id="privacy"><a href="http://wikimediafoundation.org/wiki/Privacy_policy" title="wikimedia:Privacy policy">Privacy policy</a></li> - <li id="about"><a href="/wiki/Wikipedia:About" title="Wikipedia:About">About Wikipedia</a></li> - <li id="disclaimer"><a href="/wiki/Wikipedia:General_disclaimer" title="Wikipedia:General disclaimer">Disclaimers</a></li> - </ul> - </div> - <script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script> -</div> -<!-- Served by srv85 in 0.069 secs. --> -</body></html> - diff --git a/tests/Zend/Http/_files/response_302 b/tests/Zend/Http/_files/response_302 deleted file mode 100644 index e274f0aada166e932d98cb7178a31b291460f136..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Http/_files/response_302 and /dev/null differ diff --git a/tests/Zend/Http/_files/response_403_nomessage b/tests/Zend/Http/_files/response_403_nomessage deleted file mode 100644 index e917ade18921711fa8ca6a56d2ff3d31d5db1c7a..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_403_nomessage +++ /dev/null @@ -1,18 +0,0 @@ -HTTP/1.1 403 -Date: Fri, 17 Nov 2006 22:27:35 GMT -Server: Apache -Content-Length: 264 -Keep-Alive: timeout=15, max=99 -Connection: Keep-Alive -Content-Type: text/html; charset=iso-8859-1 - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<html><head> -<title>403 Forbidden</title> -</head><body> -<h1>Forbidden</h1> -<p>You don't have permission to access / -on this server.</p> -<hr> -<address>Apache Server at shahar.local Port 80</address> -</body></html> diff --git a/tests/Zend/Http/_files/response_404 b/tests/Zend/Http/_files/response_404 deleted file mode 100644 index 39caf7fbe3c556bc99817b6339e055f16cf8f304..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_404 +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 404 Not Found -Date: Fri, 17 Nov 2006 22:22:40 GMT -Server: Apache -Content-Length: 272 -Keep-Alive: timeout=15, max=100 -Connection: Keep-Alive -Content-Type: text/html; charset=iso-8859-1 - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<html><head> -<title>404 Not Found</title> -</head><body> -<h1>Not Found</h1> -<p>The requested URL /some/wrong/path was not found on this server.</p> -<hr> -<address>Apache Server at localhost Port 80</address> -</body></html> diff --git a/tests/Zend/Http/_files/response_500 b/tests/Zend/Http/_files/response_500 deleted file mode 100644 index c8b8a1c52eb565751103b4a67c7ee92a5b87e00d..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_500 +++ /dev/null @@ -1,24 +0,0 @@ -HTTP/1.1 500 Internal Server Error -Date: Sat, 18 Nov 2006 03:10:33 GMT -Server: Apache -Content-Length: 596 -Connection: close -Content-Type: text/html; charset=iso-8859-1 - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<html><head> -<title>500 Internal Server Error</title> -</head><body> -<h1>Internal Server Error</h1> -<p>The server encountered an internal error or -misconfiguration and was unable to complete -your request.</p> -<p>Please contact the server administrator, - root@localhost and inform them of the time the error occurred, -and anything you might have done that may have -caused the error.</p> -<p>More information about this error may be available -in the server error log.</p> -<hr> -<address>Apache Server at shahar.local Port 80</address> -</body></html> diff --git a/tests/Zend/Http/_files/response_chunked b/tests/Zend/Http/_files/response_chunked deleted file mode 100644 index d81506caed5bc1056dd47d25365bb22430631bdd..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_chunked +++ /dev/null @@ -1,191 +0,0 @@ -HTTP/1.1 200 OK -Date: Sun, 25 Jun 2006 19:55:19 GMT -Server: Apache -X-powered-by: PHP/5.1.4-pl3-gentoo -Connection: close -Transfer-encoding: chunked -Content-type: text/html - -1f98 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta name="keywords" content="Paamayim Nekudotayim,Colon (punctuation),Dot,Dual grammatical number,Hebrew language,International Phonetic Alphabet,Name resolution,Niqqud,PHP,Scope (programming),Suffix" /> -<link rel="shortcut icon" href="/favicon.ico" /> -<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" /> - <title>Paamayim Nekudotayim - Wikipedia, the free encyclopedia</title> - <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins-1.5/monobook/main.css?9"; /*]]>*/</style> - <link rel="stylesheet" type="text/css" media="print" href="/skins-1.5/common/commonPrint.css" /> - - <!--[if lt IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE50Fixes.css";</style><![endif]--> - <!--[if IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE55Fixes.css";</style><![endif]--> - <!--[if IE 6]><style type="text/css">@import "/skins-1.5/monobook/IE60Fixes.css";</style><![endif]--> - <!--[if IE 7]><style type="text/css">@import "/skins-1.5/monobook/IE70Fixes.css?1";</style><![endif]--> - <!--[if lt IE 7]><script type="text/javascript" src="/skins-1.5/common/IEFixes.js"></script> - <meta http-equiv="imagetoolbar" content="no" /><![endif]--> - <script type="text/javascript">var skin = 'monobook';var stylepath = '/skins-1.5';</script> - <script type="text/javascript" src="/skins-1.5/common/wikibits.js?1"><!-- wikibits js --></script> - <script type="text/javascript" src="/w/index.php?title=-&action=raw&gen=js"><!-- site js --></script> - - <style type="text/css">/*<![CDATA[*/ -@import "/w/index.php?title=MediaWiki:Common.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=MediaWiki:Monobook.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=-&action=raw&gen=css&maxage=2678400"; -/*]]>*/</style> - <!-- Head Scripts --> - </head> -<body class="ns-0 ltr"> - <div id="globalWrapper"> - <div id="column-content"> - <div id="content"> - <a name="top" id="top"></a> - <div id="siteNotice"><div style="text-align:right; font-size:80%">Your <b><a href="http://wikimediafoundation.org/wiki/Fundraising" class="extiw" title="wikimedia:Fundraising">continued donations</a></b> keep Wikipedia running! </div> - -</div> <h1 class="firstHeading">Paamayim Nekudotayim</h1> - <div id="bodyContent"> - <h3 id="siteSub">From Wikipedia, the free encyclopedia</h3> - <div id="contentSub"></div> - <div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content --> - - <p>The <a href="/w/index.php?title=Scope_Resolution_Operator&action=edit" class="new" title="Scope Resolution Operator">Scope Resolution Operator</a> (::) in <a href="/wiki/PHP" title="PHP">PHP</a> is officially called <b>Paamayim Nekudotayim</b> (<a href="/wiki/International_Phonetic_Alphabet" title="International Phonetic Alphabet">IPA</a>: <span title="Pronunciation in IPA" class="IPA">[paÊ”amajim nÉ™kudotajim]</span>). It means 'twice <a href="/wiki/Colon_%28punctuation%29" title="Colon (punctuation)">colon</a>' or 'double colon' in <a href="/wiki/Hebrew_language" title="Hebrew language">Hebrew</a>.</p> - -<p><br /></p> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=1" title="Edit section: Etymology">edit</a>]</div> -<p><a name="Etymology" id="Etymology"></a></p> -<h2>Etymology</h2> -<p><i>Nekudotayim</i> (× ×§×•×“×ª×™×™×) means 'colon'; it comes from <i>nekuda</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[nÉ™kuda]</span>), 'point' or '<a href="/wiki/Dot" title="Dot">dot</a>', and the <a href="/wiki/Dual_grammatical_number" title="Dual grammatical number">dual</a> <a href="/wiki/Suffix" title="Suffix">suffix</a> <i>ayim</i> (×™×™×-), hence 'two points'. Similarly, the word <i>paamayim</i> (פעמיי×) is derived by attaching the dual suffix to <i>paam</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[paÊ”am]</span>) ('one time' or 'once'), thus yielding 'twice'.</p> - -<p>The name was introduced in the Zend Engine 0.5 used in PHP 3. Although it has been confusing to many developers, it is still being used in PHP 5, as in this sample error message:</p> -<pre> -Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in... -</pre> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=2" title="Edit section: See also">edit</a>]</div> -<p><a name="See_also" id="See_also"></a></p> -<h2>See also</h2> -<ul> -<li><a href="/wiki/PHP" title="PHP">PHP</a></li> -<li><a href="/wiki/Scope_%28programming%29" title="Scope (programming)">Scope (programming)</a></li> - -<li><a href="/wiki/Name_resolution" title="Name resolution">Name resolution</a>, which includes a discussion of scope resolution</li> -<li><a href="/wiki/Niqqud" title="Niqqud">Niqqud</a> on the vowel points used in Hebrew writing</li> -</ul> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=3" title="Edit section: References">edit</a>]</div> -<p><a name="References" id="References"></a></p> -<h2>References</h2> -<ul> -<li><a href="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php" class="external autonumber" title="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php">[1]</a> PHP5 OOP Manual chapter that explains the Paamayim Nekudotayim</li> - -</ul> - - -<!-- Saved in parser cache with key enwiki:pcache:idhash:1794050-0!1!0!0!!en!2 and timestamp 20060614233233 --> -<div class="printfooter"> -Retrieved from "<a href="http://en.wikipedia.org/wiki/Paamayim_Nekudotayim">http://en.wikipedia.org/wiki/Paamayim_Nekudotayim</a>"</div> - <div id="catlinks"><p class='catlinks'><a href="/w/index.php?title=Special:Categories&article=Paamayim_Nekudotayim" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="/wiki/Category:PHP_programming_language" title="Category:PHP programming language">PHP programming language</a></span> | <span dir='ltr'><a href="/wiki/Category:Hebrew_language" title="Category:Hebrew language">Hebrew language</a></span> | <span dir='ltr'><a href="/wiki/Category:Pages_containing_IPA" title="Category:Pages containing IPA">Pages containing IPA</a></span></p></div> <!-- end content --> - - <div class="visualClear"></div> - </div> - </div> - </div> - <div id="column-one"> - <div id="p-cactions" class="portlet"> - <h5>Views</h5> - <ul> - - <li id="ca-nstab-main" class="selected"><a href="/wiki/Paamayim_Nekudotayim">Article</a></li> - <li id="ca-talk"><a href="/wiki/Talk:Paamayim_Nekudotayim">Discussion</a></li> - <li id="ca-edit"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit">Edit this page</a></li> - <li id="ca-history"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=history">History</a></li> - </ul> - </div> - <div class="portlet" id="p-personal"> - - <h5>Personal tools</h5> - <div class="pBody"> - <ul> - <li id="pt-login"><a href="/w/index.php?title=Special:Userlogin&returnto=Paamayim_Nekudotayim">Sign in / create account</a></li> - </ul> - </div> - </div> - <div class="portlet" id="p-logo"> - - <a style="background-image: url(/images/wiki-en.png);" href="/wiki/Main_Page" title="Main Page"></a> - </div> - <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> - <div class='portlet' id='p-navigation'> - <h5>Navigation</h5> - <div class='pBody'> - <ul> - <li id="n-mainpage"><a href="/wiki/Main_Page">Main Page</a></li> - - <li id="n-portal"><a href="/wiki/Wikipedia:Community_Portal">Community Portal</a></li> - <li id="n-Featured-articles"><a href="/wiki/Wikipedia:Featured_articles">Featured ar -e78 -ticles</a></li> - <li id="n-currentevents"><a href="/wiki/Current_events">Current events</a></li> - <li id="n-recentchanges"><a href="/wiki/Special:Recentchanges">Recent changes</a></li> - <li id="n-randompage"><a href="/wiki/Special:Random">Random article</a></li> - <li id="n-help"><a href="/wiki/Help:Contents">Help</a></li> - - <li id="n-contact"><a href="/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> - <li id="n-sitesupport"><a href="http://wikimediafoundation.org/wiki/Fundraising#Donation_methods">Donations</a></li> - </ul> - </div> - </div> - <div id="p-search" class="portlet"> - <h5><label for="searchInput">Search</label></h5> - - <div id="searchBody" class="pBody"> - <form action="/wiki/Special:Search" id="searchform"><div> - <input id="searchInput" name="search" type="text" accesskey="f" value="" /> - <input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" /> - <input type='submit' name="fulltext" class="searchButton" value="Search" /> - </div></form> - </div> - </div> - <div class="portlet" id="p-tb"> - - <h5>Toolbox</h5> - <div class="pBody"> - <ul> - <li id="t-whatlinkshere"><a href="/w/index.php?title=Special:Whatlinkshere&target=Paamayim_Nekudotayim">What links here</a></li> - <li id="t-recentchangeslinked"><a href="/w/index.php?title=Special:Recentchangeslinked&target=Paamayim_Nekudotayim">Related changes</a></li> -<li id="t-upload"><a href="/wiki/Special:Upload">Upload file</a></li> -<li id="t-specialpages"><a href="/wiki/Special:Specialpages">Special pages</a></li> - - <li id="t-print"><a href="/w/index.php?title=Paamayim_Nekudotayim&printable=yes">Printable version</a></li> <li id="t-permalink"><a href="/w/index.php?title=Paamayim_Nekudotayim&oldid=54444918">Permanent link</a></li><li id="t-cite"><a href="/w/index.php?title=Special:Cite&page=Paamayim_Nekudotayim&id=54444918">Cite this article</a></li> </ul> - </div> - </div> - <div id="p-lang" class="portlet"> - <h5>In other languages</h5> - <div class="pBody"> - - <ul> - <li class="interwiki-de"><a href="http://de.wikipedia.org/wiki/Paamayim_Nekudotayim">Deutsch</a></li> - <li class="interwiki-fr"><a href="http://fr.wikipedia.org/wiki/Paamayim_Nekudotayim">Français</a></li> - </ul> - </div> - </div> - </div><!-- end of the left (by default at least) column --> - <div class="visualClear"></div> - - <div id="footer"> - <div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/skins-1.5/common/images/poweredby_mediawiki_88x31.png" alt="MediaWiki" /></a></div> - <div id="f-copyrightico"><a href="http://wikimediafoundation.org/"><img src="/images/wikimedia-button.png" border="0" alt="Wikimedia Foundation"/></a></div> - <ul id="f-list"> - <li id="lastmod"> This page was last modified 00:52, 22 May 2006.</li> - <li id="copyright">All text is available under the terms of the <a class='internal' href="/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License">GNU Free Documentation License</a>. (See <b><a class='internal' href="/wiki/Wikipedia:Copyrights">Copyrights</a></b> for details.) <br /> Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.<br /></li> - - <li id="privacy"><a href="http://wikimediafoundation.org/wiki/Privacy_policy" title="wikimedia:Privacy policy">Privacy policy</a></li> - <li id="about"><a href="/wiki/Wikipedia:About" title="Wikipedia:About">About Wikipedia</a></li> - <li id="disclaimer"><a href="/wiki/Wikipedia:General_disclaimer" title="Wikipedia:General disclaimer">Disclaimers</a></li> - </ul> - </div> - <script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script> -</div> - -</body></html> - -0 - diff --git a/tests/Zend/Http/_files/response_crlf b/tests/Zend/Http/_files/response_crlf deleted file mode 100644 index 2fb31035077e78a5e0a67e9ef03656a6f51847b3..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_crlf +++ /dev/null @@ -1,174 +0,0 @@ -HTTP/1.0 200 OK -Date: Sun, 02 Jul 2006 20:17:26 GMT -Server: Apache -X-powered-by: PHP/5.1.2 -Content-language: en -Etag: W/"enwiki:pcache:idhash:1794050-0!1!0!0!!en!2--20060614224938" -Vary: Accept-Encoding,Cookie -Cache-control: private, s-maxage=0, max-age=0, must-revalidate -Last-modified: Wed, 14 Jun 2006 22:49:38 GMT -Content-type: text/html; charset=utf-8 -X-cache: MISS from srv8.wikimedia.org -X-cache: MISS from iris.knams.wikimedia.org -X-cache-lookup: MISS from srv8.wikimedia.org:80 -X-cache-lookup: MISS from iris.knams.wikimedia.org:80 -Connection: close - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta name="keywords" content="Paamayim Nekudotayim,Colon (punctuation),Dot,Dual grammatical number,Hebrew language,International Phonetic Alphabet,Name resolution,Niqqud,PHP,Scope (programming),Suffix" /> -<link rel="shortcut icon" href="/favicon.ico" /> -<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" /> - <title>Paamayim Nekudotayim - Wikipedia, the free encyclopedia</title> - <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins-1.5/monobook/main.css?9"; /*]]>*/</style> - <link rel="stylesheet" type="text/css" media="print" href="/skins-1.5/common/commonPrint.css" /> - <!--[if lt IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE50Fixes.css";</style><![endif]--> - <!--[if IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE55Fixes.css";</style><![endif]--> - <!--[if IE 6]><style type="text/css">@import "/skins-1.5/monobook/IE60Fixes.css";</style><![endif]--> - <!--[if IE 7]><style type="text/css">@import "/skins-1.5/monobook/IE70Fixes.css?1";</style><![endif]--> - <!--[if lt IE 7]><script type="text/javascript" src="/skins-1.5/common/IEFixes.js"></script> - <meta http-equiv="imagetoolbar" content="no" /><![endif]--> - <script type="text/javascript">var skin = 'monobook';var stylepath = '/skins-1.5';</script> - <script type="text/javascript" src="/skins-1.5/common/wikibits.js?1"><!-- wikibits js --></script> - <script type="text/javascript" src="/w/index.php?title=-&action=raw&gen=js"><!-- site js --></script> - <style type="text/css">/*<![CDATA[*/ -@import "/w/index.php?title=MediaWiki:Common.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=MediaWiki:Monobook.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=-&action=raw&gen=css&maxage=2678400"; -/*]]>*/</style> - <!-- Head Scripts --> - </head> -<body class="ns-0 ltr"> - <div id="globalWrapper"> - <div id="column-content"> - <div id="content"> - <a name="top" id="top"></a> - <div id="siteNotice"><div style="text-align:right; font-size:80%">Your <b><a href="http://wikimediafoundation.org/wiki/Fundraising" class="extiw" title="wikimedia:Fundraising">continued donations</a></b> keep Wikipedia running! </div> -</div> <h1 class="firstHeading">Paamayim Nekudotayim</h1> - <div id="bodyContent"> - <h3 id="siteSub">From Wikipedia, the free encyclopedia</h3> - <div id="contentSub"></div> - <div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content --> - <p>The <a href="/w/index.php?title=Scope_Resolution_Operator&action=edit" class="new" title="Scope Resolution Operator">Scope Resolution Operator</a> (::) in <a href="/wiki/PHP" title="PHP">PHP</a> is officially called <b>Paamayim Nekudotayim</b> (<a href="/wiki/International_Phonetic_Alphabet" title="International Phonetic Alphabet">IPA</a>: <span title="Pronunciation in IPA" class="IPA">[paÊ”amajim nÉ™kudotajim]</span>). It means 'twice <a href="/wiki/Colon_%28punctuation%29" title="Colon (punctuation)">colon</a>' or 'double colon' in <a href="/wiki/Hebrew_language" title="Hebrew language">Hebrew</a>.</p> -<p><br /></p> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=1" title="Edit section: Etymology">edit</a>]</div> -<p><a name="Etymology" id="Etymology"></a></p> -<h2>Etymology</h2> -<p><i>Nekudotayim</i> (× ×§×•×“×ª×™×™×) means 'colon'; it comes from <i>nekuda</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[nÉ™kuda]</span>), 'point' or '<a href="/wiki/Dot" title="Dot">dot</a>', and the <a href="/wiki/Dual_grammatical_number" title="Dual grammatical number">dual</a> <a href="/wiki/Suffix" title="Suffix">suffix</a> <i>ayim</i> (×™×™×-), hence 'two points'. Similarly, the word <i>paamayim</i> (פעמיי×) is derived by attaching the dual suffix to <i>paam</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[paÊ”am]</span>) ('one time' or 'once'), thus yielding 'twice'.</p> -<p>The name was introduced in the Zend Engine 0.5 used in PHP 3. Although it has been confusing to many developers, it is still being used in PHP 5, as in this sample error message:</p> -<pre> -Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in... -</pre> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=2" title="Edit section: See also">edit</a>]</div> -<p><a name="See_also" id="See_also"></a></p> -<h2>See also</h2> -<ul> -<li><a href="/wiki/PHP" title="PHP">PHP</a></li> -<li><a href="/wiki/Scope_%28programming%29" title="Scope (programming)">Scope (programming)</a></li> -<li><a href="/wiki/Name_resolution" title="Name resolution">Name resolution</a>, which includes a discussion of scope resolution</li> -<li><a href="/wiki/Niqqud" title="Niqqud">Niqqud</a> on the vowel points used in Hebrew writing</li> -</ul> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=3" title="Edit section: References">edit</a>]</div> -<p><a name="References" id="References"></a></p> -<h2>References</h2> -<ul> -<li><a href="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php" class="external autonumber" title="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php">[1]</a> PHP5 OOP Manual chapter that explains the Paamayim Nekudotayim</li> -</ul> - - -<!-- Saved in parser cache with key enwiki:pcache:idhash:1794050-0!1!0!0!!en!2 and timestamp 20060629024631 --> -<div class="printfooter"> -Retrieved from "<a href="http://en.wikipedia.org/wiki/Paamayim_Nekudotayim">http://en.wikipedia.org/wiki/Paamayim_Nekudotayim</a>"</div> - <div id="catlinks"><p class='catlinks'><a href="/w/index.php?title=Special:Categories&article=Paamayim_Nekudotayim" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="/wiki/Category:PHP_programming_language" title="Category:PHP programming language">PHP programming language</a></span> | <span dir='ltr'><a href="/wiki/Category:Hebrew_language" title="Category:Hebrew language">Hebrew language</a></span> | <span dir='ltr'><a href="/wiki/Category:Pages_containing_IPA" title="Category:Pages containing IPA">Pages containing IPA</a></span></p></div> <!-- end content --> - <div class="visualClear"></div> - </div> - </div> - </div> - <div id="column-one"> - <div id="p-cactions" class="portlet"> - <h5>Views</h5> - <ul> - <li id="ca-nstab-main" class="selected"><a href="/wiki/Paamayim_Nekudotayim">Article</a></li> - <li id="ca-talk"><a href="/wiki/Talk:Paamayim_Nekudotayim">Discussion</a></li> - <li id="ca-edit"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit">Edit this page</a></li> - <li id="ca-history"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=history">History</a></li> - </ul> - </div> - <div class="portlet" id="p-personal"> - <h5>Personal tools</h5> - <div class="pBody"> - <ul> - <li id="pt-login"><a href="/w/index.php?title=Special:Userlogin&returnto=Paamayim_Nekudotayim">Sign in / create account</a></li> - </ul> - </div> - </div> - <div class="portlet" id="p-logo"> - <a style="background-image: url(/images/wiki-en.png);" href="/wiki/Main_Page" title="Main Page"></a> - </div> - <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> - <div class='portlet' id='p-navigation'> - <h5>Navigation</h5> - <div class='pBody'> - <ul> - <li id="n-mainpage"><a href="/wiki/Main_Page">Main Page</a></li> - <li id="n-portal"><a href="/wiki/Wikipedia:Community_Portal">Community Portal</a></li> - <li id="n-Featured-articles"><a href="/wiki/Wikipedia:Featured_articles">Featured articles</a></li> - <li id="n-currentevents"><a href="/wiki/Portal:Current_events">Current events</a></li> - <li id="n-recentchanges"><a href="/wiki/Special:Recentchanges">Recent changes</a></li> - <li id="n-randompage"><a href="/wiki/Special:Random">Random article</a></li> - <li id="n-help"><a href="/wiki/Help:Contents">Help</a></li> - <li id="n-contact"><a href="/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> - <li id="n-sitesupport"><a href="http://wikimediafoundation.org/wiki/Fundraising#Donation_methods">Donations</a></li> - </ul> - </div> - </div> - <div id="p-search" class="portlet"> - <h5><label for="searchInput">Search</label></h5> - <div id="searchBody" class="pBody"> - <form action="/wiki/Special:Search" id="searchform"><div> - <input id="searchInput" name="search" type="text" accesskey="f" value="" /> - <input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" /> - <input type='submit' name="fulltext" class="searchButton" value="Search" /> - </div></form> - </div> - </div> - <div class="portlet" id="p-tb"> - <h5>Toolbox</h5> - <div class="pBody"> - <ul> - <li id="t-whatlinkshere"><a href="/w/index.php?title=Special:Whatlinkshere&target=Paamayim_Nekudotayim">What links here</a></li> - <li id="t-recentchangeslinked"><a href="/w/index.php?title=Special:Recentchangeslinked&target=Paamayim_Nekudotayim">Related changes</a></li> -<li id="t-upload"><a href="/wiki/Special:Upload">Upload file</a></li> -<li id="t-specialpages"><a href="/wiki/Special:Specialpages">Special pages</a></li> - <li id="t-print"><a href="/w/index.php?title=Paamayim_Nekudotayim&printable=yes">Printable version</a></li> <li id="t-permalink"><a href="/w/index.php?title=Paamayim_Nekudotayim&oldid=54444918">Permanent link</a></li><li id="t-cite"><a href="/w/index.php?title=Special:Cite&page=Paamayim_Nekudotayim&id=54444918">Cite this article</a></li> </ul> - </div> - </div> - <div id="p-lang" class="portlet"> - <h5>In other languages</h5> - <div class="pBody"> - <ul> - <li class="interwiki-de"><a href="http://de.wikipedia.org/wiki/Paamayim_Nekudotayim">Deutsch</a></li> - <li class="interwiki-fr"><a href="http://fr.wikipedia.org/wiki/Paamayim_Nekudotayim">Français</a></li> - </ul> - </div> - </div> - </div><!-- end of the left (by default at least) column --> - <div class="visualClear"></div> - <div id="footer"> - <div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/skins-1.5/common/images/poweredby_mediawiki_88x31.png" alt="MediaWiki" /></a></div> - <div id="f-copyrightico"><a href="http://wikimediafoundation.org/"><img src="/images/wikimedia-button.png" border="0" alt="Wikimedia Foundation"/></a></div> - <ul id="f-list"> - <li id="lastmod"> This page was last modified 00:52, 22 May 2006.</li> - <li id="copyright">All text is available under the terms of the <a class='internal' href="/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License" title="Wikipedia:Text of the GNU Free Documentation License">GNU Free Documentation License</a>. (See <b><a class='internal' href="/wiki/Wikipedia:Copyrights" title="Wikipedia:Copyrights">Copyrights</a></b> for details.) <br /> Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.<br /></li> - <li id="privacy"><a href="http://wikimediafoundation.org/wiki/Privacy_policy" title="wikimedia:Privacy policy">Privacy policy</a></li> - <li id="about"><a href="/wiki/Wikipedia:About" title="Wikipedia:About">About Wikipedia</a></li> - <li id="disclaimer"><a href="/wiki/Wikipedia:General_disclaimer" title="Wikipedia:General disclaimer">Disclaimers</a></li> - </ul> - </div> - <script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script> -</div> -<!-- Served by srv85 in 0.069 secs. --> -</body></html> - diff --git a/tests/Zend/Http/_files/response_deflate b/tests/Zend/Http/_files/response_deflate deleted file mode 100644 index 4295149294962004c14512bdfc95f5ef9e63ef3a..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Http/_files/response_deflate and /dev/null differ diff --git a/tests/Zend/Http/_files/response_gzip b/tests/Zend/Http/_files/response_gzip deleted file mode 100644 index 8c5575030304ab8dd152a387c6b2b87e4840a63f..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Http/_files/response_gzip and /dev/null differ diff --git a/tests/Zend/Http/_files/response_leadingws b/tests/Zend/Http/_files/response_leadingws deleted file mode 100644 index 229698fd235d9437ea60289aa3cdd8577c94f86f..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_leadingws +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Sun, 09 Sep 2007 12:52:56 GMT -Server: Apache -Last-Modified: Sun, 09 Sep 2007 12:51:35 GMT -ETag: "b7aa5e-9-550283c0" -Accept-Ranges: bytes -Content-Length: 9 -Vary: User-Agent -Keep-Alive: timeout=15, max=100 -Connection: Keep-Alive -Content-Type: text/plain - - - - x \ No newline at end of file diff --git a/tests/Zend/Http/_files/response_lfonly b/tests/Zend/Http/_files/response_lfonly deleted file mode 100644 index fe895f7f4ed32848520cbc7dafd9820bab5c56cb..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_lfonly +++ /dev/null @@ -1,174 +0,0 @@ -HTTP/1.0 200 OK -Date: Sun, 02 Jul 2006 20:17:26 GMT -Server: Apache -X-powered-by: PHP/5.1.2 -Content-language: en -Etag: W/"enwiki:pcache:idhash:1794050-0!1!0!0!!en!2--20060614224938" -Vary: Accept-Encoding,Cookie -Cache-control: private, s-maxage=0, max-age=0, must-revalidate -Last-modified: Wed, 14 Jun 2006 22:49:38 GMT -Content-type: text/html; charset=utf-8 -X-cache: MISS from srv8.wikimedia.org -X-cache: MISS from iris.knams.wikimedia.org -X-cache-lookup: MISS from srv8.wikimedia.org:80 -X-cache-lookup: MISS from iris.knams.wikimedia.org:80 -Connection: close - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta name="keywords" content="Paamayim Nekudotayim,Colon (punctuation),Dot,Dual grammatical number,Hebrew language,International Phonetic Alphabet,Name resolution,Niqqud,PHP,Scope (programming),Suffix" /> -<link rel="shortcut icon" href="/favicon.ico" /> -<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" /> - <title>Paamayim Nekudotayim - Wikipedia, the free encyclopedia</title> - <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins-1.5/monobook/main.css?9"; /*]]>*/</style> - <link rel="stylesheet" type="text/css" media="print" href="/skins-1.5/common/commonPrint.css" /> - <!--[if lt IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE50Fixes.css";</style><![endif]--> - <!--[if IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE55Fixes.css";</style><![endif]--> - <!--[if IE 6]><style type="text/css">@import "/skins-1.5/monobook/IE60Fixes.css";</style><![endif]--> - <!--[if IE 7]><style type="text/css">@import "/skins-1.5/monobook/IE70Fixes.css?1";</style><![endif]--> - <!--[if lt IE 7]><script type="text/javascript" src="/skins-1.5/common/IEFixes.js"></script> - <meta http-equiv="imagetoolbar" content="no" /><![endif]--> - <script type="text/javascript">var skin = 'monobook';var stylepath = '/skins-1.5';</script> - <script type="text/javascript" src="/skins-1.5/common/wikibits.js?1"><!-- wikibits js --></script> - <script type="text/javascript" src="/w/index.php?title=-&action=raw&gen=js"><!-- site js --></script> - <style type="text/css">/*<![CDATA[*/ -@import "/w/index.php?title=MediaWiki:Common.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=MediaWiki:Monobook.css&action=raw&ctype=text/css&smaxage=2678400"; -@import "/w/index.php?title=-&action=raw&gen=css&maxage=2678400"; -/*]]>*/</style> - <!-- Head Scripts --> - </head> -<body class="ns-0 ltr"> - <div id="globalWrapper"> - <div id="column-content"> - <div id="content"> - <a name="top" id="top"></a> - <div id="siteNotice"><div style="text-align:right; font-size:80%">Your <b><a href="http://wikimediafoundation.org/wiki/Fundraising" class="extiw" title="wikimedia:Fundraising">continued donations</a></b> keep Wikipedia running! </div> -</div> <h1 class="firstHeading">Paamayim Nekudotayim</h1> - <div id="bodyContent"> - <h3 id="siteSub">From Wikipedia, the free encyclopedia</h3> - <div id="contentSub"></div> - <div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content --> - <p>The <a href="/w/index.php?title=Scope_Resolution_Operator&action=edit" class="new" title="Scope Resolution Operator">Scope Resolution Operator</a> (::) in <a href="/wiki/PHP" title="PHP">PHP</a> is officially called <b>Paamayim Nekudotayim</b> (<a href="/wiki/International_Phonetic_Alphabet" title="International Phonetic Alphabet">IPA</a>: <span title="Pronunciation in IPA" class="IPA">[paÊ”amajim nÉ™kudotajim]</span>). It means 'twice <a href="/wiki/Colon_%28punctuation%29" title="Colon (punctuation)">colon</a>' or 'double colon' in <a href="/wiki/Hebrew_language" title="Hebrew language">Hebrew</a>.</p> -<p><br /></p> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=1" title="Edit section: Etymology">edit</a>]</div> -<p><a name="Etymology" id="Etymology"></a></p> -<h2>Etymology</h2> -<p><i>Nekudotayim</i> (× ×§×•×“×ª×™×™×) means 'colon'; it comes from <i>nekuda</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[nÉ™kuda]</span>), 'point' or '<a href="/wiki/Dot" title="Dot">dot</a>', and the <a href="/wiki/Dual_grammatical_number" title="Dual grammatical number">dual</a> <a href="/wiki/Suffix" title="Suffix">suffix</a> <i>ayim</i> (×™×™×-), hence 'two points'. Similarly, the word <i>paamayim</i> (פעמיי×) is derived by attaching the dual suffix to <i>paam</i> (IPA: <span title="Pronunciation in IPA" class="IPA">[paÊ”am]</span>) ('one time' or 'once'), thus yielding 'twice'.</p> -<p>The name was introduced in the Zend Engine 0.5 used in PHP 3. Although it has been confusing to many developers, it is still being used in PHP 5, as in this sample error message:</p> -<pre> -Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in... -</pre> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=2" title="Edit section: See also">edit</a>]</div> -<p><a name="See_also" id="See_also"></a></p> -<h2>See also</h2> -<ul> -<li><a href="/wiki/PHP" title="PHP">PHP</a></li> -<li><a href="/wiki/Scope_%28programming%29" title="Scope (programming)">Scope (programming)</a></li> -<li><a href="/wiki/Name_resolution" title="Name resolution">Name resolution</a>, which includes a discussion of scope resolution</li> -<li><a href="/wiki/Niqqud" title="Niqqud">Niqqud</a> on the vowel points used in Hebrew writing</li> -</ul> -<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit&section=3" title="Edit section: References">edit</a>]</div> -<p><a name="References" id="References"></a></p> -<h2>References</h2> -<ul> -<li><a href="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php" class="external autonumber" title="http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php">[1]</a> PHP5 OOP Manual chapter that explains the Paamayim Nekudotayim</li> -</ul> - - -<!-- Saved in parser cache with key enwiki:pcache:idhash:1794050-0!1!0!0!!en!2 and timestamp 20060629024631 --> -<div class="printfooter"> -Retrieved from "<a href="http://en.wikipedia.org/wiki/Paamayim_Nekudotayim">http://en.wikipedia.org/wiki/Paamayim_Nekudotayim</a>"</div> - <div id="catlinks"><p class='catlinks'><a href="/w/index.php?title=Special:Categories&article=Paamayim_Nekudotayim" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="/wiki/Category:PHP_programming_language" title="Category:PHP programming language">PHP programming language</a></span> | <span dir='ltr'><a href="/wiki/Category:Hebrew_language" title="Category:Hebrew language">Hebrew language</a></span> | <span dir='ltr'><a href="/wiki/Category:Pages_containing_IPA" title="Category:Pages containing IPA">Pages containing IPA</a></span></p></div> <!-- end content --> - <div class="visualClear"></div> - </div> - </div> - </div> - <div id="column-one"> - <div id="p-cactions" class="portlet"> - <h5>Views</h5> - <ul> - <li id="ca-nstab-main" class="selected"><a href="/wiki/Paamayim_Nekudotayim">Article</a></li> - <li id="ca-talk"><a href="/wiki/Talk:Paamayim_Nekudotayim">Discussion</a></li> - <li id="ca-edit"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=edit">Edit this page</a></li> - <li id="ca-history"><a href="/w/index.php?title=Paamayim_Nekudotayim&action=history">History</a></li> - </ul> - </div> - <div class="portlet" id="p-personal"> - <h5>Personal tools</h5> - <div class="pBody"> - <ul> - <li id="pt-login"><a href="/w/index.php?title=Special:Userlogin&returnto=Paamayim_Nekudotayim">Sign in / create account</a></li> - </ul> - </div> - </div> - <div class="portlet" id="p-logo"> - <a style="background-image: url(/images/wiki-en.png);" href="/wiki/Main_Page" title="Main Page"></a> - </div> - <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> - <div class='portlet' id='p-navigation'> - <h5>Navigation</h5> - <div class='pBody'> - <ul> - <li id="n-mainpage"><a href="/wiki/Main_Page">Main Page</a></li> - <li id="n-portal"><a href="/wiki/Wikipedia:Community_Portal">Community Portal</a></li> - <li id="n-Featured-articles"><a href="/wiki/Wikipedia:Featured_articles">Featured articles</a></li> - <li id="n-currentevents"><a href="/wiki/Portal:Current_events">Current events</a></li> - <li id="n-recentchanges"><a href="/wiki/Special:Recentchanges">Recent changes</a></li> - <li id="n-randompage"><a href="/wiki/Special:Random">Random article</a></li> - <li id="n-help"><a href="/wiki/Help:Contents">Help</a></li> - <li id="n-contact"><a href="/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> - <li id="n-sitesupport"><a href="http://wikimediafoundation.org/wiki/Fundraising#Donation_methods">Donations</a></li> - </ul> - </div> - </div> - <div id="p-search" class="portlet"> - <h5><label for="searchInput">Search</label></h5> - <div id="searchBody" class="pBody"> - <form action="/wiki/Special:Search" id="searchform"><div> - <input id="searchInput" name="search" type="text" accesskey="f" value="" /> - <input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" /> - <input type='submit' name="fulltext" class="searchButton" value="Search" /> - </div></form> - </div> - </div> - <div class="portlet" id="p-tb"> - <h5>Toolbox</h5> - <div class="pBody"> - <ul> - <li id="t-whatlinkshere"><a href="/w/index.php?title=Special:Whatlinkshere&target=Paamayim_Nekudotayim">What links here</a></li> - <li id="t-recentchangeslinked"><a href="/w/index.php?title=Special:Recentchangeslinked&target=Paamayim_Nekudotayim">Related changes</a></li> -<li id="t-upload"><a href="/wiki/Special:Upload">Upload file</a></li> -<li id="t-specialpages"><a href="/wiki/Special:Specialpages">Special pages</a></li> - <li id="t-print"><a href="/w/index.php?title=Paamayim_Nekudotayim&printable=yes">Printable version</a></li> <li id="t-permalink"><a href="/w/index.php?title=Paamayim_Nekudotayim&oldid=54444918">Permanent link</a></li><li id="t-cite"><a href="/w/index.php?title=Special:Cite&page=Paamayim_Nekudotayim&id=54444918">Cite this article</a></li> </ul> - </div> - </div> - <div id="p-lang" class="portlet"> - <h5>In other languages</h5> - <div class="pBody"> - <ul> - <li class="interwiki-de"><a href="http://de.wikipedia.org/wiki/Paamayim_Nekudotayim">Deutsch</a></li> - <li class="interwiki-fr"><a href="http://fr.wikipedia.org/wiki/Paamayim_Nekudotayim">Français</a></li> - </ul> - </div> - </div> - </div><!-- end of the left (by default at least) column --> - <div class="visualClear"></div> - <div id="footer"> - <div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/skins-1.5/common/images/poweredby_mediawiki_88x31.png" alt="MediaWiki" /></a></div> - <div id="f-copyrightico"><a href="http://wikimediafoundation.org/"><img src="/images/wikimedia-button.png" border="0" alt="Wikimedia Foundation"/></a></div> - <ul id="f-list"> - <li id="lastmod"> This page was last modified 00:52, 22 May 2006.</li> - <li id="copyright">All text is available under the terms of the <a class='internal' href="/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License" title="Wikipedia:Text of the GNU Free Documentation License">GNU Free Documentation License</a>. (See <b><a class='internal' href="/wiki/Wikipedia:Copyrights" title="Wikipedia:Copyrights">Copyrights</a></b> for details.) <br /> Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.<br /></li> - <li id="privacy"><a href="http://wikimediafoundation.org/wiki/Privacy_policy" title="wikimedia:Privacy policy">Privacy policy</a></li> - <li id="about"><a href="/wiki/Wikipedia:About" title="Wikipedia:About">About Wikipedia</a></li> - <li id="disclaimer"><a href="/wiki/Wikipedia:General_disclaimer" title="Wikipedia:General disclaimer">Disclaimers</a></li> - </ul> - </div> - <script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script> -</div> -<!-- Served by srv85 in 0.069 secs. --> -</body></html> - diff --git a/tests/Zend/Http/_files/response_multiline_header b/tests/Zend/Http/_files/response_multiline_header deleted file mode 100644 index 01c586104e43b72fea13829bbd8b70294ae2a4d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_multiline_header +++ /dev/null @@ -1,19 +0,0 @@ -HTTP/1.1 404 Not Found -Date: Fri, 17 Nov 2006 22:22:40 GMT -Server: Apache -Content-Length: 272 -Keep-Alive: timeout=15, - max=100 -Connection: Keep-Alive -Content-Type: text/html; - charset=iso-8859-1 - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<html><head> -<title>404 Not Found</title> -</head><body> -<h1>Not Found</h1> -<p>The requested URL /some/wrong/path was not found on this server.</p> -<hr> -<address>Apache Server at localhost Port 80</address> -</body></html> diff --git a/tests/Zend/Http/_files/response_unknown b/tests/Zend/Http/_files/response_unknown deleted file mode 100644 index fb5454edd12d2dcd8b3ddd552098fc9bc6633c33..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_unknown +++ /dev/null @@ -1,14 +0,0 @@ -HTTP/1.1 550 Printer On Fire -Server: Apache -Content-Length: 264 -Content-Type: text/html; charset=iso-8859-1 - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<html><head> -<title>550 Printer On Fire</title> -</head><body> -<h1>Help! Help!</h1> -<p>Please call the fire brigade</p> -<hr> -<address>Apache Server at shahar.local Port 80</address> -</body></html> diff --git a/tests/Zend/Http/_files/response_with_cookies b/tests/Zend/Http/_files/response_with_cookies deleted file mode 100644 index 6d550197e5de66efcfd3aec8cf9c78ad1d464181..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_with_cookies +++ /dev/null @@ -1,13 +0,0 @@ -HTTP/1.1 200 OK -Date: Wed, 22 Nov 2006 22:31:39 GMT -Server: Apache -X-Powered-By: PHP/5.1.6-pl8-gentoo -Set-Cookie: foo=bar -Set-Cookie: BOFH=Feature+was+not+beta+tested; expires=Thu, 23-Nov-2006 00:31:40 GMT -Set-Cookie: time=1164234700 -Content-Length: 26 -Keep-Alive: timeout=15, max=100 -Connection: Keep-Alive -Content-Type: text/html - -This is some response body \ No newline at end of file diff --git a/tests/Zend/Http/_files/response_with_single_cookie b/tests/Zend/Http/_files/response_with_single_cookie deleted file mode 100644 index bb33bb4ede2322929db8bcdeaa6e86335f4df2f9..0000000000000000000000000000000000000000 --- a/tests/Zend/Http/_files/response_with_single_cookie +++ /dev/null @@ -1,11 +0,0 @@ -HTTP/1.1 200 OK -Date: Wed, 22 Nov 2006 22:31:39 GMT -Server: Apache -X-Powered-By: PHP/5.1.6-pl8-gentoo -Set-Cookie: BOFH=Feature+was+not+beta+tested; expires=Thu, 23-Nov-2006 00:31:40 GMT -Content-Length: 26 -Keep-Alive: timeout=15, max=100 -Connection: Keep-Alive -Content-Type: text/html - -This is some response body \ No newline at end of file diff --git a/tests/Zend/InfoCard/AllTests.php b/tests/Zend/InfoCard/AllTests.php deleted file mode 100644 index 49e431938fdfa01eaa5fbd6a59319974232f71cc..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/AllTests.php +++ /dev/null @@ -1,57 +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_InfoCard - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_InfoCard_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/InfoCard/XmlParsingTest.php'; -require_once 'Zend/InfoCard/ProcessTest.php'; -require_once 'Zend/InfoCard/AssertionTest.php'; -require_once 'Zend/InfoCard/CipherTest.php'; - -class Zend_InfoCard_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite("Zend Framework - Zend_InfoCard"); - - $suite->addTestSuite('Zend_InfoCard_AssertionTest'); - $suite->addTestSuite('Zend_InfoCard_ProcessTest'); - $suite->addTestSuite('Zend_InfoCard_XmlParsingTest'); - $suite->addTestSuite('Zend_InfoCard_CipherTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_InfoCard_AllTests::main') { - Zend_InfoCard_AllTests::main(); -} diff --git a/tests/Zend/InfoCard/AssertionTest.php b/tests/Zend/InfoCard/AssertionTest.php deleted file mode 100644 index 91f21abad9c35f7c4e3531501a3c080eee4ce3eb..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/AssertionTest.php +++ /dev/null @@ -1,104 +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_InfoCard - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AssertionTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -// Call Zend_InfoCard_AssertionTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_InfoCard_AssertionTest::main"); -} - -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/InfoCard.php'; - -class Zend_InfoCard_AssertionTest extends PHPUnit_Framework_TestCase -{ - protected $_xmlDocument; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_InfoCard_AssertionTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->tokenDocument = dirname(__FILE__) . '/_files/signedToken.xml'; - $this->sslPubKey = dirname(__FILE__) . '/_files/ssl_pub.cert'; - $this->sslPrvKey = dirname(__FILE__) . '/_files/ssl_private.cert'; - $this->loadXmlDocument(); - } - - public function loadXmlDocument() - { - $this->_xmlDocument = file_get_contents($this->tokenDocument); - } - - public function testAssertionProcess() - { - date_default_timezone_set("America/Los_Angeles"); - - $assertions = Zend_InfoCard_Xml_Assertion::getInstance($this->_xmlDocument); - - $this->assertTrue($assertions instanceof Zend_InfoCard_Xml_Assertion_Saml); - - $this->assertSame($assertions->getMajorVersion(), 1); - $this->assertSame($assertions->getMinorversion(), 1); - $this->assertSame($assertions->getAssertionID(), "uuid:5cf2cd76-acf6-45ef-9059-a811801b80cc"); - $this->assertSame($assertions->getIssuer(), "http://schemas.xmlsoap.org/ws/2005/05/identity/issuer/self"); - $this->assertSame($assertions->getConfirmationMethod(), Zend_InfoCard_Xml_Assertion_Saml::CONFIRMATION_BEARER); - $this->assertSame($assertions->getIssuedTimestamp(), 1190153823); - - } - - public function testAssertionErrors() - { - try { - Zend_InfoCard_Xml_Assertion::getInstance(10); - $this->fail("Exception Not Thrown as Expected"); - } catch(Exception $e) { - /* yay */ - } - - $doc = file_get_contents(dirname(__FILE__) . '/_files/signedToken_bad_type.xml'); - - try { - $assertions = Zend_InfoCard_Xml_Assertion::getInstance($doc); - $this->fail("Exception Not thrown as expected"); - } catch(Exception $e) { - /* yay */ - } - } -} - -// Call Zend_InfoCard_AssertionTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_InfoCard_AssertionTest::main") { - Zend_InfoCard_AssertionTest::main(); -} diff --git a/tests/Zend/InfoCard/CipherTest.php b/tests/Zend/InfoCard/CipherTest.php deleted file mode 100644 index 1b57943cf76a9abb9447775e26dc74711cf43c75..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/CipherTest.php +++ /dev/null @@ -1,101 +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_InfoCard - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CipherTest.php 8678 2008-03-07 22:08:11Z darby $ - */ - -// Call Zend_InfoCard_ProcessTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_InfoCard_CipherTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/InfoCard.php'; -require_once 'Zend/InfoCard/Cipher/Pki/Adapter/Rsa.php'; - -class Zend_InfoCard_CipherTest extends PHPUnit_Framework_TestCase -{ - - public function testPkiPadding() - { - try { - $obj = new Zend_InfoCard_Cipher_Pki_Adapter_Rsa("thiswillbreak"); - $this->fail("Exception not thrown as expected"); - } catch(Exception $e) { - /* yay */ - } - - $obj = new Zend_InfoCard_Cipher_Pki_Adapter_Rsa(); - - $prv_key = file_get_Contents(dirname(__FILE__) . "/_files/ssl_private.cert"); - - try { - $obj->decrypt("Foo", $prv_key, null, "foo"); - $this->fail("Expected Exception Not Thrown"); - } catch(Exception $e) { - /* yay */ - } - - $result = $obj->decrypt("foo", $prv_key, null, Zend_InfoCard_Cipher_Pki_Adapter_Abstract::NO_PADDING); - - // This is sort of werid, but since we don't have a real PK-encrypted string to test against for NO_PADDING - // mode we decrypt the string "foo" instead. Mathmatically we will always arrive at the same resultant - // string so if our hash doesn't match then something broke. - $this->assertSame(md5($result), "286c1991e1f7040229a6f223065b91b5"); - } - - public function testPKIDecryptBadKey() - { - - $obj = new Zend_InfoCard_Cipher_Pki_Adapter_Rsa(); - - try { - $obj->decrypt("Foo", "bar"); - $this->fail("Exception not thrown as expected"); - } catch(Exception $e) { - /* yay */ - } - - } - - public function testCipherFactory() - { - if (!defined('MCRYPT_RIJNDAEL_128')) { - $this->markTestSkipped('Use of the Zend_InfoCard component requires the mcrypt extension to be enabled in PHP'); - } - - $this->assertTrue(Zend_InfoCard_Cipher::getInstanceByURI(Zend_InfoCard_Cipher::ENC_AES128CBC) - instanceof Zend_InfoCard_Cipher_Symmetric_Adapter_Aes128cbc); - $this->assertTrue(Zend_InfoCard_Cipher::getInstanceByURI(Zend_InfoCard_Cipher::ENC_RSA) - instanceof Zend_InfoCard_Cipher_Pki_Adapter_Rsa); - - try { - Zend_InfoCard_Cipher::getInstanceByURI("Broken"); - $this->fail("Exception not thrown as expected"); - } catch(Exception $e) { - /* yay */ - } - } -} \ No newline at end of file diff --git a/tests/Zend/InfoCard/ProcessTest.php b/tests/Zend/InfoCard/ProcessTest.php deleted file mode 100644 index b54e17c4b8b1da4dfe17a39fa68fb62ca86b0d98..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/ProcessTest.php +++ /dev/null @@ -1,320 +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_InfoCard - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ProcessTest.php 8789 2008-03-12 20:07:42Z darby $ - */ - -// Call Zend_InfoCard_ProcessTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_InfoCard_ProcessTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/InfoCard.php'; -require_once 'Zend/InfoCard/Adapter/Default.php'; - -class Zend_InfoCard_ProcessTest extends PHPUnit_Framework_TestCase -{ - protected $_xmlDocument; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_InfoCard_ProcessTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->tokenDocument = dirname(__FILE__) . '/_files/encryptedtoken.xml'; - $this->sslPubKey = dirname(__FILE__) . '/_files/ssl_pub.cert'; - $this->sslPrvKey = dirname(__FILE__) . '/_files/ssl_private.cert'; - $this->loadXmlDocument(); - } - - public function loadXmlDocument() - { - $this->_xmlDocument = file_get_contents($this->tokenDocument); - } - - public function testCertificatePairs() - { - try { - $infoCard = new Zend_InfoCard(); - } catch (Zend_InfoCard_Exception $e) { - $message = $e->getMessage(); - if (preg_match('/requires.+mcrypt/', $message)) { - $this->markTestSkipped($message); - } else { - throw $e; - } - } - - $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); - - $this->assertTrue((bool)$key_id); - - $key_pair = $infoCard->getCertificatePair($key_id); - - $this->assertTrue(!empty($key_pair['public'])); - $this->assertTrue(!empty($key_pair['private'])); - $this->assertTrue(!empty($key_pair['type_uri'])); - - $infoCard->removeCertificatePair($key_id); - - $failed = false; - - try { - $key_pair = $infoCard->getCertificatePair($key_id); - } catch(Zend_InfoCard_Exception $e) { - $failed = true; - } - - $this->assertTrue($failed); - - try { - $infoCard->addCertificatePair("I don't exist", "I don't exist"); - } catch(Zend_InfoCard_Exception $e) { - $this->assertTrue(true); - } catch(Exception $e) { - $this->assertFalse(true); - } - - $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, "foo"); - - try { - $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, "foo"); - } catch(Zend_InfoCard_Exception $e) { - $this->assertTrue(true); - } catch(Exception $e) { - $this->assertFalse(true); - } - - $this->assertTrue(!empty($key_id)); - - try { - $infoCard->removeCertificatePair($key_id); - $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, "Doesn't Exist", "foo"); - } catch(Zend_InfoCard_Exception $e) { - $this->assertTrue(true); - } catch(Exception $e) { - $this->assertFalse(true); - } - } - - public function testStandAloneProcess() - { - if (version_compare(PHP_VERSION, '5.2.0', '<')) { - $this->markTestSkipped('DOMDocument::C14N() not available until PHP 5.2.0'); - } - - $_SERVER['SERVER_NAME'] = "192.168.1.105"; - $_SERVER['SERVER_PORT'] = 80; - - try { - $infoCard = new Zend_InfoCard(); - } catch (Zend_InfoCard_Exception $e) { - $message = $e->getMessage(); - if (preg_match('/requires.+mcrypt/', $message)) { - $this->markTestSkipped($message); - } else { - throw $e; - } - } - - $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); - - $claims = $infoCard->process($this->_xmlDocument); - - $this->assertTrue($claims instanceof Zend_InfoCard_Claims); - } - - public function testPlugins() - { - if (version_compare(PHP_VERSION, '5.2.0', '<')) { - $this->markTestSkipped('DOMDocument::C14N() not available until PHP 5.2.0'); - } - - $adapter = new _Zend_InfoCard_Test_Adapter(); - - try { - $infoCard = new Zend_InfoCard(); - } catch (Zend_InfoCard_Exception $e) { - $message = $e->getMessage(); - if (preg_match('/requires.+mcrypt/', $message)) { - $this->markTestSkipped($message); - } else { - throw $e; - } - } - - $infoCard->setAdapter($adapter); - - $result = $infoCard->getAdapter() instanceof Zend_InfoCard_Adapter_Interface; - - $this->assertTrue($result); - $this->assertTrue($infoCard->getAdapter() instanceof _Zend_InfoCard_Test_Adapter); - - $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); - - $claims = $infoCard->process($this->_xmlDocument); - - $pki_object = new Zend_InfoCard_Cipher_Pki_Adapter_Rsa(Zend_InfoCard_Cipher_Pki_Adapter_Abstract::NO_PADDING); - - $infoCard->setPkiCipherObject($pki_object); - - $this->assertTrue($pki_object === $infoCard->getPkiCipherObject()); - - $sym_object = new Zend_InfoCard_Cipher_Symmetric_Adapter_Aes256cbc(); - - $infoCard->setSymCipherObject($sym_object); - - $this->assertTrue($sym_object === $infoCard->getSymCipherObject()); - } - - public function testClaims() - { - if (version_compare(PHP_VERSION, '5.2.0', '<')) { - $this->markTestSkipped('DOMDocument::C14N() not available until PHP 5.2.0'); - } - - try { - $infoCard = new Zend_InfoCard(); - } catch (Zend_InfoCard_Exception $e) { - $message = $e->getMessage(); - if (preg_match('/requires.+mcrypt/', $message)) { - $this->markTestSkipped($message); - } else { - throw $e; - } - } - - $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); - - $claims = $infoCard->process($this->_xmlDocument); - - $this->assertTrue($claims instanceof Zend_InfoCard_Claims); - - $this->assertFalse($claims->isValid()); - - $this->assertSame($claims->getCode(), Zend_InfoCard_Claims::RESULT_VALIDATION_FAILURE); - - $errormsg = $claims->getErrorMsg(); - $this->assertTrue(!empty($errormsg)); - - - @$claims->forceValid(); - - $this->assertTrue($claims->isValid()); - - $this->assertSame($claims->emailaddress, "john@zend.com"); - $this->assertSame($claims->givenname, "John"); - $this->assertSame($claims->surname, "Coggeshall"); - $this->assertSame($claims->getCardID(), "rW1/y9BuncoBK4WSipF2hHYParxxgMHk6ANBrhz1Zr4="); - $this->assertSame($claims->getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), "john@zend.com"); - $this->assertSame($claims->getDefaultNamespace(), "http://schemas.xmlsoap.org/ws/2005/05/identity/claims"); - - try { - unset($claims->givenname); - } catch(Zend_InfoCard_Exception $e) { - - } catch(Exception $e) { - $this->assertFalse(true); - } - - - try { - $claims->givenname = "Test"; - } catch(Zend_InfoCard_Exception $e) { - - } catch(Exception $e) { - $this->assertFalse(true); - } - - $this->assertTrue(isset($claims->givenname)); - } - - public function testDefaultAdapter() - { - $adapter = new Zend_InfoCard_Adapter_Default(); - - $this->assertTrue($adapter->storeAssertion(1, 2, array(3))); - $this->assertFalse($adapter->retrieveAssertion(1, 2)); - $this->assertTrue(is_null($adapter->removeAssertion(1, 2))); - } - - public function testTransforms() - { - $trans = new Zend_InfoCard_Xml_Security_Transform(); - - try { - $trans->addTransform("foo"); - $this->fail("Expected Exception Not Thrown"); - } catch(Exception $e) { - /* yay */ - } - - $this->assertTrue(is_array($trans->getTransformList())); - - } -} - -class _Zend_InfoCard_Test_Adapter - extends PHPUnit_Framework_TestCase - implements Zend_InfoCard_Adapter_Interface -{ - public function storeAssertion($assertionURI, $assertionID, $conditions) - { - $this->assertTrue(!empty($assertionURI)); - $this->assertTrue(!empty($assertionID)); - $this->assertTrue(!empty($conditions)); - return true; - } - - public function retrieveAssertion($assertionURI, $assertionID) - { - $this->assertTrue(!empty($assertionURI)); - $this->assertTrue(!empty($assertionID)); - return false; - } - - public function removeAssertion($asserionURI, $assertionID) - { - $this->assertTrue(!empty($assertionURI)); - $this->asserTrue(!empty($assertionID)); - } -} - -// Call Zend_InfoCard_ProcessTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_InfoCard_ProcessTest::main") { - Zend_InfoCard_ProcessTest::main(); -} diff --git a/tests/Zend/InfoCard/XmlParsingTest.php b/tests/Zend/InfoCard/XmlParsingTest.php deleted file mode 100644 index 7072f2250f19587b14955f0b7138fbc5c30e5e83..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/XmlParsingTest.php +++ /dev/null @@ -1,239 +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_InfoCard - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: XmlParsingTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -// Call Zend_InfoCard_XmlParsingTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_InfoCard_XmlParsingTest::main"); -} - -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/InfoCard/Xml/EncryptedData.php'; -require_once 'Zend/InfoCard/Xml/SecurityTokenReference.php'; - -class Zend_InfoCard_XmlParsingTest extends PHPUnit_Framework_TestCase -{ - protected $_xmlDocument; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_InfoCard_XmlParsingTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->tokenDocument = dirname(__FILE__) . '/_files/encryptedtoken.xml'; - $this->loadXmlDocument(); - } - - public function loadXmlDocument() - { - $this->_xmlDocument = file_get_contents($this->tokenDocument); - } - - public function testEncryptedDataType() - { - $doc = file_get_contents(dirname(__FILE__) . '/_files/encryptedtoken_bad_type.xml'); - - try { - $encryptedData = Zend_InfoCard_Xml_EncryptedData::getInstance($doc); - $this->fail("Exception not thrown as expected"); - } catch(Exception $e) { - /* yay */ - } - - try { - $encryptedData = Zend_InfoCard_Xml_EncryptedData::getInstance(10); - $this->fail("Exception not thrown as expected"); - } catch(Exception $e) { - /* yay */ - } - - } - public function testEncryptedData() - { - $encryptedData = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument); - - $this->assertTrue($encryptedData instanceof Zend_InfoCard_Xml_EncryptedData_XmlEnc); - $this->assertSame($encryptedData->getCipherValue(), '+5yXODn6COtlq4VWFl84Ue/nyf92UCqHc9LmFzDVJr+HDoLwOl1FV9VcIYs/KhmVHiHiv3nGHMvc8RBCJbQbpC8WaQRm9lGyO+4Hmj2w9D+c+O3gOr5sfxKIOK99Wmhj+0Z+7aqm+JeCaiK6nepiErOYWGMN0skX+2URber/Ks7mNgkcFuVjGYySM4m3f6Fe17UoDkV8EfgvayVvp3uS21immpwPQpWcTCdL4d3BNncuJl7RT6/wOLA2qQQKSgvqXBt9xSaiynunsb7adaA545+8eCWViN/nAjEbglahmyBWK0lctpxVB6t/zZrW1Q6uRgJUi9I0qRaPA3o/cBgERvqAd1MsonzZS4KN3IECn/zYfgLmATEJzi1EVp2oVATNubKUFhCMkDFdiqXQfQJfvtXo8zU/fPS1ZZ5KRVMICjMuWMxw2sMIPLvtCumxxFBTpEkLcoXHj/ljrAfhTqIi5mV/45vuKfd4xvT3RDT+HODWKVwIf9HXc/u6MAucoAjv7pYRc/hdTrQJXr3zjPgBYJiN7wecoUUweaxswrACAMUZY+5/DS22zxlmaFrLz8Tt06Z6YuTgr+J6JEf6sam+KOR+kZParc+yRidU4/KRBnaiLDIfEaUMtlvYAg1MaNdj1MFXqsPPqcDl+ZAyHasF6W1dcfahSEMeBR+Ml14BbZ57XOtFHeW2U012J0ygwi7Evb53op+daPT/odkzeCVz9O734Rm6gkmwlKZgZdPo4TZRTOHH7RTxUXMaCsWC5liY99Yxev0PsDALZbhKZaVpd67tFK3Y+Cud4dNdUvakcw3kktdA9251Z4kqCdj9720Uu3fu3OOVSAhCP7xbLnjfEBqwiRcZ2rXV1lxiDDulDM5dZ8uvjKreGWKSPmMK0EHFJJIWW4ZVfbKN8loPdP3ytZ2TXhZ/v06x8tPX3QctRgU5SmBTiKwFvW4tKROV78MAC7L9wNSEq5ZuCrOhrdOosayGWgmTCinuBHiinL8ejSi6F+yCPAmXXy8OhHb/v1YNAL+q4i9052a7fUD5hjSfpiii6S2RxPXHNnWgu6f5dQUzCAfE303rE6BJu5mocSFmcJYReJoYX7kVlgoYnRwUxDGofHWQ+0dHYeW7aDxH0bCnGsP1Tz6sIPCkZCjMnFpuDFYstXkgU0fddqNRNhOCQsy04vK8Oy9r5H0RqvLg+Z3yVE+TWErZtl1E2MmuKeDY9wVulGpxDWqSOn1+4yTtfSnfMqBZE2QGl9v8Vkgw90o/rKNtS8OGqZ4Iu1sutric4VrRyM64MiqVcTdyPocCNu07N9nK8v/QrjdVkn4Xo+RvRnopZV5I5HEE5ocQjqsF/ppKBUWeoOr1qRLbKJPZzF2VLx7x58lWy+Bj9COl4pSHmYiZu0k+wpg1VBqOOHh/6q/0Iup8bos8yos8OHLJM+kZrf8nmxVvBJKhcOfJu9prqRLcd/06p2EjxIRY8vZc2vK8EUA2gOJqKoLFZLPxjtYE9lcj3rFX4vF18VgbikM4Mdks+JWM5J0/XbyDO5N/ViygxS7muIr44iqvb6jaNvceUCQ+L+Dp893QXEor7P8P1tiCxqW16+PNcyQiK34HxslTHwDiiZTxAY30qDwj/6ZF7Na2us5hYAw0GjDFlGhVywDNcO+zv48SOlhpTFXYPqVXCRh59ZeA0F2hG1Oza7WTGQqvfCk1UbuNBEq076HM5Kh9epLLP+Os61xnggODycnaHThrtK0XnLLi39QsFZbfeAgvvSFsudM7xREKJ54vybDKic4agxLuG9SwDYuJnzC1g/dts061dM2wGzJJpM+Z1pJYjCfLfK5/Ni1+PPr1wpgRSnstN5PytENICJNssexixB3yM6ctrPXZ0VExpcnuJgqYfZX0/kiQhkLT78FZ3sRnDw4L2V+u9CFCldhlKx+Lk44mkocZGvAVHxfmN2KXWjf+7EXGbTPyZ54RGYXlDGdq5YGpHCGh3mNURdXVSIMKRwOMmjHI0aI5vF+CEnMtaP2qn0eEOwv9iPEoHDeCp5lNAgeHeMVvbkuZwJAtJ5ugpAMioyXOmYcqVceZLH24ECmUXBSB0Hl0du4YNTebUc5dBg3A8fANEVgw3NqNMfpZXFtGaNKUNxsmG3SB6DXeOrdQEjIfF9Hd6I8OYcEkklUEvLpgzG3es8PudMA0WkE3dV54BNAmHcD8UMu9mqjiQ4TmTf3LB7T5XzOXkiHCk3x1620KDFFw9VHFo4U+CyLdq0XYDf4Acfv8J6Zv3+62Lo33HCpzKQ/mhcjRSuiL5t1PZd8bDsLkxhO1+9hru9nSbqGw6aHsjiIeG6gDaem1+0OvN5nLlK6sDHwXRUH5jhble15fVK4nBBAJdv/XbvVXZ0wnC7X4GFGDcu3IghpGW9byw2KCuNAHo0hSfIuADzBXH4kglmujfkY6RzDKTZgHGO6nGItdHK6eOhL9LnAosYLkOgPB2GSSNj9Exe6c7d4JXyEbLwiY4PaUhA2FzQNCWqd/DHaG8gqxHFOqxjggANB3CQhIH1LVNKpV1nt+ulwkOgCby09UffvAxJoVE4JyoKGfHpVfNPa2ADHQp/mA+ltP0kzCFK1i3YmAvhJlzdoAf4WGYJ1YkvX3XRQXijBYI439bK9yVvlCSVncutObuAD9ikDYcorVPDUrzBsIZnvFtN/r/nM9WMHeL6XEA+MT7+tMS4wyvuo0Cb8MZ8v/Eeix287J70sI6or1Tq9TPLHf4X5uh+N46w5RWYjnnuIJNe44ffCWroGqdjQMCElwBwRVReZZ6y5/DW2UYgQuc1pf/CDpyAmAcEDVJY/bwSjTAhcfylFhLjK/suOkWTns82qsf3XmyGkFLidCIlMaYA4ZbasCFlQelv2mythwmlXbX9dADUoU8W7jfvRecgcgSBbK4kwUbYarwF/g5iFA4iRHj1mAWs0cJRFX5ZSJrHPyo0Q/x+w2rY+lYZ25IGwzCgPUIPmxAbNVDlyLbPyTmbh/AY1BaA28aHRN8e2rdUX9kRmCT8b917pmZ6BGmynvG+0as5nqNhwqZj83ROW3xaa/m+BTkBf4YMPEbqJjUPMBS6jDefthDoiCsn3MSY78eREuC2QTWucVji8J59ikGm9O4RARkJdPiy0DczlhSXSYxDP+S3hYV572l//Ms9M+bnwjeCh+zft7N9IzMg9Ge3cjTGakWCT3+RNQhRlL5KCIvmF0otl9WBa5bhr0jeGVaaSJ2BWM5syuMqN7tGjtKhDfRbexkiH5Vi5d/nSUVDL61fUF4nB/g4mzSmrnSvYUXMe04OVoDB1z/Jt5ssRK3DkT7Do1z8Ya2pUce9MevowwXCQ04qoSZpvmao3DwUIsyNwq2aLmmUc9JMmEqTyd62zZZKu7y3BQNelcXAZCaTb9Ds/XZl/bel7uBMTPyDrppvL90fAq48rW7sPCNaw6CBbSu7R9tmx3d81UI7X39H5afWphydUfPIJMgPIiPT91RHPq0+30uL7jQzTr6i9MK5fymgrk+nKiZanKA/Lck9TdfpMlgOZ/AuFS7CzzvA6XL3n1GCCk8/TD1HRIaCZxnT53bpKcKGa8VT64RO1yt4hYOyar0sj/KSbx62//FxeZJ7eILudcbLmKGu+cF0E7uLk9+GMThnTwpDFIvsGqZF8298MHGs958bEEMqcG/0RNwjJriMo4UpcKnGF1eb5kgKoU2pvYENDHyBdfxIUiJ+N58P0ut1e94nn263A4h9fHH4k71NbcnJcch+mkwFzgWDhU1Tpi0dKJJ9rQilNXdC3+Fhkvs0ZRV0+cKzcn8NFPVlSuLOpIJDP+E61tmAixSPRGn+aRvW9H1rmmmqUfLD1m671Q2LLnIPM4GucS2UbT+ocb/r0yZpnPHHs2uZEHEf+qbDX3J/q7uzY8HRe289i/aXTAcKF8FkWOKCp4N3gIR8PsQ9D6Q4i/PWNKHyTLszGYRcK+fZWpWjjdXOyrzr2axoEmsS8b0DdoelHa9rsyowynKYe1t7iccmnfSaZDgRT3t8UCPXmx4aGSCa5yejQ08HdlNw9vqHk7yMuGAELvol5PwxCZUFlwyR1nC3R3BC+mRZ18ONDskKNdTzwQ'); - - $this->assertSame($encryptedData->getEncryptionMethod(), 'http://www.w3.org/2001/04/xmlenc#aes256-cbc'); - $this->assertTrue($encryptedData->getKeyInfo() instanceof Zend_InfoCard_Xml_KeyInfo_XmlDSig); - } - - public function testTostring() - { - $encryptedData = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument); - $key = $encryptedData->getKeyInfo(); - - $this->assertTrue(is_string($key->__toString())); - } - - public function testConversion() - { - $encryptedData = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument); - - $keyInfo = $encryptedData->getKeyInfo(); - - $this->assertTrue($keyInfo instanceof SimpleXMLElement); - - $dom = Zend_InfoCard_Xml_KeyInfo_XmlDSig::convertToDOM($keyInfo); - $this->assertTrue($dom instanceof DOMNode); - $sxe = Zend_InfoCard_Xml_KeyInfo_XmlDSig::convertToObject($dom, 'Zend_InfoCard_Xml_KeyInfo_XmlDSig'); - - $this->assertTrue($sxe instanceof Zend_InfoCard_Xml_KeyInfo_XmlDSig); - } - - public function testEncryptedDataKeyInfo() - { - $keyinfo = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument)->getKeyInfo(); - - $this->assertTrue($keyinfo instanceof Zend_InfoCard_Xml_KeyInfo_XmlDSig); - $this->assertTrue($keyinfo->getEncryptedKey() instanceof Zend_InfoCard_Xml_EncryptedKey); - } - - public function testEncryptedKey() - { - $enckey = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument)->getKeyInfo()->getEncryptedKey(); - - $this->assertTrue($enckey instanceof Zend_InfoCard_Xml_EncryptedKey); - - $this->assertSame($enckey->getEncryptionMethod(), 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'); - $this->assertSame($enckey->getDigestMethod(), 'http://www.w3.org/2000/09/xmldsig#sha1'); - $this->assertSame($enckey->getCipherValue(), 'AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo='); - - $this->assertTrue($enckey->getKeyInfo() instanceof Zend_InfoCard_Xml_KeyInfo_Default); - } - - public function testEncryptedKeyKeyInfo() - { - $keyinfo = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument)->getKeyInfo()->getEncryptedKey()->getKeyInfo(); - - $this->assertTrue($keyinfo instanceof Zend_InfoCard_Xml_KeyInfo_Default); - $this->assertTrue($keyinfo->getSecurityTokenReference() instanceof Zend_InfoCard_Xml_SecurityTokenReference); - } - - public function testSecurityTokenReference() - { - $sectoken = Zend_InfoCard_Xml_EncryptedData::getInstance($this->_xmlDocument)->getKeyInfo() - ->getEncryptedKey() - ->getKeyInfo() - ->getSecurityTokenReference(); - $this->assertTrue($sectoken instanceof Zend_InfoCard_Xml_SecurityTokenReference); - - $this->assertSame($sectoken->getKeyThumbprintType(), 'http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1'); - $this->assertSame($sectoken->getKeyThumbprintEncodingType(), 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'); - $this->assertSame($sectoken->getKeyReference(false), '/OCqQ7Np25sOiA+4OsFh1R6qIeY='); - } - - public function testEncryptedKeyErrors() - { - try { - Zend_InfoCard_Xml_EncryptedKey::getInstance(10); - $this->fail("Expected Exception Not thrown"); - } catch(Exception $e) { - /* yay */ - } - - $doc = file_get_contents(dirname(__FILE__) . "/_files/encryptedkey_bad_block.xml"); - - try { - Zend_InfoCard_Xml_EncryptedKey::getInstance($doc); - $this->fail("Expected Exception not thrown"); - } catch(Exception $e) { - /* yay */ - } - - - - $doc = file_get_contents(dirname(__FILE__) . "/_files/encryptedkey_missing_enc_algo.xml"); - $ek = Zend_InfoCard_Xml_EncryptedKey::getInstance($doc); - - try { - $ek->getEncryptionMethod(); - $this->fail("Expected Exception not thrown"); - } catch(Exception $e) { - /* yay */ - } - - } - - public function testKeyInfo() - { - try { - Zend_InfoCard_Xml_KeyInfo::getInstance("<foo/>"); - $this->fail("Expected Exception Not thrown"); - } catch(Exception $e) { - /* yay */ - } - - try { - Zend_InfoCard_Xml_KeyInfo::getInstance(10); - $this->fail("Expected Exception Not thrown"); - } catch(Exception $e) { - /* yay */ - } - } - - public function testSecurityTokenReferenceErrors() - { - try { - Zend_InfoCard_Xml_SecurityTokenReference::getInstance("<foo/>"); - $this->fail("Expected Exception Not thrown"); - } catch(Exception $e) { - /* yay */ - } - - try { - Zend_InfoCard_Xml_SecurityTokenReference::getInstance(10); - $this->fail("Expected Exception Not thrown"); - } catch(Exception $e) { - /* yay */ - } - - $doc = file_get_contents(dirname(__FILE__) . "/_files/security_token_bad_keyref.xml"); - - try { - $si = Zend_InfoCard_Xml_SecurityTokenReference::getInstance($doc); - $si->getKeyReference(); - $this->fail("Expected Exception Not thrown"); - } catch(Exception $e) { - /* yay */ - } - } - -} - -// Call Zend_InfoCard_XmlParsingTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_InfoCard_XmlParsingTest::main") { - Zend_InfoCard_XmlParsingTest::main(); -} diff --git a/tests/Zend/InfoCard/_files/encryptedkey.xml b/tests/Zend/InfoCard/_files/encryptedkey.xml deleted file mode 100644 index 183d6e960be43fba1f0e148eb1838ab88b3dfab1..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/encryptedkey.xml +++ /dev/null @@ -1,15 +0,0 @@ -<e:BadEncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#"> - <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"> - <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> - </e:EncryptionMethod> - <KeyInfo> - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - </KeyInfo> - <e:CipherData> - <e:CipherValue>AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo=</e:CipherValue> - </e:CipherData> - </e:EncryptedKey> - diff --git a/tests/Zend/InfoCard/_files/encryptedkey_bad_block.xml b/tests/Zend/InfoCard/_files/encryptedkey_bad_block.xml deleted file mode 100644 index 35c9a4c91a5f0fbf60acd40eb8269c3f68a3675d..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/encryptedkey_bad_block.xml +++ /dev/null @@ -1,15 +0,0 @@ -<e:BadEncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#"> - <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"> - <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> - </e:EncryptionMethod> - <KeyInfo> - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - </KeyInfo> - <e:CipherData> - <e:CipherValue>AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo=</e:CipherValue> - </e:CipherData> - </e:BadEncryptedKey> - diff --git a/tests/Zend/InfoCard/_files/encryptedkey_missing_enc_algo.xml b/tests/Zend/InfoCard/_files/encryptedkey_missing_enc_algo.xml deleted file mode 100644 index d3e3c479059c443869a8150dc2bc67cfb4a19619..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/encryptedkey_missing_enc_algo.xml +++ /dev/null @@ -1,15 +0,0 @@ -<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#"> - <e:EncryptionMethod > - <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> - </e:EncryptionMethod> - <KeyInfo> - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - </KeyInfo> - <e:CipherData> - <e:CipherValue>AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo=</e:CipherValue> - </e:CipherData> - </e:EncryptedKey> - diff --git a/tests/Zend/InfoCard/_files/encryptedkey_missing_encryptionmethod.xml b/tests/Zend/InfoCard/_files/encryptedkey_missing_encryptionmethod.xml deleted file mode 100644 index 1cfc57e52d48c3874b7245319b3f9384b0dc67f4..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/encryptedkey_missing_encryptionmethod.xml +++ /dev/null @@ -1,12 +0,0 @@ -<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#"> - <KeyInfo> - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - </KeyInfo> - <e:CipherData> - <e:CipherValue>AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo=</e:CipherValue> - </e:CipherData> - </e:EncryptedKey> - diff --git a/tests/Zend/InfoCard/_files/encryptedtoken.xml b/tests/Zend/InfoCard/_files/encryptedtoken.xml deleted file mode 100644 index 1d94e2ba9b5773fc900de483fdc8d4c3cc56b2f3..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/encryptedtoken.xml +++ /dev/null @@ -1,26 +0,0 @@ -<enc:EncryptedData - Type="http://www.w3.org/2001/04/xmlenc#Element" - xmlns:enc="http://www.w3.org/2001/04/xmlenc#"> - - <enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /> - <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> - <e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#"> - <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"> - <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> - </e:EncryptionMethod> - <KeyInfo> - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - </KeyInfo> - <e:CipherData> - <e:CipherValue>AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo=</e:CipherValue> - </e:CipherData> - </e:EncryptedKey> - </KeyInfo> - <enc:CipherData> - <enc:CipherValue>+5yXODn6COtlq4VWFl84Ue/nyf92UCqHc9LmFzDVJr+HDoLwOl1FV9VcIYs/KhmVHiHiv3nGHMvc8RBCJbQbpC8WaQRm9lGyO+4Hmj2w9D+c+O3gOr5sfxKIOK99Wmhj+0Z+7aqm+JeCaiK6nepiErOYWGMN0skX+2URber/Ks7mNgkcFuVjGYySM4m3f6Fe17UoDkV8EfgvayVvp3uS21immpwPQpWcTCdL4d3BNncuJl7RT6/wOLA2qQQKSgvqXBt9xSaiynunsb7adaA545+8eCWViN/nAjEbglahmyBWK0lctpxVB6t/zZrW1Q6uRgJUi9I0qRaPA3o/cBgERvqAd1MsonzZS4KN3IECn/zYfgLmATEJzi1EVp2oVATNubKUFhCMkDFdiqXQfQJfvtXo8zU/fPS1ZZ5KRVMICjMuWMxw2sMIPLvtCumxxFBTpEkLcoXHj/ljrAfhTqIi5mV/45vuKfd4xvT3RDT+HODWKVwIf9HXc/u6MAucoAjv7pYRc/hdTrQJXr3zjPgBYJiN7wecoUUweaxswrACAMUZY+5/DS22zxlmaFrLz8Tt06Z6YuTgr+J6JEf6sam+KOR+kZParc+yRidU4/KRBnaiLDIfEaUMtlvYAg1MaNdj1MFXqsPPqcDl+ZAyHasF6W1dcfahSEMeBR+Ml14BbZ57XOtFHeW2U012J0ygwi7Evb53op+daPT/odkzeCVz9O734Rm6gkmwlKZgZdPo4TZRTOHH7RTxUXMaCsWC5liY99Yxev0PsDALZbhKZaVpd67tFK3Y+Cud4dNdUvakcw3kktdA9251Z4kqCdj9720Uu3fu3OOVSAhCP7xbLnjfEBqwiRcZ2rXV1lxiDDulDM5dZ8uvjKreGWKSPmMK0EHFJJIWW4ZVfbKN8loPdP3ytZ2TXhZ/v06x8tPX3QctRgU5SmBTiKwFvW4tKROV78MAC7L9wNSEq5ZuCrOhrdOosayGWgmTCinuBHiinL8ejSi6F+yCPAmXXy8OhHb/v1YNAL+q4i9052a7fUD5hjSfpiii6S2RxPXHNnWgu6f5dQUzCAfE303rE6BJu5mocSFmcJYReJoYX7kVlgoYnRwUxDGofHWQ+0dHYeW7aDxH0bCnGsP1Tz6sIPCkZCjMnFpuDFYstXkgU0fddqNRNhOCQsy04vK8Oy9r5H0RqvLg+Z3yVE+TWErZtl1E2MmuKeDY9wVulGpxDWqSOn1+4yTtfSnfMqBZE2QGl9v8Vkgw90o/rKNtS8OGqZ4Iu1sutric4VrRyM64MiqVcTdyPocCNu07N9nK8v/QrjdVkn4Xo+RvRnopZV5I5HEE5ocQjqsF/ppKBUWeoOr1qRLbKJPZzF2VLx7x58lWy+Bj9COl4pSHmYiZu0k+wpg1VBqOOHh/6q/0Iup8bos8yos8OHLJM+kZrf8nmxVvBJKhcOfJu9prqRLcd/06p2EjxIRY8vZc2vK8EUA2gOJqKoLFZLPxjtYE9lcj3rFX4vF18VgbikM4Mdks+JWM5J0/XbyDO5N/ViygxS7muIr44iqvb6jaNvceUCQ+L+Dp893QXEor7P8P1tiCxqW16+PNcyQiK34HxslTHwDiiZTxAY30qDwj/6ZF7Na2us5hYAw0GjDFlGhVywDNcO+zv48SOlhpTFXYPqVXCRh59ZeA0F2hG1Oza7WTGQqvfCk1UbuNBEq076HM5Kh9epLLP+Os61xnggODycnaHThrtK0XnLLi39QsFZbfeAgvvSFsudM7xREKJ54vybDKic4agxLuG9SwDYuJnzC1g/dts061dM2wGzJJpM+Z1pJYjCfLfK5/Ni1+PPr1wpgRSnstN5PytENICJNssexixB3yM6ctrPXZ0VExpcnuJgqYfZX0/kiQhkLT78FZ3sRnDw4L2V+u9CFCldhlKx+Lk44mkocZGvAVHxfmN2KXWjf+7EXGbTPyZ54RGYXlDGdq5YGpHCGh3mNURdXVSIMKRwOMmjHI0aI5vF+CEnMtaP2qn0eEOwv9iPEoHDeCp5lNAgeHeMVvbkuZwJAtJ5ugpAMioyXOmYcqVceZLH24ECmUXBSB0Hl0du4YNTebUc5dBg3A8fANEVgw3NqNMfpZXFtGaNKUNxsmG3SB6DXeOrdQEjIfF9Hd6I8OYcEkklUEvLpgzG3es8PudMA0WkE3dV54BNAmHcD8UMu9mqjiQ4TmTf3LB7T5XzOXkiHCk3x1620KDFFw9VHFo4U+CyLdq0XYDf4Acfv8J6Zv3+62Lo33HCpzKQ/mhcjRSuiL5t1PZd8bDsLkxhO1+9hru9nSbqGw6aHsjiIeG6gDaem1+0OvN5nLlK6sDHwXRUH5jhble15fVK4nBBAJdv/XbvVXZ0wnC7X4GFGDcu3IghpGW9byw2KCuNAHo0hSfIuADzBXH4kglmujfkY6RzDKTZgHGO6nGItdHK6eOhL9LnAosYLkOgPB2GSSNj9Exe6c7d4JXyEbLwiY4PaUhA2FzQNCWqd/DHaG8gqxHFOqxjggANB3CQhIH1LVNKpV1nt+ulwkOgCby09UffvAxJoVE4JyoKGfHpVfNPa2ADHQp/mA+ltP0kzCFK1i3YmAvhJlzdoAf4WGYJ1YkvX3XRQXijBYI439bK9yVvlCSVncutObuAD9ikDYcorVPDUrzBsIZnvFtN/r/nM9WMHeL6XEA+MT7+tMS4wyvuo0Cb8MZ8v/Eeix287J70sI6or1Tq9TPLHf4X5uh+N46w5RWYjnnuIJNe44ffCWroGqdjQMCElwBwRVReZZ6y5/DW2UYgQuc1pf/CDpyAmAcEDVJY/bwSjTAhcfylFhLjK/suOkWTns82qsf3XmyGkFLidCIlMaYA4ZbasCFlQelv2mythwmlXbX9dADUoU8W7jfvRecgcgSBbK4kwUbYarwF/g5iFA4iRHj1mAWs0cJRFX5ZSJrHPyo0Q/x+w2rY+lYZ25IGwzCgPUIPmxAbNVDlyLbPyTmbh/AY1BaA28aHRN8e2rdUX9kRmCT8b917pmZ6BGmynvG+0as5nqNhwqZj83ROW3xaa/m+BTkBf4YMPEbqJjUPMBS6jDefthDoiCsn3MSY78eREuC2QTWucVji8J59ikGm9O4RARkJdPiy0DczlhSXSYxDP+S3hYV572l//Ms9M+bnwjeCh+zft7N9IzMg9Ge3cjTGakWCT3+RNQhRlL5KCIvmF0otl9WBa5bhr0jeGVaaSJ2BWM5syuMqN7tGjtKhDfRbexkiH5Vi5d/nSUVDL61fUF4nB/g4mzSmrnSvYUXMe04OVoDB1z/Jt5ssRK3DkT7Do1z8Ya2pUce9MevowwXCQ04qoSZpvmao3DwUIsyNwq2aLmmUc9JMmEqTyd62zZZKu7y3BQNelcXAZCaTb9Ds/XZl/bel7uBMTPyDrppvL90fAq48rW7sPCNaw6CBbSu7R9tmx3d81UI7X39H5afWphydUfPIJMgPIiPT91RHPq0+30uL7jQzTr6i9MK5fymgrk+nKiZanKA/Lck9TdfpMlgOZ/AuFS7CzzvA6XL3n1GCCk8/TD1HRIaCZxnT53bpKcKGa8VT64RO1yt4hYOyar0sj/KSbx62//FxeZJ7eILudcbLmKGu+cF0E7uLk9+GMThnTwpDFIvsGqZF8298MHGs958bEEMqcG/0RNwjJriMo4UpcKnGF1eb5kgKoU2pvYENDHyBdfxIUiJ+N58P0ut1e94nn263A4h9fHH4k71NbcnJcch+mkwFzgWDhU1Tpi0dKJJ9rQilNXdC3+Fhkvs0ZRV0+cKzcn8NFPVlSuLOpIJDP+E61tmAixSPRGn+aRvW9H1rmmmqUfLD1m671Q2LLnIPM4GucS2UbT+ocb/r0yZpnPHHs2uZEHEf+qbDX3J/q7uzY8HRe289i/aXTAcKF8FkWOKCp4N3gIR8PsQ9D6Q4i/PWNKHyTLszGYRcK+fZWpWjjdXOyrzr2axoEmsS8b0DdoelHa9rsyowynKYe1t7iccmnfSaZDgRT3t8UCPXmx4aGSCa5yejQ08HdlNw9vqHk7yMuGAELvol5PwxCZUFlwyR1nC3R3BC+mRZ18ONDskKNdTzwQ</enc:CipherValue> - </enc:CipherData> -</enc:EncryptedData> - diff --git a/tests/Zend/InfoCard/_files/encryptedtoken_bad_type.xml b/tests/Zend/InfoCard/_files/encryptedtoken_bad_type.xml deleted file mode 100644 index e0b700d8d6042383564308ae69421b9c39de3f56..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/encryptedtoken_bad_type.xml +++ /dev/null @@ -1,26 +0,0 @@ -<enc:EncryptedData - Type="foo" - xmlns:enc="http://www.w3.org/2001/04/xmlenc#"> - - <enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /> - <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> - <e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#"> - <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"> - <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> - </e:EncryptionMethod> - <KeyInfo> - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - </KeyInfo> - <e:CipherData> - <e:CipherValue>AIgtBEv9lGMikyHjV/b5mQ5LbLyupNtRH8hl5I6tJsZI5CYP32BLo9FgxAY5ZReEv+XZbqcs5KORBvTbMkP6l7MY32WJGPBDDMSB7k6DshryoZqlmGMbjt2g1nM7xOuwwfru1jC7t+qCBXL4PPBpHDhHzAW7u8tB8LQCU6GklIFa1+GoZbQ00BY/OoPbE3rxhxgGPAHXfYPLjGALIkYo9czeTO/zfcydHl5Xcyp/PsskSOUhNFcftxG+fQELb/oqc50ldBWlxBM/qU7fLI4KRfUag3J5sanCUsgiYdF0iQNfiYnUKLa9ThDHjHUQnB5EEt77cM2/DKQkyExMBBgYcRo9GzqyLXiDCYWVatCQU6rAD8NkBBpFs8W/0QXIV1J/S3DuZS3Eo4x27gRlT5YfUeO7jAZvwqy51WHNXwq13QTV2AOGfvpK3054sZm+10jdfAq6tgYdShQgO2kHRGP1q9vAC3SfD49mP9q+AemJrAkiR2HZTxkEQ+AttdfPhc2dzdLXp+ukQdqpL/xlywIp+KIim+YVjhO+Bi92rRn5Kl0h7q6MkpoTGI1F+akmNhD6VmB1Nd0G6e4AGTisuyd+vygEH7fsZhZuiMSknajfgPgazKiLUihwRvfk4FJm18Ju97tXcl6LhIJpkOcq7sI25GhWz0mHX1ErOf/949pcozo=</e:CipherValue> - </e:CipherData> - </e:EncryptedKey> - </KeyInfo> - <enc:CipherData> - <enc:CipherValue>+5yXODn6COtlq4VWFl84Ue/nyf92UCqHc9LmFzDVJr+HDoLwOl1FV9VcIYs/KhmVHiHiv3nGHMvc8RBCJbQbpC8WaQRm9lGyO+4Hmj2w9D+c+O3gOr5sfxKIOK99Wmhj+0Z+7aqm+JeCaiK6nepiErOYWGMN0skX+2URber/Ks7mNgkcFuVjGYySM4m3f6Fe17UoDkV8EfgvayVvp3uS21immpwPQpWcTCdL4d3BNncuJl7RT6/wOLA2qQQKSgvqXBt9xSaiynunsb7adaA545+8eCWViN/nAjEbglahmyBWK0lctpxVB6t/zZrW1Q6uRgJUi9I0qRaPA3o/cBgERvqAd1MsonzZS4KN3IECn/zYfgLmATEJzi1EVp2oVATNubKUFhCMkDFdiqXQfQJfvtXo8zU/fPS1ZZ5KRVMICjMuWMxw2sMIPLvtCumxxFBTpEkLcoXHj/ljrAfhTqIi5mV/45vuKfd4xvT3RDT+HODWKVwIf9HXc/u6MAucoAjv7pYRc/hdTrQJXr3zjPgBYJiN7wecoUUweaxswrACAMUZY+5/DS22zxlmaFrLz8Tt06Z6YuTgr+J6JEf6sam+KOR+kZParc+yRidU4/KRBnaiLDIfEaUMtlvYAg1MaNdj1MFXqsPPqcDl+ZAyHasF6W1dcfahSEMeBR+Ml14BbZ57XOtFHeW2U012J0ygwi7Evb53op+daPT/odkzeCVz9O734Rm6gkmwlKZgZdPo4TZRTOHH7RTxUXMaCsWC5liY99Yxev0PsDALZbhKZaVpd67tFK3Y+Cud4dNdUvakcw3kktdA9251Z4kqCdj9720Uu3fu3OOVSAhCP7xbLnjfEBqwiRcZ2rXV1lxiDDulDM5dZ8uvjKreGWKSPmMK0EHFJJIWW4ZVfbKN8loPdP3ytZ2TXhZ/v06x8tPX3QctRgU5SmBTiKwFvW4tKROV78MAC7L9wNSEq5ZuCrOhrdOosayGWgmTCinuBHiinL8ejSi6F+yCPAmXXy8OhHb/v1YNAL+q4i9052a7fUD5hjSfpiii6S2RxPXHNnWgu6f5dQUzCAfE303rE6BJu5mocSFmcJYReJoYX7kVlgoYnRwUxDGofHWQ+0dHYeW7aDxH0bCnGsP1Tz6sIPCkZCjMnFpuDFYstXkgU0fddqNRNhOCQsy04vK8Oy9r5H0RqvLg+Z3yVE+TWErZtl1E2MmuKeDY9wVulGpxDWqSOn1+4yTtfSnfMqBZE2QGl9v8Vkgw90o/rKNtS8OGqZ4Iu1sutric4VrRyM64MiqVcTdyPocCNu07N9nK8v/QrjdVkn4Xo+RvRnopZV5I5HEE5ocQjqsF/ppKBUWeoOr1qRLbKJPZzF2VLx7x58lWy+Bj9COl4pSHmYiZu0k+wpg1VBqOOHh/6q/0Iup8bos8yos8OHLJM+kZrf8nmxVvBJKhcOfJu9prqRLcd/06p2EjxIRY8vZc2vK8EUA2gOJqKoLFZLPxjtYE9lcj3rFX4vF18VgbikM4Mdks+JWM5J0/XbyDO5N/ViygxS7muIr44iqvb6jaNvceUCQ+L+Dp893QXEor7P8P1tiCxqW16+PNcyQiK34HxslTHwDiiZTxAY30qDwj/6ZF7Na2us5hYAw0GjDFlGhVywDNcO+zv48SOlhpTFXYPqVXCRh59ZeA0F2hG1Oza7WTGQqvfCk1UbuNBEq076HM5Kh9epLLP+Os61xnggODycnaHThrtK0XnLLi39QsFZbfeAgvvSFsudM7xREKJ54vybDKic4agxLuG9SwDYuJnzC1g/dts061dM2wGzJJpM+Z1pJYjCfLfK5/Ni1+PPr1wpgRSnstN5PytENICJNssexixB3yM6ctrPXZ0VExpcnuJgqYfZX0/kiQhkLT78FZ3sRnDw4L2V+u9CFCldhlKx+Lk44mkocZGvAVHxfmN2KXWjf+7EXGbTPyZ54RGYXlDGdq5YGpHCGh3mNURdXVSIMKRwOMmjHI0aI5vF+CEnMtaP2qn0eEOwv9iPEoHDeCp5lNAgeHeMVvbkuZwJAtJ5ugpAMioyXOmYcqVceZLH24ECmUXBSB0Hl0du4YNTebUc5dBg3A8fANEVgw3NqNMfpZXFtGaNKUNxsmG3SB6DXeOrdQEjIfF9Hd6I8OYcEkklUEvLpgzG3es8PudMA0WkE3dV54BNAmHcD8UMu9mqjiQ4TmTf3LB7T5XzOXkiHCk3x1620KDFFw9VHFo4U+CyLdq0XYDf4Acfv8J6Zv3+62Lo33HCpzKQ/mhcjRSuiL5t1PZd8bDsLkxhO1+9hru9nSbqGw6aHsjiIeG6gDaem1+0OvN5nLlK6sDHwXRUH5jhble15fVK4nBBAJdv/XbvVXZ0wnC7X4GFGDcu3IghpGW9byw2KCuNAHo0hSfIuADzBXH4kglmujfkY6RzDKTZgHGO6nGItdHK6eOhL9LnAosYLkOgPB2GSSNj9Exe6c7d4JXyEbLwiY4PaUhA2FzQNCWqd/DHaG8gqxHFOqxjggANB3CQhIH1LVNKpV1nt+ulwkOgCby09UffvAxJoVE4JyoKGfHpVfNPa2ADHQp/mA+ltP0kzCFK1i3YmAvhJlzdoAf4WGYJ1YkvX3XRQXijBYI439bK9yVvlCSVncutObuAD9ikDYcorVPDUrzBsIZnvFtN/r/nM9WMHeL6XEA+MT7+tMS4wyvuo0Cb8MZ8v/Eeix287J70sI6or1Tq9TPLHf4X5uh+N46w5RWYjnnuIJNe44ffCWroGqdjQMCElwBwRVReZZ6y5/DW2UYgQuc1pf/CDpyAmAcEDVJY/bwSjTAhcfylFhLjK/suOkWTns82qsf3XmyGkFLidCIlMaYA4ZbasCFlQelv2mythwmlXbX9dADUoU8W7jfvRecgcgSBbK4kwUbYarwF/g5iFA4iRHj1mAWs0cJRFX5ZSJrHPyo0Q/x+w2rY+lYZ25IGwzCgPUIPmxAbNVDlyLbPyTmbh/AY1BaA28aHRN8e2rdUX9kRmCT8b917pmZ6BGmynvG+0as5nqNhwqZj83ROW3xaa/m+BTkBf4YMPEbqJjUPMBS6jDefthDoiCsn3MSY78eREuC2QTWucVji8J59ikGm9O4RARkJdPiy0DczlhSXSYxDP+S3hYV572l//Ms9M+bnwjeCh+zft7N9IzMg9Ge3cjTGakWCT3+RNQhRlL5KCIvmF0otl9WBa5bhr0jeGVaaSJ2BWM5syuMqN7tGjtKhDfRbexkiH5Vi5d/nSUVDL61fUF4nB/g4mzSmrnSvYUXMe04OVoDB1z/Jt5ssRK3DkT7Do1z8Ya2pUce9MevowwXCQ04qoSZpvmao3DwUIsyNwq2aLmmUc9JMmEqTyd62zZZKu7y3BQNelcXAZCaTb9Ds/XZl/bel7uBMTPyDrppvL90fAq48rW7sPCNaw6CBbSu7R9tmx3d81UI7X39H5afWphydUfPIJMgPIiPT91RHPq0+30uL7jQzTr6i9MK5fymgrk+nKiZanKA/Lck9TdfpMlgOZ/AuFS7CzzvA6XL3n1GCCk8/TD1HRIaCZxnT53bpKcKGa8VT64RO1yt4hYOyar0sj/KSbx62//FxeZJ7eILudcbLmKGu+cF0E7uLk9+GMThnTwpDFIvsGqZF8298MHGs958bEEMqcG/0RNwjJriMo4UpcKnGF1eb5kgKoU2pvYENDHyBdfxIUiJ+N58P0ut1e94nn263A4h9fHH4k71NbcnJcch+mkwFzgWDhU1Tpi0dKJJ9rQilNXdC3+Fhkvs0ZRV0+cKzcn8NFPVlSuLOpIJDP+E61tmAixSPRGn+aRvW9H1rmmmqUfLD1m671Q2LLnIPM4GucS2UbT+ocb/r0yZpnPHHs2uZEHEf+qbDX3J/q7uzY8HRe289i/aXTAcKF8FkWOKCp4N3gIR8PsQ9D6Q4i/PWNKHyTLszGYRcK+fZWpWjjdXOyrzr2axoEmsS8b0DdoelHa9rsyowynKYe1t7iccmnfSaZDgRT3t8UCPXmx4aGSCa5yejQ08HdlNw9vqHk7yMuGAELvol5PwxCZUFlwyR1nC3R3BC+mRZ18ONDskKNdTzwQ</enc:CipherValue> - </enc:CipherData> -</enc:EncryptedData> - diff --git a/tests/Zend/InfoCard/_files/security_token_bad_keyref.xml b/tests/Zend/InfoCard/_files/security_token_bad_keyref.xml deleted file mode 100644 index e9f5c427d561a0fbec2616e63584a5ad3bd48ee5..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/security_token_bad_keyref.xml +++ /dev/null @@ -1,5 +0,0 @@ - <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> - <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1" - EncodingType="foo">/OCqQ7Np25sOiA+4OsFh1R6qIeY=</o:KeyIdentifier> - </o:SecurityTokenReference> - diff --git a/tests/Zend/InfoCard/_files/signedToken.xml b/tests/Zend/InfoCard/_files/signedToken.xml deleted file mode 100644 index 1a8d9d57177fe0766ce5d13ee6f161d0bd792bb1..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/signedToken.xml +++ /dev/null @@ -1 +0,0 @@ -<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="uuid:5cf2cd76-acf6-45ef-9059-a811801b80cc" Issuer="http://schemas.xmlsoap.org/ws/2005/05/identity/issuer/self" IssueInstant="2007-09-18T22:17:03.812Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><saml:Conditions NotBefore="2007-09-18T22:17:03.812Z" NotOnOrAfter="2007-09-18T23:17:03.812Z"><saml:AudienceRestrictionCondition><saml:Audience>https://192.168.1.105/</saml:Audience></saml:AudienceRestrictionCondition></saml:Conditions><saml:AttributeStatement><saml:Subject><saml:SubjectConfirmation><saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod></saml:SubjectConfirmation></saml:Subject><saml:Attribute AttributeName="givenname" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>John</saml:AttributeValue></saml:Attribute><saml:Attribute AttributeName="surname" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>Coggeshall</saml:AttributeValue></saml:Attribute><saml:Attribute AttributeName="emailaddress" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>john@zend.com</saml:AttributeValue></saml:Attribute><saml:Attribute AttributeName="privatepersonalidentifier" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>rW1/y9BuncoBK4WSipF2hHYParxxgMHk6ANBrhz1Zr4=</saml:AttributeValue></saml:Attribute></saml:AttributeStatement><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference URI="#uuid:5cf2cd76-acf6-45ef-9059-a811801b80cc"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>yFSYBpQeAjaXDv5h0zeTa93BotQ=</DigestValue></Reference></SignedInfo><SignatureValue>DSNpAxguIMB2akSMzre4SJJwrfCLLHIGzmeiAPb72KbcA/rEWkrH4f0BnGw92/Ky4xIuAbUjNLfn+bhdBfGmFGNUbH8dxSMdbALW0aGnqqcGGGWaeb0UZaMiIm+rYzMaWi2QAheSR8dFwJ5spWJ3BHigHZjFkNZ2wuNpgpDbpeLMfR4hPbOxyNNeUQWMyPDuP2SeMcwOkqYPSUyrhVfy8CR6Ub4Pa0Jr9Ewt7/Q0QyYei3/xgNHls7eOG5zPQ7l9uFWPXzYifvBXbmrkMWC7QLAK8r08V1rF+Mr/r8PayhMdlZ9Ix2bksuoFavltLOiwn4SCVc6zqgUczuKLtQeG4Q==</SignatureValue><KeyInfo><KeyValue><RSAKeyValue><Modulus>0nDenDIv8SoPI+zrS5FREIecN4P1Sy2dRugqEEKCyZ6lAHP+8WKK8Ar56PudYR7/AYdaq/2GiWu0Ul5+MZBMGYBV1+vriq5JBhWp6LvoVnEk0yqnXbNe096cVfPLa0Ts8YmLb4hMAGGLwb9FTgmMeKqC2JCGf4DGO4czny0j5FPtJBVwTtzznY3OeJxKqGimrKHJ7K7NXTYcuNqA+s+pldhj1dSej1gsxST3dwAwm+QsxH06GhmeliIu1mFGVNw0JprCgaBYIt24KKURugYQvtQdyUqTFCJh8PSWMHddV9O76NSan0M89agSjn7coHgRYDVKzhowrnCemNietbNkkQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></saml:Assertion> \ No newline at end of file diff --git a/tests/Zend/InfoCard/_files/signedToken_bad_type.xml b/tests/Zend/InfoCard/_files/signedToken_bad_type.xml deleted file mode 100644 index c1060ce87196619c072a0e8b5d3e97a62b6f05dc..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/signedToken_bad_type.xml +++ /dev/null @@ -1 +0,0 @@ -<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="uuid:5cf2cd76-acf6-45ef-9059-a811801b80cc" Issuer="http://schemas.xmlsoap.org/ws/2005/05/identity/issuer/self" IssueInstant="2007-09-18T22:17:03.812Z" xmlns:saml="foo"><saml:Conditions NotBefore="2007-09-18T22:17:03.812Z" NotOnOrAfter="2007-09-18T23:17:03.812Z"><saml:AudienceRestrictionCondition><saml:Audience>https://192.168.1.105/</saml:Audience></saml:AudienceRestrictionCondition></saml:Conditions><saml:AttributeStatement><saml:Subject><saml:SubjectConfirmation><saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod></saml:SubjectConfirmation></saml:Subject><saml:Attribute AttributeName="givenname" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>John</saml:AttributeValue></saml:Attribute><saml:Attribute AttributeName="surname" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>Coggeshall</saml:AttributeValue></saml:Attribute><saml:Attribute AttributeName="emailaddress" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>john@zend.com</saml:AttributeValue></saml:Attribute><saml:Attribute AttributeName="privatepersonalidentifier" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>rW1/y9BuncoBK4WSipF2hHYParxxgMHk6ANBrhz1Zr4=</saml:AttributeValue></saml:Attribute></saml:AttributeStatement><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference URI="#uuid:5cf2cd76-acf6-45ef-9059-a811801b80cc"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>yFSYBpQeAjaXDv5h0zeTa93BotQ=</DigestValue></Reference></SignedInfo><SignatureValue>DSNpAxguIMB2akSMzre4SJJwrfCLLHIGzmeiAPb72KbcA/rEWkrH4f0BnGw92/Ky4xIuAbUjNLfn+bhdBfGmFGNUbH8dxSMdbALW0aGnqqcGGGWaeb0UZaMiIm+rYzMaWi2QAheSR8dFwJ5spWJ3BHigHZjFkNZ2wuNpgpDbpeLMfR4hPbOxyNNeUQWMyPDuP2SeMcwOkqYPSUyrhVfy8CR6Ub4Pa0Jr9Ewt7/Q0QyYei3/xgNHls7eOG5zPQ7l9uFWPXzYifvBXbmrkMWC7QLAK8r08V1rF+Mr/r8PayhMdlZ9Ix2bksuoFavltLOiwn4SCVc6zqgUczuKLtQeG4Q==</SignatureValue><KeyInfo><KeyValue><RSAKeyValue><Modulus>0nDenDIv8SoPI+zrS5FREIecN4P1Sy2dRugqEEKCyZ6lAHP+8WKK8Ar56PudYR7/AYdaq/2GiWu0Ul5+MZBMGYBV1+vriq5JBhWp6LvoVnEk0yqnXbNe096cVfPLa0Ts8YmLb4hMAGGLwb9FTgmMeKqC2JCGf4DGO4czny0j5FPtJBVwTtzznY3OeJxKqGimrKHJ7K7NXTYcuNqA+s+pldhj1dSej1gsxST3dwAwm+QsxH06GhmeliIu1mFGVNw0JprCgaBYIt24KKURugYQvtQdyUqTFCJh8PSWMHddV9O76NSan0M89agSjn7coHgRYDVKzhowrnCemNietbNkkQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></saml:Assertion> diff --git a/tests/Zend/InfoCard/_files/ssl_private.cert b/tests/Zend/InfoCard/_files/ssl_private.cert deleted file mode 100644 index 6248b0c565b6b7b61f9a86ef81a2f04239378040..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/ssl_private.cert +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJKAIBAAKCAgEAtmCinv4c2Y5oh7go62or4lQMJiM/oBJnRiA+7zqcvsbl4AYJ -Ke3dEBz19i2kIL56GezMzeCyC89GsLQ1+0W8L2Ysyr1TyH8ZqVMjtL63utxkDXKE -0NniQttijgkqfK7D4yH8TMiTu0WVoa1OU8vrSDe8KLF11pHEVWjb41MlJvK2eDea -kbb96hU3Xcvfuuthd49TNZ45EbqgEuUMpJIpd9GnRPV+46jTbKHR6hkw/udm8X2g -6nJ+5Nb3Ju7d972YsMnpO9jJ/0l/JYUXCOAEeJEGAaPLv+LsFlatP9FzJ5fXx5H6 -uf/u8ipHo5zVr6/1eI3I9BvEz/5wqxIRe6RvlN5DWdVvmBNnPur4rb5j8/7TVLaR -7nMO1VSK3/roMXAGxwvcFV7/amHxWvHbDIw0AuBBfrjW92PKjrpIyER3scFzSNbd -S3tdyylMsRahFEp1qjkcv6QlZWPZJzqdKZMb7TOI/lP+VWh/BkfCt9xo3bWOm1/u -pKNANXeQl5AyQqzJ/xZdpZLDY3yG0+8e6YdBR+6gNnlYTcumZlYSHGPxTsXWW8Hn -SsinMFxabH4uqXbVOQE0wY+xE7Q2ip6+RzovAsSTkSv2b5QinxOw4mSO3GdtlP8d -MnS8uL/MNHN4/Zl41kbx96kct7QRPWN6S2crRqag+7kyDEDiKh2DoQr5bKkCAwEA -AQKCAgBeo1a/2m1uF4/2nYHeZ4HOOH71a2Ug02vz39fInEmqVdwDnB41O9FzAxQ/ -Yv/AXhdOTKsaSncZ2b19BIbelRlKH2Mu8YAAkrPmQdZNfIoq1SK2N67kEaxvtRg3 -TFpXyPitbH1X+t1uWHWFKEF1CmRVXVauZygW6B1RlNBF7mdhBqHZUEFNTAAG8GuC -qMC4Zlx1hlJPiINkx8s5AtLEs3QBUTHTfvERghH0VSRwrhHWtI2e0uolvrRKW6J0 -+Y8Fd8U8OApnm992MdVgyudhG542UksjnrOkJ0ULcn8EltOCwDCgxwesbTq5P2dd -Z40bVduzax/UTHSc2hPtMbsQxgt/+7l6iIJ2CPuSRQORQQJf9Ar8b7qLf6aXK11O -KO56gl4DcPlo5n19BdqkSMZ6zeJaJAe0UEhag4wkE1mpgPFVmm5av40zNQ1XnCJN -D8RaA7tZHiXCkRXtmcInSzEIOJDEpBx53eCiOTci+TxBvX4BUo03r6hPdA8pxgRj -PXKd+w5Mz/mj5UJHsf8OtCqBPaM+oRm8xLRSRRzwIx02QacUNO957y5weUtdscPE -Y1+CRhxSEut8mjsn6vuuujM2w+v/sXHDqbB1QHDPbsbAXWX5d+1BuTu87tUsz24q -/bjnIAk9qjW/XdfSmmcMIWi8AHgumVtItn8AcWHBnag+qyqtYQKCAQEA6kvGBAOr -Q46rhIz70tjlFZXNdNFm62xqJwmYBzlOuHVzYtwnH1W471NZizkMh9Uvuhtsn9UM -0nC7adsWqe6GHk0YoeR93HpEwI08smWWdGV0SYIMJPOQPQ9z8QjlzWBdGJwZKuXb -VVqpvYH6FVJYTQIyb1tZ7kbMXkJZkabpCKOiT/7WSw9dN7Spbc8DuyJ68EIlJImD -1z/j4UVjVfigs/6oUo83Uam623YETl1+DKF2lPVUBELwh6B3jdR+ujANGLGZ5NXB -1jqvzZrbC1uMj5JPUcNDwjj7SDwQJ+7gSsq96pZ/dLYfT5o0Z5p+BvuYjarkoQuN -QFfKC+gu19eeYwKCAQEAx0WjGWiQSUzHL5NVYtBdkmEdjF+rZ7OXL0cn/NywH/y3 -se+oJuySh3TMUgQxmz7oTH7k7pOhXqeiTEpOs3ItS47QSlnMdaIW/S215YQ5qk1r -R9YxuqESKGpsL65+1likAGtvWazcZuY98eY04cSRsHanO165uMdSqFg6uoK2daB9 -6NQXX4EZsCT2/eaHuxqscQaVG1k+tnBYqZLHovqAsWadOTPTVNDXvuiyU1F1Uveo -SudT98UUnVpxU/wktHzqP6eDU4CPBbREEXdpqIYvR4QeqkyTvnuVNGTigRtkPaJ9 -YsZ4epCBfd2pteu+2na/fWVc/2bR++MO9JEONP0ggwKCAQBuOoIJx3Qez5OQRAgB -9bspgZXs3MvP/OygOxpEY8jObauAmlTpoBnmts8M+iUUDs9qfpaHR+PFafYyYjny -bt64iMsK94XjYb7Q3GHvCG5VipnAL6fpBpIYuBlzEB2Vlz2VY3NPxF6BdKshFnKC -73/NkzgJPfA8cyCZRBwBs4Y1Y07s1dcZ7zuLBrsjh16Y/yrZuDTjULMvZMagaFXI -z7VDmY61cN201Oatc4OpHsE7zgcNI7KIYrnpBSzaFFwe2pZ+xKfDinGsiWXGlJFz -cXna3hnlPLm3Obm3DVMIhpENfv8EzBNg5IIsoD8BcyTRwjLOi9UOk3G8ENFk8rJ/ -J9lDAoIBAB68AtfcZMSpbt9LnhPLh2MYT3JjHxCzhlHoa6Z4c0G7vKlZCVpXipIR -1aGgu/Xx0epad/zEEFOFD2cs3s6WgZ3xvPZ6uyo5gcoyzqdDqZE2t6EwzCK4zRAm -ueDwzOdKbKET8Oyn2KaWRF+W3fkkVEQfSNPDXGm/dGQ6l3REzNd/lWvfqms0gj3E -tcObVrvo9UfJeB3rudxxn3soBFqCwG6cIQu9jo66V0w+n6JyIeJWCELlQvIoF3Hd -jTUi4pZj3c1LjNnILkb28riu7kDr0Ub6fbBOd0sdzHl0Resbym4nLaeabOKafx5m -ndJNNfaD8izpAVrzBNgQwTG/Xa2WjPkCggEBAIhTAdNmTNHpTymb3OksR81YNRIo -+0Y2AMLXbYnOV0hshWlaiTtffPFUVrhbm+w6nCPimPknVCqjHvIvFyNQpqSOs5YX -NwNmDtBiOQBcgmQ4Zd3K/JtvbXc6g1cHaa4ESP6X3d0VfH/y5RGHuo1rAlzvejfS -i8mbstDw3lntc/7PACzbWzRKg4Hyc6m/08vhCG0HXgar9/neZP85Ur9YLgakcqDu -AFcSPi9trTJVv3Wq6tEbyv1coORJA+CnCOhztMpM83DvEhqGjOtHeXRyC8EPJ2kj -AlaoCXXh/ymc+I7SlXonCh9VwaDAErPWvIj5y6wJPKq4JHnIVzVAJ6iKAzY= ------END RSA PRIVATE KEY----- diff --git a/tests/Zend/InfoCard/_files/ssl_pub.cert b/tests/Zend/InfoCard/_files/ssl_pub.cert deleted file mode 100644 index 758a3129ad678227e4419056c5cf4ac64abd0b74..0000000000000000000000000000000000000000 --- a/tests/Zend/InfoCard/_files/ssl_pub.cert +++ /dev/null @@ -1,33 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFxDCCA6wCAQEwDQYJKoZIhvcNAQEFBQAwgaQxCzAJBgNVBAYTAlVTMREwDwYD -VQQIEwhOZXcgWW9yazEQMA4GA1UEBxMHQnVmZmFsbzEaMBgGA1UEChMRWmVuZCBU -ZWNobm9sb2dpZXMxHjAcBgNVBAsTFVByb2Zlc3Npb25hbCBTZXJ2aWNlczEWMBQG -A1UEAxMNMTkyLjE2OC4xLjEwNTEcMBoGCSqGSIb3DQEJARYNam9obkB6ZW5kLmNv -bTAeFw0wNzA5MTgxNjQyNTdaFw0wODA5MTcxNjQyNTdaMIGqMQswCQYDVQQGEwJV -UzERMA8GA1UECBMITmV3IFlvcmsxEDAOBgNVBAcTB0J1ZmZhbG8xIDAeBgNVBAoT -F1plbmQgVGVjaG5vbG9naWVzLCBJbmMuMR4wHAYDVQQLExVQcm9mZXNzaW9uYWwg -U2VydmljZXMxFjAUBgNVBAMTDTE5Mi4xNjguMS4xMDUxHDAaBgkqhkiG9w0BCQEW -DWpvaG5AemVuZC5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2 -YKKe/hzZjmiHuCjraiviVAwmIz+gEmdGID7vOpy+xuXgBgkp7d0QHPX2LaQgvnoZ -7MzN4LILz0awtDX7RbwvZizKvVPIfxmpUyO0vre63GQNcoTQ2eJC22KOCSp8rsPj -IfxMyJO7RZWhrU5Ty+tIN7wosXXWkcRVaNvjUyUm8rZ4N5qRtv3qFTddy9+662F3 -j1M1njkRuqAS5Qykkil30adE9X7jqNNsodHqGTD+52bxfaDqcn7k1vcm7t33vZiw -yek72Mn/SX8lhRcI4AR4kQYBo8u/4uwWVq0/0XMnl9fHkfq5/+7yKkejnNWvr/V4 -jcj0G8TP/nCrEhF7pG+U3kNZ1W+YE2c+6vitvmPz/tNUtpHucw7VVIrf+ugxcAbH -C9wVXv9qYfFa8dsMjDQC4EF+uNb3Y8qOukjIRHexwXNI1t1Le13LKUyxFqEUSnWq -ORy/pCVlY9knOp0pkxvtM4j+U/5VaH8GR8K33GjdtY6bX+6ko0A1d5CXkDJCrMn/ -Fl2lksNjfIbT7x7ph0FH7qA2eVhNy6ZmVhIcY/FOxdZbwedKyKcwXFpsfi6pdtU5 -ATTBj7ETtDaKnr5HOi8CxJORK/ZvlCKfE7DiZI7cZ22U/x0ydLy4v8w0c3j9mXjW -RvH3qRy3tBE9Y3pLZytGpqD7uTIMQOIqHYOhCvlsqQIDAQABMA0GCSqGSIb3DQEB -BQUAA4ICAQCiBzdsthUHuCv5ec8r/yH93l3fRkoIEh1ZZAycnLjTC5rKZvRlWAXu -VKs7ViauRSt4dth6MTGmCZO6Lv3uO4G/YmvwcANYVOl0z7DoC0QCccmRtGcGHWt/ -jciQgqvoUe+d5JHQeU9AtclLXSIIbQr9FtlBYdaPHjq+6AXtKgy+Gzo8lQITcqh9 -OBODgIvt6O/rILg26G4Ud/X1aJbfD3xCrwNMs0FQMnnl9mFyNO3ZZPtbGcuaVQTJ -w3immpFZQloqh6W5/+0OBAXmdz/LQITomUjajTBsoEJIgT6qTIniPLb2oxgw4dcM -p3ECXNc7S6xO41ky1jsN9NDCeY8OL3zaXjN0cdUVfWTCbUeVQ9K4cq6NeUCNko21 -pa+N6vsZYXUBNqvvDWwGqstZIwnE0awZ9UX6hfK+AqdNWIoBTcclmTQCgS3JWuXP -p1u8N5wTyAsxiEmJhMPOZSgj1i+OgPrh3zaAc84WtXk6BKVsMK1Yo0lu55tVrMI0 -sa00deH3HTxrtVWKmwfmfwZEjMmwd8YJEhmYcOr5hgB9/cS0b3svSJnQCifrYNg0 -PmTZprqmalzFdTmsFeogCx79f9yDEmFrw3/UZFeF/+4GHMbBzTHPYvwdKZFPXHma -EHOj/mkX+lt19SkiPzg9rDNaCF2SyvBH1lQWCRNn1yPivpWdcxIF9A== ------END CERTIFICATE----- diff --git a/tests/Zend/Json/AllTests.php b/tests/Zend/Json/AllTests.php deleted file mode 100644 index 44007d0c87f1c353453a8755240d15d1a530d1af..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/AllTests.php +++ /dev/null @@ -1,64 +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_Json - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10130 2008-07-16 14:51:08Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Json_AllTests::main'); -} - -require_once 'Zend/Json/JsonXMLTest.php'; -require_once 'Zend/Json/ServerTest.php'; -require_once 'Zend/Json/Server/AllTests.php'; - -/** - * @category Zend - * @package Zend_Json - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Json_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Json'); - - $suite->addTestSuite('Zend_Json_JsonXMLTest'); - $suite->addTestSuite('Zend_Json_ServerTest'); - $suite->addTest(Zend_Json_Server_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Json_AllTests::main') { - Zend_Json_AllTests::main(); -} diff --git a/tests/Zend/Json/JsonXMLTest.php b/tests/Zend/Json/JsonXMLTest.php deleted file mode 100644 index 897b5d3a6b27875207075dddf4d16cfe28e77b34..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/JsonXMLTest.php +++ /dev/null @@ -1,537 +0,0 @@ -<?php -/** - * @package Zend_JsonXML - * @subpackage UnitTests - */ - -error_reporting( E_ALL | E_STRICT ); // now required for each test suite - -/** - * Zend_Json - */ -require_once 'Zend/Json.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - -/** - * @package Zend_JsonXML - * @subpackage UnitTests - */ -class Zend_Json_JsonXMLTest extends PHPUnit_Framework_TestCase -{ - /** - * xml2json Test 1 - * It tests the conversion of a contact list xml into Json format. - * - * XML characteristic to be tested: XML containing an array of child elements. - * - */ - public function testUsingXML1() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -<?xml version="1.0" encoding="UTF-8"?> -<contacts> - <contact> - <name> - John Doe - </name> - <phone> - 123-456-7890 - </phone> - </contact> - - <contact> - <name> - Jane Doe - </name> - <phone> - 123-456-0000 - </phone> - </contact> - - <contact> - <name> - John Smith - </name> - <phone> - 123-456-1111 - </phone> - </contact> - - <contact> - <name> - Jane Smith - </name> - <phone> - 123-456-9999 - </phone> - </contact> - -</contacts> - -EOT; - - // There are not going to be any XML attributes in this test XML. - // Hence, set the flag to ignore XML attributes. - $ignoreXmlAttributes = true; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertSame($ex, null, "Zend_JSON::fromXml returned an exception."); - - // Convert the JSON string into a PHP array. - $phpArray = Zend_Json::decode($jsonContents); - // Test if it is not a NULL object. - $this->assertNotNull($phpArray, "JSON result for XML input 1 is NULL"); - // Test for one of the expected fields in the JSON result. - $this->assertSame("Jane Smith", $phpArray['contacts']['contact'][3]['name'], "The last contact name converted from XML input 1 is not correct"); - } // End of function testUsingXML1 - - /** - * xml2json Test 2 - * It tests the conversion of book publication xml into Json format. - * - * XML characteristic to be tested: XML containing an array of child elements with XML attributes. - * - */ - public function testUsingXML2() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -<?xml version="1.0" encoding="UTF-8"?> -<books> - <book id="1"> - <title>Code Generation in Action</title> - <author><first>Jack</first><last>Herrington</last></author> - <publisher>Manning</publisher> - </book> - <book id="2"> - <title>PHP Hacks</title> - <author><first>Jack</first><last>Herrington</last></author> - <publisher>O'Reilly</publisher> - </book> - <book id="3"> - <title>Podcasting Hacks</title> - <author><first>Jack</first><last>Herrington</last></author> - <publisher>O'Reilly</publisher> - </book> -</books> - -EOT; - - // There are going to be XML attributes in this test XML. - // Hence, set the flag NOT to ignore XML attributes. - $ignoreXmlAttributes = false; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertSame($ex, null, "Zend_JSON::fromXml returned an exception."); - - // Convert the JSON string into a PHP array. - $phpArray = Zend_Json::decode($jsonContents); - // Test if it is not a NULL object. - $this->assertNotNull($phpArray, "JSON result for XML input 2 is NULL"); - // Test for one of the expected fields in the JSON result. - $this->assertSame("Podcasting Hacks", $phpArray['books']['book'][2]['title'], "The last book title converted from XML input 2 is not correct"); - // Test one of the expected XML attributes carried over in the JSON result. - $this->assertSame("3", $phpArray['books']['book'][2]['@attributes']['id'], "The last id attribute converted from XML input 2 is not correct"); - } // End of function testUsingXML2 - - /** - * xml2json Test 3 - * It tests the conversion of food menu xml into Json format. - * - * XML characteristic to be tested: XML containing an array of child elements. - * - */ - public function testUsingXML3() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -<?xml version="1.0" encoding="ISO-8859-1" ?> -<breakfast_menu> - <food> - <name>Belgian Waffles</name> - <price>$5.95</price> - <description> - two of our famous Belgian Waffles with plenty of real maple - syrup - </description> - <calories>650</calories> - </food> - <food> - <name>Strawberry Belgian Waffles</name> - <price>$7.95</price> - <description> - light Belgian waffles covered with strawberries and whipped - cream - </description> - <calories>900</calories> - </food> - <food> - <name>Berry-Berry Belgian Waffles</name> - <price>$8.95</price> - <description> - light Belgian waffles covered with an assortment of fresh - berries and whipped cream - </description> - <calories>900</calories> - </food> - <food> - <name>French Toast</name> - <price>$4.50</price> - <description> - thick slices made from our homemade sourdough bread - </description> - <calories>600</calories> - </food> - <food> - <name>Homestyle Breakfast</name> - <price>$6.95</price> - <description> - two eggs, bacon or sausage, toast, and our ever-popular hash - browns - </description> - <calories>950</calories> - </food> -</breakfast_menu> - -EOT; - - // There are not going to be any XML attributes in this test XML. - // Hence, set the flag to ignore XML attributes. - $ignoreXmlAttributes = true; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertSame($ex, null, "Zend_JSON::fromXml returned an exception."); - - // Convert the JSON string into a PHP array. - $phpArray = Zend_Json::decode($jsonContents); - // Test if it is not a NULL object. - $this->assertNotNull($phpArray, "JSON result for XML input 3 is NULL"); - // Test for one of the expected fields in the JSON result. - $this->assertContains("Homestyle Breakfast", $phpArray['breakfast_menu']['food'][4], "The last breakfast item name converted from XML input 3 is not correct"); - } // End of function testUsingXML3 - - /** - * xml2json Test 4 - * It tests the conversion of RosettaNet purchase order xml into Json format. - * - * XML characteristic to be tested: XML containing an array of child elements and multiple attributes. - * - */ - public function testUsingXML4() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -<?xml version="1.0" encoding="UTF-8"?> -<PurchaseRequisition> - <Submittor> - <SubmittorName>John Doe</SubmittorName> - <SubmittorEmail>john@nodomain.net</SubmittorEmail> - <SubmittorTelephone>1-123-456-7890</SubmittorTelephone> - </Submittor> - <Billing/> - <Approval/> - <Item number="1"> - <ItemType>Electronic Component</ItemType> - <ItemDescription>25 microfarad 16 volt surface-mount tantalum capacitor</ItemDescription> - <ItemQuantity>42</ItemQuantity> - <Specification> - <Category type="UNSPSC" value="32121501" name="Fixed capacitors"/> - <RosettaNetSpecification> - <query max.records="1"> - <element dicRef="XJA039"> - <name>CAPACITOR - FIXED - TANTAL - SOLID</name> - </element> - <element> - <name>Specific Features</name> - <value>R</value> - </element> - <element> - <name>Body Material</name> - <value>C</value> - </element> - <element> - <name>Terminal Position</name> - <value>A</value> - </element> - <element> - <name>Package: Outline Style</name> - <value>CP</value> - </element> - <element> - <name>Lead Form</name> - <value>D</value> - </element> - <element> - <name>Rated Capacitance</name> - <value>0.000025</value> - </element> - <element> - <name>Tolerance On Rated Capacitance (%)</name> - <value>10</value> - </element> - <element> - <name>Leakage Current (Short Term)</name> - <value>0.0000001</value> - </element> - <element> - <name>Rated Voltage</name> - <value>16</value> - </element> - <element> - <name>Operating Temperature</name> - <value type="max">140</value> - <value type="min">-10</value> - </element> - <element> - <name>Mounting</name> - <value>Surface</value> - </element> - </query> - </RosettaNetSpecification> - </Specification> - <Vendor number="1"> - <VendorName>Capacitors 'R' Us, Inc.</VendorName> - <VendorIdentifier>98-765-4321</VendorIdentifier> - <VendorImplementation>http://sylviaearle/capaciorsRus/wsdl/buyerseller-implementation.wsdl</VendorImplementation> - </Vendor> - </Item> -</PurchaseRequisition> - -EOT; - - // There are going to be XML attributes in this test XML. - // Hence, set the flag NOT to ignore XML attributes. - $ignoreXmlAttributes = false; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertSame($ex, null, "Zend_JSON::fromXml returned an exception."); - - // Convert the JSON string into a PHP array. - $phpArray = Zend_Json::decode($jsonContents); - // Test if it is not a NULL object. - $this->assertNotNull($phpArray, "JSON result for XML input 4 is NULL"); - // Test for one of the expected fields in the JSON result. - $this->assertContains("98-765-4321", $phpArray['PurchaseRequisition']['Item']['Vendor'], "The vendor id converted from XML input 4 is not correct"); - // Test for the presence of multiple XML attributes present that were carried over in the JSON result. - $this->assertContains("UNSPSC", $phpArray['PurchaseRequisition']['Item']['Specification']['Category']['@attributes'], "The type attribute converted from XML input 4 is not correct"); - $this->assertContains("32121501", $phpArray['PurchaseRequisition']['Item']['Specification']['Category']['@attributes'], "The value attribute converted from XML input 4 is not correct"); - $this->assertContains("Fixed capacitors", $phpArray['PurchaseRequisition']['Item']['Specification']['Category']['@attributes'], "The name attribute converted from XML input 4 is not correct"); - } // End of function testUsingXML4 - - /** - * xml2json Test 5 - * It tests the conversion of TV shows xml into Json format. - * - * XML characteristic to be tested: XML containing simple CDATA. - * - */ - public function testUsingXML5() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -<?xml version="1.0"?> -<tvshows> - <show> - <name>The Simpsons</name> - </show> - - <show> - <name><![CDATA[Lois & Clark]]></name> - </show> -</tvshows> - -EOT; - - // There are not going to be any XML attributes in this test XML. - // Hence, set the flag to ignore XML attributes. - $ignoreXmlAttributes = true; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertSame($ex, null, "Zend_JSON::fromXml returned an exception."); - - // Convert the JSON string into a PHP array. - $phpArray = Zend_Json::decode($jsonContents); - // Test if it is not a NULL object. - $this->assertNotNull($phpArray, "JSON result for XML input 5 is NULL"); - // Test for one of the expected CDATA fields in the JSON result. - $this->assertContains("Lois & Clark", $phpArray['tvshows']['show'][1]['name'], "The CDATA name converted from XML input 5 is not correct"); - } // End of function testUsingXML5 - - /** - * xml2json Test 6 - * It tests the conversion of demo application xml into Json format. - * - * XML characteristic to be tested: XML containing a large CDATA. - * - */ - public function testUsingXML6() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -<?xml version="1.0"?> -<demo> - <application> - <name>Killer Demo</name> - </application> - - <author> - <name>John Doe</name> - </author> - - <platform> - <name>LAMP</name> - </platform> - - <framework> - <name>Zend</name> - </framework> - - <language> - <name>PHP</name> - </language> - - <listing> - <code> - <![CDATA[ -/* -It may not be a syntactically valid PHP code. -It is used here just to illustrate the CDATA feature of Zend_Xml2Json -*/ -<?php -include 'example.php'; -new SimpleXMLElement(); -echo(getMovies()->movie[0]->characters->addChild('character')); -getMovies()->movie[0]->characters->character->addChild('name', "Mr. Parser"); -getMovies()->movie[0]->characters->character->addChild('actor', "John Doe"); -// Add it as a child element. -getMovies()->movie[0]->addChild('rating', 'PG'); -getMovies()->movie[0]->rating->addAttribute("type", 'mpaa'); -echo getMovies()->asXML(); -?> - ]]> - </code> - </listing> -</demo> - -EOT; - - // There are not going to be any XML attributes in this test XML. - // Hence, set the flag to ignore XML attributes. - $ignoreXmlAttributes = true; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertSame($ex, null, "Zend_JSON::fromXml returned an exception."); - - // Convert the JSON string into a PHP array. - $phpArray = Zend_Json::decode($jsonContents); - // Test if it is not a NULL object. - $this->assertNotNull($phpArray, "JSON result for XML input 6 is NULL"); - // Test for one of the expected fields in the JSON result. - $this->assertContains("Zend", $phpArray['demo']['framework']['name'], "The framework name field converted from XML input 6 is not correct"); - // Test for one of the expected CDATA fields in the JSON result. - $this->assertContains('echo getMovies()->asXML();', $phpArray['demo']['listing']['code'], "The CDATA code converted from XML input 6 is not correct"); - } // End of function testUsingXML6 - - /** - * xml2json Test 7 - * It tests the conversion of an invalid xml into Json format. - * - * XML characteristic to be tested: XML containing invalid syntax. - * - */ -/* - public function testUsingXML7() - { - // Set the XML contents that will be tested here. - $xmlStringContents = <<<EOT -This is an invalid XML file. -Use this file to test the xml2json feature in the Zend_Json class. -Since it is an invalid XML file, an appropriate exception should be -thrown by the Zend_Json::fromXml function. -<?xml version="1.0"?> -<invalidxml> - </code> - </listing> -</invalidxml> - -EOT; - - // There are not going to be any XML attributes in this test XML. - // Hence, set the flag to ignore XML attributes. - $ignoreXmlAttributes = true; - $jsonContents = ""; - $ex = null; - - // Convert XNL to JSON now. - // fromXml function simply takes a String containing XML contents as input. - try { - $jsonContents = Zend_Json::fromXml($xmlStringContents, $ignoreXmlAttributes); - } catch (Exception $ex) { - ; - } - - $this->assertNotSame($ex, null, "Zend_JSON::fromXml returned an exception."); - } // End of function testUsingXML7 -*/ -} // End of class Zend_Json_JsonXMLTest - - diff --git a/tests/Zend/Json/Server/AllTests.php b/tests/Zend/Json/Server/AllTests.php deleted file mode 100644 index 295245d0444551a85ae0f959f68e2dc07ac82dfb..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/Server/AllTests.php +++ /dev/null @@ -1,68 +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_Json - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10130 2008-07-16 14:51:08Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Json_Server_AllTests::main'); -} - -require_once 'Zend/Json/Server/ErrorTest.php'; -require_once 'Zend/Json/Server/RequestTest.php'; -require_once 'Zend/Json/Server/ResponseTest.php'; -require_once 'Zend/Json/Server/SmdTest.php'; -require_once 'Zend/Json/Server/Smd/ServiceTest.php'; - -/** - * @category Zend - * @package Zend_Json - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Json_Server_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Json - Server'); - - $suite->addTestSuite('Zend_Json_Server_ErrorTest'); - $suite->addTestSuite('Zend_Json_Server_RequestTest'); - $suite->addTestSuite('Zend_Json_Server_ResponseTest'); - $suite->addTestSuite('Zend_Json_Server_SmdTest'); - $suite->addTestSuite('Zend_Json_Server_Smd_ServiceTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Json_Server_AllTests::main') { - Zend_Json_Server_AllTests::main(); -} diff --git a/tests/Zend/Json/Server/ErrorTest.php b/tests/Zend/Json/Server/ErrorTest.php deleted file mode 100644 index c98b963778bd47a5254162d713e9b4e97b4bebd6..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/Server/ErrorTest.php +++ /dev/null @@ -1,160 +0,0 @@ -<?php -// Call Zend_Json_Server_ErrorTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Json_Server_ErrorTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Json/Server/Error.php'; -require_once 'Zend/Json.php'; - -/** - * Test class for Zend_Json_Server_Error - */ -class Zend_Json_Server_ErrorTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Json_Server_ErrorTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->error = new Zend_Json_Server_Error(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testCodeShouldBeErrOtherByDefault() - { - $this->assertEquals(Zend_Json_Server_Error::ERROR_OTHER, $this->error->getCode()); - } - - public function testSetCodeShouldCastToInteger() - { - $this->error->setCode('-32768'); - $this->assertEquals(-32768, $this->error->getCode()); - } - - public function testCodeShouldBeLimitedToStandardIntegers() - { - foreach (array(true, 'foo', array(), new stdClass, 2.0, 25) as $code) { - $this->error->setCode($code); - $this->assertEquals(Zend_Json_Server_Error::ERROR_OTHER, $this->error->getCode()); - } - } - - public function testCodeShouldAllowArbitraryAppErrorCodesInXmlRpcErrorCodeRange() - { - foreach (range(-32099, -32000) as $code) { - $this->error->setCode($code); - $this->assertEquals($code, $this->error->getCode()); - } - } - - public function testMessageShouldBeNullByDefault() - { - $this->assertNull($this->error->getMessage()); - } - - public function testSetMessageShouldCastToString() - { - foreach (array(true, 2.0, 25) as $message) { - $this->error->setMessage($message); - $this->assertEquals((string) $message, $this->error->getMessage()); - } - } - - public function testSetMessageToNonScalarShouldSilentlyFail() - { - foreach (array(array(), new stdClass) as $message) { - $this->error->setMessage($message); - $this->assertNull($this->error->getMessage()); - } - } - - public function testDataShouldBeNullByDefault() - { - $this->assertNull($this->error->getData()); - } - - public function testShouldAllowArbitraryData() - { - foreach (array(true, 'foo', 2, 2.0, array(), new stdClass) as $datum) { - $this->error->setData($datum); - $this->assertEquals($datum, $this->error->getData()); - } - } - - public function testShouldBeAbleToCastToArray() - { - $this->setupError(); - $array = $this->error->toArray(); - $this->validateArray($array); - } - - public function testShouldBeAbleToCastToJson() - { - $this->setupError(); - $json = $this->error->toJson(); - $this->validateArray(Zend_Json::decode($json)); - } - - public function testCastingToStringShouldCastToJson() - { - $this->setupError(); - $json = $this->error->__toString(); - $this->validateArray(Zend_Json::decode($json)); - } - - public function setupError() - { - $this->error->setCode(Zend_Json_Server_Error::ERROR_OTHER) - ->setMessage('Unknown Error') - ->setData(array('foo' => 'bar')); - } - - public function validateArray($error) - { - $this->assertTrue(is_array($error)); - $this->assertTrue(array_key_exists('code', $error)); - $this->assertTrue(array_key_exists('message', $error)); - $this->assertTrue(array_key_exists('data', $error)); - - $this->assertTrue(is_int($error['code'])); - $this->assertTrue(is_string($error['message'])); - $this->assertTrue(is_array($error['data'])); - - $this->assertEquals($this->error->getCode(), $error['code']); - $this->assertEquals($this->error->getMessage(), $error['message']); - $this->assertSame($this->error->getData(), $error['data']); - } -} - -// Call Zend_Json_Server_ErrorTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Json_Server_ErrorTest::main") { - Zend_Json_Server_ErrorTest::main(); -} diff --git a/tests/Zend/Json/Server/RequestTest.php b/tests/Zend/Json/Server/RequestTest.php deleted file mode 100644 index b2e47d667d262926a8dbeb8b550a01000e902c1f..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/Server/RequestTest.php +++ /dev/null @@ -1,268 +0,0 @@ -<?php -// Call Zend_Json_Server_RequestTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Json_Server_RequestTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Json/Server/Request.php'; -require_once 'Zend/Json.php'; - -/** - * Test class for Zend_Json_Server_Request - */ -class Zend_Json_Server_RequestTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Json_Server_RequestTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->request = new Zend_Json_Server_Request(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testShouldHaveNoParamsByDefault() - { - $params = $this->request->getParams(); - $this->assertTrue(empty($params)); - } - - public function testShouldBeAbleToAddAParamAsValueOnly() - { - $this->request->addParam('foo'); - $params = $this->request->getParams(); - $this->assertEquals(1, count($params)); - $test = array_shift($params); - $this->assertEquals('foo', $test); - } - - public function testShouldBeAbleToAddAParamAsKeyValuePair() - { - $this->request->addParam('bar', 'foo'); - $params = $this->request->getParams(); - $this->assertEquals(1, count($params)); - $this->assertTrue(array_key_exists('foo', $params)); - $this->assertEquals('bar', $params['foo']); - } - - public function testInvalidKeysShouldBeIgnored() - { - $count = 0; - foreach (array(array('foo', true), array('foo', new stdClass), array('foo', array())) as $spec) { - $this->request->addParam($spec[0], $spec[1]); - $this->assertNull($this->request->getParam('foo')); - $params = $this->request->getParams(); - ++$count; - $this->assertEquals($count, count($params)); - } - } - - public function testShouldBeAbleToAddMultipleIndexedParamsAtOnce() - { - $params = array( - 'foo', - 'bar', - 'baz', - ); - $this->request->addParams($params); - $test = $this->request->getParams(); - $this->assertSame($params, $test); - } - - public function testShouldBeAbleToAddMultipleNamedParamsAtOnce() - { - $params = array( - 'foo' => 'bar', - 'bar' => 'baz', - 'baz' => 'bat', - ); - $this->request->addParams($params); - $test = $this->request->getParams(); - $this->assertSame($params, $test); - } - - public function testShouldBeAbleToAddMixedIndexedAndNamedParamsAtOnce() - { - $params = array( - 'foo' => 'bar', - 'baz', - 'baz' => 'bat', - ); - $this->request->addParams($params); - $test = $this->request->getParams(); - $this->assertEquals(array_values($params), array_values($test)); - $this->assertTrue(array_key_exists('foo', $test)); - $this->assertTrue(array_key_exists('baz', $test)); - $this->assertTrue(in_array('baz', $test)); - } - - public function testSetParamsShouldOverwriteParams() - { - $this->testShouldBeAbleToAddMixedIndexedAndNamedParamsAtOnce(); - $params = array( - 'one', - 'two', - 'three', - ); - $this->request->setParams($params); - $this->assertSame($params, $this->request->getParams()); - } - - public function testShouldBeAbleToRetrieveParamByKeyOrIndex() - { - $this->testShouldBeAbleToAddMixedIndexedAndNamedParamsAtOnce(); - $params = $this->request->getParams(); - $this->assertEquals('bar', $this->request->getParam('foo'), var_export($params, 1)); - $this->assertEquals('baz', $this->request->getParam(1), var_export($params, 1)); - $this->assertEquals('bat', $this->request->getParam('baz'), var_export($params, 1)); - } - - public function testMethodShouldBeNullByDefault() - { - $this->assertNull($this->request->getMethod()); - } - - public function testMethodErrorShouldBeFalseByDefault() - { - $this->assertFalse($this->request->isMethodError()); - } - - public function testMethodAccessorsShouldWorkUnderNormalInput() - { - $this->request->setMethod('foo'); - $this->assertEquals('foo', $this->request->getMethod()); - } - - public function testSettingMethodWithInvalidNameShouldSetError() - { - foreach (array('1ad', 'abc-123', 'ad$$832r#@') as $method) { - $this->request->setMethod($method); - $this->assertNull($this->request->getMethod()); - $this->assertTrue($this->request->isMethodError()); - } - } - - public function testIdShouldBeNullByDefault() - { - $this->assertNull($this->request->getId()); - } - - public function testIdAccessorsShouldWorkUnderNormalInput() - { - $this->request->setId('foo'); - $this->assertEquals('foo', $this->request->getId()); - } - - public function testVersionShouldBeJsonRpcV1ByDefault() - { - $this->assertEquals('1.0', $this->request->getVersion()); - } - - public function testVersionShouldBeLimitedToV1AndV2() - { - $this->testVersionShouldBeJsonRpcV1ByDefault(); - $this->request->setVersion('2.0'); - $this->assertEquals('2.0', $this->request->getVersion()); - $this->request->setVersion('foo'); - $this->assertEquals('1.0', $this->request->getVersion()); - } - - public function testShouldBeAbleToLoadRequestFromJsonString() - { - $options = $this->getOptions(); - $json = Zend_Json::encode($options); - $this->request->loadJson($json); - - $this->assertEquals('foo', $this->request->getMethod()); - $this->assertEquals('foobar', $this->request->getId()); - $this->assertEquals($options['params'], $this->request->getParams()); - } - - public function testLoadingFromJsonShouldSetJsonRpcVersionWhenPresent() - { - $options = $this->getOptions(); - $options['jsonrpc'] = '2.0'; - $json = Zend_Json::encode($options); - $this->request->loadJson($json); - $this->assertEquals('2.0', $this->request->getVersion()); - } - - public function testShouldBeAbleToCastToJson() - { - $options = $this->getOptions(); - $this->request->setOptions($options); - $json = $this->request->toJson(); - $this->validateJson($json, $options); - } - - public function testCastingToStringShouldCastToJson() - { - $options = $this->getOptions(); - $this->request->setOptions($options); - $json = $this->request->__toString(); - $this->validateJson($json, $options); - } - - public function getOptions() - { - return array( - 'method' => 'foo', - 'params' => array( - 5, - 'four', - true, - ), - 'id' => 'foobar' - ); - } - - public function validateJson($json, array $options) - { - $test = Zend_Json::decode($json); - $this->assertTrue(is_array($test), var_export($json, 1)); - - $this->assertTrue(array_key_exists('id', $test)); - $this->assertTrue(array_key_exists('method', $test)); - $this->assertTrue(array_key_exists('params', $test)); - - $this->assertTrue(is_string($test['id'])); - $this->assertTrue(is_string($test['method'])); - $this->assertTrue(is_array($test['params'])); - - $this->assertEquals($options['id'], $test['id']); - $this->assertEquals($options['method'], $test['method']); - $this->assertSame($options['params'], $test['params']); - } -} - -// Call Zend_Json_Server_RequestTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Json_Server_RequestTest::main") { - Zend_Json_Server_RequestTest::main(); -} diff --git a/tests/Zend/Json/Server/ResponseTest.php b/tests/Zend/Json/Server/ResponseTest.php deleted file mode 100644 index de932faf52f2d6800ae3594871e00bc577400beb..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/Server/ResponseTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -// Call Zend_Json_Server_ResponseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Json_Server_ResponseTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Json/Server/Response.php'; -require_once 'Zend/Json/Server/Error.php'; -require_once 'Zend/Json.php'; - -/** - * Test class for Zend_Json_Server_Response - */ -class Zend_Json_Server_ResponseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Json_Server_ResponseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->response = new Zend_Json_Server_Response(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testResultShouldBeNullByDefault() - { - $this->assertNull($this->response->getResult()); - } - - public function testResultAccessorsShouldWorkWithNormalInput() - { - foreach (array(true, 'foo', 2, 2.0, array(), array('foo' => 'bar')) as $result) { - $this->response->setResult($result); - $this->assertEquals($result, $this->response->getResult()); - } - } - - public function testResultShouldNotBeErrorByDefault() - { - $this->assertFalse($this->response->isError()); - } - - public function testSettingErrorShouldMarkRequestAsError() - { - $error = new Zend_Json_Server_Error(); - $this->response->setError($error); - $this->assertTrue($this->response->isError()); - } - - public function testShouldBeAbleToRetrieveErrorObject() - { - $error = new Zend_Json_Server_Error(); - $this->response->setError($error); - $this->assertSame($error, $this->response->getError()); - } - - public function testIdShouldBeNullByDefault() - { - $this->assertNull($this->response->getId()); - } - - public function testIdAccesorsShouldWorkWithNormalInput() - { - $this->response->setId('foo'); - $this->assertEquals('foo', $this->response->getId()); - } - - public function testVersionShouldBeNullByDefault() - { - $this->assertNull($this->response->getVersion()); - } - - public function testVersionShouldBeLimitedToV2() - { - $this->response->setVersion('2.0'); - $this->assertEquals('2.0', $this->response->getVersion()); - foreach (array('a', 1, '1.0', array(), true) as $version) { - $this->response->setVersion($version); - $this->assertNull($this->response->getVersion()); - } - } - - public function testResponseShouldBeAbleToCastToJson() - { - $this->response->setResult(true) - ->setId('foo') - ->setVersion('2.0'); - $json = $this->response->toJson(); - $test = Zend_Json::decode($json); - - $this->assertTrue(is_array($test)); - $this->assertTrue(array_key_exists('result', $test)); - $this->assertFalse(array_key_exists('error', $test)); - $this->assertTrue(array_key_exists('id', $test)); - $this->assertTrue(array_key_exists('jsonrpc', $test)); - - $this->assertTrue($test['result']); - $this->assertEquals($this->response->getId(), $test['id']); - $this->assertEquals($this->response->getVersion(), $test['jsonrpc']); - } - - public function testResponseShouldCastErrorToJsonIfIsError() - { - $error = new Zend_Json_Server_Error(); - $error->setCode(Zend_Json_Server_Error::ERROR_INTERNAL) - ->setMessage('error occurred'); - $this->response->setId('foo') - ->setResult(true) - ->setError($error); - $json = $this->response->toJson(); - $test = Zend_Json::decode($json); - - $this->assertTrue(is_array($test)); - $this->assertFalse(array_key_exists('result', $test)); - $this->assertTrue(array_key_exists('id', $test)); - $this->assertFalse(array_key_exists('jsonrpc', $test)); - - $this->assertEquals($this->response->getId(), $test['id']); - $this->assertEquals($error->getCode(), $test['error']['code']); - $this->assertEquals($error->getMessage(), $test['error']['message']); - } - - public function testCastToStringShouldCastToJson() - { - $this->response->setResult(true) - ->setId('foo'); - $json = $this->response->__toString(); - $test = Zend_Json::decode($json); - - $this->assertTrue(is_array($test)); - $this->assertTrue(array_key_exists('result', $test)); - $this->assertFalse(array_key_exists('error', $test)); - $this->assertTrue(array_key_exists('id', $test)); - $this->assertFalse(array_key_exists('jsonrpc', $test)); - - $this->assertTrue($test['result']); - $this->assertEquals($this->response->getId(), $test['id']); - } -} - -// Call Zend_Json_Server_ResponseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Json_Server_ResponseTest::main") { - Zend_Json_Server_ResponseTest::main(); -} diff --git a/tests/Zend/Json/Server/Smd/ServiceTest.php b/tests/Zend/Json/Server/Smd/ServiceTest.php deleted file mode 100644 index 88d6d12140d98b20af130888804d9ac0d9d10978..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/Server/Smd/ServiceTest.php +++ /dev/null @@ -1,355 +0,0 @@ -<?php -// Call Zend_Json_Server_Smd_ServiceTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Json_Server_Smd_ServiceTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -require_once 'Zend/Json/Server/Smd/Service.php'; -require_once 'Zend/Json/Server/Smd.php'; -require_once 'Zend/Json.php'; - -/** - * Test class for Zend_Json_Server_Smd_Service - */ -class Zend_Json_Server_Smd_ServiceTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Json_Server_Smd_ServiceTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->service = new Zend_Json_Server_Smd_Service('foo'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testConstructorShouldThrowExceptionWhenNoNameSet() - { - try { - $service = new Zend_Json_Server_Smd_Service(null); - $this->fail('Should throw exception when no name set'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('requires a name', $e->getMessage()); - } - - try { - $service = new Zend_Json_Server_Smd_Service(array()); - $this->fail('Should throw exception when no name set'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('requires a name', $e->getMessage()); - } - } - - public function testSettingNameShouldThrowExceptionWhenContainingInvalidFormat() - { - try { - $this->service->setName('0ab-?'); - $this->fail('Invalid name should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid name', $e->getMessage()); - } - try { - $this->service->setName('ab-?'); - $this->fail('Invalid name should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid name', $e->getMessage()); - } - } - - public function testNameAccessorsShouldWorkWithNormalInput() - { - $this->assertEquals('foo', $this->service->getName()); - $this->service->setName('bar'); - $this->assertEquals('bar', $this->service->getName()); - } - - public function testTransportShouldDefaultToPost() - { - $this->assertEquals('POST', $this->service->getTransport()); - } - - public function testTransportShouldBeLimitedToPost() - { - try { - $this->service->setTransport('GET'); - $this->fail('Invalid transport should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid transport', $e->getMessage()); - } - try { - $this->service->setTransport('REST'); - $this->fail('Invalid transport should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid transport', $e->getMessage()); - } - } - - public function testTransportAccessorsShouldWorkUnderNormalInput() - { - $this->service->setTransport('POST'); - $this->assertEquals('POST', $this->service->getTransport()); - } - - public function testTargetShouldBeNullInitially() - { - $this->assertNull($this->service->getTarget()); - } - - public function testTargetAccessorsShouldWorkUnderNormalInput() - { - $this->testTargetShouldBeNullInitially(); - $this->service->setTarget('foo'); - $this->assertEquals('foo', $this->service->getTarget()); - } - - public function testTargetAccessorsShouldNormalizeToString() - { - $this->testTargetShouldBeNullInitially(); - $this->service->setTarget(123); - $value = $this->service->getTarget(); - $this->assertTrue(is_string($value)); - $this->assertEquals((string) 123, $value); - } - - public function testEnvelopeShouldBeJsonRpc1CompliantByDefault() - { - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_1, $this->service->getEnvelope()); - } - - public function testEnvelopeShouldOnlyComplyWithJsonRpc1And2() - { - $this->testEnvelopeShouldBeJsonRpc1CompliantByDefault(); - $this->service->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_2, $this->service->getEnvelope()); - $this->service->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_1); - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_1, $this->service->getEnvelope()); - try { - $this->service->setEnvelope('JSON-P'); - $this->fail('Should not be able to set non-JSON-RPC spec envelopes'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid envelope', $e->getMessage()); - } - } - - public function testShouldHaveNoParamsByDefault() - { - $params = $this->service->getParams(); - $this->assertTrue(empty($params)); - } - - public function testShouldBeAbleToAddParamsByTypeOnly() - { - $this->service->addParam('integer'); - $params = $this->service->getParams(); - $this->assertEquals(1, count($params)); - $param = array_shift($params); - $this->assertEquals('integer', $param['type']); - } - - public function testParamsShouldAcceptArrayOfTypes() - { - $type = array('integer', 'string'); - $this->service->addParam($type); - $params = $this->service->getParams(); - $param = array_shift($params); - $test = $param['type']; - $this->assertTrue(is_array($test)); - $this->assertEquals($type, $test); - } - - public function testInvalidParamTypeShouldThrowException() - { - try { - $this->service->addParam(new stdClass); - $this->fail('Invalid param type should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid param type', $e->getMessage()); - } - } - - public function testShouldBeAbleToOrderParams() - { - $this->service->addParam('integer', array(), 4) - ->addParam('string') - ->addParam('boolean', array(), 3); - $params = $this->service->getParams(); - - $this->assertEquals(3, count($params)); - - $param = array_shift($params); - $this->assertEquals('string', $param['type'], var_export($params, 1)); - $param = array_shift($params); - $this->assertEquals('boolean', $param['type'], var_export($params, 1)); - $param = array_shift($params); - $this->assertEquals('integer', $param['type'], var_export($params, 1)); - } - - public function testShouldBeAbleToAddArbitraryParamOptions() - { - $this->service->addParam( - 'integer', - array( - 'name' => 'foo', - 'optional' => false, - 'default' => 1, - 'description' => 'Foo parameter', - ) - ); - $params = $this->service->getParams(); - $param = array_shift($params); - $this->assertEquals('foo', $param['name']); - $this->assertFalse($param['optional']); - $this->assertEquals(1, $param['default']); - $this->assertEquals('Foo parameter', $param['description']); - } - - public function testShouldBeAbleToAddMultipleParamsAtOnce() - { - $this->service->addParams(array( - array('type' => 'integer', 'order' => 4), - array('type' => 'string', 'name' => 'foo'), - array('type' => 'boolean', 'order' => 3), - )); - $params = $this->service->getParams(); - - $this->assertEquals(3, count($params)); - $param = array_shift($params); - $this->assertEquals('string', $param['type']); - $this->assertEquals('foo', $param['name']); - - $param = array_shift($params); - $this->assertEquals('boolean', $param['type']); - - $param = array_shift($params); - $this->assertEquals('integer', $param['type']); - } - - public function testSetparamsShouldOverwriteExistingParams() - { - $this->testShouldBeAbleToAddMultipleParamsAtOnce(); - $params = $this->service->getParams(); - $this->assertEquals(3, count($params)); - - $this->service->setParams(array( - array('type' => 'string'), - array('type' => 'integer'), - )); - $test = $this->service->getParams(); - $this->assertNotEquals($params, $test); - $this->assertEquals(2, count($test)); - } - - public function testReturnShouldBeNullByDefault() - { - $this->assertNull($this->service->getReturn()); - } - - public function testReturnAccessorsShouldWorkWithNormalInput() - { - $this->testReturnShouldBeNullByDefault(); - $this->service->setReturn('integer'); - $this->assertEquals('integer', $this->service->getReturn()); - } - - public function testReturnAccessorsShouldAllowArrayOfTypes() - { - $this->testReturnShouldBeNullByDefault(); - $type = array('integer', 'string'); - $this->service->setReturn($type); - $this->assertEquals($type, $this->service->getReturn()); - } - - public function testInvalidReturnTypeShouldThrowException() - { - try { - $this->service->setReturn(new stdClass); - $this->fail('Invalid return type should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid param type', $e->getMessage()); - } - } - - public function testToArrayShouldCreateSmdCompatibleHash() - { - $this->setupSmdValidationObject(); - $smd = $this->service->toArray(); - $this->validateSmdArray($smd); - } - - public function testTojsonShouldEmitJson() - { - $this->setupSmdValidationObject(); - $json = $this->service->toJson(); - $smd = Zend_Json::decode($json); - - $this->assertTrue(array_key_exists('foo', $smd)); - $this->assertTrue(is_array($smd['foo'])); - - $this->validateSmdArray($smd['foo']); - } - - public function setupSmdValidationObject() - { - $this->service->setName('foo') - ->setTransport('POST') - ->setTarget('/foo') - ->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2) - ->addParam('boolean') - ->addParam('array') - ->addParam('object') - ->setReturn('boolean'); - } - - public function validateSmdArray(array $smd) - { - $this->assertTrue(array_key_exists('transport', $smd)); - $this->assertEquals('POST', $smd['transport']); - - $this->assertTrue(array_key_exists('envelope', $smd)); - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_2, $smd['envelope']); - - $this->assertTrue(array_key_exists('parameters', $smd)); - $params = $smd['parameters']; - $this->assertEquals(3, count($params)); - $param = array_shift($params); - $this->assertEquals('boolean', $param['type']); - $param = array_shift($params); - $this->assertEquals('array', $param['type']); - $param = array_shift($params); - $this->assertEquals('object', $param['type']); - - $this->assertTrue(array_key_exists('returns', $smd)); - $this->assertEquals('boolean', $smd['returns']); - } -} - -// Call Zend_Json_Server_Smd_ServiceTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Json_Server_Smd_ServiceTest::main") { - Zend_Json_Server_Smd_ServiceTest::main(); -} diff --git a/tests/Zend/Json/Server/SmdTest.php b/tests/Zend/Json/Server/SmdTest.php deleted file mode 100644 index 7de8a96be10307287deb4ebb8434f64abf2ef020..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/Server/SmdTest.php +++ /dev/null @@ -1,404 +0,0 @@ -<?php -// Call Zend_Json_Server_SmdTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Json_Server_SmdTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/Json/Server/Smd.php'; -require_once 'Zend/Json/Server/Smd/Service.php'; -require_once 'Zend/Json.php'; - -/** - * Test class for Zend_Json_Server_Smd - */ -class Zend_Json_Server_SmdTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Json_Server_SmdTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->smd = new Zend_Json_Server_Smd(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testTransportShouldDefaultToPost() - { - $this->assertEquals('POST', $this->smd->getTransport()); - } - - public function testTransportAccessorsShouldWorkUnderNormalInput() - { - $this->smd->setTransport('POST'); - $this->assertEquals('POST', $this->smd->getTransport()); - } - - public function testTransportShouldBeLimitedToPost() - { - foreach (array('GET', 'REST') as $transport) { - try { - $this->smd->setTransport($transport); - $this->fail('Invalid transport should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid transport', $e->getMessage()); - } - } - } - - public function testEnvelopeShouldDefaultToJsonRpcVersion1() - { - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_1, $this->smd->getEnvelope()); - } - - public function testEnvelopeAccessorsShouldWorkUnderNormalInput() - { - $this->testEnvelopeShouldDefaultToJsonRpcVersion1(); - $this->smd->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_2, $this->smd->getEnvelope()); - $this->smd->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_1); - $this->assertEquals(Zend_Json_Server_Smd::ENV_JSONRPC_1, $this->smd->getEnvelope()); - } - - public function testEnvelopeShouldBeLimitedToJsonRpcVersions() - { - foreach (array('URL', 'PATH', 'JSON') as $env) { - try { - $this->smd->setEnvelope($env); - $this->fail('Invalid envelope type should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid envelope', $e->getMessage()); - } - } - } - - public function testContentTypeShouldDefaultToApplicationJson() - { - $this->assertEquals('application/json', $this->smd->getContentType()); - } - - public function testContentTypeAccessorsShouldWorkUnderNormalInput() - { - foreach (array('text/json', 'text/plain', 'application/x-json') as $type) { - $this->smd->setContentType($type); - $this->assertEquals($type, $this->smd->getContentType()); - } - } - - public function testContentTypeShouldBeLimitedToMimeFormatStrings() - { - foreach (array('plain', 'json', 'foobar') as $type) { - try { - $this->smd->setContentType($type); - $this->fail('Invalid content type should raise exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid content type', $e->getMessage()); - } - } - } - - public function testTargetShouldDefaultToNull() - { - $this->assertNull($this->smd->getTarget()); - } - - public function testTargetAccessorsShouldWorkUnderNormalInput() - { - $this->testTargetShouldDefaultToNull(); - $this->smd->setTarget('foo'); - $this->assertEquals('foo', $this->smd->getTarget()); - } - - public function testIdShouldDefaultToNull() - { - $this->assertNull($this->smd->getId()); - } - - public function testIdAccessorsShouldWorkUnderNormalInput() - { - $this->testIdShouldDefaultToNull(); - $this->smd->setId('foo'); - $this->assertEquals('foo', $this->smd->getId()); - } - - public function testDescriptionShouldDefaultToNull() - { - $this->assertNull($this->smd->getDescription()); - } - - public function testDescriptionAccessorsShouldWorkUnderNormalInput() - { - $this->testDescriptionShouldDefaultToNull(); - $this->smd->setDescription('foo'); - $this->assertEquals('foo', $this->smd->getDescription()); - } - - public function testDojoCompatibilityShouldBeDisabledByDefault() - { - $this->assertFalse($this->smd->isDojoCompatible()); - } - - public function testDojoCompatibilityFlagShouldBeMutable() - { - $this->testDojoCompatibilityShouldBeDisabledByDefault(); - $this->smd->setDojoCompatible(true); - $this->assertTrue($this->smd->isDojoCompatible()); - $this->smd->setDojoCompatible(false); - $this->assertFalse($this->smd->isDojoCompatible()); - } - - public function testServicesShouldBeEmptyByDefault() - { - $services = $this->smd->getServices(); - $this->assertTrue(is_array($services)); - $this->assertTrue(empty($services)); - } - - public function testShouldBeAbleToUseServiceObjectToAddService() - { - $service = new Zend_Json_Server_Smd_Service('foo'); - $this->smd->addService($service); - $this->assertSame($service, $this->smd->getService('foo')); - } - - public function testShouldBeAbleToUseArrayToAddService() - { - $service = array( - 'name' => 'foo', - ); - $this->smd->addService($service); - $foo = $this->smd->getService('foo'); - $this->assertTrue($foo instanceof Zend_Json_Server_Smd_Service); - $this->assertEquals('foo', $foo->getName()); - } - - public function testAddingServiceWithExistingServiceNameShouldThrowException() - { - $service = new Zend_Json_Server_Smd_Service('foo'); - $this->smd->addService($service); - $test = new Zend_Json_Server_Smd_Service('foo'); - try { - $this->smd->addService($test); - $this->fail('Adding service with existing service name should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('already register', $e->getMessage()); - } - } - - public function testAttemptingToRegisterInvalidServiceShouldThrowException() - { - foreach (array('foo', false, 1, 1.0) as $service) { - try { - $this->smd->addService($service); - $this->fail('Attempt to register invalid service should throw exception'); - } catch (Zend_Json_Server_Exception $e) { - $this->assertContains('Invalid service', $e->getMessage()); - } - } - } - - public function testShouldBeAbleToAddManyServicesAtOnceWithArrayOfServiceObjects() - { - $one = new Zend_Json_Server_Smd_Service('one'); - $two = new Zend_Json_Server_Smd_Service('two'); - $three = new Zend_Json_Server_Smd_Service('three'); - $services = array($one, $two, $three); - $this->smd->addServices($services); - $test = $this->smd->getServices(); - $this->assertSame($services, array_values($test)); - } - - public function testShouldBeAbleToAddManyServicesAtOnceWithArrayOfArrays() - { - $services = array( - array('name' => 'one'), - array('name' => 'two'), - array('name' => 'three'), - ); - $this->smd->addServices($services); - $test = $this->smd->getServices(); - $this->assertSame(array('one', 'two', 'three'), array_keys($test)); - } - - public function testShouldBeAbleToAddManyServicesAtOnceWithMixedArrayOfObjectsAndArrays() - { - $two = new Zend_Json_Server_Smd_Service('two'); - $services = array( - array('name' => 'one'), - $two, - array('name' => 'three'), - ); - $this->smd->addServices($services); - $test = $this->smd->getServices(); - $this->assertSame(array('one', 'two', 'three'), array_keys($test)); - $this->assertEquals($two, $test['two']); - } - - public function testSetServicesShouldOverwriteExistingServices() - { - $this->testShouldBeAbleToAddManyServicesAtOnceWithMixedArrayOfObjectsAndArrays(); - $five = new Zend_Json_Server_Smd_Service('five'); - $services = array( - array('name' => 'four'), - $five, - array('name' => 'six'), - ); - $this->smd->setServices($services); - $test = $this->smd->getServices(); - $this->assertSame(array('four', 'five', 'six'), array_keys($test)); - $this->assertEquals($five, $test['five']); - } - - public function testShouldBeAbleToRetrieveServiceByName() - { - $this->testShouldBeAbleToUseServiceObjectToAddService(); - } - - public function testShouldBeAbleToRemoveServiceByName() - { - $this->testShouldBeAbleToUseServiceObjectToAddService(); - $this->assertTrue($this->smd->removeService('foo')); - $this->assertFalse($this->smd->getService('foo')); - } - - public function testShouldBeAbleToCastToArray() - { - $options = $this->getOptions(); - $this->smd->setOptions($options); - $service = $this->smd->toArray(); - $this->validateServiceArray($service, $options); - } - - public function testShouldBeAbleToCastToDojoArray() - { - $options = $this->getOptions(); - $this->smd->setOptions($options); - $smd = $this->smd->toDojoArray(); - - $this->assertTrue(is_array($smd)); - - $this->assertTrue(array_key_exists('SMDVersion', $smd)); - $this->assertTrue(array_key_exists('serviceType', $smd)); - $this->assertTrue(array_key_exists('methods', $smd)); - - $this->assertEquals('.1', $smd['SMDVersion']); - $this->assertEquals('JSON-RPC', $smd['serviceType']); - $methods = $smd['methods']; - $this->assertEquals(2, count($methods)); - - $foo = array_shift($methods); - $this->assertTrue(array_key_exists('name', $foo)); - $this->assertTrue(array_key_exists('serviceURL', $foo)); - $this->assertTrue(array_key_exists('parameters', $foo)); - $this->assertEquals('foo', $foo['name']); - $this->assertEquals($this->smd->getTarget(), $foo['serviceURL']); - $this->assertTrue(is_array($foo['parameters'])); - $this->assertEquals(1, count($foo['parameters'])); - - $bar = array_shift($methods); - $this->assertTrue(array_key_exists('name', $bar)); - $this->assertTrue(array_key_exists('serviceURL', $bar)); - $this->assertTrue(array_key_exists('parameters', $bar)); - $this->assertEquals('bar', $bar['name']); - $this->assertEquals($this->smd->getTarget(), $bar['serviceURL']); - $this->assertTrue(is_array($bar['parameters'])); - $this->assertEquals(1, count($bar['parameters'])); - } - - public function testShouldBeAbleToRenderAsJson() - { - $options = $this->getOptions(); - $this->smd->setOptions($options); - $json = $this->smd->toJson(); - $smd = Zend_Json::decode($json); - $this->validateServiceArray($smd, $options); - } - - public function testToStringImplementationShouldProxyToJson() - { - $options = $this->getOptions(); - $this->smd->setOptions($options); - $json = $this->smd->__toString(); - $smd = Zend_Json::decode($json); - $this->validateServiceArray($smd, $options); - } - - public function getOptions() - { - return array( - 'target' => '/test/me', - 'id' => '/test/me', - 'services' => array( - array( - 'name' => 'foo', - 'params' => array( - array('type' => 'boolean'), - ), - 'return' => 'boolean', - ), - array( - 'name' => 'bar', - 'params' => array( - array('type' => 'integer'), - ), - 'return' => 'string', - ), - ) - ); - } - - public function validateServiceArray(array $smd, array $options) - { - $this->assertTrue(is_array($smd)); - - $this->assertTrue(array_key_exists('SMDVersion', $smd)); - $this->assertTrue(array_key_exists('target', $smd)); - $this->assertTrue(array_key_exists('id', $smd)); - $this->assertTrue(array_key_exists('transport', $smd)); - $this->assertTrue(array_key_exists('envelope', $smd)); - $this->assertTrue(array_key_exists('contentType', $smd)); - $this->assertTrue(array_key_exists('services', $smd)); - - $this->assertEquals(Zend_Json_Server_Smd::SMD_VERSION, $smd['SMDVersion']); - $this->assertEquals($options['target'], $smd['target']); - $this->assertEquals($options['id'], $smd['id']); - $this->assertEquals($this->smd->getTransport(), $smd['transport']); - $this->assertEquals($this->smd->getEnvelope(), $smd['envelope']); - $this->assertEquals($this->smd->getContentType(), $smd['contentType']); - $services = $smd['services']; - $this->assertEquals(2, count($services)); - $this->assertTrue(array_key_exists('foo', $services)); - $this->assertTrue(array_key_exists('bar', $services)); - } -} - -// Call Zend_Json_Server_SmdTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Json_Server_SmdTest::main") { - Zend_Json_Server_SmdTest::main(); -} diff --git a/tests/Zend/Json/ServerTest.php b/tests/Zend/Json/ServerTest.php deleted file mode 100644 index 5f644e5c03471b1c23c589f9f791879b31fa9e85..0000000000000000000000000000000000000000 --- a/tests/Zend/Json/ServerTest.php +++ /dev/null @@ -1,410 +0,0 @@ -<?php -// Call Zend_Json_ServerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Json_ServerTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Json/Server.php'; -require_once 'Zend/Json/Server/Request.php'; -require_once 'Zend/Json/Server/Response.php'; -require_once 'Zend/Json.php'; - -/** - * Test class for Zend_Json_Server - */ -class Zend_Json_ServerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Json_ServerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->server = new Zend_Json_Server(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testShouldBeAbleToBindFunctionToServer() - { - $this->server->addFunction('strtolower'); - $methods = $this->server->getFunctions(); - $this->assertTrue(array_key_exists('strtolower', $methods)); - } - - public function testShouldBeAbleToBindCallbackToServer() - { - $this->server->addFunction(array($this, 'setUp')); - $methods = $this->server->getFunctions(); - $this->assertTrue(array_key_exists('setUp', $methods)); - } - - public function testShouldBeAbleToBindClassToServer() - { - $this->server->setClass('Zend_Json_Server'); - $test = $this->server->getFunctions(); - $this->assertTrue(0 < count($test)); - } - - public function testBindingClassToServerShouldRegisterAllPublicMethods() - { - $this->server->setClass('Zend_Json_Server'); - $test = $this->server->getFunctions(); - $methods = get_class_methods('Zend_Json_Server'); - foreach ($methods as $method) { - if ('_' == $method[0]) { - continue; - } - $this->assertTrue(array_key_exists($method, $test), 'Testing for method ' . $method . ' against ' . var_export(array_keys($test), 1)); - } - } - - public function testShouldBeAbleToBindObjectToServer() - { - $object = new Zend_Json_Server(); - $this->server->setClass($object); - $test = $this->server->getFunctions(); - $this->assertTrue(0 < count($test)); - } - - public function testBindingObjectToServerShouldRegisterAllPublicMethods() - { - $object = new Zend_Json_Server(); - $this->server->setClass($object); - $test = $this->server->getFunctions(); - $methods = get_class_methods($object); - foreach ($methods as $method) { - if ('_' == $method[0]) { - continue; - } - $this->assertTrue(array_key_exists($method, $test), 'Testing for method ' . $method . ' against ' . var_export(array_keys($test), 1)); - } - } - - public function testShouldBeAbleToBindMultipleClassesAndObjectsToServer() - { - $this->server->setClass('Zend_Json_Server') - ->setClass(new Zend_Json()); - $methods = $this->server->getFunctions(); - $zjsMethods = get_class_methods('Zend_Json_Server'); - $zjMethods = get_class_methods('Zend_Json'); - $this->assertTrue(count($zjsMethods) < count($methods)); - $this->assertTrue(count($zjMethods) < count($methods)); - } - - public function testNamingCollisionsShouldResolveToLastRegisteredMethod() - { - $this->server->setClass('Zend_Json_Server_Request') - ->setClass('Zend_Json_Server_Response'); - $methods = $this->server->getFunctions(); - $this->assertTrue(array_key_exists('toJson', $methods)); - $toJson = $methods['toJson']; - $this->assertEquals('Zend_Json_Server_Response', $toJson->getDeclaringClass()->getName()); - } - - public function testGetRequestShouldInstantiateRequestObjectByDefault() - { - $request = $this->server->getRequest(); - $this->assertTrue($request instanceof Zend_Json_Server_Request); - } - - public function testShouldAllowSettingRequestObjectManually() - { - $orig = $this->server->getRequest(); - $new = new Zend_Json_Server_Request(); - $this->server->setRequest($new); - $test = $this->server->getRequest(); - $this->assertSame($new, $test); - $this->assertNotSame($orig, $test); - } - - public function testGetResponseShouldInstantiateResponseObjectByDefault() - { - $response = $this->server->getResponse(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - } - - public function testShouldAllowSettingResponseObjectManually() - { - $orig = $this->server->getResponse(); - $new = new Zend_Json_Server_Response(); - $this->server->setResponse($new); - $test = $this->server->getResponse(); - $this->assertSame($new, $test); - $this->assertNotSame($orig, $test); - } - - public function testFaultShouldCreateErrorResponse() - { - $response = $this->server->getResponse(); - $this->assertFalse($response->isError()); - $this->server->fault('error condition', -32000); - $this->assertTrue($response->isError()); - $error = $response->getError(); - $this->assertEquals(-32000, $error->getCode()); - $this->assertEquals('error condition', $error->getMessage()); - } - - public function testResponseShouldBeEmittedAutomaticallyByDefault() - { - $this->assertTrue($this->server->autoEmitResponse()); - } - - public function testShouldBeAbleToDisableAutomaticResponseEmission() - { - $this->testResponseShouldBeEmittedAutomaticallyByDefault(); - $this->server->setAutoEmitResponse(false); - $this->assertFalse($this->server->autoEmitResponse()); - } - - public function testShouldBeAbleToRetrieveSmdObject() - { - $smd = $this->server->getServiceMap(); - $this->assertTrue($smd instanceof Zend_Json_Server_Smd); - } - - public function testShouldBeAbleToSetArbitrarySmdMetadata() - { - $this->server->setTransport('POST') - ->setEnvelope('JSON-RPC-1.0') - ->setContentType('application/x-json') - ->setTarget('/foo/bar') - ->setId('foobar') - ->setDescription('This is a test service'); - - $this->assertEquals('POST', $this->server->getTransport()); - $this->assertEquals('JSON-RPC-1.0', $this->server->getEnvelope()); - $this->assertEquals('application/x-json', $this->server->getContentType()); - $this->assertEquals('/foo/bar', $this->server->getTarget()); - $this->assertEquals('foobar', $this->server->getId()); - $this->assertEquals('This is a test service', $this->server->getDescription()); - } - - public function testSmdObjectRetrievedFromServerShouldReflectServerState() - { - $this->server->addFunction('strtolower') - ->setClass('Zend_Json_Server') - ->setTransport('POST') - ->setEnvelope('JSON-RPC-1.0') - ->setContentType('application/x-json') - ->setTarget('/foo/bar') - ->setId('foobar') - ->setDescription('This is a test service'); - $smd = $this->server->getServiceMap(); - $this->assertEquals('POST', $this->server->getTransport()); - $this->assertEquals('JSON-RPC-1.0', $this->server->getEnvelope()); - $this->assertEquals('application/x-json', $this->server->getContentType()); - $this->assertEquals('/foo/bar', $this->server->getTarget()); - $this->assertEquals('foobar', $this->server->getId()); - $this->assertEquals('This is a test service', $this->server->getDescription()); - - $services = $smd->getServices(); - $this->assertTrue(is_array($services)); - $this->assertTrue(0 < count($services)); - $this->assertTrue(array_key_exists('strtolower', $services)); - $methods = get_class_methods('Zend_Json_Server'); - foreach ($methods as $method) { - if ('_' == $method[0]) { - continue; - } - $this->assertTrue(array_key_exists($method, $services)); - } - } - - public function testHandleValidMethodShouldWork() - { - $this->server->setClass('Zend_Json_ServerTest_Foo') - ->addFunction('Zend_Json_ServerTest_FooFunc') - ->setAutoEmitResponse(false); - $request = $this->server->getRequest(); - $request->setMethod('bar') - ->setParams(array(true, 'foo', 'bar')) - ->setId('foo'); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertFalse($response->isError()); - - - $request->setMethod('Zend_Json_ServerTest_FooFunc') - ->setId('foo'); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertFalse($response->isError()); - } - - public function testHandleValidMethodWithTooFewParamsShouldPassDefaultsOrNullsForMissingParams() - { - $this->server->setClass('Zend_Json_ServerTest_Foo') - ->setAutoEmitResponse(false); - $request = $this->server->getRequest(); - $request->setMethod('bar') - ->setParams(array(true)) - ->setId('foo'); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertFalse($response->isError()); - $result = $response->getResult(); - $this->assertTrue(is_array($result)); - $this->assertTrue(3 == count($result)); - $this->assertEquals('two', $result[1]); - $this->assertNull($result[2]); - } - - public function testHandleValidMethodWithTooManyParamsShouldWork() - { - $this->server->setClass('Zend_Json_ServerTest_Foo') - ->setAutoEmitResponse(false); - $request = $this->server->getRequest(); - $request->setMethod('bar') - ->setParams(array(true, 'foo', 'bar', 'baz')) - ->setId('foo'); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertFalse($response->isError()); - $result = $response->getResult(); - $this->assertTrue(is_array($result)); - $this->assertTrue(3 == count($result)); - $this->assertEquals('foo', $result[1]); - $this->assertEquals('bar', $result[2]); - } - - public function testHandleRequestWithErrorsShouldReturnErrorResponse() - { - $this->server->setClass('Zend_Json_ServerTest_Foo') - ->setAutoEmitResponse(false); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertTrue($response->isError()); - $this->assertEquals(Zend_Json_Server_Error::ERROR_INVALID_REQUEST, $response->getError()->getCode()); - } - - public function testHandleRequestWithInvalidMethodShouldReturnErrorResponse() - { - $this->server->setClass('Zend_Json_ServerTest_Foo') - ->setAutoEmitResponse(false); - $request = $this->server->getRequest(); - $request->setMethod('bogus') - ->setId('foo'); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertTrue($response->isError()); - $this->assertEquals(Zend_Json_Server_Error::ERROR_INVALID_METHOD, $response->getError()->getCode()); - } - - public function testHandleRequestWithExceptionShouldReturnErrorResponse() - { - $this->server->setClass('Zend_Json_ServerTest_Foo') - ->setAutoEmitResponse(false); - $request = $this->server->getRequest(); - $request->setMethod('baz') - ->setId('foo'); - $response = $this->server->handle(); - $this->assertTrue($response instanceof Zend_Json_Server_Response); - $this->assertTrue($response->isError()); - $this->assertEquals(Zend_Json_Server_Error::ERROR_OTHER, $response->getError()->getCode()); - $this->assertEquals('application error', $response->getError()->getMessage()); - } - - public function testHandleShouldEmitResponseByDefault() - { - $this->server->setClass('Zend_Json_ServerTest_Foo'); - $request = $this->server->getRequest(); - $request->setMethod('bar') - ->setParams(array(true, 'foo', 'bar')) - ->setId('foo'); - ob_start(); - $this->server->handle(); - $buffer = ob_get_clean(); - - $decoded = Zend_Json::decode($buffer); - $this->assertTrue(is_array($decoded)); - $this->assertTrue(array_key_exists('result', $decoded)); - $this->assertTrue(array_key_exists('id', $decoded)); - - $response = $this->server->getResponse(); - $this->assertEquals($response->getResult(), $decoded['result']); - $this->assertEquals($response->getId(), $decoded['id']); - } - - public function testResponseShouldBeEmptyWhenRequestHasNoId() - { - $this->server->setClass('Zend_Json_ServerTest_Foo'); - $request = $this->server->getRequest(); - $request->setMethod('bar') - ->setParams(array(true, 'foo', 'bar')); - ob_start(); - $this->server->handle(); - $buffer = ob_get_clean(); - - $this->assertTrue(empty($buffer)); - } -} - -/** - * Class for testing JSON-RPC server - */ -class Zend_Json_ServerTest_Foo -{ - /** - * Bar - * - * @param bool $one - * @param string $two - * @param mixed $three - * @return array - */ - public function bar($one, $two = 'two', $three = null) - { - return array($one, $two, $three); - } - - /** - * Baz - * - * @return void - */ - public function baz() - { - throw new Exception('application error'); - } -} - -/** - * Test function for JSON-RPC server - * - * @return bool - */ -function Zend_Json_ServerTest_FooFunc() -{ - return true; -} - -// Call Zend_Json_ServerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Json_ServerTest::main") { - Zend_Json_ServerTest::main(); -} diff --git a/tests/Zend/JsonTest.php b/tests/Zend/JsonTest.php deleted file mode 100644 index 701eeff4fa093e5e1fc0e5549363ab2bbb9bc446..0000000000000000000000000000000000000000 --- a/tests/Zend/JsonTest.php +++ /dev/null @@ -1,462 +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_Json - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: JsonTest.php 11037 2008-08-25 04:00:06Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * @see Zend_Json - */ -require_once 'Zend/Json.php'; - -/** - * @see Zend_Json_Encoder - */ -require_once 'Zend/Json/Encoder.php'; - -/** - * @see Zend_Json_Decoder - */ -require_once 'Zend/Json/Decoder.php'; - -/** - * @category Zend - * @package Zend_Json - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_JsonTest extends PHPUnit_Framework_TestCase -{ - - public function testJsonWithPhpJsonExtension() - { - if (!extension_loaded('json')) { - $this->markTestSkipped('JSON extension is not loaded'); - } - $u = Zend_Json::$useBuiltinEncoderDecoder; - Zend_Json::$useBuiltinEncoderDecoder = false; - $this->_testJson(array('string', 327, true, null)); - Zend_Json::$useBuiltinEncoderDecoder = $u; - } - - public function testJsonWithBuiltins() - { - $u = Zend_Json::$useBuiltinEncoderDecoder; - Zend_Json::$useBuiltinEncoderDecoder = true; - $this->_testJson(array('string', 327, true, null)); - Zend_Json::$useBuiltinEncoderDecoder = $u; - } - - /** - * Test encoding and decoding in a single step - * @param array $values array of values to test against encode/decode - */ - protected function _testJson($values) - { - $encoded = Zend_Json::encode($values); - $this->assertEquals($values, Zend_Json::decode($encoded)); - } - - /** - * test null encoding/decoding - */ - public function testNull() - { - $this->_testEncodeDecode(array(null)); - } - - - /** - * test boolean encoding/decoding - */ - public function testBoolean() - { - $this->assertTrue(Zend_Json_Decoder::decode(Zend_Json_Encoder::encode(true))); - $this->assertFalse(Zend_Json_Decoder::decode(Zend_Json_Encoder::encode(false))); - } - - - /** - * test integer encoding/decoding - */ - public function testInteger() - { - $this->_testEncodeDecode(array(-2)); - $this->_testEncodeDecode(array(-1)); - - $zero = Zend_Json_Decoder::decode(Zend_Json_Encoder::encode(0)); - $this->assertEquals(0, $zero, 'Failed 0 integer test. Encoded: ' . serialize(Zend_Json_Encoder::encode(0))); - } - - - /** - * test float encoding/decoding - */ - public function testFloat() - { - $this->_testEncodeDecode(array(-2.1, 1.2)); - } - - /** - * test string encoding/decoding - */ - public function testString() - { - $this->_testEncodeDecode(array('string')); - $this->assertEquals('', Zend_Json_Decoder::decode(Zend_Json_Encoder::encode('')), 'Empty string encoded: ' . serialize(Zend_Json_Encoder::encode(''))); - } - - /** - * Test backslash escaping of string - */ - public function testString2() - { - $string = 'INFO: Path \\\\test\\123\\abc'; - $expected = '"INFO: Path \\\\\\\\test\\\\123\\\\abc"'; - $encoded = Zend_Json_Encoder::encode($string); - $this->assertEquals($expected, $encoded, 'Backslash encoding incorrect: expected: ' . serialize($expected) . '; received: ' . serialize($encoded) . "\n"); - $this->assertEquals($string, Zend_Json_Decoder::decode($encoded)); - } - - /** - * Test newline escaping of string - */ - public function testString3() - { - $expected = '"INFO: Path\nSome more"'; - $string = "INFO: Path\nSome more"; - $encoded = Zend_Json_Encoder::encode($string); - $this->assertEquals($expected, $encoded, 'Newline encoding incorrect: expected ' . serialize($expected) . '; received: ' . serialize($encoded) . "\n"); - $this->assertEquals($string, Zend_Json_Decoder::decode($encoded)); - } - - /** - * Test tab/non-tab escaping of string - */ - public function testString4() - { - $expected = '"INFO: Path\\t\\\\tSome more"'; - $string = "INFO: Path\t\\tSome more"; - $encoded = Zend_Json_Encoder::encode($string); - $this->assertEquals($expected, $encoded, 'Tab encoding incorrect: expected ' . serialize($expected) . '; received: ' . serialize($encoded) . "\n"); - $this->assertEquals($string, Zend_Json_Decoder::decode($encoded)); - } - - /** - * Test double-quote escaping of string - */ - public function testString5() - { - $expected = '"INFO: Path \"Some more\""'; - $string = 'INFO: Path "Some more"'; - $encoded = Zend_Json_Encoder::encode($string); - $this->assertEquals($expected, $encoded, 'Quote encoding incorrect: expected ' . serialize($expected) . '; received: ' . serialize($encoded) . "\n"); - $this->assertEquals($string, Zend_Json_Decoder::decode($encoded)); - } - - /** - * test indexed array encoding/decoding - */ - public function testArray() - { - $array = array(1, 'one', 2, 'two'); - $encoded = Zend_Json_Encoder::encode($array); - $this->assertSame($array, Zend_Json_Decoder::decode($encoded), 'Decoded array does not match: ' . serialize($encoded)); - } - - /** - * test associative array encoding/decoding - */ - public function testAssocArray() - { - $this->_testEncodeDecode(array(array('one' => 1, 'two' => 2))); - } - - /** - * test associative array encoding/decoding, with mixed key types - */ - public function testAssocArray2() - { - $this->_testEncodeDecode(array(array('one' => 1, 2 => 2))); - } - - /** - * test associative array encoding/decoding, with integer keys not starting at 0 - */ - public function testAssocArray3() - { - $this->_testEncodeDecode(array(array(1 => 'one', 2 => 'two'))); - } - - /** - * test object encoding/decoding (decoding to array) - */ - public function testObject() - { - $value = new stdClass(); - $value->one = 1; - $value->two = 2; - - $array = array('__className' => 'stdClass', 'one' => 1, 'two' => 2); - - $encoded = Zend_Json_Encoder::encode($value); - $this->assertSame($array, Zend_Json_Decoder::decode($encoded)); - } - - /** - * test object encoding/decoding (decoding to stdClass) - */ - public function testObjectAsObject() - { - $value = new stdClass(); - $value->one = 1; - $value->two = 2; - - $encoded = Zend_Json_Encoder::encode($value); - $decoded = Zend_Json_Decoder::decode($encoded, Zend_Json::TYPE_OBJECT); - $this->assertTrue(is_object($decoded), 'Not decoded as an object'); - $this->assertTrue($decoded instanceof StdClass, 'Not a StdClass object'); - $this->assertTrue(isset($decoded->one), 'Expected property not set'); - $this->assertEquals($value->one, $decoded->one, 'Unexpected value'); - } - - /** - * Test that arrays of objects decode properly; see issue #144 - */ - public function testDecodeArrayOfObjects() - { - $value = '[{"id":1},{"foo":2}]'; - $expect = array(array('id' => 1), array('foo' => 2)); - $this->assertEquals($expect, Zend_Json_Decoder::decode($value)); - } - - /** - * Test that objects of arrays decode properly; see issue #107 - */ - public function testDecodeObjectOfArrays() - { - $value = '{"codeDbVar" : {"age" : ["int", 5], "prenom" : ["varchar", 50]}, "234" : [22, "jb"], "346" : [64, "francois"], "21" : [12, "paul"]}'; - $expect = array( - 'codeDbVar' => array( - 'age' => array('int', 5), - 'prenom' => array('varchar', 50), - ), - 234 => array(22, 'jb'), - 346 => array(64, 'francois'), - 21 => array(12, 'paul') - ); - $this->assertEquals($expect, Zend_Json_Decoder::decode($value)); - } - - /** - * Test encoding and decoding in a single step - * @param array $values array of values to test against encode/decode - */ - protected function _testEncodeDecode($values) - { - foreach ($values as $value) { - $encoded = Zend_Json_Encoder::encode($value); - $this->assertEquals($value, Zend_Json_Decoder::decode($encoded)); - } - } - - /** - * Test that version numbers such as 4.10 are encoded and decoded properly; - * See ZF-377 - */ - public function testEncodeReleaseNumber() - { - $value = '4.10'; - - $this->_testEncodeDecode(array($value)); - } - - /** - * Tests that spaces/linebreaks prior to a closing right bracket don't throw - * exceptions. See ZF-283. - */ - public function testEarlyLineBreak() - { - $expected = array('data' => array(1, 2, 3, 4)); - - $json = '{"data":[1,2,3,4' . "\n]}"; - $this->assertEquals($expected, Zend_Json_Decoder::decode($json)); - - $json = '{"data":[1,2,3,4 ]}'; - $this->assertEquals($expected, Zend_Json_Decoder::decode($json)); - } - - /** - * Tests for ZF-504 - * - * Three confirmed issues reported: - * - encoder improperly encoding empty arrays as structs - * - decoder happily decoding clearly borked JSON - * - decoder decoding octal values improperly (shouldn't decode them at all, as JSON does not support them) - */ - public function testZf504() - { - $test = array(); - $this->assertSame('[]', Zend_Json_Encoder::encode($test)); - - try { - $json = '[a"],["a],[][]'; - $test = Zend_Json_Decoder::decode($json); - $this->fail("Should not be able to decode '$json'"); - - $json = '[a"],["a]'; - $test = Zend_Json_Decoder::decode($json); - $this->fail("Should not be able to decode '$json'"); - } catch (Exception $e) { - // success - } - - try { - $expected = 010; - $test = Zend_Json_Decoder::decode('010'); - $this->fail('Octal values are not supported in JSON notation'); - } catch (Exception $e) { - // sucess - } - } - - /** - * Tests for ZF-461 - * - * Check to see that cycling detection works properly - */ - public function testZf461() - { - $item1 = new Zend_JsonTest_Item() ; - $item2 = new Zend_JsonTest_Item() ; - $everything = array() ; - $everything['allItems'] = array($item1, $item2) ; - $everything['currentItem'] = $item1 ; - - try { - $encoded = Zend_Json_Encoder::encode($everything); - } catch (Exception $e) { - $this->fail('Object cycling checks should check for recursion, not duplicate usage of an item'); - } - - try { - $encoded = Zend_Json_Encoder::encode($everything, true); - $this->fail('Object cycling not allowed when cycleCheck parameter is true'); - } catch (Exception $e) { - // success - } - } - - /** - * Test for ZF-4053 - * - * Check to see that cyclical exceptions are silenced when - * $option['silenceCyclicalExceptions'] = true is used - */ - public function testZf4053() - { - $item1 = new Zend_JsonTest_Item() ; - $item2 = new Zend_JsonTest_Item() ; - $everything = array() ; - $everything['allItems'] = array($item1, $item2) ; - $everything['currentItem'] = $item1 ; - - $options = array('silenceCyclicalExceptions'=>true); - - Zend_Json::$useBuiltinEncoderDecoder = true; - $encoded = Zend_Json::encode($everything, true, $options); - $json = '{"allItems":[{"__className":"Zend_JsonTest_Item"},{"__className":"Zend_JsonTest_Item"}],"currentItem":"* RECURSION (Zend_JsonTest_Item) *"}'; - - $this->assertEquals($encoded,$json); - } - - public function testEncodeObject() - { - $actual = new Zend_JsonTest_Object(); - $encoded = Zend_Json_Encoder::encode($actual); - $decoded = Zend_Json_Decoder::decode($encoded, Zend_Json::TYPE_OBJECT); - - $this->assertTrue(isset($decoded->__className)); - $this->assertEquals('Zend_JsonTest_Object', $decoded->__className); - $this->assertTrue(isset($decoded->foo)); - $this->assertEquals('bar', $decoded->foo); - $this->assertTrue(isset($decoded->bar)); - $this->assertEquals('baz', $decoded->bar); - $this->assertFalse(isset($decoded->_foo)); - } - - public function testEncodeClass() - { - $encoded = Zend_Json_Encoder::encodeClass('Zend_JsonTest_Object'); - - $this->assertContains("Class.create('Zend_JsonTest_Object'", $encoded); - $this->assertContains("ZAjaxEngine.invokeRemoteMethod(this, 'foo'", $encoded); - $this->assertContains("ZAjaxEngine.invokeRemoteMethod(this, 'bar'", $encoded); - $this->assertNotContains("ZAjaxEngine.invokeRemoteMethod(this, 'baz'", $encoded); - - $this->assertContains('variables:{foo:"bar",bar:"baz"}', $encoded); - $this->assertContains('constants : {FOO: "bar"}', $encoded); - } - - public function testEncodeClasses() - { - $encoded = Zend_Json_Encoder::encodeClasses(array('Zend_JsonTest_Object', 'Zend_JsonTest')); - - $this->assertContains("Class.create('Zend_JsonTest_Object'", $encoded); - $this->assertContains("Class.create('Zend_JsonTest'", $encoded); - } -} - -/** - * Zend_JsonTest_Item: test item for use with testZf461() - */ -class Zend_JsonTest_Item -{ -} - -/** - * Zend_JsonTest_Object: test class for encoding classes - */ -class Zend_JsonTest_Object -{ - const FOO = 'bar'; - - public $foo = 'bar'; - public $bar = 'baz'; - - protected $_foo = 'fooled you'; - - public function foo($bar, $baz) - { - } - - public function bar($baz) - { - } - - protected function baz() - { - } -} diff --git a/tests/Zend/Layout/AllTests.php b/tests/Zend/Layout/AllTests.php deleted file mode 100644 index 2bd536f72e020f8d5063ffeaf7a3e496ec322206..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/AllTests.php +++ /dev/null @@ -1,66 +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_Layout - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10746 2008-08-07 05:35:31Z ralph $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Layout_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Layout/LayoutTest.php'; -require_once 'Zend/Layout/HelperTest.php'; -require_once 'Zend/Layout/PluginTest.php'; -require_once 'Zend/Layout/FunctionalTest.php'; - -/** - * @category Zend - * @package Zend_Layout - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Layout_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Layout'); - - $suite->addTestSuite('Zend_Layout_LayoutTest'); - $suite->addTestSuite('Zend_Layout_HelperTest'); - $suite->addTestSuite('Zend_Layout_PluginTest'); - $suite->addTestSuite('Zend_Layout_FunctionalTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Layout_AllTests::main') { - Zend_Layout_AllTests::main(); -} diff --git a/tests/Zend/Layout/FunctionalTest.php b/tests/Zend/Layout/FunctionalTest.php deleted file mode 100644 index cbc36de9225f33f7bbd3b136bc99f2e45557fa07..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/FunctionalTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -// Call Zend_Layout_FunctionalTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Layout_FunctionalTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -require_once 'Zend/Test/PHPUnit/ControllerTestCase.php'; - -require_once 'Zend/Controller/Plugin/ErrorHandler.php'; - -class Zend_Layout_FunctionalTest extends Zend_Test_PHPUnit_ControllerTestCase -{ - public function setUp() - { - $this->bootstrap = array($this, 'appBootstrap'); - parent::setUp(); - } - - public function appBootstrap() - { - $this->frontController->setControllerDirectory(dirname(__FILE__) . '/_files/functional-test-app/controllers/'); - - // create an instance of the ErrorHandler so we can make sure it will point to our specially named ErrorController - $plugin = new Zend_Controller_Plugin_ErrorHandler(); - $plugin->setErrorHandlerController('zend-layout-functional-test-error') - ->setErrorHandlerAction('error'); - $this->frontController->registerPlugin($plugin, 100); - - Zend_Layout::startMvc(dirname(__FILE__) . '/_files/functional-test-app/layouts/'); - } - - public function testMissingViewScriptDoesNotDoubleRender() - { - // go to the test controller for this funcitonal test - $this->dispatch('/zend-layout-functional-test-test/missing-view-script'); - $this->assertEquals($this->response->getBody(), "[DEFAULT_LAYOUT_START]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]"); - } - - public function testMissingViewScriptDoesDoubleRender() - { - Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-91, new Zend_Controller_Action_Helper_ViewRenderer()); - // go to the test controller for this funcitonal test - $this->dispatch('/zend-layout-functional-test-test/missing-view-script'); - $this->assertEquals($this->response->getBody(), "[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_END](ErrorController::errorAction output)[DEFAULT_LAYOUT_END]"); - } - -} diff --git a/tests/Zend/Layout/HelperTest.php b/tests/Zend/Layout/HelperTest.php deleted file mode 100644 index 410df3e5cd0a50344d422ea2428397f03b2d555d..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/HelperTest.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php -// Call Zend_LayoutTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Layout_HelperTest::main"); -} - -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Layout/Controller/Action/Helper/Layout.php'; -require_once 'Zend/Layout.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; - -/** - * Test class for Zend_Layout_Controller_Action_Helper_Layout - */ -class Zend_Layout_HelperTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Layout_HelperTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Layout_HelperTest_Layout::$_mvcInstance = null; - Zend_Controller_Front::getInstance()->resetInstance(); - if (Zend_Controller_Action_HelperBroker::hasHelper('Layout')) { - Zend_Controller_Action_HelperBroker::removeHelper('Layout'); - } - if (Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) { - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - } - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testConstructorWithLayoutObject() - { - $layout = new Zend_Layout(); - $helper = new Zend_Layout_Controller_Action_Helper_Layout($layout); - $this->assertSame($layout, $helper->getLayoutInstance()); - } - - public function testGetLayoutCreatesLayoutObjectWhenNoPluginRegistered() - { - $helper = new Zend_Layout_Controller_Action_Helper_Layout(); - $layout = $helper->getLayoutInstance(); - $this->assertTrue($layout instanceof Zend_Layout); - } - - public function testGetLayoutInstancePullsMvcLayoutInstance() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_Layout_Controller_Action_Helper_Layout(); - $this->assertSame($layout, $helper->getLayoutInstance()); - } - - public function testSetLayoutInstanceReplacesExistingLayoutObject() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_Layout_Controller_Action_Helper_Layout(); - $this->assertSame($layout, $helper->getLayoutInstance()); - - $newLayout = new Zend_Layout(); - $this->assertNotSame($layout, $newLayout); - - $helper->setLayoutInstance($newLayout); - $this->assertSame($newLayout, $helper->getLayoutInstance()); - } - - public function testDirectFetchesLayoutObject() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_Layout_Controller_Action_Helper_Layout(); - - $received = $helper->direct(); - $this->assertSame($layout, $received); - } - - public function testHelperProxiesToLayoutObjectMethods() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_Layout_Controller_Action_Helper_Layout(); - - $helper->setOptions(array( - 'layout' => 'foo.phtml', - 'layoutPath' => dirname(__FILE__) . '/_files/layouts', - 'contentKey' => 'foo' - )); - $this->assertEquals('foo.phtml', $helper->getLayout()); - $this->assertEquals(dirname(__FILE__) . '/_files/layouts', $helper->getLayoutPath()); - $this->assertEquals('foo', $helper->getContentKey()); - } -} - -/** - * Zend_Layout extension to allow resetting MVC instance - */ -class Zend_Layout_HelperTest_Layout extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_Layout_HelperTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Layout_HelperTest::main") { - Zend_Layout_HelperTest::main(); -} diff --git a/tests/Zend/Layout/LayoutTest.php b/tests/Zend/Layout/LayoutTest.php deleted file mode 100644 index 3a6721d266e06dc70d6db671b2130057ebb0b80f..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/LayoutTest.php +++ /dev/null @@ -1,532 +0,0 @@ -<?php -// Call Zend_Layout_LayoutTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Layout_LayoutTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Layout.php'; -require_once 'Zend/Layout/Controller/Plugin/Layout.php'; -require_once 'Zend/Layout/Controller/Action/Helper/Layout.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Filter/Inflector.php'; -require_once 'Zend/View/Interface.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_Layout. - */ -class Zend_Layout_LayoutTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Layout_LayoutTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Layout_LayoutTest_Override::$_mvcInstance = null; - - Zend_Controller_Front::getInstance()->resetInstance(); - if (Zend_Controller_Action_HelperBroker::hasHelper('Layout')) { - Zend_Controller_Action_HelperBroker::removeHelper('Layout'); - } - if (Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) { - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - } - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testDefaultLayoutStatusAtInitialization() - { - $layout = new Zend_Layout(); - $this->assertEquals('layout', $layout->getLayout()); - $this->assertEquals('content', $layout->getContentKey()); - $this->assertTrue($layout->isEnabled()); - $this->assertTrue($layout->inflectorEnabled()); - $this->assertNull($layout->getLayoutPath()); - $this->assertFalse($layout->getMvcEnabled()); - } - - public function testDefaultLayoutStatusAtInitializationWhenInitMvcFlagPassed() - { - $layout = new Zend_Layout(null, true); - $this->assertEquals('layout', $layout->getLayout()); - $this->assertEquals('content', $layout->getContentKey()); - $this->assertTrue($layout->isEnabled()); - $this->assertTrue($layout->inflectorEnabled()); - $this->assertNull($layout->getLayoutPath()); - $this->assertTrue($layout->getMvcEnabled()); - } - - /** - * @return void - */ - public function testSetConfigModifiesAttributes() - { - $layout = new Zend_Layout(); - - require_once 'Zend/Config.php'; - $config = new Zend_Config(array( - 'layout' => 'foo', - 'contentKey' => 'foo', - 'layoutPath' => dirname(__FILE__), - 'mvcEnabled' => false, - )); - $layout->setConfig($config); - $this->assertEquals('foo', $layout->getLayout()); - $this->assertEquals('foo', $layout->getContentKey()); - $this->assertEquals(dirname(__FILE__), $layout->getLayoutPath()); - $this->assertFalse($layout->getMvcEnabled()); - } - - /** - * @return void - */ - public function testSetOptionsWithConfigObjectModifiesAttributes() - { - $layout = new Zend_Layout(); - - require_once 'Zend/Config.php'; - $config = new Zend_Config(array( - 'layout' => 'foo', - 'contentKey' => 'foo', - 'layoutPath' => dirname(__FILE__), - 'mvcEnabled' => false, - )); - $layout->setOptions($config); - $this->assertEquals('foo', $layout->getLayout()); - $this->assertEquals('foo', $layout->getContentKey()); - $this->assertEquals(dirname(__FILE__), $layout->getLayoutPath()); - $this->assertFalse($layout->getMvcEnabled()); - } - - /** - * @return void - */ - public function testLayoutAccessorsModifyAndRetrieveLayoutValue() - { - $layout = new Zend_Layout(); - $layout->setLayout('foo'); - $this->assertEquals('foo', $layout->getLayout()); - } - - /** - * @return void - */ - public function testSetLayoutEnablesLayouts() - { - $layout = new Zend_Layout(); - $layout->disableLayout(); - $this->assertFalse($layout->isEnabled()); - $layout->setLayout('foo'); - $this->assertTrue($layout->isEnabled()); - } - - /** - * @return void - */ - public function testDisableLayoutDisablesLayouts() - { - $layout = new Zend_Layout(); - $this->assertTrue($layout->isEnabled()); - $layout->disableLayout(); - $this->assertFalse($layout->isEnabled()); - } - - /** - * @return void - */ - public function testEnableLayoutEnablesLayouts() - { - $layout = new Zend_Layout(); - $this->assertTrue($layout->isEnabled()); - $layout->disableLayout(); - $this->assertFalse($layout->isEnabled()); - $layout->enableLayout(); - $this->assertTrue($layout->isEnabled()); - } - - /** - * @return void - */ - public function testLayoutPathAccessorsWork() - { - $layout = new Zend_Layout(); - $layout->setLayoutPath(dirname(__FILE__)); - $this->assertEquals(dirname(__FILE__), $layout->getLayoutPath()); - } - - /** - * @return void - */ - public function testContentKeyAccessorsWork() - { - $layout = new Zend_Layout(); - $layout->setContentKey('foo'); - $this->assertEquals('foo', $layout->getContentKey()); - } - - /** - * @return void - */ - public function testMvcEnabledFlagFalseAfterStandardInstantiation() - { - $layout = new Zend_Layout(); - $this->assertFalse($layout->getMvcEnabled()); - } - - /** - * @return void - */ - public function testMvcEnabledFlagTrueWhenInstantiatedViaStartMvcMethod() - { - $layout = Zend_Layout::startMvc(); - $this->assertTrue($layout->getMvcEnabled()); - } - - /** - * @return void - */ - public function testGetViewRetrievesViewWhenNoneSet() - { - $layout = new Zend_Layout(); - $view = $layout->getView(); - $this->assertTrue($view instanceof Zend_View_Interface); - } - - /** - * @return void - */ - public function testGetViewRetrievesViewFromViewRenderer() - { - $layout = new Zend_Layout(); - $view = $layout->getView(); - $vr = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $this->assertSame($vr->view, $view); - } - - /** - * @return void - */ - public function testViewAccessorsAllowSettingView() - { - $layout = new Zend_Layout(); - $view = new Zend_View(); - $layout->setView($view); - $received = $layout->getView(); - $this->assertSame($view, $received); - } - - /** - * @return void - */ - public function testInflectorAccessorsWork() - { - $layout = new Zend_Layout(); - $inflector = new Zend_Filter_Inflector(); - $layout->setInflector($inflector); - $this->assertSame($inflector, $layout->getInflector()); - } - - /** - * @return void - */ - public function testPluginClassAccessorsSetState() - { - $layout = new Zend_Layout(); - $layout->setPluginClass('Foo_Bar'); - $this->assertEquals('Foo_Bar', $layout->getPluginClass()); - } - - /** - * @return void - */ - public function testPluginClassPassedToStartMvcIsUsed() - { - $layout = Zend_Layout::startMvc(array('pluginClass' => 'Zend_Layout_LayoutTest_Controller_Plugin_Layout')); - $this->assertTrue(Zend_Controller_Front::getInstance()->hasPlugin('Zend_Layout_LayoutTest_Controller_Plugin_Layout')); - } - - /** - * @return void - */ - public function testHelperClassAccessorsSetState() - { - $layout = new Zend_Layout(); - $layout->setHelperClass('Foo_Bar'); - $this->assertEquals('Foo_Bar', $layout->getHelperClass()); - } - - /** - * @return void - */ - public function testHelperClassPassedToStartMvcIsUsed() - { - $layout = Zend_Layout::startMvc(array('helperClass' => 'Zend_Layout_LayoutTest_Controller_Action_Helper_Layout')); - $this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper('layout')); - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('layout'); - $this->assertTrue($helper instanceof Zend_Layout_LayoutTest_Controller_Action_Helper_Layout); - } - - /** - * @return void - */ - public function testEnableInflector() - { - $layout = new Zend_Layout(); - $layout->disableInflector(); - $this->assertFalse($layout->inflectorEnabled()); - $layout->enableInflector(); - $this->assertTrue($layout->inflectorEnabled()); - } - - /** - * @return void - */ - public function testDisableInflector() - { - $layout = new Zend_Layout(); - $layout->disableInflector(); - $this->assertFalse($layout->inflectorEnabled()); - } - - /** - * @return void - */ - public function testOverloadingAccessorsWork() - { - $layout = new Zend_Layout(); - $layout->foo = 'bar'; - $this->assertTrue(isset($layout->foo)); - $this->assertEquals('bar', $layout->foo); - unset($layout->foo); - $this->assertFalse(isset($layout->foo)); - } - - /** - * @return void - */ - public function testAssignWithKeyValuePairPopulatesPropertyAccessibleViaOverloading() - { - $layout = new Zend_Layout(); - $layout->assign('foo', 'bar'); - $this->assertEquals('bar', $layout->foo); - } - - /** - * @return void - */ - public function testAssignWithArrayPopulatesPropertiesAccessibleViaOverloading() - { - $layout = new Zend_Layout(); - $layout->assign(array( - 'foo' => 'bar', - 'bar' => 'baz' - )); - $this->assertEquals('bar', $layout->foo); - $this->assertEquals('baz', $layout->bar); - } - - /** - * @return void - */ - public function testRenderWithNoInflection() - { - $layout = new Zend_Layout(); - $view = new Zend_View(); - $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') - ->disableInflector() - ->setLayout('layout.phtml') - ->setView($view); - $layout->message = 'Rendered layout'; - $received = $layout->render(); - $this->assertContains('Testing layouts:', $received); - $this->assertContains($layout->message, $received); - } - - public function testRenderWithDefaultInflection() - { - $layout = new Zend_Layout(); - $view = new Zend_View(); - $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') - ->setView($view); - $layout->message = 'Rendered layout'; - $received = $layout->render(); - $this->assertContains('Testing layouts:', $received); - $this->assertContains($layout->message, $received); - } - - public function testRenderWithCustomInflection() - { - $layout = new Zend_Layout(); - $view = new Zend_View(); - $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') - ->setView($view); - $inflector = $layout->getInflector(); - $inflector->setTarget('test/:script.:suffix') - ->setStaticRule('suffix', 'php'); - $layout->message = 'Rendered layout'; - $received = $layout->render(); - $this->assertContains('Testing layouts with custom inflection:', $received); - $this->assertContains($layout->message, $received); - } - - public function testGetMvcInstanceReturnsNullWhenStartMvcHasNotBeenCalled() - { - $this->assertNull(Zend_Layout::getMvcInstance()); - } - - public function testGetMvcInstanceReturnsLayoutInstanceWhenStartMvcHasBeenCalled() - { - $layout = Zend_Layout::startMvc(); - $received = Zend_Layout::getMvcInstance(); - $this->assertSame($layout, $received); - } - - public function testSubsequentCallsToStartMvcWithOptionsSetState() - { - $layout = Zend_Layout::startMvc(); - $this->assertTrue($layout->getMvcSuccessfulActionOnly()); - $this->assertEquals('content', $layout->getContentKey()); - - Zend_Layout::startMvc(array( - 'mvcSuccessfulActionOnly' => false, - 'contentKey' => 'foobar' - )); - $this->assertFalse($layout->getMvcSuccessfulActionOnly()); - $this->assertEquals('foobar', $layout->getContentKey()); - } - - public function testGetViewSuffixRetrievesDefaultValue() - { - $layout = new Zend_Layout(); - $this->assertEquals('phtml', $layout->getViewSuffix()); - } - - public function testViewSuffixAccessorsWork() - { - $layout = new Zend_Layout(); - $layout->setViewSuffix('php'); - $this->assertEquals('php', $layout->getViewSuffix()); - } - - public function testSettingViewSuffixChangesInflectorSuffix() - { - $layout = new Zend_Layout(); - $inflector = $layout->getInflector(); - $rules = $inflector->getRules(); - $this->assertTrue(isset($rules['suffix'])); - $this->assertEquals($layout->getViewSuffix(), $rules['suffix']); - $layout->setViewSuffix('php'); - $this->assertEquals($layout->getViewSuffix(), $rules['suffix']); - } - - public function testGetInflectorTargetRetrievesDefaultValue() - { - $layout = new Zend_Layout(); - $this->assertEquals(':script.:suffix', $layout->getInflectorTarget()); - } - - public function testInflectorTargetAccessorsWork() - { - $layout = new Zend_Layout(); - $layout->setInflectorTarget(':script-foo.:suffix'); - $this->assertEquals(':script-foo.:suffix', $layout->getInflectorTarget()); - } - - public function testSettingInflectorTargetChangesInflectorSuffix() - { - $layout = new Zend_Layout(); - $inflector = $layout->getInflector(); - $target = $inflector->getTarget(); - $this->assertEquals($layout->getInflectorTarget(), $inflector->getTarget()); - $layout->setInflectorTarget('php'); - $this->assertEquals($layout->getInflectorTarget(), $inflector->getTarget()); - } - - public function testLayoutWithViewBasePath() - { - $layout = new Zend_Layout(array( - 'viewBasePath' => dirname(__FILE__) . '/_files/layouts-basepath/') - ); - $this->assertEquals('layout inside basePath', $layout->render()); - $layout->setLayout('layout2'); - $this->assertEquals('foobar-helper-output', $layout->render()); - } - - public function testResettingMvcInstanceUnregistersHelperAndPlugin() - { - $this->testGetMvcInstanceReturnsLayoutInstanceWhenStartMvcHasBeenCalled(); - Zend_Layout::resetMvcInstance(); - $front = Zend_Controller_Front::getInstance(); - $this->assertFalse($front->hasPlugin('Zend_Layout_Controller_Plugin_Layout'), 'Plugin not unregistered'); - $this->assertFalse(Zend_Controller_Action_HelperBroker::hasHelper('Layout'), 'Helper not unregistered'); - } - - public function testResettingMvcInstanceRemovesMvcSingleton() - { - $this->testGetMvcInstanceReturnsLayoutInstanceWhenStartMvcHasBeenCalled(); - Zend_Layout::resetMvcInstance(); - $this->assertNull(Zend_Layout::getMvcInstance()); - } - - public function testMinimalViewObjectWorks() - { - require_once dirname(__FILE__) . '/_files/MinimalCustomView.php'; - $layout = new Zend_Layout(array( - 'view' => new Zend_Layout_Test_MinimalCustomView(), - 'ViewScriptPath' => 'some/path' - )); - $layout->render(); - } - -} - -/** - * Zend_Layout extension to allow resetting mvcInstance static member - */ -class Zend_Layout_LayoutTest_Override extends Zend_Layout -{ - public static $_mvcInstance; -} - -class Zend_Layout_LayoutTest_Controller_Plugin_Layout extends Zend_Layout_Controller_Plugin_Layout -{ -} - -class Zend_Layout_LayoutTest_Controller_Action_Helper_Layout extends Zend_Layout_Controller_Action_Helper_Layout -{ -} - -// Call Zend_Layout_LayoutTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Layout_LayoutTest::main") { - Zend_Layout_LayoutTest::main(); -} diff --git a/tests/Zend/Layout/PluginTest.php b/tests/Zend/Layout/PluginTest.php deleted file mode 100644 index 156f99fac2bb91fc22be2bc264aac91f18e21ec5..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/PluginTest.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php -// Call Zend_LayoutTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Layout_PluginTest::main"); -} - -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/Layout/Controller/Plugin/Layout.php'; -require_once 'Zend/Layout.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Request/Simple.php'; -require_once 'Zend/Controller/Response/Cli.php'; - -/** - * Test class for Zend_Layout_Controller_Plugin_Layout - */ -class Zend_Layout_PluginTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Layout_PluginTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Controller_Front::getInstance()->resetInstance(); - - Zend_Layout_PluginTest_Layout::$_mvcInstance = null; - - if (Zend_Controller_Action_HelperBroker::hasHelper('Layout')) { - Zend_Controller_Action_HelperBroker::removeHelper('Layout'); - } - if (Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) { - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - } - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testConstructorWithLayoutObject() - { - $layout = new Zend_Layout(array('mvcEnabled' => false)); - $plugin = new Zend_Layout_Controller_Plugin_Layout($layout); - $this->assertSame($layout, $plugin->getLayout()); - } - - public function testGetLayoutReturnsNullWithNoLayoutPresent() - { - $plugin = new Zend_Layout_Controller_Plugin_Layout(); - $this->assertNull($plugin->getLayout()); - } - - public function testLayoutAccessorsWork() - { - $plugin = new Zend_Layout_Controller_Plugin_Layout(); - $this->assertNull($plugin->getLayout()); - - $layout = new Zend_Layout(array('mvcEnabled' => false)); - $plugin->setlayout($layout); - $this->assertSame($layout, $plugin->getLayout()); - } - - public function testGetLayoutReturnsLayoutObjectWhenPulledFromPluginBroker() - { - $layout = Zend_Layout::startMvc(); - $front = Zend_Controller_Front::getInstance(); - $this->assertTrue($front->hasPlugin('Zend_Layout_Controller_Plugin_Layout')); - $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout'); - $this->assertSame($layout, $plugin->getLayout()); - } - - public function testPostDispatchRendersLayout() - { - $front = Zend_Controller_Front::getInstance(); - $request = new Zend_Controller_Request_Simple(); - $response = new Zend_Controller_Response_Cli(); - - $request->setDispatched(true); - $response->setBody('Application content'); - $front->setRequest($request) - ->setResponse($response); - - $layout = Zend_Layout::startMvc(); - $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') - ->setLayout('plugin.phtml') - ->disableInflector(); - - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('layout'); - $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout'); - $plugin->setResponse($response); - - $helper->postDispatch(); - $plugin->postDispatch($request); - - $body = $response->getBody(); - $this->assertContains('Application content', $body, $body); - $this->assertContains('Site Layout', $body, $body); - } - - public function testPostDispatchDoesNotRenderLayoutWhenForwardDetected() - { - $front = Zend_Controller_Front::getInstance(); - $request = new Zend_Controller_Request_Simple(); - $response = new Zend_Controller_Response_Cli(); - - $request->setDispatched(false); - $response->setBody('Application content'); - $front->setRequest($request) - ->setResponse($response); - - $layout = Zend_Layout::startMvc(); - $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') - ->setLayout('plugin.phtml') - ->disableInflector(); - - $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout'); - $plugin->setResponse($response); - $plugin->postDispatch($request); - - $body = $response->getBody(); - $this->assertContains('Application content', $body); - $this->assertNotContains('Site Layout', $body); - } - - public function testPostDispatchDoesNotRenderLayoutWhenLayoutDisabled() - { - $front = Zend_Controller_Front::getInstance(); - $request = new Zend_Controller_Request_Simple(); - $response = new Zend_Controller_Response_Cli(); - - $request->setDispatched(true); - $response->setBody('Application content'); - $front->setRequest($request) - ->setResponse($response); - - $layout = Zend_Layout::startMvc(); - $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') - ->setLayout('plugin.phtml') - ->disableInflector() - ->disableLayout(); - - $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout'); - $plugin->setResponse($response); - $plugin->postDispatch($request); - - $body = $response->getBody(); - $this->assertContains('Application content', $body); - $this->assertNotContains('Site Layout', $body); - } -} - -/** - * Zend_Layout extension to allow resetting MVC instance - */ -class Zend_Layout_PluginTest_Layout extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_Layout_PluginTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Layout_PluginTest::main") { - Zend_Layout_PluginTest::main(); -} diff --git a/tests/Zend/Layout/_files/MinimalCustomView.php b/tests/Zend/Layout/_files/MinimalCustomView.php deleted file mode 100644 index 1093872a4bb2c000e507d76859a3f743b5e17822..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/MinimalCustomView.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -class Zend_Layout_Test_MinimalCustomView implements Zend_View_Interface -{ - - public function getEngine() {} - - public function setScriptPath($path) {} - - public function getScriptPaths() {} - - public function setBasePath($path, $classPrefix = 'Zend_View') {} - - public function addBasePath($path, $classPrefix = 'Zend_View') {} - - public function __set($key, $val) {} - - public function __isset($key) {} - - public function __unset($key) {} - - public function assign($spec, $value = null) {} - - public function clearVars() {} - - public function render($name) {} - -} \ No newline at end of file diff --git a/tests/Zend/Layout/_files/functional-test-app/controllers/ZendLayoutFunctionalTestErrorController.php b/tests/Zend/Layout/_files/functional-test-app/controllers/ZendLayoutFunctionalTestErrorController.php deleted file mode 100644 index 1c7aef7b1ccbc6efe6a3801bded1164847f42b53..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/functional-test-app/controllers/ZendLayoutFunctionalTestErrorController.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -class ZendLayoutFunctionalTestErrorController extends Zend_Controller_Action -{ - - public function errorAction() - { - } - -} \ No newline at end of file diff --git a/tests/Zend/Layout/_files/functional-test-app/controllers/ZendLayoutFunctionalTestTestController.php b/tests/Zend/Layout/_files/functional-test-app/controllers/ZendLayoutFunctionalTestTestController.php deleted file mode 100644 index 92831cdf30e81e8d7ac6cd0085219eb74a6c4bb2..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/functional-test-app/controllers/ZendLayoutFunctionalTestTestController.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -class ZendLayoutFunctionalTestTestController extends Zend_Controller_Action -{ - - public function indexAction() - { - - } - - public function missingViewScriptAction() - { - } - -} \ No newline at end of file diff --git a/tests/Zend/Layout/_files/functional-test-app/layouts/layout.phtml b/tests/Zend/Layout/_files/functional-test-app/layouts/layout.phtml deleted file mode 100644 index d404779e3bcf070a4396f9655bbb7c754712fe2e..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/functional-test-app/layouts/layout.phtml +++ /dev/null @@ -1,3 +0,0 @@ -[DEFAULT_LAYOUT_START] -<?= $this->layout()->content; ?> -[DEFAULT_LAYOUT_END] \ No newline at end of file diff --git a/tests/Zend/Layout/_files/functional-test-app/views/scripts/zend-layout-functional-test-error/error.phtml b/tests/Zend/Layout/_files/functional-test-app/views/scripts/zend-layout-functional-test-error/error.phtml deleted file mode 100644 index 8df3812938de3dc3caa6008fe7e4ca6db2634bc7..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/functional-test-app/views/scripts/zend-layout-functional-test-error/error.phtml +++ /dev/null @@ -1 +0,0 @@ -(ErrorController::errorAction output) \ No newline at end of file diff --git a/tests/Zend/Layout/_files/functional-test-app/views/scripts/zend-layout-functional-test-test/index.phtml b/tests/Zend/Layout/_files/functional-test-app/views/scripts/zend-layout-functional-test-test/index.phtml deleted file mode 100644 index 32f95c0d1244a78b2be1bab8de17906fabb2c4a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/functional-test-app/views/scripts/zend-layout-functional-test-test/index.phtml +++ /dev/null @@ -1 +0,0 @@ -hi \ No newline at end of file diff --git a/tests/Zend/Layout/_files/layouts-basepath/helpers/FooBar.php b/tests/Zend/Layout/_files/layouts-basepath/helpers/FooBar.php deleted file mode 100644 index c8c6f0fe1428d208e10be8e984d4146a78de5fa3..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/layouts-basepath/helpers/FooBar.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -class Layout_View_Helper_FooBar -{ - - public function fooBar() - { - return 'foobar-helper-output'; - } - -} \ No newline at end of file diff --git a/tests/Zend/Layout/_files/layouts-basepath/scripts/layout.phtml b/tests/Zend/Layout/_files/layouts-basepath/scripts/layout.phtml deleted file mode 100644 index 33d4383c42a8abdf29d44638400939c787d6f456..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/layouts-basepath/scripts/layout.phtml +++ /dev/null @@ -1 +0,0 @@ -layout inside basePath \ No newline at end of file diff --git a/tests/Zend/Layout/_files/layouts-basepath/scripts/layout2.phtml b/tests/Zend/Layout/_files/layouts-basepath/scripts/layout2.phtml deleted file mode 100644 index 8f5b3feb690d82736c05422950c3f18e22665dbf..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/layouts-basepath/scripts/layout2.phtml +++ /dev/null @@ -1 +0,0 @@ -<?= $this->fooBar(); ?> \ No newline at end of file diff --git a/tests/Zend/Layout/_files/layouts/layout.phtml b/tests/Zend/Layout/_files/layouts/layout.phtml deleted file mode 100644 index 1a7d03c69b2ffa827408a63bdf8c3845e425ad61..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/layouts/layout.phtml +++ /dev/null @@ -1,3 +0,0 @@ -Testing layouts: -<?php echo $this->placeholder('Zend_Layout')->message ?> - diff --git a/tests/Zend/Layout/_files/layouts/plugin.phtml b/tests/Zend/Layout/_files/layouts/plugin.phtml deleted file mode 100644 index 6da92048e7667e8984c80a4230da22d6b989c8a1..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/layouts/plugin.phtml +++ /dev/null @@ -1,3 +0,0 @@ -Site Layout -<?php echo $this->placeholder('Zend_Layout')->content ?> - diff --git a/tests/Zend/Layout/_files/layouts/test/layout.php b/tests/Zend/Layout/_files/layouts/test/layout.php deleted file mode 100644 index d29edc2d6178b3427f3430db56626b43c9c33692..0000000000000000000000000000000000000000 --- a/tests/Zend/Layout/_files/layouts/test/layout.php +++ /dev/null @@ -1,3 +0,0 @@ -Testing layouts with custom inflection: -<?php echo $this->placeholder('Zend_Layout')->message ?> - diff --git a/tests/Zend/Ldap/AllTests.php b/tests/Zend/Ldap/AllTests.php deleted file mode 100644 index 43281fc056a8210ab01bbfe000ee861f53762794..0000000000000000000000000000000000000000 --- a/tests/Zend/Ldap/AllTests.php +++ /dev/null @@ -1,98 +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_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Ldap_AllTests::main'); -} - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Ldap_OfflineTest - */ -require_once 'Zend/Ldap/OfflineTest.php'; - -/** - * @category Zend - * @package Zend_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Ldap_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Ldap'); - - $suite->addTestSuite('Zend_Ldap_OfflineTest'); - - if (defined('TESTS_ZEND_LDAP_ONLINE_ENABLED') - && constant('TESTS_ZEND_LDAP_ONLINE_ENABLED')) { - /** - * @see Zend_Ldap_ConnectTest - */ - require_once 'Zend/Ldap/ConnectTest.php'; - $suite->addTestSuite('Zend_Ldap_ConnectTest'); - /** - * @see Zend_Ldap_BindTest - */ - require_once 'Zend/Ldap/BindTest.php'; - $suite->addTestSuite('Zend_Ldap_BindTest'); - /** - * @see Zend_Ldap_CanonTest - */ - require_once 'Zend/Ldap/CanonTest.php'; - $suite->addTestSuite('Zend_Ldap_CanonTest'); - } else { - $suite->addTest(new Zend_Ldap_SkipOnlineTests()); - } - - return $suite; - } -} - -class Zend_Ldap_SkipOnlineTests extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped('Zend_Ldap online tests not enabled in TestConfiguration.php'); - } - - public function testNothing() - { - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Ldap_AllTests::main') { - Zend_Ldap_AllTests::main(); -} diff --git a/tests/Zend/Ldap/BindTest.php b/tests/Zend/Ldap/BindTest.php deleted file mode 100644 index 21709040d31499462bb0496c823a9aa8f4e7ee9f..0000000000000000000000000000000000000000 --- a/tests/Zend/Ldap/BindTest.php +++ /dev/null @@ -1,190 +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_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BindTest.php 10171 2008-07-18 04:57:08Z miallen $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Ldap - */ -require_once 'Zend/Ldap.php'; - -/* Note: The ldap_connect function does not actually try to connect. This - * is why many tests attempt to bind with invalid credentials. If the - * bind returns 'Invalid credentials' we know the transport related work - * was successful. - */ - -/** - * @category Zend - * @package Zend_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Ldap_BindTest extends PHPUnit_Framework_TestCase -{ - protected $_options = null; - protected $_principalName = TESTS_ZEND_LDAP_PRINCIPAL_NAME; - protected $_altUsername = TESTS_ZEND_LDAP_PRINCIPAL_NAME; - protected $_bindRequiresDn = false; - - public function setUp() - { - $this->_options = array( - 'host' => TESTS_ZEND_LDAP_HOST, - 'username' => TESTS_ZEND_LDAP_USERNAME, - 'password' => TESTS_ZEND_LDAP_PASSWORD, - 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, - ); - if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT != 389) - $this->_options['port'] = TESTS_ZEND_LDAP_PORT; - if (defined('TESTS_ZEND_LDAP_USE_START_TLS')) - $this->_options['useStartTls'] = TESTS_ZEND_LDAP_USE_START_TLS; - if (defined('TESTS_ZEND_LDAP_USE_SSL')) - $this->_options['useSsl'] = TESTS_ZEND_LDAP_USE_SSL; - if (defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN')) - $this->_options['bindRequiresDn'] = TESTS_ZEND_LDAP_BIND_REQUIRES_DN; - if (defined('TESTS_ZEND_LDAP_ALT_USERNAME')) - $this->_altUsername = TESTS_ZEND_LDAP_ALT_USERNAME; - - if (isset($this->_options['bindRequiresDn'])) - $this->_bindRequiresDn = $this->_options['bindRequiresDn']; - } - - public function testEmptyOptionsBind() - { - $ldap = new Zend_Ldap(array()); - try { - $ldap->bind(); - $this->fail('Expected exception for empty options'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('A host parameter is required', $zle->getMessage()); - } - } - public function testAnonymousBind() - { - $options = $this->_options; - unset($options['password']); - - $ldap = new Zend_Ldap($options); - try { - $ldap->bind(); - } catch (Zend_Ldap_Exception $zle) { - // or I guess the server doesn't allow unauthenticated binds - $this->assertContains('unauthenticated bind', $zle->getMessage()); - } - } - public function testNoBaseDnBind() - { - $options = $this->_options; - unset($options['baseDn']); - $options['bindRequiresDn'] = true; - - $ldap = new Zend_Ldap($options); - try { - $ldap->bind('invalid', 'ignored'); - $this->fail('Expected exception for baseDn missing'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Base DN not set', $zle->getMessage()); - } - } - public function testNoDomainNameBind() - { - $options = $this->_options; - unset($options['baseDn']); - $options['bindRequiresDn'] = false; - - $ldap = new Zend_Ldap($options); - try { - $ldap->bind('invalid', 'ignored'); - $this->fail('Expected exception for missing accountDomainName'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Option required: accountDomainName', $zle->getMessage()); - } - } - public function testPlainBind() - { - $ldap = new Zend_Ldap($this->_options); - $ldap->bind(); - } - public function testConnectBind() - { - $ldap = new Zend_Ldap($this->_options); - $ldap->connect()->bind(); - } - public function testExplicitParamsBind() - { - $options = $this->_options; - $username = $options['username']; - $password = $options['password']; - - unset($options['username']); - unset($options['password']); - - $ldap = new Zend_Ldap($options); - $ldap->bind($username, $password); - } - public function testRequiresDnBind() - { - $options = $this->_options; - - /* Fixup filter since bindRequiresDn is used to determine default accountFilterFormat - */ - if (!isset($options['accountFilterFormat']) && $this->_bindRequiresDn === false) - $options['accountFilterFormat'] = '(&(objectClass=user)(sAMAccountName=%s))'; - - $options['bindRequiresDn'] = true; - - $ldap = new Zend_Ldap($options); - try { - $ldap->bind($this->_altUsername, 'invalid'); - } catch (Zend_Ldap_Exception $zle) { - $message = str_replace("\n", " ", $zle->getMessage()); - $this->assertContains('Invalid credentials', $message); - } - } - public function testRequiresDnWithoutDnBind() - { - $options = $this->_options; - - /* Fixup filter since bindRequiresDn is used to determine default accountFilterFormat - */ - if (!isset($options['accountFilterFormat']) && !$this->_bindRequiresDn) - $options['accountFilterFormat'] = '(&(objectClass=user)(sAMAccountName=%s))'; - - $options['bindRequiresDn'] = true; - - unset($options['username']); - - $ldap = new Zend_Ldap($options); - try { - $ldap->bind($this->_principalName); - } catch (Zend_Ldap_Exception $zle) { - /* Note that if your server actually allows anonymous binds this test will fail. - */ - $this->assertContains('Failed to retrieve DN', $zle->getMessage()); - } - } -} diff --git a/tests/Zend/Ldap/CanonTest.php b/tests/Zend/Ldap/CanonTest.php deleted file mode 100644 index ba54df97cc068be8e1a43cc9d3883a9a2afc36b6..0000000000000000000000000000000000000000 --- a/tests/Zend/Ldap/CanonTest.php +++ /dev/null @@ -1,128 +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_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CanonTest.php 8565 2008-03-06 04:08:06Z miallen $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Ldap - */ -require_once 'Zend/Ldap.php'; - -/* Note: The ldap_connect function does not actually try to connect. This - * is why many tests attempt to bind with invalid credentials. If the - * bind returns 'Invalid credentials' we know the transport related work - * was successful. - */ - -/** - * @category Zend - * @package Zend_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Ldap_CanonTest extends PHPUnit_Framework_TestCase -{ - protected $_options = null; - protected $_principalName = TESTS_ZEND_LDAP_PRINCIPAL_NAME; - protected $_names = array(); - - public function setUp() - { - $this->_options = array( - 'host' => TESTS_ZEND_LDAP_HOST, - 'username' => TESTS_ZEND_LDAP_USERNAME, - 'password' => TESTS_ZEND_LDAP_PASSWORD, - 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, - ); - if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT != 389) - $this->_options['port'] = TESTS_ZEND_LDAP_PORT; - if (defined('TESTS_ZEND_LDAP_USE_SSL')) - $this->_options['useSsl'] = TESTS_ZEND_LDAP_USE_SSL; - if (defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN')) - $this->_options['bindRequiresDn'] = TESTS_ZEND_LDAP_BIND_REQUIRES_DN; - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME')) - $this->_options['accountDomainName'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME; - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT')) - $this->_options['accountDomainNameShort'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT; - if (defined('TESTS_ZEND_LDAP_ALT_USERNAME')) { - $this->_names[Zend_Ldap::ACCTNAME_FORM_USERNAME] = TESTS_ZEND_LDAP_ALT_USERNAME; - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME')) { - $this->_names[Zend_Ldap::ACCTNAME_FORM_PRINCIPAL] = - TESTS_ZEND_LDAP_ALT_USERNAME . '@' . TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME; - } - if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT')) { - $this->_names[Zend_Ldap::ACCTNAME_FORM_BACKSLASH] = - TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT . '\\' . TESTS_ZEND_LDAP_ALT_USERNAME; - } - } - } - - public function testPlainCanon() - { - $ldap = new Zend_Ldap($this->_options); - - /* This test tries to canonicalize each name (uname, uname@example.com, - * EXAMPLE\uname) to each of the 3 forms (username, principal and backslash) - * for a total of canonicalizations. - */ - foreach ($this->_names as $_form => $name) { - foreach ($this->_names as $form => $_name) { - $ret = $ldap->getCanonicalAccountName($name, $form); - $this->assertTrue($ret === $this->_names[$form]); - } - } - } - public function testInvalidAccountCanon() - { - $ldap = new Zend_Ldap($this->_options); - try { - $ldap->bind('invalid', 'invalid'); - } catch (Zend_Ldap_Exception $zle) { - $msg = $zle->getMessage(); - $this->assertTrue(strstr($msg, 'Invalid credentials') || strstr($msg, 'No such object')); - } - } - public function testDnCanon() - { - $ldap = new Zend_Ldap($this->_options); - $name = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_DN, Zend_Ldap::ACCTNAME_FORM_DN); - } - public function testMismatchDomainBind() - { - $ldap = new Zend_Ldap($this->_options); - try { - $ldap->bind('BOGUS\\doesntmatter', 'doesntmatter'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertTrue($zle->getCode() == Zend_Ldap_Exception::LDAP_X_DOMAIN_MISMATCH); - } - } - public function testBindCanon() - { - /** - * @todo test accountCanonicalForm option - */ - } -} diff --git a/tests/Zend/Ldap/ConnectTest.php b/tests/Zend/Ldap/ConnectTest.php deleted file mode 100644 index 538981e224f56a22a386fabe7a9275008a4990bb..0000000000000000000000000000000000000000 --- a/tests/Zend/Ldap/ConnectTest.php +++ /dev/null @@ -1,178 +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_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ConnectTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Ldap - */ -require_once 'Zend/Ldap.php'; - -/* Note: The ldap_connect function does not actually try to connect. This - * is why many tests attempt to bind with invalid credentials. If the - * bind returns 'Invalid credentials' we know the transport related work - * was successful. - */ - -/** - * @category Zend - * @package Zend_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Ldap_ConnectTest extends PHPUnit_Framework_TestCase -{ - protected $_options = null; - - public function setUp() - { - $this->_options = array('host' => TESTS_ZEND_LDAP_HOST); - if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT != 389) - $this->_options['port'] = TESTS_ZEND_LDAP_PORT; - if (defined('TESTS_ZEND_LDAP_USE_SSL')) - $this->_options['useSsl'] = TESTS_ZEND_LDAP_USE_SSL; - } - - public function testEmptyOptionsConnect() - { - $ldap = new Zend_Ldap(array()); - try { - $ldap->connect(); - $this->fail('Expected exception for empty options'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('host parameter is required', $zle->getMessage()); - } - } - public function testUnknownHostConnect() - { - $ldap = new Zend_Ldap(array('host' => 'bogus.example.com')); - try { - // connect doesn't actually try to connect until bind is called - $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for unknown host'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Can\'t contact LDAP server', $zle->getMessage()); - } - } - public function testPlainConnect() - { - $ldap = new Zend_Ldap($this->_options); - try { - // Connect doesn't actually try to connect until bind is called - // but if we get 'Invalid credentials' then we know the connect - // succeeded. - $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for invalid username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Invalid credentials', $zle->getMessage()); - } - } - public function testExplicitParamsConnect() - { - $host = TESTS_ZEND_LDAP_HOST; - $port = 0; - if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT != 389) - $port = TESTS_ZEND_LDAP_PORT; - $useSsl = false; - if (defined('TESTS_ZEND_LDAP_USE_SSL')) - $useSsl = TESTS_ZEND_LDAP_USE_SSL; - - $ldap = new Zend_Ldap(); - try { - $ldap->connect($host, $port, $useSsl) - ->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for invalid username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Invalid credentials', $zle->getMessage()); - } - } - public function testExplicitPortConnect() - { - $port = 389; - if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT) - $port = TESTS_ZEND_LDAP_PORT; - if (defined('TESTS_ZEND_LDAP_USE_SSL') && TESTS_ZEND_LDAP_USE_SSL) - $port = 636; - - $ldap = new Zend_Ldap($this->_options); - try { - $ldap->connect(null, $port) - ->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for invalid username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Invalid credentials', $zle->getMessage()); - } - } - public function testBadPortConnect() - { - $options = $this->_options; - $options['port'] = 10; - - $ldap = new Zend_Ldap($options); - try { - $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for unknown username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Can\'t contact LDAP server', $zle->getMessage()); - } - } - public function testSetOptionsConnect() - { - $ldap = new Zend_Ldap(); - $ldap->setOptions($this->_options); - try { - $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for invalid username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Invalid credentials', $zle->getMessage()); - } - } - public function testMultiConnect() - { - $ldap = new Zend_Ldap($this->_options); - for ($i = 0; $i < 3; $i++) { - try { - $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for unknown username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Invalid credentials', $zle->getMessage()); - } - } - } - public function testDisconnect() - { - $ldap = new Zend_Ldap($this->_options); - for ($i = 0; $i < 3; $i++) { - $ldap->disconnect(); - try { - $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); - $this->fail('Expected exception for unknown username'); - } catch (Zend_Ldap_Exception $zle) { - $this->assertContains('Invalid credentials', $zle->getMessage()); - } - } - } -} diff --git a/tests/Zend/Ldap/OfflineTest.php b/tests/Zend/Ldap/OfflineTest.php deleted file mode 100644 index 910b39f50f99db52e512f4a6f3211c2abdc33b36..0000000000000000000000000000000000000000 --- a/tests/Zend/Ldap/OfflineTest.php +++ /dev/null @@ -1,120 +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_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OfflineTest.php 8261 2008-02-21 21:36:34Z miallen $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Ldap - */ -require_once 'Zend/Ldap.php'; - - -/** - * @category Zend - * @package Zend_Ldap - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Ldap_OfflineTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Ldap instance - * - * @var Zend_Ldap - */ - protected $_ldap = null; - - /** - * Setup operations run prior to each test method: - * - * * Creates an instance of Zend_Ldap - * - * @return void - */ - public function setUp() - { - $this->_ldap = new Zend_Ldap(); - } - - /** - * @return void - */ - public function testFilterEscapeBasicOperation() - { - $input = 'a*b(b)d\e/f'; - $expected = 'a\2ab\28b\29d\5ce\2ff'; - $this->assertEquals($expected, Zend_Ldap::filterEscape($input)); - } - - /** - * @return void - */ - public function testInvalidOptionResultsInException() - { - $optionName = 'invalid'; - try { - $this->_ldap->setOptions(array($optionName => 'irrelevant')); - $this->fail('Expected Zend_Ldap_Exception not thrown'); - } catch (Zend_Ldap_Exception $e) { - $this->assertEquals("Unknown Zend_Ldap option: $optionName", $e->getMessage()); - } - } - - /** - * @return void - */ - public function testExplodeDnOperation() - { - $inputs = array( - 'CN=Alice Baker,CN=Users,DC=example,DC=com' => true, - 'CN=Baker\\, Alice,CN=Users,DC=example,DC=com' => true, - 'OU=Sales,DC=local' => true, - 'OU=Sales;DC=local' => true, - 'OU=Sales ,DC=local' => true, - 'OU=Sales, dC=local' => true, - 'ou=Sales , DC=local' => true, - 'OU=Sales ; dc=local' => true, - 'DC=local' => true, - ' DC=local' => true, - 'DC= local ' => true, - 'username' => false, - 'username@example.com' => false, - 'EXAMPLE\\username' => false, - 'CN=,Alice Baker,CN=Users,DC=example,DC=com' => false, - 'CN=Users,DC==example,DC=com' => false, - 'O=ACME' => true, - '' => false, - ' ' => false, - ); - - foreach ($inputs as $dn => $expected) { - $ret = Zend_Ldap::explodeDn($dn); - $this->assertTrue($ret === $expected); - } - } -} diff --git a/tests/Zend/Loader/AutoloadDoesNotHideParseError.php b/tests/Zend/Loader/AutoloadDoesNotHideParseError.php deleted file mode 100644 index 0f9ef924d838c2f3bb14c5f5a483427312618f0d..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/AutoloadDoesNotHideParseError.php +++ /dev/null @@ -1,38 +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_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AutoloadDoesNotHideParseError.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - -Zend_Loader::registerAutoload(); - -set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/_files'); - -$parseError = new ParseError(); diff --git a/tests/Zend/Loader/AutoloadableClass.php b/tests/Zend/Loader/AutoloadableClass.php deleted file mode 100644 index e9bea71daddb97a9959406723795d0498dca53cd..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/AutoloadableClass.php +++ /dev/null @@ -1,33 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @category Zend - * @package Zend_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_Loader_AutoloadableClass -{ -} diff --git a/tests/Zend/Loader/MyLoader.php b/tests/Zend/Loader/MyLoader.php deleted file mode 100644 index a4d875ba1fab20aa469ca81f4348171dfdc22906..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/MyLoader.php +++ /dev/null @@ -1,44 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Static methods for loading classes and files. - * - * @category Zend - * @package Zend_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Loader_MyLoader extends Zend_Loader -{ - public static function loadClass($class, $dirs = null) - { - parent::loadClass($class, $dirs); - } -} diff --git a/tests/Zend/Loader/MyOverloader.php b/tests/Zend/Loader/MyOverloader.php deleted file mode 100644 index f6562d3c722f482d052d6667ebb4cdbd0538c864..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/MyOverloader.php +++ /dev/null @@ -1,54 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Loader - */ -require_once 'Zend/Loader.php'; - -// require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Static methods for loading classes and files. - * - * @category Zend - * @package Zend_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Loader_MyOverloader extends Zend_Loader -{ - public static function loadClass($class, $dirs = null) - { - parent::loadClass($class, $dirs); - } - - public static function autoload($class) - { - try { - self::loadClass($class); - return $class; - } catch (Exception $e) { - return false; - } - } -} diff --git a/tests/Zend/Loader/PluginLoaderTest.php b/tests/Zend/Loader/PluginLoaderTest.php deleted file mode 100644 index d5722e861a94c626f9671a1948f8f9ce7eb89731..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/PluginLoaderTest.php +++ /dev/null @@ -1,348 +0,0 @@ -<?php -// Call Zend_Loader_PluginLoaderTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Loader_PluginLoaderTest::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Loader/PluginLoader.php'; - -/** - * Test class for Zend_Loader_PluginLoader. - */ -class Zend_Loader_PluginLoaderTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Loader_PluginLoaderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->libPath = realpath(dirname(__FILE__) . '/../../../library'); - $this->key = null; - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - $this->clearStaticPaths(); - } - - public function clearStaticPaths() - { - if (null !== $this->key) { - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->clearPaths(); - } - } - - public function testAddPrefixPathNonStatically() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths(); - $this->assertEquals(2, count($paths)); - $this->assertTrue(array_key_exists('Zend_View_', $paths)); - $this->assertTrue(array_key_exists('Zend_Loader_', $paths)); - $this->assertEquals(1, count($paths['Zend_View_'])); - $this->assertEquals(2, count($paths['Zend_Loader_'])); - } - - public function testAddPrefixPathStatically() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths(); - $this->assertEquals(2, count($paths)); - $this->assertTrue(array_key_exists('Zend_View_', $paths)); - $this->assertTrue(array_key_exists('Zend_Loader_', $paths)); - $this->assertEquals(1, count($paths['Zend_View_'])); - $this->assertEquals(2, count($paths['Zend_Loader_'])); - } - - public function testAddPrefixPathThrowsExceptionWithNonStringPrefix() - { - $loader = new Zend_Loader_PluginLoader(); - try { - $loader->addPrefixPath(array(), $this->libPath); - $this->fail('addPrefixPath() should throw exception with non-string prefix'); - } catch (Exception $e) { - } - } - - public function testAddPrefixPathThrowsExceptionWithNonStringPath() - { - $loader = new Zend_Loader_PluginLoader(); - try { - $loader->addPrefixPath('Foo_Bar', array()); - $this->fail('addPrefixPath() should throw exception with non-string path'); - } catch (Exception $e) { - } - } - - public function testRemoveAllPathsForGivenPrefixNonStatically() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths('Zend_Loader'); - $this->assertEquals(2, count($paths)); - $loader->removePrefixPath('Zend_Loader'); - $this->assertFalse($loader->getPaths('Zend_Loader')); - } - - public function testRemoveAllPathsForGivenPrefixStatically() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths('Zend_Loader'); - $this->assertEquals(2, count($paths)); - $loader->removePrefixPath('Zend_Loader'); - $this->assertFalse($loader->getPaths('Zend_Loader')); - } - - public function testRemovePrefixPathThrowsExceptionIfPrefixNotRegistered() - { - $loader = new Zend_Loader_PluginLoader(); - try { - $loader->removePrefixPath('Foo_Bar'); - $this->fail('Removing non-existent prefix should throw an exception'); - } catch (Exception $e) { - } - } - - public function testRemovePrefixPathThrowsExceptionIfPrefixPathPairNotRegistered() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Foo_Bar', realpath(dirname(__FILE__))); - $paths = $loader->getPaths(); - $this->assertTrue(isset($paths['Foo_Bar_'])); - try { - $loader->removePrefixPath('Foo_Bar', $this->libPath); - $this->fail('Removing non-existent prefix/path pair should throw an exception'); - } catch (Exception $e) { - } - } - - public function testClearPathsNonStaticallyClearsPathArray() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths(); - $this->assertEquals(2, count($paths)); - $loader->clearPaths(); - $paths = $loader->getPaths(); - $this->assertEquals(0, count($paths)); - } - - public function testClearPathsStaticallyClearsPathArray() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths(); - $this->assertEquals(2, count($paths)); - $loader->clearPaths(); - $paths = $loader->getPaths(); - $this->assertEquals(0, count($paths)); - } - - public function testClearPathsWithPrefixNonStaticallyClearsPathArray() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths(); - $this->assertEquals(2, count($paths)); - $loader->clearPaths('Zend_Loader'); - $paths = $loader->getPaths(); - $this->assertEquals(1, count($paths)); - } - - public function testClearPathsWithPrefixStaticallyClearsPathArray() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View', $this->libPath . '/Zend/View') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend/Loader') - ->addPrefixPath('Zend_Loader', $this->libPath . '/Zend'); - $paths = $loader->getPaths(); - $this->assertEquals(2, count($paths)); - $loader->clearPaths('Zend_Loader'); - $paths = $loader->getPaths(); - $this->assertEquals(1, count($paths)); - } - - public function testGetClassNameNonStaticallyReturnsFalseWhenClassNotLoaded() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - $this->assertFalse($loader->getClassName('FormElement')); - } - - public function testGetClassNameStaticallyReturnsFalseWhenClassNotLoaded() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - $this->assertFalse($loader->getClassName('FormElement')); - } - - public function testLoadPluginNonStaticallyLoadsClass() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - try { - $className = $loader->load('FormButton'); - } catch (Exception $e) { - $paths = $loader->getPaths(); - $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1))); - } - $this->assertEquals('Zend_View_Helper_FormButton', $className); - $this->assertTrue(class_exists('Zend_View_Helper_FormButton', false)); - $this->assertTrue($loader->isLoaded('FormButton')); - } - - public function testLoadPluginStaticallyLoadsClass() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - try { - $className = $loader->load('FormRadio'); - } catch (Exception $e) { - $paths = $loader->getPaths(); - $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1))); - } - $this->assertEquals('Zend_View_Helper_FormRadio', $className); - $this->assertTrue(class_exists('Zend_View_Helper_FormRadio', false)); - $this->assertTrue($loader->isLoaded('FormRadio')); - } - - public function testLoadThrowsExceptionIfFileFoundInPrefixButClassNotLoaded() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Foo_Helper', $this->libPath . '/Zend/View/Helper'); - try { - $className = $loader->load('DocType'); - $this->fail('Invalid prefix for a path should throw an exception'); - } catch (Exception $e) { - } - } - - public function testLoadThrowsExceptionIfNoHelperClassLoaded() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Foo_Helper', $this->libPath . '/Zend/View/Helper'); - try { - $className = $loader->load('FooBarBazBat'); - $this->fail('Not finding a helper should throw an exception'); - } catch (Exception $e) { - } - } - - public function testGetClassAfterNonStaticLoadReturnsResolvedClassName() - { - $loader = new Zend_Loader_PluginLoader(); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - try { - $className = $loader->load('FormSelect'); - } catch (Exception $e) { - $paths = $loader->getPaths(); - $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1))); - } - $this->assertEquals($className, $loader->getClassName('FormSelect')); - $this->assertEquals('Zend_View_Helper_FormSelect', $loader->getClassName('FormSelect')); - } - - public function testGetClassAfterStaticLoadReturnsResolvedClassName() - { - $this->key = 'foobar'; - $loader = new Zend_Loader_PluginLoader(array(), $this->key); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - try { - $className = $loader->load('FormCheckbox'); - } catch (Exception $e) { - $paths = $loader->getPaths(); - $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1))); - } - $this->assertEquals($className, $loader->getClassName('FormCheckbox')); - $this->assertEquals('Zend_View_Helper_FormCheckbox', $loader->getClassName('FormCheckbox')); - } - - public function testClassFilesAreSearchedInLifoOrder() - { - $loader = new Zend_Loader_PluginLoader(array()); - $loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper'); - $loader->addPrefixPath('ZfTest', dirname(__FILE__) . '/_files/ZfTest'); - try { - $className = $loader->load('FormSubmit'); - } catch (Exception $e) { - $paths = $loader->getPaths(); - $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1))); - } - $this->assertEquals($className, $loader->getClassName('FormSubmit')); - $this->assertEquals('ZfTest_FormSubmit', $loader->getClassName('FormSubmit')); - } - - /** - * @issue ZF-2741 - */ - public function testWin32UnderscoreSpacedShortNamesWillLoad() - { - $loader = new Zend_Loader_PluginLoader(array()); - $loader->addPrefixPath('Zend_Filter', $this->libPath . '/Zend/Filter'); - try { - // Plugin loader will attempt to load "c:\path\to\library/Zend/Filter/Word\UnderscoreToDash.php" - $className = $loader->load('Word_UnderscoreToDash'); - } catch (Exception $e) { - $paths = $loader->getPaths(); - $this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1))); - } - $this->assertEquals($className, $loader->getClassName('Word_UnderscoreToDash')); - } - -} - -// Call Zend_Loader_PluginLoaderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD === 'Zend_Loader_PluginLoaderTest::main') { - Zend_Loader_PluginLoaderTest::main(); -} diff --git a/tests/Zend/Loader/_files/ParseError.php b/tests/Zend/Loader/_files/ParseError.php deleted file mode 100644 index fbc73d3f75bf7a171418d0f86c7633a160c694ee..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/_files/ParseError.php +++ /dev/null @@ -1,36 +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_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ParseError.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * A class containing a parse error - * - * @category Zend - * @package Zend_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class ParseError -{ - parseError; -} \ No newline at end of file diff --git a/tests/Zend/Loader/_files/ZfTest/FormSubmit.php b/tests/Zend/Loader/_files/ZfTest/FormSubmit.php deleted file mode 100644 index 7d90e1c65d097562de4ac0604dae31b5ee3b47d3..0000000000000000000000000000000000000000 --- a/tests/Zend/Loader/_files/ZfTest/FormSubmit.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class ZfTest_FormSubmit -{ -} diff --git a/tests/Zend/LoaderTest.php b/tests/Zend/LoaderTest.php deleted file mode 100644 index f75137f098e9ccf68849d0c84b02cf5861bf764b..0000000000000000000000000000000000000000 --- a/tests/Zend/LoaderTest.php +++ /dev/null @@ -1,366 +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_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LoaderTest.php 9301 2008-04-24 13:21:59Z doctorrock83 $ - */ - -// Call Zend_LoaderTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_LoaderTest::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * Zend_Loader - */ -require_once 'Zend/Loader.php'; - -/** - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_LoaderTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_LoaderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Tests that a class can be loaded from a well-formed PHP file - */ - public function testLoaderClassValid() - { - $dir = implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR); - - Zend_Loader::loadClass('Class1', $dir); - } - - public function testLoaderInterfaceViaLoadClass() - { - try { - Zend_Loader::loadClass('Zend_Controller_Dispatcher_Interface'); - } catch (Zend_Exception $e) { - $this->fail('Loading interfaces should not fail'); - } - } - - public function testLoaderLoadClassWithDotDir() - { - $dirs = array('.'); - try { - Zend_Loader::loadClass('Zend_Version', $dirs); - } catch (Zend_Exception $e) { - $this->fail('Loading from dot should not fail'); - } - } - - /** - * Tests that an exception is thrown when a file is loaded but the - * class is not found within the file - */ - public function testLoaderClassNonexistent() - { - $dir = implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR); - - try { - Zend_Loader::loadClass('ClassNonexistent', $dir); - $this->fail('Zend_Exception was expected but never thrown.'); - } catch (Zend_Exception $e) { - $this->assertRegExp('/file(.*)does not exist or class(.*)not found/i', $e->getMessage()); - } - } - - /** - * Tests that an exception is thrown if the $dirs argument is - * not a string or an array. - */ - public function testLoaderInvalidDirs() - { - try { - Zend_Loader::loadClass('Zend_Invalid_Dirs', new stdClass()); - $this->fail('Zend_Exception was expected but never thrown.'); - } catch (Zend_Exception $e) { - $this->assertEquals('Directory argument must be a string or an array', $e->getMessage()); - } - } - - /** - * Tests that a class can be loaded from the search directories. - */ - public function testLoaderClassSearchDirs() - { - $dirs = array(); - foreach (array('_testDir1', '_testDir2') as $dir) { - $dirs[] = implode(array(dirname(__FILE__), '_files', $dir), DIRECTORY_SEPARATOR); - } - - // throws exception on failure - Zend_Loader::loadClass('Class1', $dirs); - Zend_Loader::loadClass('Class2', $dirs); - } - - /** - * Tests that a class locatedin a subdirectory can be loaded from the search directories - */ - public function testLoaderClassSearchSubDirs() - { - $dirs = array(); - foreach (array('_testDir1', '_testDir2') as $dir) { - $dirs[] = implode(array(dirname(__FILE__), '_files', $dir), DIRECTORY_SEPARATOR); - } - - // throws exception on failure - Zend_Loader::loadClass('Class1_Subclass2', $dirs); - } - - /** - * Tests that the security filter catches illegal characters. - */ - public function testLoaderClassIllegalFilename() - { - try { - Zend_Loader::loadClass('/path/:to/@danger'); - $this->fail('Zend_Exception was expected but never thrown.'); - } catch (Zend_Exception $e) { - $this->assertRegExp('/security(.*)filename/i', $e->getMessage()); - } - } - - /** - * Tests that loadFile() finds a file in the include_path when $dirs is null - */ - public function testLoaderFileIncludePathEmptyDirs() - { - $saveIncludePath = get_include_path(); - set_include_path(implode(array($saveIncludePath, implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR)); - - $this->assertTrue(Zend_Loader::loadFile('Class3.php', null)); - - set_include_path($saveIncludePath); - } - - /** - * Tests that loadFile() finds a file in the include_path when $dirs is non-null - * This was not working vis-a-vis ZF-1174 - */ - public function testLoaderFileIncludePathNonEmptyDirs() - { - $saveIncludePath = get_include_path(); - set_include_path(implode(array($saveIncludePath, implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR)); - - $this->assertTrue(Zend_Loader::loadFile('Class4.php', implode(PATH_SEPARATOR, array('foo', 'bar')))); - - set_include_path($saveIncludePath); - } - - /** - * Tests that isReadable works - */ - public function testLoaderIsReadable() - { - $this->assertTrue(Zend_Loader::isReadable(__FILE__)); - $this->assertFalse(Zend_Loader::isReadable(__FILE__ . '.foobaar')); - - // test that a file in include_path gets loaded, see ZF-2985 - $this->assertTrue(Zend_Loader::isReadable('Zend/Controller/Front.php')); - } - - /** - * Tests that autoload works for valid classes and interfaces - */ - public function testLoaderAutoloadLoadsValidClasses() - { - $this->assertEquals('Zend_Db_Profiler_Exception', Zend_Loader::autoload('Zend_Db_Profiler_Exception')); - $this->assertEquals('Zend_Auth_Storage_Interface', Zend_Loader::autoload('Zend_Auth_Storage_Interface')); - } - - /** - * Tests that autoload returns false on invalid classes - */ - public function testLoaderAutoloadFailsOnInvalidClasses() - { - $this->assertFalse(Zend_Loader::autoload('Zend_FooBar_Magic_Abstract')); - } - - public function testLoaderRegisterAutoloadRegisters() - { - if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload not installed on this PHP installation"); - } - - Zend_Loader::registerAutoload(); - $autoloaders = spl_autoload_functions(); - $expected = array('Zend_Loader', 'autoload'); - $found = false; - foreach($autoloaders as $function) { - if ($expected == $function) { - $found = true; - break; - } - } - $this->assertTrue($found, "Failed to register Zend_Loader::autoload() with spl_autoload"); - - spl_autoload_unregister($expected); - } - - public function testLoaderRegisterAutoloadExtendedClassNeedsAutoloadMethod() - { - if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload not installed on this PHP installation"); - } - - Zend_Loader::registerAutoload('Zend_Loader_MyLoader'); - $autoloaders = spl_autoload_functions(); - $expected = array('Zend_Loader_MyLoader', 'autoload'); - $found = false; - foreach ($autoloaders as $function) { - if ($expected == $function) { - $found = true; - break; - } - } - $this->assertFalse($found, "Failed to register Zend_Loader_MyLoader::autoload() with spl_autoload"); - - spl_autoload_unregister($expected); - } - - public function testLoaderRegisterAutoloadExtendedClassWithAutoloadMethod() - { - if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload not installed on this PHP installation"); - } - - Zend_Loader::registerAutoload('Zend_Loader_MyOverloader'); - $autoloaders = spl_autoload_functions(); - $expected = array('Zend_Loader_MyOverloader', 'autoload'); - $found = false; - foreach ($autoloaders as $function) { - if ($expected == $function) { - $found = true; - break; - } - } - $this->assertTrue($found, "Failed to register Zend_Loader_MyOverloader::autoload() with spl_autoload"); - - // try to instantiate a class that is known not to be loaded - $obj = new Zend_Loader_AutoloadableClass(); - - // now it should be loaded - $this->assertTrue(class_exists('Zend_Loader_AutoloadableClass'), - 'Expected Zend_Loader_AutoloadableClass to be loaded'); - - // and we verify it is the correct type - $this->assertType('Zend_Loader_AutoloadableClass', $obj, - 'Expected to instantiate Zend_Loader_AutoloadableClass, got '.get_class($obj)); - - spl_autoload_unregister($expected); - } - - public function testLoaderRegisterAutoloadFailsWithoutSplAutoload() - { - if (function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() is installed on this PHP installation; cannot test for failure"); - } - - try { - Zend_Loader::registerAutoload(); - $this->fail('registerAutoload should fail without spl_autoload'); - } catch (Zend_Exception $e) { - } - } - - public function testLoaderRegisterAutoloadInvalidClass() - { - if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() not installed on this PHP installation"); - } - - try { - Zend_Loader::registerAutoload('stdClass'); - $this->fail('registerAutoload should fail without spl_autoload'); - } catch (Zend_Exception $e) { - $this->assertEquals('The class "stdClass" does not have an autoload() method', $e->getMessage()); - } - } - - public function testLoaderUnregisterAutoload() - { - if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() not installed on this PHP installation"); - } - - Zend_Loader::registerAutoload(); - $autoloaders = spl_autoload_functions(); - $expected = array('Zend_Loader', 'autoload'); - $found = false; - foreach($autoloaders as $function) { - if ($expected == $function) { - $found = true; - break; - } - } - $this->assertTrue($found, "Failed to register Zend_Loader::autoload() with spl_autoload"); - - Zend_Loader::registerAutoload('Zend_Loader', false); - $autoloaders = spl_autoload_functions(); - $expected = array('Zend_Loader', 'autoload'); - $found = false; - foreach($autoloaders as $function) { - if ($expected == $function) { - $found = true; - break; - } - } - $this->assertFalse($found, "Failed to unregister Zend_Loader::autoload() with spl_autoload"); - } - - /** - * @return void - * @see http://framework.zend.com/issues/browse/ZF-2463 - */ - public function testLoaderAutoloadDoesNotHideParseError() - { - $command = 'php -d include_path=' - . escapeshellarg(get_include_path()) - . ' Zend/Loader/AutoloadDoesNotHideParseError.php 2>&1'; - $output = shell_exec($command); - $this->assertRegexp('/error, unexpected T_STRING, expecting T_FUNCTION/i', $output, $output); - } -} - -// Call Zend_LoaderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD === 'Zend_LoaderTest::main') { - Zend_LoaderTest::main(); -} diff --git a/tests/Zend/Locale/AllTests.php b/tests/Zend/Locale/AllTests.php deleted file mode 100644 index 3bb974b374f782ecfe26dbd675c84c8e636b69b7..0000000000000000000000000000000000000000 --- a/tests/Zend/Locale/AllTests.php +++ /dev/null @@ -1,80 +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_Locale - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 4013 2007-03-16 10:20:43Z gavin $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Locale_AllTests::main'); -} - -if (!defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE')) { - /** - * Read in user-defined test configuration if available; otherwise, read default test configuration. - * This facilitates running "php AllTests.php" in this subdirectory or "phpunit Zend_Locale_AllTests". - */ - $_test_configuration = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . 'TestConfiguration.php'; - if (is_readable($_test_configuration)) { - include_once $_test_configuration; - } else if (is_readable("$_test_configuration.dist")) { - include_once "$_test_configuration.dist"; - } -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -error_reporting( E_ALL | E_STRICT ); // now required for each test suite -// define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', false); // uncomment to disable use of bcmath extension by Zend_Date - -require_once 'Zend/Locale/DataTest.php'; -require_once 'Zend/Locale/FormatTest.php'; -require_once 'Zend/Locale/MathTest.php'; - -// echo "BCMATH is ", Zend_Locale_Math::isBcmathDisabled() ? 'disabled':'not disabled', "\n"; - -class Zend_Locale_AllTests -{ - public static function main() - { - if (defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE') && TESTS_ZEND_LOCALE_FORMAT_SETLOCALE) { - // run all tests in a special locale - setlocale(LC_ALL, TESTS_ZEND_LOCALE_FORMAT_SETLOCALE); - } - - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Locale'); - - $suite->addTestSuite('Zend_Locale_DataTest'); - $suite->addTestSuite('Zend_Locale_FormatTest'); - $suite->addTestSuite('Zend_Locale_MathTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Locale_AllTests::main') { - Zend_Locale_AllTests::main(); -} diff --git a/tests/Zend/Locale/DataTest.php b/tests/Zend/Locale/DataTest.php deleted file mode 100644 index 98e175abb8f1af597b0dd8a81fcb5806cffb625b..0000000000000000000000000000000000000000 --- a/tests/Zend/Locale/DataTest.php +++ /dev/null @@ -1,1848 +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_Locale - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DataTest.php 8025 2008-02-15 08:53:01Z thomas $ - */ - -/** - * Zend_Locale_Data - */ -require_once 'Zend/Locale/Data.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Locale - * @subpackage UnitTests - */ -class Zend_Locale_DataTest extends PHPUnit_Framework_TestCase -{ - - private $_cache = null; - - public function setUp() - { - require_once 'Zend/Cache.php'; - $this->_cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 1, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/../_files/')); - Zend_Locale_Data::setCache($this->_cache); - } - - - public function tearDown() - { - $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL); - } - - /** - * test for reading with standard locale - * expected array - */ - public function testNoLocale() - { - $this->assertTrue(is_array(Zend_Locale_Data::getList(null, 'language'))); - - try { - $value = Zend_Locale_Data::getList('nolocale','language'); - $this->fail('locale should throw exception'); - } catch (Zend_Locale_Exception $e) { - // success - } - - $locale = new Zend_Locale('de'); - $this->assertTrue(is_array(Zend_Locale_Data::getList($locale, 'language'))); - } - - - /** - * test for reading without type - * expected empty array - */ - public function testNoType() - { - try { - $value = Zend_Locale_Data::getContent('de',''); - $this->fail('content should throw an exception'); - } catch (Zend_Locale_Exception $e) { - // success - } - - try { - $value = Zend_Locale_Data::getContent('de','xxxxxxx'); - $this->fail('content should throw an exception'); - } catch (Zend_Locale_Exception $e) { - // success - } - } - - - /** - * test for reading the languagelist from locale - * expected array - */ - public function testLanguage() - { - $data = Zend_Locale_Data::getList('de','language'); - $this->assertEquals('Deutsch', $data['de']); - $this->assertEquals('Englisch', $data['en']); - - $value = Zend_Locale_Data::getContent('de', 'language', 'de'); - $this->assertEquals('Deutsch', $value); - } - - /** - * test for reading the scriptlist from locale - * expected array - */ - public function testScript() - { - $data = Zend_Locale_Data::getList('de_AT', 'script'); - $this->assertEquals('Arabisch', $data['Arab']); - $this->assertEquals('Lateinisch', $data['Latn']); - - $value = Zend_Locale_Data::getContent('de_AT', 'script', 'Arab'); - $this->assertEquals('Arabisch', $value); - } - - /** - * test for reading the territorylist from locale - * expected array - */ - public function testTerritory() - { - $data = Zend_Locale_Data::getList('de_AT', 'territory'); - $this->assertEquals('Österreich', $data['AT']); - $this->assertEquals('Martinique', $data['MQ']); - - $value = Zend_Locale_Data::getContent('de_AT', 'territory', 'AT'); - $this->assertEquals('Österreich', $value); - } - - /** - * test for reading the variantlist from locale - * expected array - */ - public function testVariant() - { - $data = Zend_Locale_Data::getList('de_AT', 'variant'); - $this->assertEquals('Boontling', $data['BOONT']); - $this->assertEquals('Saho', $data['SAAHO']); - - $value = Zend_Locale_Data::getContent('de_AT', 'variant', 'POSIX'); - $this->assertEquals('Posix', $value); - } - - /** - * test for reading the keylist from locale - * expected array - */ - public function testKey() - { - $data = Zend_Locale_Data::getList('de_AT', 'key'); - $this->assertEquals('Kalender', $data['calendar']); - $this->assertEquals('Sortierung', $data['collation']); - - $value = Zend_Locale_Data::getContent('de_AT', 'key', 'collation'); - $this->assertEquals('Sortierung', $value); - } - - /** - * test for reading the typelist from locale - * expected array - */ - public function testType() - { - $data = Zend_Locale_Data::getList('de_AT', 'type'); - $this->assertEquals('Chinesischer Kalender', $data['chinese']); - $this->assertEquals('Strichfolge', $data['stroke']); - - $data = Zend_Locale_Data::getList('de_AT', 'type', 'calendar'); - $this->assertEquals('Chinesischer Kalender', $data['chinese']); - $this->assertEquals('Japanischer Kalender', $data['japanese']); - - $value = Zend_Locale_Data::getList('de_AT', 'type', 'chinese'); - $this->assertEquals('Chinesischer Kalender', $value['chinese']); - } - - /** - * test for reading layout from locale - * expected array - */ - public function testLayout() - { - $layout = Zend_Locale_Data::getList('es', 'layout'); - $this->assertEquals("", $layout['lines']); - $this->assertEquals("", $layout['characters']); - $this->assertEquals("titlecase-firstword", $layout['inList']); - $this->assertEquals("lowercase-words", $layout['currency']); - $this->assertEquals("mixed", $layout['dayWidth']); - $this->assertEquals("mixed", $layout['fields']); - $this->assertEquals("lowercase-words", $layout['keys']); - $this->assertEquals("lowercase-words", $layout['languages']); - $this->assertEquals("lowercase-words", $layout['long']); - $this->assertEquals("lowercase-words", $layout['measurementSystemNames']); - $this->assertEquals("mixed", $layout['monthWidth']); - $this->assertEquals("mixed", $layout['quarterWidth']); - $this->assertEquals("mixed", $layout['scripts']); - $this->assertEquals("mixed", $layout['territories']); - $this->assertEquals("lowercase-words", $layout['types']); - $this->assertEquals("mixed", $layout['variants']); - } - - /** - * test for reading characters from locale - * expected array - */ - public function testCharacters() - { - $char = Zend_Locale_Data::getList('de', 'characters'); - $this->assertEquals("[a ä b-o ö p-s ß t u ü v-z]", $char['characters']); - $this->assertEquals("[á à ă â Ã¥ ä Ä Ã¦ ç é è Ä• ê ë Ä“ à ì Ä Ã® ï Ä« ñ ó ò Šô ö ø Å Å“ ß ú ù Šû ü Å« ÿ]", $char['auxiliary']); - $this->assertEquals("[\\$ £ Â¥ ₤ â‚§ € a-z]", $char['currencySymbol']); - } - - /** - * test for reading delimiters from locale - * expected array - */ - public function testDelimiters() - { - $quote = Zend_Locale_Data::getList('de', 'delimiters'); - $this->assertEquals("„", $quote['quoteStart']); - $this->assertEquals("“", $quote['quoteEnd']); - $this->assertEquals("‚", $quote['quoteStartAlt']); - $this->assertEquals("‘", $quote['quoteEndAlt']); - } - - /** - * test for reading measurement from locale - * expected array - */ - public function testMeasurement() - { - $measure = Zend_Locale_Data::getList('de', 'measurement'); - $this->assertEquals("001", $measure['metric']); - $this->assertEquals("US", $measure['US']); - $this->assertEquals("001", $measure['A4']); - $this->assertEquals("US", $measure['US-Letter']); - } - - /** - * test for reading datechars from locale - * expected array - */ - public function testDateChars() - { - $date = Zend_Locale_Data::getContent('de_AT', 'datechars'); - $this->assertEquals("GjMtkHmsSEDFwWahKzJeugAZvcL", $date); - } - - /** - * test for reading defaultcalendar from locale - * expected array - */ - public function testDefaultCalendar() - { - $date = Zend_Locale_Data::getContent('de_AT', 'defaultcalendar'); - $this->assertEquals("gregorian", $date); - } - - /** - * test for reading defaultmonthcontext from locale - * expected array - */ - public function testDefaultMonthContext() - { - $date = Zend_Locale_Data::getContent('de_AT', 'monthcontext'); - $this->assertEquals("format", $date); - - $date = Zend_Locale_Data::getContent('de_AT', 'monthcontext', 'islamic'); - $this->assertEquals("format", $date); - } - - /** - * test for reading defaultmonth from locale - * expected array - */ - public function testDefaultMonth() - { - $date = Zend_Locale_Data::getContent('de_AT', 'defaultmonth'); - $this->assertEquals("wide", $date); - - $date = Zend_Locale_Data::getContent('de_AT', 'defaultmonth', 'islamic'); - $this->assertEquals("wide", $date); - } - - /** - * test for reading month from locale - * expected array - */ - public function testMonth() - { - $date = Zend_Locale_Data::getList('de_AT', 'months'); - $result = array("context" => "format", "default" => "wide", "format" => - array("abbreviated" => - array(1 => "Jän", 2 => "Feb", 3 => "Mär", 4 => "Apr", 5 => "Mai", - 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10=> "Okt", - 11 => "Nov", 12 => "Dez"), - "narrow" => array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', - 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12'), - "wide" => - array(1 => "Jänner" , 2 => "Februar" , 3 => "März" , 4 => "April" , 5 => "Mai", - 6 => "Juni" , 7 => "Juli" , 8 => "August", 9 => "September", 10=> "Oktober", - 11 => "November", 12 => "Dezember") - ), - "stand-alone" => array("abbreviated" => - array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => "Jul.", - 8 => "Aug.", 9 => "Sept.", 10 => "Okt.", 11 => "Nov.", 12 => "Dez."), - "narrow" => - array(1 => "J", 2 => "F", 3 => "M", 4 => "A", 5 => "M", 6 => "J", 7 => "J" , 8 => "A", - 9 => "S", 10 => "O", 11 => "N", 12 => "D"), - "wide" => array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', - 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12'), - )); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'months', 'islamic'); - $result = array("context" => "format", "default" => "wide", "format" => - array("abbreviated" => - array(1 => "Muharram" , 2 => "Safar", 3 => "RabiÊ» I" , 4 => "RabiÊ» II" , 5 => "Jumada I", - 6 => "Jumada II" , 7 => "Rajab", 8 => "ShaÊ»ban", 9 => "Ramadan", 10=> "Shawwal", - 11 => "DhuÊ»l-QiÊ»dah", 12 => "DhuÊ»l-Hijjah"), - "narrow" => array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', - 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12'), - "wide" => - array(1 => "Muharram" , 2 => "Safar", 3 => "RabiÊ» I" , 4 => "RabiÊ» II" , 5 => "Jumada I", - 6 => "Jumada II" , 7 => "Rajab", 8 => "ShaÊ»ban", 9 => "Ramadan", 10=> "Shawwal", - 11 => "DhuÊ»l-QiÊ»dah", 12 => "DhuÊ»l-Hijjah") - ), - "stand-alone" => array("abbreviated" => - array(1 => "Muharram" , 2 => "Safar", 3 => "RabiÊ» I" , 4 => "RabiÊ» II" , 5 => "Jumada I", - 6 => "Jumada II" , 7 => "Rajab", 8 => "ShaÊ»ban", 9 => "Ramadan", 10=> "Shawwal", - 11 => "DhuÊ»l-QiÊ»dah", 12 => "DhuÊ»l-Hijjah"), - "narrow" => array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', - 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12'), - "wide" => - array(1 => "Muharram" , 2 => "Safar", 3 => "RabiÊ» I" , 4 => "RabiÊ» II" , 5 => "Jumada I", - 6 => "Jumada II" , 7 => "Rajab", 8 => "ShaÊ»ban", 9 => "Ramadan", 10=> "Shawwal", - 11 => "DhuÊ»l-QiÊ»dah", 12 => "DhuÊ»l-Hijjah") - )); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'month'); - $this->assertEquals(array(1 => "Jänner" , 2 => "Februar" , 3 => "März" , 4 => "April" , 5 => "Mai", - 6 => "Juni" , 7 => "Juli" , 8 => "August", 9 => "September", 10=> "Oktober", - 11 => "November", 12 => "Dezember"), $date); - - $date = Zend_Locale_Data::getList('de_AT', 'month', array('gregorian', 'format', 'wide')); - $this->assertEquals(array(1 => "Jänner" , 2 => "Februar" , 3 => "März" , 4 => "April" , 5 => "Mai", - 6 => "Juni" , 7 => "Juli" , 8 => "August", 9 => "September", 10=> "Oktober", - 11 => "November", 12 => "Dezember"), $date); - - $value = Zend_Locale_Data::getContent('de_AT', 'month', 12); - $this->assertEquals('Dezember', $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'month', array('gregorian', 'format', 'wide', 12)); - $this->assertEquals('Dezember', $value); - - $value = Zend_Locale_Data::getContent('ar', 'month', array('islamic', 'format', 'wide', 1)); - $this->assertEquals("Ù…ØØ±Ù…", $value); - } - - /** - * test for reading defaultdaycontext from locale - * expected array - */ - public function testDefaultDayContext() - { - $date = Zend_Locale_Data::getContent('de_AT', 'daycontext'); - $this->assertEquals("format", $date); - - $date = Zend_Locale_Data::getContent('de_AT', 'daycontext', 'islamic'); - $this->assertEquals("format", $date); - } - - /** - * test for reading defaultday from locale - * expected array - */ - public function testDefaultDay() - { - $date = Zend_Locale_Data::getContent('de_AT', 'defaultday'); - $this->assertEquals("wide", $date); - - $date = Zend_Locale_Data::getContent('de_AT', 'defaultday', 'islamic'); - $this->assertEquals("wide", $date); - } - - /** - * test for reading day from locale - * expected array - */ - public function testDay() - { - $date = Zend_Locale_Data::getList('de_AT', 'days'); - $result = array("context" => "format", "default" => "wide", "format" => - array("abbreviated" => array("sun" => "So", "mon" => "Mo", "tue" => "Di", "wed" => "Mi", - "thu" => "Do", "fri" => "Fr", "sat" => "Sa"), - "narrow" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7"), - "wide" => array("sun" => "Sonntag", "mon" => "Montag", "tue" => "Dienstag", - "wed" => "Mittwoch", "thu" => "Donnerstag", "fri" => "Freitag", "sat" => "Samstag") - ), - "stand-alone" => array("abbreviated" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7"), - "narrow" => array("sun" => "S", "mon" => "M", "tue" => "D", "wed" => "M", - "thu" => "D", "fri" => "F", "sat" => "S"), - "wide" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7") - )); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'days', 'islamic'); - $result = array("context" => "format", "default" => "wide", "format" => - array("abbreviated" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7"), - "narrow" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7"), - "wide" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7") - ), - "stand-alone" => array("abbreviated" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7"), - "narrow" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7"), - "wide" => array("sun" => "1", "mon" => "2", "tue" => "3", "wed" => "4", - "thu" => "5", "fri" => "6", "sat" => "7") - )); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'day'); - $this->assertEquals(array("sun" => "Sonntag", "mon" => "Montag", "tue" => "Dienstag", - "wed" => "Mittwoch", "thu" => "Donnerstag", "fri" => "Freitag", "sat" => "Samstag"), $date); - - $date = Zend_Locale_Data::getList('de_AT', 'day', array('gregorian', 'format', 'wide')); - $this->assertEquals(array("sun" => "Sonntag", "mon" => "Montag", "tue" => "Dienstag", - "wed" => "Mittwoch", "thu" => "Donnerstag", "fri" => "Freitag", "sat" => "Samstag"), $date); - - $value = Zend_Locale_Data::getContent('de_AT', 'day', 'mon'); - $this->assertEquals('Montag', $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'day', array('gregorian', 'format', 'wide', 'mon')); - $this->assertEquals('Montag', $value); - - $value = Zend_Locale_Data::getContent('ar', 'day', array('islamic', 'format', 'wide', 'mon')); - $this->assertEquals("2", $value); - } - - /** - * test for reading quarter from locale - * expected array - */ - public function testQuarter() - { - $date = Zend_Locale_Data::getList('de_AT', 'quarters'); - $result = array("format" => - array("abbreviated" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", "4" => "Q4"), - "narrow" => array("1" => "1", "2" => "2", "3" => "3", "4" => "4"), - "wide" => array("1" => "1. Quartal", "2" => "2. Quartal", "3" => "3. Quartal", - "4" => "4. Quartal") - ), - "stand-alone" => array("abbreviated" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", "4" => "Q4"), - "narrow" => array("1" => "1", "2" => "2", "3" => "3", "4" => "4"), - "wide" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", "4" => "Q4") - )); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'quarters', 'islamic'); - $result = array("format" => - array("abbreviated" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", "4" => "Q4"), - "narrow" => array("1" => "1", "2" => "2", "3" => "3", "4" => "4"), - "wide" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", - "4" => "Q4") - ), - "stand-alone" => array("abbreviated" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", "4" => "Q4"), - "narrow" => array("1" => "1", "2" => "2", "3" => "3", "4" => "4"), - "wide" => array("1" => "Q1", "2" => "Q2", "3" => "Q3", "4" => "Q4") - )); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'quarter'); - $this->assertEquals(array("1" => "1. Quartal", "2" => "2. Quartal", "3" => "3. Quartal", - "4" => "4. Quartal"), $date); - - $date = Zend_Locale_Data::getList('de_AT', 'quarter', array('gregorian', 'format', 'wide')); - $this->assertEquals(array("1" => "1. Quartal", "2" => "2. Quartal", "3" => "3. Quartal", - "4" => "4. Quartal"), $date); - - $value = Zend_Locale_Data::getContent('de_AT', 'quarter', '1'); - $this->assertEquals('1. Quartal', $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'quarter', array('gregorian', 'format', 'wide', '1')); - $this->assertEquals('1. Quartal', $value); - - $value = Zend_Locale_Data::getContent('ar', 'quarter', array('islamic', 'format', 'wide', '1')); - $this->assertEquals("Q1", $value); - } - - /** - * test for reading week from locale - * expected array - */ - public function testWeek() - { - $value = Zend_Locale_Data::getList('de_AT', 'week'); - $this->assertEquals(array('minDays' => 4, 'firstDay' => 'mon', 'weekendStart' => 'sat', - 'weekendEnd' => 'sun'), $value); - - $value = Zend_Locale_Data::getList('en_US', 'week'); - $this->assertEquals(array('minDays' => 1, 'firstDay' => 'sun', 'weekendStart' => 'sat', - 'weekendEnd' => 'sun'), $value); - } - - /** - * test for reading am from locale - * expected array - */ - public function testAm() - { - $date = Zend_Locale_Data::getContent('de_AT', 'am'); - $this->assertEquals("vorm.", $date); - - $date = Zend_Locale_Data::getContent('de_AT', 'am', 'islamic'); - $this->assertEquals("AM", $date); - } - - /** - * test for reading pm from locale - * expected array - */ - public function testPm() - { - $date = Zend_Locale_Data::getContent('de_AT', 'pm'); - $this->assertEquals("nachm.", $date); - - $date = Zend_Locale_Data::getContent('de_AT', 'pm', 'islamic'); - $this->assertEquals("PM", $date); - } - - /** - * test for reading era from locale - * expected array - */ - public function testEra() - { - $date = Zend_Locale_Data::getList('de_AT', 'eras'); - $result = array( - "abbreviated" => array("0" => "v. Chr.", "1" => "n. Chr."), - "narrow" => array("0" => "BCE", "1" => "CE"), - "names" => array("0" => "v. Chr.", "1" => "n. Chr.") - ); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'eras', 'islamic'); - $result = array("abbreviated" => array("0" => "AH"), "narrow" => array("0" => "AH"), "names" => array("0" => "AH")); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'era'); - $this->assertEquals(array("0" => "v. Chr.", "1" => "n. Chr."), $date); - - $date = Zend_Locale_Data::getList('de_AT', 'era', array('gregorian', 'Abbr')); - $this->assertEquals(array("0" => "v. Chr.", "1" => "n. Chr."), $date); - - $value = Zend_Locale_Data::getContent('de_AT', 'era', '1'); - $this->assertEquals('n. Chr.', $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'era', array('gregorian', 'Names', '1')); - $this->assertEquals('n. Chr.', $value); - - $value = Zend_Locale_Data::getContent('ar', 'era', array('islamic', 'Abbr', '0')); - $this->assertEquals("Ù‡â€", $value); - } - - /** - * test for reading defaultdate from locale - * expected array - */ - public function testDefaultDate() - { - $value = Zend_Locale_Data::getContent('de_AT', 'defaultdate'); - $this->assertEquals("medium", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'defaultdate', 'gregorian'); - $this->assertEquals("medium", $value); - } - - /** - * test for reading era from locale - * expected array - */ - public function testDate() - { - $date = Zend_Locale_Data::getList('de_AT', 'date'); - $result = array("full" => "EEEE, dd. MMMM yyyy", "long" => "dd. MMMM yyyy", - "medium" => "dd.MM.yyyy", "short" => "dd.MM.yy"); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'date', 'islamic'); - $result = array("full" => "EEEE, yyyy MMMM dd", "long" => "yyyy MMMM d", - "medium" => "yyyy MMM d", "short" => "yyyy-MM-dd"); - $this->assertEquals($result, $date); - - $value = Zend_Locale_Data::getContent('de_AT', 'date'); - $this->assertEquals("dd.MM.yyyy", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'date', 'long'); - $this->assertEquals("dd. MMMM yyyy", $value); - - $value = Zend_Locale_Data::getContent('ar', 'date', array('islamic', 'long')); - $this->assertEquals("yyyy MMMM d", $value); - } - - /** - * test for reading defaulttime from locale - * expected array - */ - public function testDefaultTime() - { - $value = Zend_Locale_Data::getContent('de_AT', 'defaulttime'); - $this->assertEquals("medium", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'defaulttime', 'gregorian'); - $this->assertEquals("medium", $value); - } - - /** - * test for reading time from locale - * expected array - */ - public function testTime() - { - $date = Zend_Locale_Data::getList('de_AT', 'time'); - $result = array("full" => "HH:mm:ss v", "long" => "HH:mm:ss z", - "medium" => "HH:mm:ss", "short" => "HH:mm"); - $this->assertEquals($result, $date); - - $date = Zend_Locale_Data::getList('de_AT', 'time', 'islamic'); - $result = array("full" => "HH:mm:ss v", "long" => "HH:mm:ss z", - "medium" => "HH:mm:ss", "short" => "HH:mm"); - $this->assertEquals($result, $date); - - $value = Zend_Locale_Data::getContent('de_AT', 'time'); - $this->assertEquals("HH:mm:ss", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'time', 'long'); - $this->assertEquals("HH:mm:ss z", $value); - - $value = Zend_Locale_Data::getContent('ar', 'time', array('islamic', 'long')); - $this->assertEquals("HH:mm:ss z", $value); - } - - /** - * test for reading datetime from locale - * expected array - */ - public function testDateTime() - { - $value = Zend_Locale_Data::getList('de_AT', 'datetime'); - $result = array( - "Ed" => "E d", "H" => "H", "HHmm" => "HH:mm", "HHmmss" => "HH:mm:ss", - "MMMEd" => "E MMM d", "MMMMd" => "d. MMMM", "MMMMdd" => "dd. MMMM", "MMd" => "d/MM", - "MMdd" => "dd.MM.", "Md" => "d.M.", "hhmm" => "hh:mm a", "hhmmss" => "hh:mm:ss a", - "mmss" => "mm:ss", "yyMM" => "MM.yy", "yyMMM" => "MMM yy", "yyMMdd" => "dd.MM.yy", - "yyQ" => "Q yy", "yyQQQQ" => "QQQQ yy", "yyyy" => "yyyy", "yyyyMMMM" => "MMMM yyyy"); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getList('de_AT', 'datetime', 'gregorian'); - $result = array( - "Ed" => "E d", "H" => "H", "HHmm" => "HH:mm", "HHmmss" => "HH:mm:ss", - "MMMEd" => "E MMM d", "MMMMd" => "d. MMMM", "MMMMdd" => "dd. MMMM", "MMd" => "d/MM", - "MMdd" => "dd.MM.", "Md" => "d.M.", "hhmm" => "hh:mm a", "hhmmss" => "hh:mm:ss a", - "mmss" => "mm:ss", "yyMM" => "MM.yy", "yyMMM" => "MMM yy", "yyMMdd" => "dd.MM.yy", - "yyQ" => "Q yy", "yyQQQQ" => "QQQQ yy", "yyyy" => "yyyy", "yyyyMMMM" => "MMMM yyyy"); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'datetime'); - $this->assertEquals("{1} {0}", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'datetime', 'gregorian'); - $this->assertEquals("{1} {0}", $value); - } - - /** - * test for reading field from locale - * expected array - */ - public function testField() - { - $value = Zend_Locale_Data::getList('de_AT', 'field'); - $this->assertEquals(array("era" => "Epoche", "year" => "Jahr", "month" => "Monat", "week" => "Woche", - "day" => "Tag", "weekday" => "Wochentag", "dayperiod" => "Tageshälfte", "hour" => "Stunde", - "minute" => "Minute", "second" => "Sekunde", "zone" => "Zone"), $value); - - $value = Zend_Locale_Data::getList('de_AT', 'field', 'gregorian'); - $this->assertEquals(array("era" => "Epoche", "year" => "Jahr", "month" => "Monat", "week" => "Woche", - "day" => "Tag", "weekday" => "Wochentag", "dayperiod" => "Tageshälfte", "hour" => "Stunde", - "minute" => "Minute", "second" => "Sekunde", "zone" => "Zone"), $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'field', 'week'); - $this->assertEquals("Woche", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'field', array('gregorian', 'week')); - $this->assertEquals("Woche", $value); - } - - /** - * test for reading relative from locale - * expected array - */ - public function testRelative() - { - $value = Zend_Locale_Data::getList('de_AT', 'relative'); - $this->assertEquals(array("0" => "Heute", "1" => "Morgen", "2" => "Übermorgen", - "3" => "in drei Tagen", "-1" => "Gestern", "-2" => "Vorgestern"), $value); - - $value = Zend_Locale_Data::getList('de_AT', 'relative', 'gregorian'); - $this->assertEquals(array("0" => "Heute", "1" => "Morgen", "2" => "Übermorgen", - "3" => "in drei Tagen", "-1" => "Gestern", "-2" => "Vorgestern"), $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'relative', '-1'); - $this->assertEquals("Gestern", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'relative', array('gregorian', '-1')); - $this->assertEquals("Gestern", $value); - } - - /** - * test for reading symbols from locale - * expected array - */ - public function testSymbols() - { - $value = Zend_Locale_Data::getList('de_AT', 'symbols'); - $result = array( "decimal" => ",", "group" => ".", "list" => ";", "percent" => "%", - "zero" => "0", "pattern" => "#", "plus" => "+", "minus" => "-", "exponent" => "E", - "mille" => "‰", "infinity" => "∞", "nan" => "NaN"); - $this->assertEquals($result, $value); - } - - /** - * test for reading decimalnumber from locale - * expected array - */ - public function testDecimalNumber() - { - $value = Zend_Locale_Data::getContent('de_AT', 'decimalnumber'); - $this->assertEquals("#,##0.###", $value); - } - - /** - * test for reading scientificnumber from locale - * expected array - */ - public function testScientificNumber() - { - $value = Zend_Locale_Data::getContent('de_AT', 'scientificnumber'); - $this->assertEquals("#E0", $value); - } - - /** - * test for reading percentnumber from locale - * expected array - */ - public function testPercentNumber() - { - $value = Zend_Locale_Data::getContent('de_AT', 'percentnumber'); - $this->assertEquals("#,##0 %", $value); - } - - /** - * test for reading currencynumber from locale - * expected array - */ - public function testCurrencyNumber() - { - $value = Zend_Locale_Data::getContent('de_AT', 'currencynumber'); - $this->assertEquals("¤ #,##0.00", $value); - } - - /** - * test for reading nametocurrency from locale - * expected array - */ - public function testNameToCurrency() - { - $value = Zend_Locale_Data::getList('de_AT', 'nametocurrency'); - $result = array( - 'ADP' => 'Andorranische Pesete', 'AED' => 'UAE Dirham', 'AFA' => 'Afghani (1927-2002)', - 'AFN' => 'Afghani', 'ALL' => 'Lek', 'AMD' => 'Dram', 'ANG' => 'Niederl. Antillen Gulden', - 'AOA' => 'Kwanza', 'AOK' => 'Angolanischer Kwanza (1977-1990)', 'AON' => 'Neuer Kwanza', - 'AOR' => 'Kwanza Reajustado', 'ARA' => 'Argentinischer Austral', - 'ARP' => 'Argentinischer Peso (1983-1985)', 'ARS' => 'Argentinischer Peso', - 'ATS' => 'Österreichischer Schilling', 'AUD' => 'Australischer Dollar', 'AWG' => 'Aruba Florin', - 'AZM' => 'Aserbeidschan Manat', 'AZN' => 'Aserbaidschan-Manat', - 'BAD' => 'Bosnien und Herzegowina Dinar', 'BAM' => 'Konvertierbare Mark', - 'BBD' => 'Barbados-Dollar', 'BDT' => 'Taka', 'BEC' => 'Belgischer Franc (konvertibel)', - 'BEF' => 'Belgischer Franc', 'BEL' => 'Belgischer Finanz-Franc', 'BGL' => 'Lew (1962-1999)', - 'BGN' => 'Lew', 'BHD' => 'Bahrain-Dinar', 'BIF' => 'Burundi-Franc', 'BMD' => 'Bermuda-Dollar', - 'BND' => 'Brunei-Dollar', 'BOB' => 'Boliviano', 'BOP' => 'Bolivianischer Peso', 'BOV' => 'Mvdol', - 'BRB' => 'Brasilianischer Cruzeiro Novo (1967-1986)', 'BRC' => 'Brasilianischer Cruzado', - 'BRE' => 'Brasilianischer Cruzeiro (1990-1993)', 'BRL' => 'Real', - 'BRN' => 'Brasilianischer Cruzado Novo', 'BRR' => 'Brasilianischer Cruzeiro', - 'BSD' => 'Bahama-Dollar', 'BTN' => 'Ngultrum', 'BUK' => 'Birmanischer Kyat', 'BWP' => 'Pula', - 'BYB' => 'Belarus Rubel (alt)', 'BYR' => 'Belarus Rubel (neu)', 'BZD' => 'Belize-Dollar', - 'CAD' => 'Kanadischer Dollar', 'CDF' => 'Franc congolais', 'CHE' => 'WIR Euro', - 'CHF' => 'Schweizer Franken', 'CHW' => 'WIR Franken', 'CLF' => 'Unidades de Fomento', - 'CLP' => 'Chilenischer Peso', 'CNY' => 'Renminbi Yuan', 'COP' => 'Kolumbianischer Peso', - 'COU' => 'Unidad de Valor Real', 'CRC' => 'Costa Rica Colon', 'CSD' => 'Alter Serbischer Dinar', - 'CSK' => 'Tschechoslowakische Krone', 'CUP' => 'Kubanischer Peso', 'CVE' => 'Kap Verde Escudo', - 'CYP' => 'Zypern Pfund', 'CZK' => 'Tschechische Krone', 'DDM' => 'Mark der DDR', - 'DEM' => 'Deutsche Mark', 'DJF' => 'Dschibuti-Franc', 'DKK' => 'Dänische Krone', - 'DOP' => 'Dominikanischer Peso', 'DZD' => 'Algerischer Dinar', 'ECS' => 'Ecuadorianischer Sucre', - 'ECV' => 'Verrechnungseinheit für EC', 'EEK' => 'Estnische Krone', 'EGP' => 'Ägyptisches Pfund', - 'EQE' => 'Ekwele', 'ERN' => 'Nakfa', 'ESA' => 'Spanische Peseta (A-Konten)', - 'ESB' => 'Spanische Peseta (konvertibel)', 'ESP' => 'Spanische Pesete', 'ETB' => 'Birr', - 'EUR' => 'Euro', 'FIM' => 'Finnische Mark', 'FJD' => 'Fidschi Dollar', 'FKP' => 'Falkland Pfund', - 'FRF' => 'Französischer Franc', 'GBP' => 'Pfund Sterling', 'GEK' => 'Georgischer Kupon Larit', - 'GEL' => 'Georgischer Lari', 'GHC' => 'Cedi', 'GIP' => 'Gibraltar Pfund', 'GMD' => 'Dalasi', - 'GNF' => 'Guinea Franc', 'GNS' => 'Guineischer Syli', 'GQE' => 'Äquatorialguinea Ekwele Guineana', - 'GRD' => 'Griechische Drachme', 'GTQ' => 'Quetzal', 'GWE' => 'Portugiesisch Guinea Escudo', - 'GWP' => 'Guinea Bissau Peso', 'GYD' => 'Guyana Dollar', 'HKD' => 'Hongkong-Dollar', - 'HNL' => 'Lempira', 'HRD' => 'Kroatischer Dinar', 'HRK' => 'Kuna', 'HTG' => 'Gourde', - 'HUF' => 'Forint', 'IDR' => 'Rupiah', 'IEP' => 'Irisches Pfund', 'ILP' => 'Israelisches Pfund', - 'ILS' => 'Schekel', 'INR' => 'Indische Rupie', 'IQD' => 'Irak Dinar', 'IRR' => 'Rial', - 'ISK' => 'Isländische Krone', 'ITL' => 'Italienische Lire', 'JMD' => 'Jamaika Dollar', - 'JOD' => 'Jordanischer Dinar', 'JPY' => 'Yen', 'KES' => 'Kenia Schilling', 'KGS' => 'Som', - 'KHR' => 'Riel', 'KMF' => 'Komoren Franc', 'KPW' => 'Nordkoreanischer Won', - 'KRW' => 'Südkoreanischer Won', 'KWD' => 'Kuwait Dinar', 'KYD' => 'Kaiman-Dollar', - 'KZT' => 'Tenge', 'LAK' => 'Kip', 'LBP' => 'Libanesisches Pfund', 'LKR' => 'Sri Lanka Rupie', - 'LRD' => 'Liberianischer Dollar', 'LSL' => 'Loti', 'LSM' => 'Maloti', 'LTL' => 'Litauischer Litas', - 'LTT' => 'Litauischer Talonas', 'LUC' => 'Luxemburgischer Franc (konvertibel)', - 'LUF' => 'Luxemburgischer Franc', 'LUL' => 'Luxemburgischer Finanz-Franc', - 'LVL' => 'Lettischer Lats', 'LVR' => 'Lettischer Rubel', 'LYD' => 'Libyscher Dinar', - 'MAD' => 'Marokkanischer Dirham', 'MAF' => 'Marokkanischer Franc', 'MDL' => 'Moldau Leu', - 'MGA' => 'Madagaskar Ariary', 'MGF' => 'Madagaskar Franc', 'MKD' => 'Denar', - 'MLF' => 'Malischer Franc', 'MMK' => 'Kyat', 'MNT' => 'Tugrik', 'MOP' => 'Pataca', - 'MRO' => 'Ouguiya', 'MTL' => 'Maltesische Lira', 'MTP' => 'Maltesisches Pfund', - 'MUR' => 'Mauritius Rupie', 'MVR' => 'Rufiyaa', 'MWK' => 'Malawi Kwacha', - 'MXN' => 'Mexikanischer Peso', 'MXP' => 'Mexikanischer Silber-Peso (1861-1992)', - 'MXV' => 'Mexican Unidad de Inversion (UDI)', 'MYR' => 'Malaysischer Ringgit', - 'MZE' => 'Mosambikanischer Escudo', 'MZM' => 'Alter Metical', 'MZN' => 'Metical', - 'NAD' => 'Namibia Dollar', 'NGN' => 'Naira', 'NIC' => 'Cordoba', 'NIO' => 'Gold-Cordoba', - 'NLG' => 'Holländischer Gulden', 'NOK' => 'Norwegische Krone', 'NPR' => 'Nepalesische Rupie', - 'NZD' => 'Neuseeland-Dollar', 'OMR' => 'Rial Omani', 'PAB' => 'Balboa', - 'PEI' => 'Peruanischer Inti', 'PEN' => 'Neuer Sol', 'PES' => 'Sol', 'PGK' => 'Kina', - 'PHP' => 'Philippinischer Peso', 'PKR' => 'Pakistanische Rupie', 'PLN' => 'Zloty', - 'PLZ' => 'Zloty (1950-1995)', 'PTE' => 'Portugiesischer Escudo', 'PYG' => 'Guarani', - 'QAR' => 'Katar Riyal', 'RHD' => 'Rhodesischer Dollar', 'ROL' => 'Leu', 'RON' => 'Rumänischer Leu', - 'RSD' => 'Serbischer Dinar', 'RUB' => 'Russischer Rubel (neu)', 'RUR' => 'Russischer Rubel (alt)', - 'RWF' => 'Ruanda Franc', 'SAR' => 'Saudi Riyal', 'SBD' => 'Salomonen Dollar', - 'SCR' => 'Seychellen Rupie', 'SDD' => 'Sudanesischer Dinar', 'SDP' => 'Sudanesisches Pfund', - 'SEK' => 'Schwedische Krone', 'SGD' => 'Singapur-Dollar', 'SHP' => 'St. Helena Pfund', - 'SIT' => 'Tolar', 'SKK' => 'Slowakische Krone', 'SLL' => 'Leone', 'SOS' => 'Somalia Schilling', - 'SRD' => 'Surinamischer Dollar', 'SRG' => 'Suriname Gulden', 'STD' => 'Dobra', - 'SUR' => 'Sowjetischer Rubel', 'SVC' => 'El Salvador Colon', 'SYP' => 'Syrisches Pfund', - 'SZL' => 'Lilangeni', 'THB' => 'Baht', 'TJR' => 'Tadschikistan Rubel', - 'TJS' => 'Tadschikistan Somoni', 'TMM' => 'Turkmenistan-Manat', 'TND' => 'Tunesischer Dinar', - 'TOP' => 'PaÊ»anga', 'TPE' => 'Timor Escudo', 'TRL' => 'Türkische Lira', - 'TRY' => 'Neue Türkische Lira', 'TTD' => 'Trinidad und Tobago Dollar', - 'TWD' => 'Neuer Taiwan Dollar', 'TZS' => 'Tansania Schilling', 'UAH' => 'Hryvnia', - 'UAK' => 'Ukrainischer Karbovanetz', 'UGS' => 'Uganda Schilling (1966-1987)', - 'UGX' => 'Uganda Schilling', 'USD' => 'US-Dollar', 'USN' => 'US Dollar (Nächster Tag)', - 'USS' => 'US Dollar (Gleicher Tag)', 'UYP' => 'Uruguayischer Neuer Peso (1975-1993)', - 'UYU' => 'Uruguayischer Peso', 'UZS' => 'Usbekistan Sum', 'VEB' => 'Bolivar', 'VND' => 'Dong', - 'VUV' => 'Vatu', 'WST' => 'Tala', 'XAF' => 'CFA Franc (Äquatorial)', 'XAG' => 'Silber', - 'XAU' => 'Gold', 'XBA' => 'Europäische Rechnungseinheit', - 'XBB' => 'Europäische Währungseinheit (XBB)', 'XBC' => 'Europäische Rechnungseinheit (XBC)', - 'XBD' => 'Europäische Rechnungseinheit (XBD)', 'XCD' => 'Ostkaribischer Dollar', - 'XDR' => 'Sonderziehungsrechte', 'XEU' => 'Europäische Währungseinheit (XEU)', - 'XFO' => 'Französischer Gold-Franc', 'XFU' => 'Französischer UIC-Franc', - 'XOF' => 'CFA Franc (West)', 'XPD' => 'Palladium', 'XPF' => 'CFP Franc', 'XPT' => 'Platin', - 'XRE' => 'RINET Funds', 'XTS' => 'Testwährung', 'XXX' => 'Keine Währung', 'YDD' => 'Jemen Dinar', - 'YER' => 'Jemen Rial', 'YUD' => 'Jugoslawischer Dinar (1966-1990)', 'YUM' => 'Neuer Dinar', - 'YUN' => 'Jugoslawischer Dinar (konvertibel)', 'ZAR' => 'Rand', 'ZMK' => 'Kwacha', - 'ZRN' => 'Neuer Zaire', 'ZRZ' => 'Zaire', 'ZWD' => 'Simbabwe Dollar'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'nametocurrency', 'USD'); - $this->assertEquals("US-Dollar", $value); - } - - /** - * test for reading currencytoname from locale - * expected array - */ - public function testCurrencyToName() - { - $value = Zend_Locale_Data::getList('de_AT', 'currencytoname'); - $result = array('Andorranische Pesete' => 'ADP', 'UAE Dirham' => 'AED', 'Afghani (1927-2002)' => 'AFA', - 'Afghani' => 'AFN', 'Lek' => 'ALL', 'Dram' => 'AMD', 'Niederl. Antillen Gulden' => 'ANG', - 'Kwanza' => 'AOA', 'Angolanischer Kwanza (1977-1990)' => 'AOK', 'Neuer Kwanza' => 'AON', - 'Kwanza Reajustado' => 'AOR', 'Argentinischer Austral' => 'ARA', 'Argentinischer Peso (1983-1985)' => 'ARP', - 'Argentinischer Peso' => 'ARS', 'Österreichischer Schilling' => 'ATS', 'Australischer Dollar' => 'AUD', - 'Aruba Florin' => 'AWG', 'Aserbeidschan Manat' => 'AZM', 'Aserbaidschan-Manat' => 'AZN', - 'Bosnien und Herzegowina Dinar' => 'BAD', 'Konvertierbare Mark' => 'BAM', 'Barbados-Dollar' => 'BBD', - 'Taka' => 'BDT', 'Belgischer Franc (konvertibel)' => 'BEC', 'Belgischer Franc' => 'BEF', - 'Belgischer Finanz-Franc' => 'BEL', 'Lew (1962-1999)' => 'BGL', 'Lew' => 'BGN', 'Bahrain-Dinar' => 'BHD', - 'Burundi-Franc' => 'BIF', 'Bermuda-Dollar' => 'BMD', 'Brunei-Dollar' => 'BND', 'Boliviano' => 'BOB', - 'Bolivianischer Peso' => 'BOP', 'Mvdol' => 'BOV', 'Brasilianischer Cruzeiro Novo (1967-1986)' => 'BRB', - 'Brasilianischer Cruzado' => 'BRC', 'Brasilianischer Cruzeiro (1990-1993)' => 'BRE', 'Real' => 'BRL', - 'Brasilianischer Cruzado Novo' => 'BRN', 'Brasilianischer Cruzeiro' => 'BRR', 'Bahama-Dollar' => 'BSD', - 'Ngultrum' => 'BTN', 'Birmanischer Kyat' => 'BUK', 'Pula' => 'BWP', 'Belarus Rubel (alt)' => 'BYB', - 'Belarus Rubel (neu)' => 'BYR', 'Belize-Dollar' => 'BZD', 'Kanadischer Dollar' => 'CAD', 'Franc congolais' => 'CDF', - 'WIR Euro' => 'CHE', 'Schweizer Franken' => 'CHF', 'WIR Franken' => 'CHW', 'Unidades de Fomento' => 'CLF', - 'Chilenischer Peso' => 'CLP', 'Renminbi Yuan' => 'CNY', 'Kolumbianischer Peso' => 'COP', 'Unidad de Valor Real' => 'COU', - 'Costa Rica Colon' => 'CRC', 'Alter Serbischer Dinar' => 'CSD', 'Tschechoslowakische Krone' => 'CSK', - 'Kubanischer Peso' => 'CUP', 'Kap Verde Escudo' => 'CVE', 'Zypern Pfund' => 'CYP', 'Tschechische Krone' => 'CZK', - 'Mark der DDR' => 'DDM', 'Deutsche Mark' => 'DEM', 'Dschibuti-Franc' => 'DJF', 'Dänische Krone' => 'DKK', - 'Dominikanischer Peso' => 'DOP', 'Algerischer Dinar' => 'DZD', 'Ecuadorianischer Sucre' => 'ECS', - 'Verrechnungseinheit für EC' => 'ECV', 'Estnische Krone' => 'EEK', 'Ägyptisches Pfund' => 'EGP', - 'Ekwele' => 'EQE', 'Nakfa' => 'ERN', 'Spanische Peseta (A-Konten)' => 'ESA', 'Spanische Peseta (konvertibel)' => 'ESB', - 'Spanische Pesete' => 'ESP', 'Birr' => 'ETB', 'Euro' => 'EUR', 'Finnische Mark' => 'FIM', - 'Fidschi Dollar' => 'FJD', 'Falkland Pfund' => 'FKP', 'Französischer Franc' => 'FRF', 'Pfund Sterling' => 'GBP', - 'Georgischer Kupon Larit' => 'GEK', 'Georgischer Lari' => 'GEL', 'Cedi' => 'GHC', 'Gibraltar Pfund' => 'GIP', - 'Dalasi' => 'GMD', 'Guinea Franc' => 'GNF', 'Guineischer Syli' => 'GNS', 'Äquatorialguinea Ekwele Guineana' => 'GQE', - 'Griechische Drachme' => 'GRD', 'Quetzal' => 'GTQ', 'Portugiesisch Guinea Escudo' => 'GWE', - 'Guinea Bissau Peso' => 'GWP', 'Guyana Dollar' => 'GYD', 'Hongkong-Dollar' => 'HKD', 'Lempira' => 'HNL', - 'Kroatischer Dinar' => 'HRD', 'Kuna' => 'HRK', 'Gourde' => 'HTG', 'Forint' => 'HUF', 'Rupiah' => 'IDR', - 'Irisches Pfund' => 'IEP', 'Israelisches Pfund' => 'ILP', 'Schekel' => 'ILS', 'Indische Rupie' => 'INR', - 'Irak Dinar' => 'IQD', 'Rial' => 'IRR', 'Isländische Krone' => 'ISK', 'Italienische Lire' => 'ITL', - 'Jamaika Dollar' => 'JMD', 'Jordanischer Dinar' => 'JOD', 'Yen' => 'JPY', 'Kenia Schilling' => 'KES', - 'Som' => 'KGS', 'Riel' => 'KHR', 'Komoren Franc' => 'KMF', 'Nordkoreanischer Won' => 'KPW', - 'Südkoreanischer Won' => 'KRW', 'Kuwait Dinar' => 'KWD', 'Kaiman-Dollar' => 'KYD', 'Tenge' => 'KZT', - 'Kip' => 'LAK', 'Libanesisches Pfund' => 'LBP', 'Sri Lanka Rupie' => 'LKR', 'Liberianischer Dollar' => 'LRD', - 'Loti' => 'LSL', 'Maloti' => 'LSM', 'Litauischer Litas' => 'LTL', 'Litauischer Talonas' => 'LTT', - 'Luxemburgischer Franc (konvertibel)' => 'LUC', 'Luxemburgischer Franc' => 'LUF', 'Luxemburgischer Finanz-Franc' => 'LUL', - 'Lettischer Lats' => 'LVL', 'Lettischer Rubel' => 'LVR', 'Libyscher Dinar' => 'LYD', 'Marokkanischer Dirham' => 'MAD', - 'Marokkanischer Franc' => 'MAF', 'Moldau Leu' => 'MDL', 'Madagaskar Ariary' => 'MGA', 'Madagaskar Franc' => 'MGF', - 'Denar' => 'MKD', 'Malischer Franc' => 'MLF', 'Kyat' => 'MMK', 'Tugrik' => 'MNT', 'Pataca' => 'MOP', - 'Ouguiya' => 'MRO', 'Maltesische Lira' => 'MTL', 'Maltesisches Pfund' => 'MTP', 'Mauritius Rupie' => 'MUR', - 'Rufiyaa' => 'MVR', 'Malawi Kwacha' => 'MWK', 'Mexikanischer Peso' => 'MXN', 'Mexikanischer Silber-Peso (1861-1992)' => 'MXP', - 'Mexican Unidad de Inversion (UDI)' => 'MXV', 'Malaysischer Ringgit' => 'MYR', 'Mosambikanischer Escudo' => 'MZE', - 'Alter Metical' => 'MZM', 'Metical' => 'MZN', 'Namibia Dollar' => 'NAD', 'Naira' => 'NGN', 'Cordoba' => 'NIC', - 'Gold-Cordoba' => 'NIO', 'Holländischer Gulden' => 'NLG', 'Norwegische Krone' => 'NOK', 'Nepalesische Rupie' => 'NPR', - 'Neuseeland-Dollar' => 'NZD', 'Rial Omani' => 'OMR', 'Balboa' => 'PAB', 'Peruanischer Inti' => 'PEI', - 'Neuer Sol' => 'PEN', 'Sol' => 'PES', 'Kina' => 'PGK', 'Philippinischer Peso' => 'PHP', 'Pakistanische Rupie' => 'PKR', - 'Zloty' => 'PLN', 'Zloty (1950-1995)' => 'PLZ', 'Portugiesischer Escudo' => 'PTE', 'Guarani' => 'PYG', - 'Katar Riyal' => 'QAR', 'Rhodesischer Dollar' => 'RHD', 'Leu' => 'ROL', 'Rumänischer Leu' => 'RON', - 'Serbischer Dinar' => 'RSD', 'Russischer Rubel (neu)' => 'RUB', 'Russischer Rubel (alt)' => 'RUR', - 'Ruanda Franc' => 'RWF', 'Saudi Riyal' => 'SAR', 'Salomonen Dollar' => 'SBD', 'Seychellen Rupie' => 'SCR', - 'Sudanesischer Dinar' => 'SDD', 'Sudanesisches Pfund' => 'SDP', 'Schwedische Krone' => 'SEK', - 'Singapur-Dollar' => 'SGD', 'St. Helena Pfund' => 'SHP', 'Tolar' => 'SIT', 'Slowakische Krone' => 'SKK', - 'Leone' => 'SLL', 'Somalia Schilling' => 'SOS', 'Surinamischer Dollar' => 'SRD', 'Suriname Gulden' => 'SRG', - 'Dobra' => 'STD', 'Sowjetischer Rubel' => 'SUR', 'El Salvador Colon' => 'SVC', 'Syrisches Pfund' => 'SYP', - 'Lilangeni' => 'SZL', 'Baht' => 'THB', 'Tadschikistan Rubel' => 'TJR', 'Tadschikistan Somoni' => 'TJS', - 'Turkmenistan-Manat' => 'TMM', 'Tunesischer Dinar' => 'TND', 'PaÊ»anga' => 'TOP', 'Timor Escudo' => 'TPE', - 'Türkische Lira' => 'TRL', 'Neue Türkische Lira' => 'TRY', 'Trinidad und Tobago Dollar' => 'TTD', - 'Neuer Taiwan Dollar' => 'TWD', 'Tansania Schilling' => 'TZS', 'Hryvnia' => 'UAH', 'Ukrainischer Karbovanetz' => 'UAK', - 'Uganda Schilling (1966-1987)' => 'UGS', 'Uganda Schilling' => 'UGX', 'US-Dollar' => 'USD', - 'US Dollar (Nächster Tag)' => 'USN', 'US Dollar (Gleicher Tag)' => 'USS', 'Uruguayischer Neuer Peso (1975-1993)' => 'UYP', - 'Uruguayischer Peso' => 'UYU', 'Usbekistan Sum' => 'UZS', 'Bolivar' => 'VEB', 'Dong' => 'VND', 'Vatu' => 'VUV', - 'Tala' => 'WST', 'CFA Franc (Äquatorial)' => 'XAF', 'Silber' => 'XAG', 'Gold' => 'XAU', - 'Europäische Rechnungseinheit' => 'XBA', 'Europäische Währungseinheit (XBB)' => 'XBB', - 'Europäische Rechnungseinheit (XBC)' => 'XBC', 'Europäische Rechnungseinheit (XBD)' => 'XBD', - 'Ostkaribischer Dollar' => 'XCD', 'Sonderziehungsrechte' => 'XDR', 'Europäische Währungseinheit (XEU)' => 'XEU', - 'Französischer Gold-Franc' => 'XFO', 'Französischer UIC-Franc' => 'XFU', 'CFA Franc (West)' => 'XOF', - 'Palladium' => 'XPD', 'CFP Franc' => 'XPF', 'Platin' => 'XPT', 'RINET Funds' => 'XRE', - 'Testwährung' => 'XTS', 'Keine Währung' => 'XXX', 'Jemen Dinar' => 'YDD', 'Jemen Rial' => 'YER', - 'Jugoslawischer Dinar (1966-1990)' => 'YUD', 'Neuer Dinar' => 'YUM', 'Jugoslawischer Dinar (konvertibel)' => 'YUN', - 'Rand' => 'ZAR', 'Kwacha' => 'ZMK', 'Neuer Zaire' => 'ZRN', 'Zaire' => 'ZRZ', 'Simbabwe Dollar' => 'ZWD'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencytoname', 'Platin'); - $this->assertEquals("XPT", $value); - } - - /** - * test for reading currencysymbol from locale - * expected array - */ - public function testCurrencySymbol() - { - $value = Zend_Locale_Data::getList('de_AT', 'currencysymbol'); - $result = array("AFN" => "Af", "ATS" => "öS", "BRL" => "R$", "CHF" => "SFr.", "DEM" => "DM", - "ESP" => "â‚§", "EUR" => "€", "FRF" => "FF", "GBP" => "£", "INR" => "0≤Rs.|1≤Re.|1<Rs.", - "ITL" => "₤", "JPY" => "Â¥", "KGS" => "som", "USD" => "$", "XCD" => "EC$"); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencysymbol', 'USD'); - $this->assertEquals("$", $value); - } - - /** - * test for reading question from locale - * expected array - */ - public function testQuestion() - { - $value = Zend_Locale_Data::getList('de_AT', 'question'); - $this->assertEquals(array("yes" => "ja:j", "no" => "nein:n"), $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'question', 'yes'); - $this->assertEquals("ja:j", $value); - } - - /** - * test for reading currencyfraction from locale - * expected array - */ - public function testCurrencyFraction() - { - $value = Zend_Locale_Data::getList('de_AT', 'currencyfraction'); - $this->assertEquals(array('ADP' => '0', 'BHD' => '3', 'BIF' => '0', 'BYR' => '0', 'CHF' => '2', - 'CLF' => '0', 'CLP' => '0', 'DEFAULT' => '2', 'DJF' => '0', 'ESP' => '0', 'GNF' => '0', - 'IQD' => '3', 'ITL' => '0', 'JOD' => '3', 'JPY' => '0', 'KMF' => '0', 'KRW' => '0', 'KWD' => '3', - 'LUF' => '0', 'LYD' => '3', 'MGA' => '0', 'MGF' => '0', 'OMR' => '3', 'PYG' => '0', 'RWF' => '0', - 'TND' => '3', 'TRL' => '0', 'VUV' => '0', 'XAF' => '0', 'XOF' => '0', 'XPF' => '0'), $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencyfraction'); - $this->assertEquals("2", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencyfraction', 'BHD'); - $this->assertEquals("3", $value); - } - - /** - * test for reading currencyrounding from locale - * expected array - */ - public function testCurrencyRounding() - { - $value = Zend_Locale_Data::getList('de_AT', 'currencyrounding'); - $this->assertEquals(array('ADP' => '0', 'BHD' => '0', 'BIF' => '0', 'BYR' => '0', 'CHF' => '5', - 'CLF' => '0', 'CLP' => '0', 'DEFAULT' => '0', 'DJF' => '0', 'ESP' => '0', 'GNF' => '0', - 'IQD' => '0', 'ITL' => '0', 'JOD' => '0', 'JPY' => '0', 'KMF' => '0', 'KRW' => '0', 'KWD' => '0', - 'LUF' => '0', 'LYD' => '0', 'MGA' => '0', 'MGF' => '0', 'OMR' => '0', 'PYG' => '0', 'RWF' => '0', - 'TND' => '0', 'TRL' => '0', 'VUV' => '0', 'XAF' => '0', 'XOF' => '0', 'XPF' => '0'), $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencyrounding'); - $this->assertEquals("0", $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencyrounding', 'BHD'); - $this->assertEquals("0", $value); - } - - /** - * test for reading currencytoregion from locale - * expected array - */ - public function testCurrencyToRegion() - { - $value = Zend_Locale_Data::getList('de_AT', 'currencytoregion'); - $result = array( 'AD' => 'EUR', 'AE' => 'AED', 'AF' => 'AFN', 'AG' => 'XCD', 'AI' => 'XCD', - 'AL' => 'ALL', 'AM' => 'AMD', 'AN' => 'ANG', 'AO' => 'AOA', 'AQ' => 'XXX', 'AR' => 'ARS', - 'AS' => 'USD', 'AT' => 'EUR', 'AU' => 'AUD', 'AW' => 'AWG', 'AX' => 'EUR', 'AZ' => 'AZN', - 'BA' => 'BAM', 'BB' => 'BBD', 'BD' => 'BDT', 'BE' => 'EUR', 'BF' => 'XOF', 'BG' => 'BGN', - 'BH' => 'BHD', 'BI' => 'BIF', 'BJ' => 'XOF', 'BM' => 'BMD', 'BN' => 'BND', 'BO' => 'BOB', - 'BR' => 'BRL', 'BS' => 'BSD', 'BT' => 'INR', 'BV' => 'NOK', 'BW' => 'BWP', 'BY' => 'BYR', - 'BZ' => 'BZD', 'CA' => 'CAD', 'CC' => 'AUD', 'CD' => 'CDF', 'CF' => 'XAF', 'CG' => 'XAF', - 'CH' => 'CHF', 'CI' => 'XOF', 'CK' => 'NZD', 'CL' => 'CLP', 'CM' => 'XAF', 'CN' => 'CNY', - 'CO' => 'COP', 'CR' => 'CRC', 'CS' => 'CSD', 'CU' => 'CUP', 'CV' => 'CVE', 'CX' => 'AUD', - 'CY' => 'EUR', 'CZ' => 'CZK', 'DE' => 'EUR', 'DJ' => 'DJF', 'DK' => 'DKK', 'DM' => 'XCD', - 'DO' => 'DOP', 'DZ' => 'DZD', 'EC' => 'USD', 'EE' => 'EEK', 'EG' => 'EGP', 'EH' => 'MAD', - 'ER' => 'ERN', 'ES' => 'EUR', 'ET' => 'ETB', 'FI' => 'EUR', 'FJ' => 'FJD', 'FK' => 'FKP', - 'FM' => 'USD', 'FO' => 'DKK', 'FR' => 'EUR', 'GA' => 'XAF', 'GB' => 'GBP', 'GD' => 'XCD', - 'GE' => 'GEL', 'GF' => 'EUR', 'GG' => 'GBP', 'GH' => 'GHS', 'GI' => 'GIP', 'GL' => 'DKK', - 'GM' => 'GMD', 'GN' => 'GNF', 'GP' => 'EUR', 'GQ' => 'XAF', 'GR' => 'EUR', 'GS' => 'GBP', - 'GT' => 'GTQ', 'GU' => 'USD', 'GW' => 'GWP', 'GY' => 'GYD', 'HK' => 'HKD', 'HM' => 'AUD', - 'HN' => 'HNL', 'HR' => 'HRK', 'HT' => 'HTG', 'HU' => 'HUF', 'ID' => 'IDR', 'IE' => 'EUR', - 'IL' => 'ILS', 'IM' => 'GBP', 'IN' => 'INR', 'IO' => 'USD', 'IQ' => 'IQD', 'IR' => 'IRR', - 'IS' => 'ISK', 'IT' => 'EUR', 'JE' => 'GBP', 'JM' => 'JMD', 'JO' => 'JOD', 'JP' => 'JPY', - 'KE' => 'KES', 'KG' => 'KGS', 'KH' => 'KHR', 'KI' => 'AUD', 'KM' => 'KMF', 'KN' => 'XCD', - 'KP' => 'KPW', 'KR' => 'KRW', 'KW' => 'KWD', 'KY' => 'KYD', 'KZ' => 'KZT', 'LA' => 'LAK', - 'LB' => 'LBP', 'LC' => 'XCD', 'LI' => 'CHF', 'LK' => 'LKR', 'LR' => 'LRD', 'LS' => 'ZAR', - 'LT' => 'LTL', 'LU' => 'EUR', 'LV' => 'LVL', 'LY' => 'LYD', 'MA' => 'MAD', 'MC' => 'EUR', - 'MD' => 'MDL', 'ME' => 'EUR', 'MG' => 'MGA', 'MH' => 'USD', 'MK' => 'MKD', 'ML' => 'XOF', - 'MM' => 'MMK', 'MN' => 'MNT', 'MO' => 'MOP', 'MP' => 'USD', 'MQ' => 'EUR', 'MR' => 'MRO', - 'MS' => 'XCD', 'MT' => 'EUR', 'MU' => 'MUR', 'MV' => 'MVR', 'MW' => 'MWK', 'MX' => 'MXN', - 'MY' => 'MYR', 'MZ' => 'MZN', 'NA' => 'ZAR', 'NC' => 'XPF', 'NE' => 'XOF', 'NF' => 'AUD', - 'NG' => 'NGN', 'NI' => 'NIO', 'NL' => 'EUR', 'NO' => 'NOK', 'NP' => 'NPR', 'NR' => 'AUD', - 'NU' => 'NZD', 'NZ' => 'NZD', 'OM' => 'OMR', 'PA' => 'PAB', 'PE' => 'PEN', 'PF' => 'XPF', - 'PG' => 'PGK', 'PH' => 'PHP', 'PK' => 'PKR', 'PL' => 'PLN', 'PM' => 'EUR', 'PN' => 'NZD', - 'PR' => 'USD', 'PS' => 'JOD', 'PT' => 'EUR', 'PW' => 'USD', 'PY' => 'PYG', 'QA' => 'QAR', - 'RE' => 'EUR', 'RO' => 'RON', 'RS' => 'RSD', 'RU' => 'RUB', 'RW' => 'RWF', 'SA' => 'SAR', - 'SB' => 'SBD', 'SC' => 'SCR', 'SD' => 'SDG', 'SE' => 'SEK', 'SG' => 'SGD', 'SH' => 'SHP', - 'SI' => 'EUR', 'SJ' => 'NOK', 'SK' => 'SKK', 'SL' => 'SLL', 'SM' => 'EUR', 'SN' => 'XOF', - 'SO' => 'SOS', 'SR' => 'SRD', 'ST' => 'STD', 'SV' => 'SVC', 'SY' => 'SYP', 'SZ' => 'SZL', - 'TC' => 'USD', 'TD' => 'XAF', 'TF' => 'EUR', 'TG' => 'XOF', 'TH' => 'THB', 'TJ' => 'TJS', - 'TK' => 'NZD', 'TL' => 'USD', 'TM' => 'TMM', 'TN' => 'TND', 'TO' => 'TOP', 'TR' => 'TRY', - 'TT' => 'TTD', 'TV' => 'AUD', 'TW' => 'TWD', 'TZ' => 'TZS', 'UA' => 'UAH', 'UG' => 'UGX', - 'UM' => 'USD', 'US' => 'USD', 'UY' => 'UYU', 'UZ' => 'UZS', 'VA' => 'EUR', 'VC' => 'XCD', - 'VE' => 'VEF', 'VG' => 'USD', 'VI' => 'USD', 'VN' => 'VND', 'VU' => 'VUV', 'WF' => 'XPF', - 'WS' => 'WST', 'YE' => 'YER', 'YT' => 'EUR', 'ZA' => 'ZAR', 'ZM' => 'ZMK', 'ZW' => 'ZWD', - 'ZR' => 'ZRN', 'YU' => 'YUM', 'TP' => 'TPE', 'SU' => 'SUR', 'QU' => 'EUR', 'MF' => 'EUR', - 'DD' => 'DDM', 'BU' => 'BUK', 'BL' => 'EUR'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'currencytoregion', 'AT'); - $this->assertEquals("EUR", $value); - } - - /** - * test for reading regiontocurrency from locale - * expected array - */ - public function testRegionToCurrency() - { - $value = Zend_Locale_Data::getList('de_AT', 'regiontocurrency'); - $result = array( - 'EUR' => 'AD AT AX BE BL CY DE ES FI FR GF GP GR IE IT LU MC ME MF MQ MT NL PM PT QU RE SI SM TF VA YT', - 'AED' => 'AE', 'AFN' => 'AF', 'XCD' => 'AG AI DM GD KN LC MS VC', 'ALL' => 'AL', 'AMD' => 'AM', - 'ANG' => 'AN', 'AOA' => 'AO', 'XXX' => 'AQ', 'ARS' => 'AR', 'AWG' => 'AW', 'AZN' => 'AZ', - 'USD' => 'AS EC FM GU IO MH MP PR PW TC TL UM US VG VI', 'AUD' => 'AU CC CX HM KI NF NR TV', - 'BAM' => 'BA', 'BBD' => 'BB', 'BDT' => 'BD', 'XOF' => 'BF BJ CI ML NE SN TG', 'BGN' => 'BG', - 'BHD' => 'BH', 'BIF' => 'BI', 'BMD' => 'BM', 'BND' => 'BN', 'BOB' => 'BO', 'BRL' => 'BR', - 'BSD' => 'BS', 'INR' => 'BT IN', 'NOK' => 'BV NO SJ', 'BWP' => 'BW', 'BYR' => 'BY', 'BZD' => 'BZ', - 'CAD' => 'CA', 'CDF' => 'CD', 'XAF' => 'CF CG CM GA GQ TD', 'CHF' => 'CH LI', - 'NZD' => 'CK NU NZ PN TK', 'CLP' => 'CL', 'CNY' => 'CN', 'COP' => 'CO', 'CRC' => 'CR', - 'CUP' => 'CU', 'CVE' => 'CV', 'CZK' => 'CZ', 'DJF' => 'DJ', 'DKK' => 'DK FO GL', 'DOP' => 'DO', - 'DZD' => 'DZ', 'EEK' => 'EE', 'EGP' => 'EG', 'MAD' => 'EH MA', 'ERN' => 'ER', 'ETB' => 'ET', - 'FJD' => 'FJ', 'FKP' => 'FK', 'GBP' => 'GB GG GS IM JE', 'GEL' => 'GE', 'GHS' => 'GH', - 'GIP' => 'GI', 'GMD' => 'GM', 'GNF' => 'GN', 'GTQ' => 'GT', 'GWP' => 'GW', 'GYD' => 'GY', - 'HKD' => 'HK', 'HNL' => 'HN', 'HRK' => 'HR', 'HTG' => 'HT', 'HUF' => 'HU', 'IDR' => 'ID', - 'ILS' => 'IL', 'IQD' => 'IQ', 'IRR' => 'IR', 'ISK' => 'IS', 'JMD' => 'JM', 'JOD' => 'JO PS', - 'JPY' => 'JP', 'KES' => 'KE', 'KGS' => 'KG', 'KHR' => 'KH', 'KMF' => 'KM', 'KPW' => 'KP', - 'KRW' => 'KR', 'KWD' => 'KW', 'KYD' => 'KY', 'KZT' => 'KZ', 'LAK' => 'LA', 'LBP' => 'LB', - 'LKR' => 'LK', 'LRD' => 'LR', 'ZAR' => 'LS NA ZA', 'LTL' => 'LT', 'LVL' => 'LV', 'LYD' => 'LY', - 'MDL' => 'MD', 'MGA' => 'MG', 'MKD' => 'MK', 'MMK' => 'MM', 'MNT' => 'MN', 'MOP' => 'MO', - 'MRO' => 'MR', 'MUR' => 'MU', 'MVR' => 'MV', 'MWK' => 'MW', 'MXN' => 'MX', 'MYR' => 'MY', - 'MZN' => 'MZ', 'XPF' => 'NC PF WF', 'NGN' => 'NG', 'NIO' => 'NI', 'NPR' => 'NP', 'OMR' => 'OM', - 'PAB' => 'PA', 'PEN' => 'PE', 'PGK' => 'PG', 'PHP' => 'PH', 'PKR' => 'PK', 'PLN' => 'PL', - 'PYG' => 'PY', 'QAR' => 'QA', 'RON' => 'RO', 'RSD' => 'RS', 'RUB' => 'RU', 'RWF' => 'RW', - 'SAR' => 'SA', 'SBD' => 'SB', 'SCR' => 'SC', 'SDG' => 'SD', 'SEK' => 'SE', 'SGD' => 'SG', - 'SHP' => 'SH', 'SKK' => 'SK', 'SLL' => 'SL', 'SOS' => 'SO', 'SRD' => 'SR', 'STD' => 'ST', - 'SVC' => 'SV', 'SYP' => 'SY', 'SZL' => 'SZ', 'THB' => 'TH', 'TJS' => 'TJ', 'TMM' => 'TM', - 'TND' => 'TN', 'TOP' => 'TO', 'TRY' => 'TR', 'TTD' => 'TT', 'TWD' => 'TW', 'TZS' => 'TZ', - 'UAH' => 'UA', 'UGX' => 'UG', 'UYU' => 'UY', 'UZS' => 'UZ', 'VEF' => 'VE', 'VND' => 'VN', - 'VUV' => 'VU', 'WST' => 'WS', 'YER' => 'YE', 'ZMK' => 'ZM', 'ZWD' => 'ZW', 'ZRN' => 'ZR', - 'YUM' => 'YU', 'TPE' => 'TP', 'SUR' => 'SU', 'DDM' => 'DD', 'CSD' => 'CS', 'BUK' => 'BU'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'regiontocurrency', 'EUR'); - $this->assertEquals("AD AT AX BE BL CY DE ES FI FR GF GP GR IE IT LU MC ME MF MQ MT NL PM PT QU RE SI SM TF VA YT", $value); - } - - /** - * test for reading regiontoterritory from locale - * expected array - */ - public function testRegionToTerritory() - { - $value = Zend_Locale_Data::getList('de_AT', 'regiontoterritory'); - $result = array('001' => '002 009 019 142 150', - '011' => 'BF BJ CI CV GH GM GN GW LR ML MR NE NG SH SL SN TG', '013' => 'BZ CR GT HN MX NI PA SV', - '014' => 'BI DJ ER ET KE KM MG MU MW MZ RE RW SC SO TZ UG YT ZM ZW', - '142' => '030 035 143 145 034 062', '143' => 'TM TJ KG KZ UZ', - '145' => 'AE AM AZ BH CY GE IL IQ JO KW LB OM PS QA SA NT SY TR YE YD', - '015' => 'DZ EG EH LY MA SD TN', '150' => '039 151 154 155 QU', - '151' => 'BG BY CZ HU MD PL RO RU SU SK UA', - '154' => 'GG IM JE AX DK EE FI FO GB IE IM IS LT LV NO SE SJ', '830' => 'GG JE', - '155' => 'AT BE CH DE DD FR FX LI LU MC NL', '017' => 'AO CD ZR CF CG CM GA GQ ST TD', - '172' => 'AM AZ BY GE KG KZ MD RU TJ TM UA UZ', '018' => 'BW LS NA SZ ZA', - '019' => '005 013 021 029 003 419', '002' => '011 014 015 017 018', '021' => 'BM CA GL PM US', - '029' => 'AG AI AN AW BB BL BS CU DM DO GD GP HT JM KN KY LC MF MQ MS PR TC TT VC VG VI', - '003' => '013 021 029', '030' => 'CN HK JP KP KR MN MO TW', - '035' => 'BN ID KH LA MM BU MY PH SG TH TL TP VN', - '039' => 'AD AL BA ES GI GR HR IT ME MK MT CS RS PT SI SM VA YU', '419' => '005 013 029', - '005' => 'AR BO BR CL CO EC FK GF GY PE PY SR UY VE', '053' => 'AU NF NZ', - '054' => 'FJ NC PG SB VU', '057' => 'FM GU KI MH MP NR PW', - '061' => 'AS CK NU PF PN TK TO TV WF WS', '062' => '034 143', '034' => 'AF BD BT IN IR LK MV NP PK', - '009' => '053 054 057 061 QO', 'QO' => 'AQ BV CC CX GS HM IO TF UM', - 'QU' => 'AT BE CY CZ DE DK EE ES FI FR GB GR HU IE IT LT LU LV MT NL PL PT SE SI SK BG RO'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'regiontoterritory', '143'); - $this->assertEquals("TM TJ KG KZ UZ", $value); - } - - /** - * test for reading territorytoregion from locale - * expected array - */ - public function testTerritoryToRegion() - { - $value = Zend_Locale_Data::getList('de_AT', 'territorytoregion'); - $result = array('002' => '001', '009' => '001', '019' => '001', '142' => '001', '150' => '001', - 'BF' => '011', 'BJ' => '011', 'CI' => '011', 'CV' => '011', 'GH' => '011', 'GM' => '011', - 'GN' => '011', 'GW' => '011', 'LR' => '011', 'ML' => '011', 'MR' => '011', 'NE' => '011', - 'NG' => '011', 'SH' => '011', 'SL' => '011', 'SN' => '011', 'TG' => '011', 'BZ' => '013', - 'CR' => '013', 'GT' => '013', 'HN' => '013', 'MX' => '013', 'NI' => '013', 'PA' => '013', - 'SV' => '013', 'BI' => '014', 'DJ' => '014', 'ER' => '014', 'ET' => '014', 'KE' => '014', - 'KM' => '014', 'MG' => '014', 'MU' => '014', 'MW' => '014', 'MZ' => '014', 'RE' => '014', - 'RW' => '014', 'SC' => '014', 'SO' => '014', 'TZ' => '014', 'UG' => '014', 'YT' => '014', - 'ZM' => '014', 'ZW' => '014', '030' => '142', '035' => '142', '143' => '142 062', '145' => '142', - '034' => '142 062', '062' => '142', 'TM' => '143 172', 'TJ' => '143 172', 'KG' => '143 172', - 'KZ' => '143 172', 'UZ' => '143 172', 'AE' => '145', 'AM' => '145 172', 'AZ' => '145 172', - 'BH' => '145', 'CY' => '145 QU', 'GE' => '145 172', 'IL' => '145', 'IQ' => '145', 'JO' => '145', - 'KW' => '145', 'LB' => '145', 'OM' => '145', 'PS' => '145', 'QA' => '145', 'SA' => '145', - 'NT' => '145', 'SY' => '145', 'TR' => '145', 'YE' => '145', 'YD' => '145', 'DZ' => '015', - 'EG' => '015', 'EH' => '015', 'LY' => '015', 'MA' => '015', 'SD' => '015', 'TN' => '015', - '039' => '150', '151' => '150', '154' => '150', '155' => '150', 'QU' => '150', 'BG' => '151 QU', - 'BY' => '151 172', 'CZ' => '151 QU', 'HU' => '151 QU', 'MD' => '151 172', 'PL' => '151 QU', - 'RO' => '151 QU', 'RU' => '151 172', 'SU' => '151', 'SK' => '151 QU', 'UA' => '151 172', - 'GG' => '154 830', 'IM' => '154 154', 'JE' => '154 830', 'AX' => '154', 'DK' => '154 QU', - 'EE' => '154 QU', 'FI' => '154 QU', 'FO' => '154', 'GB' => '154 QU', 'IE' => '154 QU', - 'IS' => '154', 'LT' => '154 QU', 'LV' => '154 QU', 'NO' => '154', 'SE' => '154 QU', 'SJ' => '154', - 'AT' => '155 QU', 'BE' => '155 QU', 'CH' => '155', 'DE' => '155 QU', 'DD' => '155', - 'FR' => '155 QU', 'FX' => '155', 'LI' => '155', 'LU' => '155 QU', 'MC' => '155', 'NL' => '155 QU', - 'AO' => '017', 'CD' => '017', 'ZR' => '017', 'CF' => '017', 'CG' => '017', 'CM' => '017', - 'GA' => '017', 'GQ' => '017', 'ST' => '017', 'TD' => '017', 'BW' => '018', 'LS' => '018', - 'NA' => '018', 'SZ' => '018', 'ZA' => '018', '005' => '019 419', '013' => '019 003 419', - '021' => '019 003', '029' => '019 003 419', '003' => '019', '419' => '019', '011' => '002', - '014' => '002', '015' => '002', '017' => '002', '018' => '002', 'BM' => '021', 'CA' => '021', - 'GL' => '021', 'PM' => '021', 'US' => '021', 'AG' => '029', 'AI' => '029', 'AN' => '029', - 'AW' => '029', 'BB' => '029', 'BS' => '029', 'CU' => '029', 'DM' => '029', 'DO' => '029', - 'GD' => '029', 'GP' => '029', 'HT' => '029', 'JM' => '029', 'KN' => '029', 'KY' => '029', - 'LC' => '029', 'MQ' => '029', 'MS' => '029', 'PR' => '029', 'TC' => '029', 'TT' => '029', - 'VC' => '029', 'VG' => '029', 'VI' => '029', 'CN' => '030', 'HK' => '030', 'JP' => '030', - 'KP' => '030', 'KR' => '030', 'MN' => '030', 'MO' => '030', 'TW' => '030', 'BN' => '035', - 'ID' => '035', 'KH' => '035', 'LA' => '035', 'MM' => '035', 'BU' => '035', 'MY' => '035', - 'PH' => '035', 'SG' => '035', 'TH' => '035', 'TL' => '035', 'TP' => '035', 'VN' => '035', - 'AD' => '039', 'AL' => '039', 'BA' => '039', 'ES' => '039 QU', 'GI' => '039', 'GR' => '039 QU', - 'HR' => '039', 'IT' => '039 QU', 'ME' => '039', 'MK' => '039', 'MT' => '039 QU', 'CS' => '039', - 'RS' => '039', 'PT' => '039 QU', 'SI' => '039 QU', 'SM' => '039', 'VA' => '039', 'YU' => '039', - 'AR' => '005', 'BO' => '005', 'BR' => '005', 'CL' => '005', 'CO' => '005', 'EC' => '005', - 'FK' => '005', 'GF' => '005', 'GY' => '005', 'PE' => '005', 'PY' => '005', 'SR' => '005', - 'UY' => '005', 'VE' => '005', 'AU' => '053', 'NF' => '053', 'NZ' => '053', 'FJ' => '054', - 'NC' => '054', 'PG' => '054', 'SB' => '054', 'VU' => '054', 'FM' => '057', 'GU' => '057', - 'KI' => '057', 'MH' => '057', 'MP' => '057', 'NR' => '057', 'PW' => '057', 'AS' => '061', - 'CK' => '061', 'NU' => '061', 'PF' => '061', 'PN' => '061', 'TK' => '061', 'TO' => '061', - 'TV' => '061', 'WF' => '061', 'WS' => '061', 'AF' => '034', 'BD' => '034', 'BT' => '034', - 'IN' => '034', 'IR' => '034', 'LK' => '034', 'MV' => '034', 'NP' => '034', 'PK' => '034', - '053' => '009', '054' => '009', '057' => '009', '061' => '009', 'QO' => '009', 'AQ' => 'QO', - 'BV' => 'QO', 'CC' => 'QO', 'CX' => 'QO', 'GS' => 'QO', 'HM' => 'QO', 'IO' => 'QO', 'TF' => 'QO', - 'UM' => 'QO', 'MF' => '029', 'BL' => '029'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'territorytoregion', 'AT'); - $this->assertEquals("155 QU", $value); - } - - /** - * test for reading scripttolanguage from locale - * expected array - */ - public function testScriptToLanguage() - { - $value = Zend_Locale_Data::getList('de_AT', 'scripttolanguage'); - $result = array('aa' => 'Latn', 'ab' => 'Cyrl', 'abq' => 'Cyrl', 'ace' => 'Latn', 'ady' => 'Cyrl', - 'af' => 'Latn', 'aii' => 'Cyrl', 'ain' => 'Kana Latn', 'ak' => 'Latn', 'akk' => 'Xsux', - 'am' => 'Ethi', 'amo' => 'Latn', 'ar' => 'Arab', 'as' => 'Beng', 'ast' => 'Latn', 'av' => 'Cyrl', - 'awa' => 'Deva', 'ay' => 'Latn', 'az' => 'Arab Cyrl Latn', 'ba' => 'Cyrl', 'bal' => 'Arab Latn', - 'ban' => 'Latn', 'bbc' => 'Latn', 'be' => 'Cyrl', 'bem' => 'Latn', 'bfq' => 'Taml', 'bft' => 'Deva', - 'bfy' => 'Deva', 'bg' => 'Cyrl', 'bh' => 'Deva', 'bhb' => 'Deva', 'bho' => 'Deva', 'bi' => 'Latn', - 'bin' => 'Latn', 'bjj' => 'Deva', 'bku' => 'Buhd', 'bm' => 'Latn', 'bn' => 'Beng', 'bo' => 'Tibt', - 'br' => 'Latn', 'bra' => 'Deva', 'bs' => 'Latn', 'btv' => 'Deva', 'buc' => 'Latn', 'bug' => 'Latn', - 'bxr' => 'Cyrl', 'bya' => 'Latn', 'byn' => 'Ethi', 'ca' => 'Latn', 'cch' => 'Latn', 'ccp' => 'Beng', - 'ce' => 'Cyrl', 'ceb' => 'Latn', 'ch' => 'Latn', 'chk' => 'Latn', 'chm' => 'Cyrl Latn', - 'chr' => 'Cher Latn', 'cja' => 'Cham Deva', 'cjm' => 'Arab', 'cjs' => 'Cyrl', 'ckt' => 'Cyrl', - 'co' => 'Latn', 'cop' => 'Arab Copt Grek', 'cpe' => 'Latn', 'cr' => 'Cans Latn', 'crk' => 'Cans', - 'cs' => 'Latn', 'cu' => 'Glag', 'cv' => 'Cyrl', 'cwd' => 'Cans', 'cy' => 'Latn', 'da' => 'Latn', - 'dar' => 'Cyrl', 'de' => 'Latn', 'dgr' => 'Latn', 'dng' => 'Cyrl', 'doi' => 'Arab', 'dv' => 'Thaa', - 'dyu' => 'Latn', 'dz' => 'Tibt', 'ee' => 'Latn', 'efi' => 'Latn', 'el' => 'Grek', 'emk' => 'Deva', - 'en' => 'Latn', 'eo' => 'Latn', 'es' => 'Latn', 'et' => 'Latn', 'ett' => 'Ital Latn', - 'eu' => 'Latn', 'evn' => 'Cyrl', 'fa' => 'Arab', 'fan' => 'Latn', 'fi' => 'Latn', 'fil' => 'Latn', - 'fiu' => 'Latn', 'fj' => 'Latn', 'fo' => 'Latn', 'fon' => 'Latn', 'fr' => 'Latn', 'fur' => 'Latn', - 'fy' => 'Latn', 'ga' => 'Latn', 'gaa' => 'Latn', 'gag' => 'Cyrl', 'gbm' => 'Deva', 'gcr' => 'Latn', - 'gd' => 'Latn', 'gez' => 'Ethi', 'gil' => 'Latn', 'gl' => 'Latn', 'gld' => 'Cyrl', 'gn' => 'Latn', - 'gon' => 'Deva Telu', 'gor' => 'Latn', 'got' => 'Goth', 'grc' => 'Cprt Grek Linb', 'grt' => 'Beng', - 'gsw' => 'Latn', 'gu' => 'Gujr', 'gv' => 'Latn', 'gwi' => 'Latn', 'ha' => 'Arab Latn', - 'hai' => 'Latn', 'haw' => 'Latn', 'he' => 'Hebr', 'hi' => 'Deva', 'hil' => 'Latn', 'hmn' => 'Latn', - 'hne' => 'Deva', 'hnn' => 'Latn', 'ho' => 'Latn', 'hoc' => 'Deva', 'hoj' => 'Deva', 'hop' => 'Latn', - 'hr' => 'Latn', 'ht' => 'Latn', 'hu' => 'Latn', 'hy' => 'Armn', 'ia' => 'Latn', 'ibb' => 'Latn', - 'id' => 'Latn', 'ig' => 'Latn', 'ii' => 'Latn Yiii', 'ik' => 'Latn', 'ilo' => 'Latn', - 'inh' => 'Cyrl', 'is' => 'Latn', 'it' => 'Latn', 'iu' => 'Cans', 'ja' => 'Jpan', 'jv' => 'Latn', - 'ka' => 'Geor', 'kaa' => 'Cyrl', 'kab' => 'Latn', 'kaj' => 'Latn', 'kam' => 'Latn', 'kbd' => 'Cyrl', - 'kca' => 'Cyrl', 'kcg' => 'Latn', 'kdt' => 'Thai', 'kfo' => 'Latn', 'kfr' => 'Deva', - 'kha' => 'Latn', 'khb' => 'Talu', 'kht' => 'Mymr', 'ki' => 'Latn', 'kj' => 'Latn', 'kjh' => 'Cyrl', - 'kk' => 'Cyrl', 'kl' => 'Latn', 'km' => 'Khmr', 'kmb' => 'Latn', 'kn' => 'Knda', 'ko' => 'Kore', - 'koi' => 'Cyrl', 'kok' => 'Deva', 'kos' => 'Latn', 'kpe' => 'Latn', 'kpv' => 'Cyrl', - 'kpy' => 'Cyrl', 'kr' => 'Latn', 'krc' => 'Cyrl', 'krl' => 'Cyrl Latn', 'kru' => 'Deva', - 'ks' => 'Arab Deva', 'ku' => 'Arab Cyrl Latn', 'kum' => 'Cyrl', 'kv' => 'Cyrl Latn', 'kw' => 'Latn', - 'ky' => 'Arab Cyrl', 'la' => 'Latn', 'lad' => 'Hebr', 'lah' => 'Arab', 'lb' => 'Latn', - 'lbe' => 'Cyrl', 'lcp' => 'Thai', 'lep' => 'Lepc', 'lez' => 'Cyrl', 'lg' => 'Latn', 'li' => 'Latn', - 'lif' => 'Deva Limb', 'lis' => 'Latn', 'lmn' => 'Telu', 'ln' => 'Latn', 'lo' => 'Laoo', - 'lol' => 'Latn', 'lt' => 'Latn', 'lu' => 'Latn', 'lua' => 'Latn', 'luo' => 'Latn', 'lut' => 'Latn', - 'lv' => 'Latn', 'lwl' => 'Thai', 'mad' => 'Latn', 'mag' => 'Deva', 'mai' => 'Deva', 'mak' => 'Latn', - 'mdf' => 'Cyrl', 'mdh' => 'Latn', 'mdr' => 'Bugi', 'men' => 'Latn', 'mfe' => 'Latn', 'mg' => 'Latn', - 'mh' => 'Latn', 'mi' => 'Latn', 'min' => 'Latn', 'mk' => 'Cyrl', 'ml' => 'Mlym', - 'mn' => 'Cyrl Mong', 'mnc' => 'Mong', 'mni' => 'Beng', 'mns' => 'Cyrl', 'mnw' => 'Mymr', - 'mo' => 'Latn', 'mos' => 'Latn', 'mr' => 'Deva', 'ms' => 'Latn', 'mt' => 'Latn', - 'muw' => 'Beng Deva', 'mwr' => 'Deva', 'my' => 'Mymr', 'myv' => 'Cyrl', 'na' => 'Latn', - 'nap' => 'Latn', 'nb' => 'Latn', 'nbf' => 'Latn', 'nd' => 'Latn', 'ne' => 'Deva', 'new' => 'Deva', - 'ng' => 'Latn', 'niu' => 'Latn', 'nl' => 'Latn', 'nn' => 'Latn', 'no' => 'Latn', 'nog' => 'Cyrl', - 'nqo' => 'Nkoo', 'nr' => 'Latn', 'nso' => 'Latn', 'nv' => 'Latn', 'ny' => 'Latn', 'nym' => 'Latn', - 'nyn' => 'Latn', 'oc' => 'Latn', 'om' => 'Latn', 'or' => 'Orya', 'os' => 'Cyrl Latn', - 'osc' => 'Ital Latn', 'pa' => 'Guru', 'pag' => 'Latn', 'pam' => 'Latn', 'pap' => 'Latn', - 'pau' => 'Latn', 'peo' => 'Xpeo', 'phn' => 'Phnx', 'pi' => 'Deva Sinh Thai', 'pl' => 'Latn', - 'pon' => 'Latn', 'pra' => 'Khar', 'prd' => 'Arab', 'prg' => 'Latn', 'ps' => 'Arab', 'pt' => 'Latn', - 'qu' => 'Latn', 'rcf' => 'Latn', 'ril' => 'Beng', 'rm' => 'Latn', 'rn' => 'Latn', 'ro' => 'Latn', - 'rom' => 'Cyrl Latn', 'ru' => 'Cyrl', 'rw' => 'Latn', 'sa' => 'Deva Sinh', 'sah' => 'Cyrl', - 'sam' => 'Hebr', 'sas' => 'Latn', 'sat' => 'Beng Deva Olck Orya', 'scn' => 'Latn', 'sco' => 'Latn', - 'sd' => 'Arab Deva', 'se' => 'Latn', 'sel' => 'Cyrl', 'sg' => 'Latn', 'sga' => 'Latn Ogam', - 'shn' => 'Mymr', 'si' => 'Sinh', 'sid' => 'Latn', 'sk' => 'Latn', 'sl' => 'Latn', 'sm' => 'Latn', - 'sma' => 'Latn', 'smi' => 'Latn', 'smj' => 'Latn', 'smn' => 'Latn', 'sms' => 'Latn', 'sn' => 'Latn', - 'snk' => 'Latn', 'so' => 'Latn', 'son' => 'Latn', 'sq' => 'Latn', 'sr' => 'Cyrl Latn', - 'srn' => 'Latn', 'srr' => 'Latn', 'ss' => 'Latn', 'st' => 'Latn', 'su' => 'Latn', 'suk' => 'Latn', - 'sus' => 'Latn', 'sv' => 'Latn', 'sw' => 'Latn', 'swb' => 'Arab', 'syl' => 'Beng', 'syr' => 'Syrc', - 'ta' => 'Taml', 'tab' => 'Cyrl', 'tbw' => 'Latn', 'tcy' => 'Knda', 'tdd' => 'Tale', 'te' => 'Telu', - 'tem' => 'Latn', 'tet' => 'Latn', 'tg' => 'Arab Cyrl Latn', 'th' => 'Thai', 'ti' => 'Ethi', - 'tig' => 'Ethi', 'tiv' => 'Latn', 'tk' => 'Arab Cyrl Latn', 'tkl' => 'Latn', 'tl' => 'Latn', - 'tmh' => 'Latn', 'tn' => 'Latn', 'to' => 'Latn', 'tpi' => 'Latn', 'tr' => 'Latn', 'tru' => 'Latn', - 'ts' => 'Latn', 'tsg' => 'Latn', 'tt' => 'Cyrl', 'tts' => 'Thai', 'ttt' => 'Cyrl', 'tum' => 'Latn', - 'tut' => 'Cyrl', 'tvl' => 'Latn', 'tw' => 'Latn', 'ty' => 'Latn', 'tyv' => 'Cyrl', - 'tzm' => 'Latn Tfng', 'ude' => 'Cyrl', 'udm' => 'Cyrl', 'ug' => 'Arab', 'uga' => 'Ugar', - 'uk' => 'Cyrl', 'uli' => 'Latn', 'umb' => 'Latn', 'ur' => 'Arab', 'uz' => 'Arab Cyrl Latn', - 'vai' => 'Vaii', 've' => 'Latn', 'vi' => 'Latn', 'vo' => 'Latn', 'wa' => 'Latn', 'wal' => 'Ethi', - 'war' => 'Latn', 'wo' => 'Latn', 'xal' => 'Cyrl', 'xh' => 'Latn', 'xsr' => 'Deva', - 'xum' => 'Ital Latn', 'yao' => 'Latn', 'yap' => 'Latn', 'yi' => 'Hebr', 'yo' => 'Latn', - 'yrk' => 'Cyrl', 'za' => 'Hani', 'zh' => 'Hans Hant', 'zu' => 'Latn', 'zbl' => 'Blis', 'nds' => 'Latn', - 'hsb' => 'Latn', 'frs' => 'Latn', 'frr' => 'Latn', 'dsb' => 'Latn'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'scripttolanguage', 'uk'); - $this->assertEquals("Cyrl", $value); - } - - /** - * test for reading languagetoscript from locale - * expected array - */ - public function testLanguageToScript() - { - $value = Zend_Locale_Data::getList('de_AT', 'languagetoscript'); - $result = array( - 'Latn' => 'aa ace af ain ak amo ast ay az bal ban bbc bem bi bin bm br bs buc bug bya ca cch ceb ch chk chm chr co cpe cr cs cy da de dgr dsb dyu ee efi en eo es et ett eu fan fi fil fiu fj fo fon fr frr frs fur fy ga gaa gcr gd gil gl gn gor gsw gv gwi ha hai haw hil hmn hnn ho hop hr hsb ht hu ia ibb id ig ii ik ilo is it jv kab kaj kam kcg kfo kha ki kj kl kmb kos kpe kr krl ku kv kw la lb lg li lis ln lol lt lu lua luo lut lv mad mak mdh men mfe mg mh mi min mo mos ms mt na nap nb nbf nd nds ng niu nl nn no nr nso nv ny nym nyn oc om os osc pag pam pap pau pl pon prg pt qu rcf rm rn ro rom rw sas scn sco se sg sga sid sk sl sm sma smi smj smn sms sn snk so son sq sr srn srr ss st su suk sus sv sw tbw tem tet tg tiv tk tkl tl tmh tn to tpi tr tru ts tsg tum tvl tw ty tzm uli umb uz ve vi vo wa war wo xh xum yao yap yo zu', - 'Cyrl' => 'ab abq ady aii av az ba be bg bxr ce chm cjs ckt cv dar dng evn gag gld inh kaa kbd kca kjh kk koi kpv kpy krc krl ku kum kv ky lbe lez mdf mk mn mns myv nog os rom ru sah sel sr tab tg tk tt ttt tut tyv ude udm uk uz xal yrk', - 'Kana' => 'ain', 'Xsux' => 'akk', 'Ethi' => 'am byn gez ti tig wal', - 'Arab' => 'ar az bal cjm cop doi fa ha ks ku ky lah prd ps sd swb tg tk ug ur uz', - 'Beng' => 'as bn ccp grt mni muw ril sat syl', - 'Deva' => 'awa bft bfy bh bhb bho bjj bra btv cja emk gbm gon hi hne hoc hoj kfr kok kru ks lif mag mai mr muw mwr ne new pi sa sat sd xsr', - 'Taml' => 'bfq ta', 'Buhd' => 'bku', 'Tibt' => 'bo dz', 'Cher' => 'chr', 'Cham' => 'cja', - 'Copt' => 'cop', 'Grek' => 'cop el grc', 'Cans' => 'cr crk cwd iu', 'Glag' => 'cu', 'Thaa' => 'dv', - 'Ital' => 'ett osc xum', 'Telu' => 'gon lmn te', 'Goth' => 'got', 'Cprt' => 'grc', 'Linb' => 'grc', - 'Gujr' => 'gu', 'Hebr' => 'he lad sam yi', 'Armn' => 'hy', 'Yiii' => 'ii', 'Jpan' => 'ja', - 'Geor' => 'ka', 'Thai' => 'kdt lcp lwl pi th tts', 'Talu' => 'khb', 'Mymr' => 'kht mnw my shn', - 'Khmr' => 'km', 'Knda' => 'kn tcy', 'Lepc' => 'lep', 'Limb' => 'lif', - 'Laoo' => 'lo', 'Bugi' => 'mdr', 'Mlym' => 'ml', 'Mong' => 'mn mnc', 'Nkoo' => 'nqo', - 'Orya' => 'or sat', 'Guru' => 'pa', 'Xpeo' => 'peo', 'Phnx' => 'phn', 'Sinh' => 'pi sa si', - 'Khar' => 'pra', 'Olck' => 'sat', 'Ogam' => 'sga', 'Syrc' => 'syr', 'Tale' => 'tdd', - 'Tfng' => 'tzm', 'Ugar' => 'uga', 'Vaii' => 'vai', 'Hani' => 'za', 'Hans' => 'zh', 'Hant' => 'zh', - 'Blis' => 'zbl', 'Kore' => 'ko'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'languagetoscript', 'Kana'); - $this->assertEquals("ain", $value); - } - - /** - * test for reading territorytolanguage from locale - * expected array - */ - public function testTerritoryToLanguage() - { - $value = Zend_Locale_Data::getList('de_AT', 'territorytolanguage'); - $result = array('aa' => 'DJ', 'ab' => 'GE', 'abr' => 'GH', 'ace' => 'ID', 'ady' => 'RU', 'af' => 'ZA', - 'ak' => 'GH', 'am' => 'ET', 'ar' => 'AE BH DJ DZ EG EH ER IL IQ JO KM KW LB LY MA MR OM PS QA SA SD SY TD TN YE', - 'as' => 'IN', 'ast' => 'ES', 'av' => 'RU', 'awa' => 'IN', 'ay' => 'BO', 'az' => 'AZ', - 'ba' => 'RU', 'bal' => 'PK', 'ban' => 'ID', 'bbc' => 'ID', 'bcl' => 'PH', 'be' => 'BY', - 'bem' => 'ZM', 'bew' => 'ID', 'bg' => 'BG', 'bgc' => 'IN', 'bhb' => 'IN', 'bhi' => 'IN', - 'bhk' => 'PH', 'bho' => 'IN MU NP', 'bi' => 'VU', 'bin' => 'NG', 'bjj' => 'IN', 'bjn' => 'ID', - 'bm' => 'ML', 'bn' => 'BD IN', 'bo' => 'CN', 'bqi' => 'IR', 'brh' => 'PK', 'bs' => 'BA', - 'buc' => 'YT', 'bug' => 'ID', 'bya' => 'ID', 'ca' => 'AD', 'ce' => 'RU', 'ceb' => 'PH', - 'cgg' => 'UG', 'ch' => 'GU', 'chk' => 'FM', 'crk' => 'CA', 'cs' => 'CZ', 'cv' => 'RU', - 'cwd' => 'CA', 'cy' => 'GB', 'da' => 'DK GL', 'dcc' => 'IN', 'de' => 'AT BE CH DE LI LU', - 'dhd' => 'IN', 'diq' => 'TR', 'dje' => 'NE', 'doi' => 'IN', 'dv' => 'MV', 'dyu' => 'BF', - 'dz' => 'BT', 'ee' => 'GH', 'efi' => 'NG', 'el' => 'CY GR', 'emk' => 'GN', - 'en' => 'AG AI AS AU BB BM BS BW BZ CA CC CK CM CX DM FJ FK FM GB GD GG GH GI GM GU GY HK HN IE IM JE JM KE KI KN KY LC LR LS MH MP MS MT MU MW NA NF NG NR NU NZ PG PH PK PN PR RW SB SC SG SH SL SZ TC TK TO TT TV TZ UG UM US VC VG VI VU WS ZA ZM ZW', - 'es' => 'AR BO CL CO CR CU DO EC ES GQ GT HN MX NI PA PE PH PR PY SV UY VE', 'et' => 'EE', - 'eu' => 'ES', 'fa' => 'AF IR', 'fan' => 'GQ', 'fi' => 'FI', 'fil' => 'PH', 'fj' => 'FJ', 'fo' => 'FO', 'fon' => 'BJ', - 'fr' => 'BE BF BI BJ BL CA CD CF CG CH CI CM DJ DZ FR GA GF GN GP GQ HT KM LU MA MC MF MG ML MQ MU NC NE PF PM RE RW SC SN SY TD TG TN VU WF YT', - 'fud' => 'WF', 'fuv' => 'NG', 'fy' => 'NL', 'ga' => 'IE', 'gaa' => 'GH', 'gbm' => 'IN', - 'gcr' => 'GF', 'gd' => 'GB', 'gil' => 'KI', 'gl' => 'ES', 'glk' => 'IR', 'gn' => 'PY', - 'gno' => 'IN', 'gon' => 'IN', 'gsw' => 'CH LI', 'gu' => 'IN', 'guz' => 'KE', 'ha' => 'NG', - 'haw' => 'US', 'haz' => 'AF', 'he' => 'IL', 'hi' => 'IN', 'hil' => 'PH', 'hne' => 'IN', - 'hno' => 'PK', 'ho' => 'PG', 'hoc' => 'IN', 'hr' => 'BA HR', 'ht' => 'HT', 'hu' => 'HU', - 'hy' => 'AM', 'ibb' => 'NG', 'id' => 'ID', 'ig' => 'NG', 'ii' => 'CN', 'ilo' => 'PH', 'inh' => 'RU', - 'is' => 'IS', 'it' => 'CH IT SM', 'iu' => 'CA GL', 'ja' => 'JP', 'jv' => 'ID', 'ka' => 'GE', - 'kab' => 'DZ', 'kam' => 'KE', 'kbd' => 'RU', 'kfy' => 'IN', 'kha' => 'IN', 'khn' => 'IN', - 'ki' => 'KE', 'kj' => 'NA', 'kk' => 'KZ', 'kl' => 'GL', 'kln' => 'KE', 'km' => 'KH', 'kmb' => 'AO', - 'kn' => 'IN', 'ko' => 'KP KR', 'koi' => 'RU', 'kok' => 'IN', 'kos' => 'FM', - 'kpv' => 'RU', 'krc' => 'RU', 'kri' => 'SL', 'kru' => 'IN', 'ks' => 'IN', 'ku' => 'IQ IR SY TR', - 'kum' => 'RU', 'kxm' => 'TH', 'ky' => 'KG', 'la' => 'VA', 'lah' => 'PK', 'lb' => 'LU', - 'lbe' => 'RU', 'lez' => 'RU', 'lg' => 'UG', 'ljp' => 'ID', 'lmn' => 'IN', 'ln' => 'CD CG', - 'lo' => 'LA', 'lrc' => 'IR', 'lt' => 'LT', 'lu' => 'CD', 'lua' => 'CD', 'luo' => 'KE', - 'luy' => 'KE', 'lv' => 'LV', 'mad' => 'ID', 'mag' => 'IN', 'mai' => 'IN NP', 'mak' => 'ID', - 'mdf' => 'RU', 'mdh' => 'PH', 'men' => 'SL', 'mer' => 'KE', 'mfa' => 'TH', 'mfe' => 'MU', - 'mg' => 'MG', 'mh' => 'MH', 'mi' => 'NZ', 'min' => 'ID', 'mk' => 'MK', 'ml' => 'IN', 'mn' => 'MN', - 'mni' => 'IN', 'mos' => 'BF', 'mr' => 'IN', 'ms' => 'BN MY SG', 'mt' => 'MT', 'mtr' => 'IN', - 'mup' => 'IN', 'muw' => 'IN', 'my' => 'MM', 'myv' => 'RU', 'na' => 'NR', 'nap' => 'IT', - 'nb' => 'NO SJ', 'nd' => 'ZW', 'ndc' => 'MZ', 'ne' => 'NP', 'ng' => 'NA', 'ngl' => 'MZ', - 'niu' => 'NU', 'nl' => 'AN AW BE NL SR', 'nn' => 'NO', 'nod' => 'TH', 'noe' => 'IN', 'nso' => 'ZA', - 'ny' => 'MW', 'nym' => 'TZ', 'nyn' => 'UG', 'om' => 'ET', 'or' => 'IN', 'os' => 'GE', 'pa' => 'IN', - 'pag' => 'PH', 'pam' => 'PH', 'pap' => 'AN', 'pau' => 'PW', 'pl' => 'PL', 'pon' => 'FM', - 'ps' => 'AF', 'pt' => 'AO BR CV GW MZ PT ST TL', 'qu' => 'BO PE', 'rcf' => 'RE', 'rej' => 'ID', - 'rif' => 'MA', 'rjb' => 'IN', 'rm' => 'CH', 'rmt' => 'IR', 'rn' => 'BI', 'ro' => 'MD RO', - 'ru' => 'BY KG KZ RU', 'rw' => 'RW', 'sa' => 'IN', 'sah' => 'RU', 'sas' => 'ID', 'sat' => 'IN', - 'sck' => 'IN', 'scn' => 'IT', 'sco' => 'GB', 'sd' => 'IN', 'se' => 'NO', 'sg' => 'CF', - 'shn' => 'MM', 'si' => 'LK', 'sid' => 'ET', 'sk' => 'SK', 'sl' => 'SI', 'sm' => 'AS WS', - 'sn' => 'ZW', 'so' => 'SO', 'sou' => 'TH', 'sq' => 'AL', 'sr' => 'BA ME RS', 'srn' => 'SR', - 'srr' => 'SN', 'ss' => 'SZ', 'st' => 'LS ZA', 'su' => 'ID', 'suk' => 'TZ', 'sv' => 'AX FI SE', - 'sw' => 'KE TZ UG', 'swb' => 'KM', 'swv' => 'IN', 'syl' => 'BD', 'ta' => 'IN LK SG', 'tcy' => 'IN', - 'te' => 'IN', 'tem' => 'SL', 'tet' => 'TL', 'tg' => 'TJ', 'th' => 'TH', 'ti' => 'ER', 'tiv' => 'NG', - 'tk' => 'TM', 'tkl' => 'TK', 'tl' => 'PH US', 'tn' => 'BW ZA', 'to' => 'TO', 'tpi' => 'PG', - 'tr' => 'CY TR', 'ts' => 'ZA', 'tsg' => 'PH', 'tt' => 'RU', 'tts' => 'TH', 'tvl' => 'TV', - 'tw' => 'GH', 'ty' => 'PF', 'tyv' => 'RU', 'tzm' => 'MA', 'udm' => 'RU', 'ug' => 'CN', 'uk' => 'UA', - 'uli' => 'FM', 'umb' => 'AO', 'und' => 'AQ BV GS HM IO TF', 'ur' => 'IN PK', 'uz' => 'UZ', - 've' => 'ZA', 'vi' => 'VN', 'vmw' => 'MZ', 'wal' => 'ET', 'war' => 'PH', 'wbq' => 'IN', - 'wbr' => 'IN', 'wls' => 'WF', 'wo' => 'SN', 'wtm' => 'IN', 'xh' => 'ZA', 'xnr' => 'IN', - 'xog' => 'UG', 'yap' => 'FM', 'yo' => 'NG', 'za' => 'CN', 'zh' => 'CN HK MO SG TW', 'zu' => 'ZA', - 'oc' => 'FR', 'kg' => 'CD'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'territorytolanguage', 'uk'); - $this->assertEquals("UA", $value); - } - - /** - * test for reading languagetoterritory from locale - * expected array - */ - public function testLanguageToTerritory() - { - $value = Zend_Locale_Data::getList('de_AT', 'languagetoterritory'); - $result = array('DJ' => 'aa ar fr', 'GE' => 'ab ka os', 'GH' => 'abr ak ee en gaa tw', - 'ID' => 'ace ban bbc bew bjn bug bya id jv ljp mad mak min rej sas su', - 'RU' => 'ady av ba ce cv inh kbd koi kpv krc kum lbe lez mdf myv ru sah tt tyv udm', - 'ZA' => 'af en nso st tn ts ve xh zu', 'ET' => 'am om sid wal', 'AE' => 'ar', 'BH' => 'ar', - 'DZ' => 'ar fr kab', 'EG' => 'ar', 'EH' => 'ar', 'ER' => 'ar ti', 'IL' => 'ar he', 'IQ' => 'ar ku', - 'JO' => 'ar', 'KM' => 'ar fr swb', 'KW' => 'ar', 'LB' => 'ar', 'LY' => 'ar', - 'MA' => 'ar fr rif tzm', 'MR' => 'ar', 'OM' => 'ar', 'PS' => 'ar', 'QA' => 'ar', 'SA' => 'ar', - 'SD' => 'ar', 'SY' => 'ar fr ku', 'TD' => 'ar fr', 'TN' => 'ar fr', 'YE' => 'ar', - 'IN' => 'as awa bgc bhb bhi bho bjj bn dcc dhd doi gbm gno gon gu hi hne hoc kfy kha khn kn kok kru ks lmn mag mai ml mni mr mtr mup muw noe or pa rjb sa sat sck sd swv ta tcy te ur wbq wbr wtm xnr', - 'ES' => 'ast es eu gl', 'FR' => 'fr oc', 'BO' => 'ay es qu', 'AZ' => 'az', - 'PK' => 'bal brh en hno lah ur', 'PH' => 'bcl bhk ceb en es fil hil ilo mdh pag pam tl tsg war', - 'BY' => 'be ru', 'ZM' => 'bem en', 'BG' => 'bg', 'MU' => 'bho en fr mfe', 'NP' => 'bho mai ne', - 'VU' => 'bi en fr', 'NG' => 'bin efi en fuv ha ibb ig tiv yo', 'ML' => 'bm fr', 'BD' => 'bn syl', - 'CN' => 'bo ii ug za zh', 'IR' => 'bqi fa glk ku lrc rmt', 'BA' => 'bs hr sr', 'YT' => 'buc fr', - 'AD' => 'ca', 'UG' => 'cgg en lg nyn sw xog', 'GU' => 'ch en', 'FM' => 'chk en kos pon uli yap', - 'CA' => 'crk cwd en fr iu', 'CZ' => 'cs', 'GB' => 'cy en gd sco', 'DK' => 'da', 'GL' => 'da iu kl', - 'AT' => 'de', 'BE' => 'de fr nl', 'CH' => 'de fr gsw it rm', 'DE' => 'de', 'LI' => 'de gsw', - 'LU' => 'de fr lb', 'TR' => 'diq ku tr', 'NE' => 'dje fr', 'MV' => 'dv', 'BF' => 'dyu fr mos', - 'BT' => 'dz', 'CY' => 'el tr', 'GR' => 'el', 'GN' => 'emk fr', 'AG' => 'en', 'AI' => 'en', - 'AS' => 'en sm', 'AU' => 'en', 'BB' => 'en', 'BM' => 'en', 'BS' => 'en', 'BW' => 'en tn', - 'BZ' => 'en', 'CC' => 'en', 'CK' => 'en', 'CM' => 'en fr', 'CX' => 'en', 'DM' => 'en', - 'FJ' => 'en fj', 'FK' => 'en', 'GD' => 'en', 'GG' => 'en', 'GI' => 'en', 'GM' => 'en', 'GY' => 'en', - 'HK' => 'en zh', 'HN' => 'en es', 'IE' => 'en ga', 'IM' => 'en', 'JE' => 'en', 'JM' => 'en', - 'KE' => 'en guz kam ki kln luo luy mer sw', 'KI' => 'en gil', 'KN' => 'en', 'KY' => 'en', - 'LC' => 'en', 'LR' => 'en', 'LS' => 'en st', 'MH' => 'en mh', 'MP' => 'en', 'MS' => 'en', - 'MT' => 'en mt', 'MW' => 'en ny', 'NA' => 'en kj ng', 'NF' => 'en', 'NR' => 'en na', - 'NU' => 'en niu', 'NZ' => 'en mi', 'PG' => 'en ho tpi', 'PN' => 'en', 'PR' => 'en es', - 'RW' => 'en fr rw', 'SB' => 'en', 'SC' => 'en fr', 'SG' => 'en ms ta zh', 'SH' => 'en', - 'SL' => 'en kri men tem', 'SZ' => 'en ss', 'TC' => 'en', 'TK' => 'en tkl', 'TO' => 'en to', - 'TT' => 'en', 'TV' => 'en tvl', 'TZ' => 'en nym suk sw', 'UM' => 'en', 'US' => 'en haw tl', - 'VC' => 'en', 'VG' => 'en', 'VI' => 'en', 'WS' => 'en sm', 'ZW' => 'en nd sn', 'AR' => 'es', - 'CL' => 'es', 'CO' => 'es', 'CR' => 'es', 'CU' => 'es', 'DO' => 'es', 'EC' => 'es', - 'GQ' => 'es fan fr', 'GT' => 'es', 'MX' => 'es', 'NI' => 'es', 'PA' => 'es', 'PE' => 'es qu', - 'PY' => 'es gn', 'SV' => 'es', 'UY' => 'es', 'VE' => 'es', 'EE' => 'et', 'AF' => 'fa haz ps', - 'FI' => 'fi sv', 'FO' => 'fo', 'BJ' => 'fon fr', 'BI' => 'fr rn', 'CD' => 'fr kg ln lu lua', - 'CF' => 'fr sg', 'CG' => 'fr ln', 'CI' => 'fr', 'GA' => 'fr', 'GF' => 'fr gcr', 'GP' => 'fr', - 'HT' => 'fr ht', 'MC' => 'fr', 'MG' => 'fr mg', 'MQ' => 'fr', 'NC' => 'fr', 'PF' => 'fr ty', - 'PM' => 'fr', 'RE' => 'fr rcf', 'SN' => 'fr srr wo', 'TG' => 'fr', 'WF' => 'fr fud wls', - 'NL' => 'fy nl', 'HR' => 'hr', 'HU' => 'hu', 'AM' => 'hy', 'IS' => 'is', 'IT' => 'it nap scn', - 'SM' => 'it', 'JP' => 'ja', 'KZ' => 'kk ru', 'KH' => 'km', 'AO' => 'kmb pt umb', 'KP' => 'ko', - 'KR' => 'ko', 'TH' => 'kxm mfa nod sou th tts', 'KG' => 'ky ru', 'VA' => 'la', 'LA' => 'lo', - 'LT' => 'lt', 'LV' => 'lv', 'MK' => 'mk', 'MN' => 'mn', 'BN' => 'ms', 'MY' => 'ms', - 'MM' => 'my shn', 'NO' => 'nb nn se', 'SJ' => 'nb', 'MZ' => 'ndc ngl pt vmw', 'AN' => 'nl pap', - 'AW' => 'nl', 'SR' => 'nl srn', 'PW' => 'pau', 'PL' => 'pl', 'BR' => 'pt', 'CV' => 'pt', - 'GW' => 'pt', 'PT' => 'pt', 'ST' => 'pt', 'TL' => 'pt tet', 'MD' => 'ro', 'RO' => 'ro', - 'LK' => 'si ta', 'SK' => 'sk', 'SI' => 'sl', 'SO' => 'so', 'AL' => 'sq', 'ME' => 'sr', 'RS' => 'sr', - 'AX' => 'sv', 'SE' => 'sv', 'TJ' => 'tg', 'TM' => 'tk', 'UA' => 'uk', 'AQ' => 'und', 'BV' => 'und', - 'GS' => 'und', 'HM' => 'und', 'IO' => 'und', 'TF' => 'und', 'UZ' => 'uz', 'VN' => 'vi', - 'MO' => 'zh', 'TW' => 'zh', 'BL' => 'fr', 'MF' => 'fr'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'languagetoterritory', 'GQ'); - $this->assertEquals("es fan fr", $value); - } - - /** - * test for reading timezonetowindows from locale - * expected array - */ - public function testTimezoneToWindows() - { - $value = Zend_Locale_Data::getList('de_AT', 'timezonetowindows'); - $result = array('Dateline' => 'Pacific/Kwajalein', 'Samoa' => 'Pacific/Apia', - 'Hawaiian' => 'Pacific/Honolulu', 'Alaskan' => 'America/Anchorage', 'Pacific' => 'America/Los_Angeles', - 'Pacific Standard Time (Mexico)' => 'America/Tijuana', 'US Mountain' => 'America/Phoenix', - 'Mountain' => 'America/Denver', 'Mountain Standard Time (Mexico)' => 'America/Chihuahua', - 'Mexico Standard Time 2' => 'America/Chihuahua', 'Central America' => 'America/Guatemala', - 'Canada Central' => 'America/Regina', 'Central Standard Time (Mexico)' => 'America/Mexico_City', - 'Mexico' => 'America/Mexico_City', 'Central' => 'America/Chicago', 'US Eastern' => 'America/Indianapolis', - 'SA Pacific' => 'America/Bogota', 'Eastern' => 'America/New_York', 'SA Western' => 'America/Caracas', - 'Pacific SA' => 'America/Santiago', 'Atlantic' => 'America/Halifax', 'Central Brazilian' => 'America/Manaus', - 'Newfoundland' => 'America/St_Johns', 'SA Eastern' => 'America/Buenos_Aires', 'Greenland' => 'America/Godthab', - 'E. South America' => 'America/Sao_Paulo', 'Montevideo' => 'America/Montevideo', 'Mid-Atlantic' => 'America/Noronha', - 'Cape Verde' => 'Atlantic/Cape_Verde', 'Azores' => 'Atlantic/Azores', 'Greenwich' => 'Africa/Casablanca', - 'GMT' => 'Europe/London', 'W. Central Africa' => 'Africa/Lagos', 'W. Europe' => 'Europe/Berlin', - 'Romance' => 'Europe/Paris', 'Central European' => 'Europe/Warsaw', 'Central Europe' => 'Europe/Prague', - 'South Africa' => 'Africa/Johannesburg', 'Israel' => 'Asia/Jerusalem', 'GTB' => 'Europe/Istanbul', - 'FLE' => 'Europe/Helsinki', 'Egypt' => 'Africa/Cairo', 'E. Europe' => 'Europe/Minsk', - 'Jordan' => 'Asia/Amman', 'Middle East' => 'Asia/Beirut', 'Namibia' => 'Africa/Windhoek', - 'E. Africa' => 'Africa/Nairobi', 'Azerbaijan' => 'Asia/Baku', 'Arab' => 'Asia/Riyadh', - 'Georgian' => 'Asia/Tbilisi', 'Russian' => 'Europe/Moscow', 'Arabic' => 'Asia/Baghdad', - 'Iran' => 'Asia/Tehran', 'Arabian' => 'Asia/Muscat', 'Caucasus' => 'Asia/Yerevan', 'Afghanistan' => 'Asia/Kabul', - 'West Asia' => 'Asia/Karachi', 'Ekaterinburg' => 'Asia/Yekaterinburg', 'India' => 'Asia/Calcutta', - 'Nepal' => 'Asia/Katmandu', 'Sri Lanka' => 'Asia/Colombo', 'Central Asia' => 'Asia/Dhaka', - 'N. Central Asia' => 'Asia/Novosibirsk', 'Myanmar' => 'Asia/Rangoon', 'SE Asia' => 'Asia/Bangkok', - 'North Asia' => 'Asia/Krasnoyarsk', 'W. Australia' => 'Australia/Perth', 'Taipei' => 'Asia/Taipei', - 'Singapore' => 'Asia/Singapore', 'China' => 'Asia/Shanghai', 'North Asia East' => 'Asia/Ulaanbaatar', - 'Tokyo' => 'Asia/Tokyo', 'Korea' => 'Asia/Seoul', 'Yakutsk' => 'Asia/Yakutsk', 'AUS Central' => 'Australia/Darwin', - 'Cen. Australia' => 'Australia/Adelaide', 'West Pacific' => 'Pacific/Guam', 'E. Australia' => 'Australia/Brisbane', - 'Vladivostok' => 'Asia/Vladivostok', 'Tasmania' => 'Australia/Hobart', 'AUS Eastern' => 'Australia/Sydney', - 'Central Pacific' => 'Pacific/Guadalcanal', 'Fiji' => 'Pacific/Fiji', 'New Zealand' => 'Pacific/Auckland', - 'Tonga' => 'Pacific/Tongatapu'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'timezonetowindows', 'Fiji'); - $this->assertEquals("Pacific/Fiji", $value); - } - - /** - * test for reading windowstotimezone from locale - * expected array - */ - public function testWindowsToTimezone() - { - $value = Zend_Locale_Data::getList('de_AT', 'windowstotimezone'); - $result = array('Pacific/Kwajalein' => 'Dateline', 'Pacific/Apia' => 'Samoa', 'Pacific/Honolulu' => 'Hawaiian', - 'America/Anchorage' => 'Alaskan', 'America/Los_Angeles' => 'Pacific', 'America/Tijuana' => 'Pacific Standard Time (Mexico)', - 'America/Phoenix' => 'US Mountain', 'America/Denver' => 'Mountain', 'America/Chihuahua' => 'Mountain Standard Time (Mexico)', - 'America/Guatemala' => 'Central America', 'America/Regina' => 'Canada Central', 'America/Mexico_City' => 'Central Standard Time (Mexico)', - 'America/Chicago' => 'Central', 'America/Indianapolis' => 'US Eastern', 'America/Bogota' => 'SA Pacific', - 'America/New_York' => 'Eastern', 'America/Caracas' => 'SA Western', 'America/Santiago' => 'Pacific SA', - 'America/Halifax' => 'Atlantic', 'America/Manaus' => 'Central Brazilian', 'America/St_Johns' => 'Newfoundland', - 'America/Buenos_Aires' => 'SA Eastern', 'America/Godthab' => 'Greenland', 'America/Sao_Paulo' => 'E. South America', - 'America/Montevideo' => 'Montevideo', 'America/Noronha' => 'Mid-Atlantic', 'Atlantic/Cape_Verde' => 'Cape Verde', - 'Atlantic/Azores' => 'Azores', 'Africa/Casablanca' => 'Greenwich', 'Europe/London' => 'GMT', - 'Africa/Lagos' => 'W. Central Africa', 'Europe/Berlin' => 'W. Europe', 'Europe/Paris' => 'Romance', - 'Europe/Warsaw' => 'Central European', 'Europe/Prague' => 'Central Europe', 'Africa/Johannesburg' => 'South Africa', - 'Asia/Jerusalem' => 'Israel', 'Europe/Istanbul' => 'GTB', 'Europe/Helsinki' => 'FLE', - 'Africa/Cairo' => 'Egypt', 'Europe/Minsk' => 'E. Europe', 'Asia/Amman' => 'Jordan', 'Asia/Beirut' => 'Middle East', - 'Africa/Windhoek' => 'Namibia', 'Africa/Nairobi' => 'E. Africa', 'Asia/Baku' => 'Azerbaijan', - 'Asia/Riyadh' => 'Arab', 'Asia/Tbilisi' => 'Georgian', 'Europe/Moscow' => 'Russian', 'Asia/Baghdad' => 'Arabic', - 'Asia/Tehran' => 'Iran', 'Asia/Muscat' => 'Arabian', 'Asia/Yerevan' => 'Caucasus', 'Asia/Kabul' => 'Afghanistan', - 'Asia/Karachi' => 'West Asia', 'Asia/Yekaterinburg' => 'Ekaterinburg', 'Asia/Calcutta' => 'India', - 'Asia/Katmandu' => 'Nepal', 'Asia/Colombo' => 'Sri Lanka', 'Asia/Dhaka' => 'Central Asia', 'Asia/Novosibirsk' => 'N. Central Asia', - 'Asia/Rangoon' => 'Myanmar', 'Asia/Bangkok' => 'SE Asia', 'Asia/Krasnoyarsk' => 'North Asia', 'Australia/Perth' => 'W. Australia', - 'Asia/Taipei' => 'Taipei', 'Asia/Singapore' => 'Singapore', 'Asia/Shanghai' => 'China', 'Asia/Ulaanbaatar' => 'North Asia East', - 'Asia/Tokyo' => 'Tokyo', 'Asia/Seoul' => 'Korea', 'Asia/Yakutsk' => 'Yakutsk', 'Australia/Darwin' => 'AUS Central', - 'Australia/Adelaide' => 'Cen. Australia', 'Pacific/Guam' => 'West Pacific', 'Australia/Brisbane' => 'E. Australia', - 'Asia/Vladivostok' => 'Vladivostok', 'Australia/Hobart' => 'Tasmania', 'Australia/Sydney' => 'AUS Eastern', - 'Pacific/Guadalcanal' => 'Central Pacific', 'Pacific/Fiji' => 'Fiji', 'Pacific/Auckland' => 'New Zealand', - 'Pacific/Tongatapu' => 'Tonga'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'windowstotimezone', 'Pacific/Fiji'); - $this->assertEquals("Fiji", $value); - } - - /** - * test for reading territorytotimezone from locale - * expected array - */ - public function testTerritoryToTimezone() - { - $value = Zend_Locale_Data::getList('de_AT', 'territorytotimezone'); - $result = array('Africa/Abidjan' => 'CI', 'Africa/Accra' => 'GH', 'Africa/Addis_Ababa' => 'ET', - 'Africa/Algiers' => 'DZ', 'Africa/Asmera' => 'ER', 'Africa/Bamako' => 'ML', 'Africa/Bangui' => 'CF', - 'Africa/Banjul' => 'GM', 'Africa/Bissau' => 'GW', 'Africa/Blantyre' => 'MW', 'Africa/Brazzaville' => 'CG', - 'Africa/Bujumbura' => 'BI', 'Africa/Cairo' => 'EG', 'Africa/Casablanca' => 'MA', 'Africa/Ceuta' => 'ES', - 'Africa/Conakry' => 'GN', 'Africa/Dakar' => 'SN', 'Africa/Dar_es_Salaam' => 'TZ', 'Africa/Djibouti' => 'DJ', - 'Africa/Douala' => 'CM', 'Africa/El_Aaiun' => 'EH', 'Africa/Freetown' => 'SL', 'Africa/Gaborone' => 'BW', - 'Africa/Harare' => 'ZW', 'Africa/Johannesburg' => 'ZA', 'Africa/Kampala' => 'UG', 'Africa/Khartoum' => 'SD', - 'Africa/Kigali' => 'RW', 'Africa/Kinshasa' => 'CD', 'Africa/Lagos' => 'NG', 'Africa/Libreville' => 'GA', - 'Africa/Lome' => 'TG', 'Africa/Luanda' => 'AO', 'Africa/Lubumbashi' => 'CD', 'Africa/Lusaka' => 'ZM', - 'Africa/Malabo' => 'GQ', 'Africa/Maputo' => 'MZ', 'Africa/Maseru' => 'LS', 'Africa/Mbabane' => 'SZ', - 'Africa/Mogadishu' => 'SO', 'Africa/Monrovia' => 'LR', 'Africa/Nairobi' => 'KE', 'Africa/Ndjamena' => 'TD', - 'Africa/Niamey' => 'NE', 'Africa/Nouakchott' => 'MR', 'Africa/Ouagadougou' => 'BF', 'Africa/Porto-Novo' => 'BJ', - 'Africa/Sao_Tome' => 'ST', 'Africa/Tripoli' => 'LY', 'Africa/Tunis' => 'TN', 'Africa/Windhoek' => 'NA', - 'America/Adak' => 'US', 'America/Anchorage' => 'US', 'America/Anguilla' => 'AI', 'America/Antigua' => 'AG', - 'America/Araguaina' => 'BR', 'America/Argentina/La_Rioja' => 'AR', 'America/Argentina/Rio_Gallegos' => 'AR', - 'America/Argentina/San_Juan' => 'AR', 'America/Argentina/Tucuman' => 'AR', 'America/Argentina/Ushuaia' => 'AR', - 'America/Aruba' => 'AW', 'America/Asuncion' => 'PY', 'America/Bahia' => 'BR', 'America/Barbados' => 'BB', - 'America/Belem' => 'BR', 'America/Belize' => 'BZ', 'America/Blanc-Sablon' => 'CA', 'America/Boa_Vista' => 'BR', - 'America/Bogota' => 'CO', 'America/Boise' => 'US', 'America/Buenos_Aires' => 'AR', 'America/Cambridge_Bay' => 'CA', - 'America/Campo_Grande' => 'BR', 'America/Cancun' => 'MX', 'America/Caracas' => 'VE', 'America/Catamarca' => 'AR', - 'America/Cayenne' => 'GF', 'America/Cayman' => 'KY', 'America/Chicago' => 'US', 'America/Chihuahua' => 'MX', - 'America/Coral_Harbour' => 'CA', 'America/Cordoba' => 'AR', 'America/Costa_Rica' => 'CR', 'America/Cuiaba' => 'BR', - 'America/Curacao' => 'AN', 'America/Danmarkshavn' => 'GL', 'America/Dawson' => 'CA', 'America/Dawson_Creek' => 'CA', - 'America/Denver' => 'US', 'America/Detroit' => 'US', 'America/Dominica' => 'DM', 'America/Edmonton' => 'CA', - 'America/Eirunepe' => 'BR', 'America/El_Salvador' => 'SV', 'America/Fortaleza' => 'BR', 'America/Glace_Bay' => 'CA', - 'America/Godthab' => 'GL', 'America/Goose_Bay' => 'CA', 'America/Grand_Turk' => 'TC', 'America/Grenada' => 'GD', - 'America/Guadeloupe' => 'GP', 'America/Guatemala' => 'GT', 'America/Guayaquil' => 'EC', 'America/Guyana' => 'GY', - 'America/Halifax' => 'CA', 'America/Havana' => 'CU', 'America/Hermosillo' => 'MX', 'America/Indiana/Knox' => 'US', - 'America/Indiana/Marengo' => 'US', 'America/Indiana/Petersburg' => 'US', 'America/Indiana/Vevay' => 'US', - 'America/Indiana/Vincennes' => 'US', 'America/Indiana/Winamac' => 'US', 'America/Indianapolis' => 'US', - 'America/Inuvik' => 'CA', 'America/Iqaluit' => 'CA', 'America/Jamaica' => 'JM', 'America/Jujuy' => 'AR', - 'America/Juneau' => 'US', 'America/Kentucky/Monticello' => 'US', 'America/La_Paz' => 'BO', 'America/Lima' => 'PE', - 'America/Los_Angeles' => 'US', 'America/Louisville' => 'US', 'America/Maceio' => 'BR', 'America/Managua' => 'NI', - 'America/Manaus' => 'BR', 'America/Martinique' => 'MQ', 'America/Mazatlan' => 'MX', 'America/Mendoza' => 'AR', - 'America/Menominee' => 'US', 'America/Merida' => 'MX', 'America/Mexico_City' => 'MX', 'America/Miquelon' => 'PM', - 'America/Moncton' => 'CA', 'America/Monterrey' => 'MX', 'America/Montevideo' => 'UY', 'America/Montreal' => 'CA', - 'America/Montserrat' => 'MS', 'America/Nassau' => 'BS', 'America/New_York' => 'US', 'America/Nipigon' => 'CA', - 'America/Nome' => 'US', 'America/Noronha' => 'BR', 'America/North_Dakota/Center' => 'US', 'America/North_Dakota/New_Salem' => 'US', - 'America/Panama' => 'PA', 'America/Pangnirtung' => 'CA', 'America/Paramaribo' => 'SR', 'America/Phoenix' => 'US', - 'America/Port_of_Spain' => 'TT', 'America/Port-au-Prince' => 'HT', 'America/Porto_Velho' => 'BR', - 'America/Puerto_Rico' => 'PR', 'America/Rainy_River' => 'CA', 'America/Rankin_Inlet' => 'CA', - 'America/Recife' => 'BR', 'America/Regina' => 'CA', 'America/Rio_Branco' => 'BR', 'America/Santiago' => 'CL', - 'America/Santo_Domingo' => 'DO', 'America/Sao_Paulo' => 'BR', 'America/Scoresbysund' => 'GL', - 'America/Shiprock' => 'US', 'America/St_Johns' => 'CA', 'America/St_Kitts' => 'KN', 'America/St_Lucia' => 'LC', - 'America/St_Thomas' => 'VI', 'America/St_Vincent' => 'VC', 'America/Swift_Current' => 'CA', - 'America/Tegucigalpa' => 'HN', 'America/Thule' => 'GL', 'America/Thunder_Bay' => 'CA', 'America/Tijuana' => 'MX', - 'America/Toronto' => 'CA', 'America/Tortola' => 'VG', 'America/Vancouver' => 'CA', 'America/Whitehorse' => 'CA', - 'America/Winnipeg' => 'CA', 'America/Yakutat' => 'US', 'America/Yellowknife' => 'CA', 'Antarctica/Casey' => 'AQ', - 'Antarctica/Davis' => 'AQ', 'Antarctica/DumontDUrville' => 'AQ', 'Antarctica/Mawson' => 'AQ', - 'Antarctica/McMurdo' => 'AQ', 'Antarctica/Palmer' => 'AQ', 'Antarctica/Rothera' => 'AQ', 'Antarctica/South_Pole' => 'AQ', - 'Antarctica/Syowa' => 'AQ', 'Antarctica/Vostok' => 'AQ', 'Arctic/Longyearbyen' => 'SJ', 'Asia/Aden' => 'YE', - 'Asia/Almaty' => 'KZ', 'Asia/Amman' => 'JO', 'Asia/Anadyr' => 'RU', 'Asia/Aqtau' => 'KZ', 'Asia/Aqtobe' => 'KZ', - 'Asia/Ashgabat' => 'TM', 'Asia/Baghdad' => 'IQ', 'Asia/Bahrain' => 'BH', 'Asia/Baku' => 'AZ', - 'Asia/Bangkok' => 'TH', 'Asia/Beirut' => 'LB', 'Asia/Bishkek' => 'KG', 'Asia/Brunei' => 'BN', 'Asia/Calcutta' => 'IN', - 'Asia/Choibalsan' => 'MN', 'Asia/Chongqing' => 'CN', 'Asia/Colombo' => 'LK', 'Asia/Damascus' => 'SY', - 'Asia/Dhaka' => 'BD', 'Asia/Dili' => 'TL', 'Asia/Dubai' => 'AE', 'Asia/Dushanbe' => 'TJ', 'Asia/Gaza' => 'PS', - 'Asia/Harbin' => 'CN', 'Asia/Hong_Kong' => 'HK', 'Asia/Hovd' => 'MN', 'Asia/Irkutsk' => 'RU', 'Asia/Jakarta' => 'ID', - 'Asia/Jayapura' => 'ID', 'Asia/Jerusalem' => 'IL', 'Asia/Kabul' => 'AF', 'Asia/Kamchatka' => 'RU', - 'Asia/Karachi' => 'PK', 'Asia/Kashgar' => 'CN', 'Asia/Katmandu' => 'NP', 'Asia/Krasnoyarsk' => 'RU', - 'Asia/Kuala_Lumpur' => 'MY', 'Asia/Kuching' => 'MY', 'Asia/Kuwait' => 'KW', 'Asia/Macau' => 'MO', - 'Asia/Magadan' => 'RU', 'Asia/Makassar' => 'ID', 'Asia/Manila' => 'PH', 'Asia/Muscat' => 'OM', 'Asia/Nicosia' => 'CY', - 'Asia/Novosibirsk' => 'RU', 'Asia/Omsk' => 'RU', 'Asia/Oral' => 'KZ', 'Asia/Phnom_Penh' => 'KH', - 'Asia/Pontianak' => 'ID', 'Asia/Pyongyang' => 'KP', 'Asia/Qatar' => 'QA', 'Asia/Qyzylorda' => 'KZ', - 'Asia/Rangoon' => 'MM', 'Asia/Riyadh' => 'SA', 'Asia/Saigon' => 'VN', 'Asia/Sakhalin' => 'RU', 'Asia/Samarkand' => 'UZ', - 'Asia/Seoul' => 'KR', 'Asia/Shanghai' => 'CN', 'Asia/Singapore' => 'SG', 'Asia/Taipei' => 'TW', - 'Asia/Tashkent' => 'UZ', 'Asia/Tbilisi' => 'GE', 'Asia/Tehran' => 'IR', 'Asia/Thimphu' => 'BT', - 'Asia/Tokyo' => 'JP', 'Asia/Ulaanbaatar' => 'MN', 'Asia/Urumqi' => 'CN', 'Asia/Vientiane' => 'LA', - 'Asia/Vladivostok' => 'RU', 'Asia/Yakutsk' => 'RU', 'Asia/Yekaterinburg' => 'RU', 'Asia/Yerevan' => 'AM', - 'Atlantic/Azores' => 'PT', 'Atlantic/Bermuda' => 'BM', 'Atlantic/Canary' => 'ES', 'Atlantic/Cape_Verde' => 'CV', - 'Atlantic/Faeroe' => 'FO', 'Atlantic/Jan_Mayen' => 'SJ', 'Atlantic/Madeira' => 'PT', 'Atlantic/Reykjavik' => 'IS', - 'Atlantic/South_Georgia' => 'GS', 'Atlantic/St_Helena' => 'SH', 'Atlantic/Stanley' => 'FK', 'Australia/Adelaide' => 'AU', - 'Australia/Brisbane' => 'AU', 'Australia/Broken_Hill' => 'AU', 'Australia/Currie' => 'AU', 'Australia/Darwin' => 'AU', - 'Australia/Eucla' => 'AU', 'Australia/Hobart' => 'AU', 'Australia/Lindeman' => 'AU', 'Australia/Lord_Howe' => 'AU', - 'Australia/Melbourne' => 'AU', 'Australia/Perth' => 'AU', 'Australia/Sydney' => 'AU', 'Etc/GMT' => '001', - 'Etc/GMT-1' => '001', 'Etc/GMT-2' => '001', 'Etc/GMT-3' => '001', 'Etc/GMT-4' => '001', 'Etc/GMT-5' => '001', - 'Etc/GMT-6' => '001', 'Etc/GMT-7' => '001', 'Etc/GMT-8' => '001', 'Etc/GMT-9' => '001', 'Etc/GMT-10' => '001', - 'Etc/GMT-11' => '001', 'Etc/GMT-12' => '001', 'Etc/GMT-13' => '001', 'Etc/GMT-14' => '001', 'Etc/GMT+1' => '001', - 'Etc/GMT+2' => '001', 'Etc/GMT+3' => '001', 'Etc/GMT+4' => '001', 'Etc/GMT+5' => '001', 'Etc/GMT+6' => '001', - 'Etc/GMT+7' => '001', 'Etc/GMT+8' => '001', 'Etc/GMT+9' => '001', 'Etc/GMT+10' => '001', 'Etc/GMT+11' => '001', - 'Etc/GMT+12' => '001', 'Etc/Unknown' => '001', 'Europe/Amsterdam' => 'NL', 'Europe/Andorra' => 'AD', - 'Europe/Athens' => 'GR', 'Europe/Belgrade' => 'RS', 'Europe/Berlin' => 'DE', 'Europe/Bratislava' => 'SK', - 'Europe/Brussels' => 'BE', 'Europe/Bucharest' => 'RO', 'Europe/Budapest' => 'HU', 'Europe/Chisinau' => 'MD', - 'Europe/Copenhagen' => 'DK', 'Europe/Dublin' => 'IE', 'Europe/Gibraltar' => 'GI', 'Europe/Guernsey' => 'GG', - 'Europe/Helsinki' => 'FI', 'Europe/Isle_of_Man' => 'IM', 'Europe/Istanbul' => 'TR', 'Europe/Jersey' => 'JE', - 'Europe/Kaliningrad' => 'RU', 'Europe/Kiev' => 'UA', 'Europe/Lisbon' => 'PT', 'Europe/Ljubljana' => 'SI', - 'Europe/London' => 'GB', 'Europe/Luxembourg' => 'LU', 'Europe/Madrid' => 'ES', 'Europe/Malta' => 'MT', - 'Europe/Mariehamn' => 'AX', 'Europe/Minsk' => 'BY', 'Europe/Monaco' => 'MC', 'Europe/Moscow' => 'RU', - 'Europe/Oslo' => 'NO', 'Europe/Paris' => 'FR', 'Europe/Podgorica' => 'ME', 'Europe/Prague' => 'CZ', - 'Europe/Riga' => 'LV', 'Europe/Rome' => 'IT', 'Europe/Samara' => 'RU', 'Europe/San_Marino' => 'SM', - 'Europe/Sarajevo' => 'BA', 'Europe/Simferopol' => 'UA', 'Europe/Skopje' => 'MK', 'Europe/Sofia' => 'BG', - 'Europe/Stockholm' => 'SE', 'Europe/Tallinn' => 'EE', 'Europe/Tirane' => 'AL', 'Europe/Uzhgorod' => 'UA', - 'Europe/Vaduz' => 'LI', 'Europe/Vatican' => 'VA', 'Europe/Vienna' => 'AT', 'Europe/Vilnius' => 'LT', - 'Europe/Volgograd' => 'RU', 'Europe/Warsaw' => 'PL', 'Europe/Zagreb' => 'HR', 'Europe/Zaporozhye' => 'UA', - 'Europe/Zurich' => 'CH', 'Indian/Antananarivo' => 'MG', 'Indian/Chagos' => 'IO', 'Indian/Christmas' => 'CX', - 'Indian/Cocos' => 'CC', 'Indian/Comoro' => 'KM', 'Indian/Kerguelen' => 'TF', 'Indian/Mahe' => 'SC', - 'Indian/Maldives' => 'MV', 'Indian/Mauritius' => 'MU', 'Indian/Mayotte' => 'YT', 'Indian/Reunion' => 'RE', - 'Pacific/Apia' => 'WS', 'Pacific/Auckland' => 'NZ', 'Pacific/Chatham' => 'NZ', 'Pacific/Easter' => 'CL', - 'Pacific/Efate' => 'VU', 'Pacific/Enderbury' => 'KI', 'Pacific/Fakaofo' => 'TK', 'Pacific/Fiji' => 'FJ', - 'Pacific/Funafuti' => 'TV', 'Pacific/Galapagos' => 'EC', 'Pacific/Gambier' => 'PF', 'Pacific/Guadalcanal' => 'SB', - 'Pacific/Guam' => 'GU', 'Pacific/Honolulu' => 'US', 'Pacific/Johnston' => 'UM', 'Pacific/Kiritimati' => 'KI', - 'Pacific/Kosrae' => 'FM', 'Pacific/Kwajalein' => 'MH', 'Pacific/Majuro' => 'MH', 'Pacific/Marquesas' => 'PF', - 'Pacific/Midway' => 'UM', 'Pacific/Nauru' => 'NR', 'Pacific/Niue' => 'NU', 'Pacific/Norfolk' => 'NF', - 'Pacific/Noumea' => 'NC', 'Pacific/Pago_Pago' => 'AS', 'Pacific/Palau' => 'PW', 'Pacific/Pitcairn' => 'PN', - 'Pacific/Ponape' => 'FM', 'Pacific/Port_Moresby' => 'PG', 'Pacific/Rarotonga' => 'CK', 'Pacific/Saipan' => 'MP', - 'Pacific/Tahiti' => 'PF', 'Pacific/Tarawa' => 'KI', 'Pacific/Tongatapu' => 'TO', 'Pacific/Truk' => 'FM', - 'Pacific/Wake' => 'UM', 'Pacific/Wallis' => 'WF', 'America/Indiana/Tell_City' => 'US', 'America/Resolute' => 'CA'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'territorytotimezone', 'Pacific/Fiji'); - $this->assertEquals("FJ", $value); - } - - /** - * test for reading timezonetoterritory from locale - * expected array - */ - public function testTimezoneToTerritory() - { - $value = Zend_Locale_Data::getList('de_AT', 'timezonetoterritory'); - $result = array('CI' => 'Africa/Abidjan', 'GH' => 'Africa/Accra', 'ET' => 'Africa/Addis_Ababa', - 'DZ' => 'Africa/Algiers', 'ER' => 'Africa/Asmera', 'ML' => 'Africa/Bamako', 'CF' => 'Africa/Bangui', - 'GM' => 'Africa/Banjul', 'GW' => 'Africa/Bissau', 'MW' => 'Africa/Blantyre', 'CG' => 'Africa/Brazzaville', - 'BI' => 'Africa/Bujumbura', 'EG' => 'Africa/Cairo', 'MA' => 'Africa/Casablanca', 'ES' => 'Africa/Ceuta', - 'GN' => 'Africa/Conakry', 'SN' => 'Africa/Dakar', 'TZ' => 'Africa/Dar_es_Salaam', 'DJ' => 'Africa/Djibouti', - 'CM' => 'Africa/Douala', 'EH' => 'Africa/El_Aaiun', 'SL' => 'Africa/Freetown', 'BW' => 'Africa/Gaborone', - 'ZW' => 'Africa/Harare', 'ZA' => 'Africa/Johannesburg', 'UG' => 'Africa/Kampala', 'SD' => 'Africa/Khartoum', - 'RW' => 'Africa/Kigali', 'CD' => 'Africa/Kinshasa', 'NG' => 'Africa/Lagos', 'GA' => 'Africa/Libreville', - 'TG' => 'Africa/Lome', 'AO' => 'Africa/Luanda', 'ZM' => 'Africa/Lusaka', 'GQ' => 'Africa/Malabo', - 'MZ' => 'Africa/Maputo', 'LS' => 'Africa/Maseru', 'SZ' => 'Africa/Mbabane', 'SO' => 'Africa/Mogadishu', - 'LR' => 'Africa/Monrovia', 'KE' => 'Africa/Nairobi', 'TD' => 'Africa/Ndjamena', 'NE' => 'Africa/Niamey', - 'MR' => 'Africa/Nouakchott', 'BF' => 'Africa/Ouagadougou', 'BJ' => 'Africa/Porto-Novo', 'ST' => 'Africa/Sao_Tome', - 'LY' => 'Africa/Tripoli', 'TN' => 'Africa/Tunis', 'NA' => 'Africa/Windhoek', 'US' => 'America/Adak', - 'AI' => 'America/Anguilla', 'AG' => 'America/Antigua', 'BR' => 'America/Araguaina', 'AR' => 'America/Argentina/La_Rioja', - 'AW' => 'America/Aruba', 'PY' => 'America/Asuncion', 'BB' => 'America/Barbados', 'BZ' => 'America/Belize', - 'CA' => 'America/Blanc-Sablon', 'CO' => 'America/Bogota', 'MX' => 'America/Cancun', 'VE' => 'America/Caracas', - 'GF' => 'America/Cayenne', 'KY' => 'America/Cayman', 'CR' => 'America/Costa_Rica', 'AN' => 'America/Curacao', - 'GL' => 'America/Danmarkshavn', 'DM' => 'America/Dominica', 'SV' => 'America/El_Salvador', 'TC' => 'America/Grand_Turk', - 'GD' => 'America/Grenada', 'GP' => 'America/Guadeloupe', 'GT' => 'America/Guatemala', 'EC' => 'America/Guayaquil', - 'GY' => 'America/Guyana', 'CU' => 'America/Havana', 'JM' => 'America/Jamaica', 'BO' => 'America/La_Paz', - 'PE' => 'America/Lima', 'NI' => 'America/Managua', 'MQ' => 'America/Martinique', 'PM' => 'America/Miquelon', - 'UY' => 'America/Montevideo', 'MS' => 'America/Montserrat', 'BS' => 'America/Nassau', 'PA' => 'America/Panama', - 'SR' => 'America/Paramaribo', 'TT' => 'America/Port_of_Spain', 'HT' => 'America/Port-au-Prince', - 'PR' => 'America/Puerto_Rico', 'CL' => 'America/Santiago', 'DO' => 'America/Santo_Domingo', 'KN' => 'America/St_Kitts', - 'LC' => 'America/St_Lucia', 'VI' => 'America/St_Thomas', 'VC' => 'America/St_Vincent', 'HN' => 'America/Tegucigalpa', - 'VG' => 'America/Tortola', 'AQ' => 'Antarctica/Casey', 'SJ' => 'Arctic/Longyearbyen', 'YE' => 'Asia/Aden', - 'KZ' => 'Asia/Almaty', 'JO' => 'Asia/Amman', 'RU' => 'Asia/Anadyr', 'TM' => 'Asia/Ashgabat', 'IQ' => 'Asia/Baghdad', - 'BH' => 'Asia/Bahrain', 'AZ' => 'Asia/Baku', 'TH' => 'Asia/Bangkok', 'LB' => 'Asia/Beirut', 'KG' => 'Asia/Bishkek', - 'BN' => 'Asia/Brunei', 'IN' => 'Asia/Calcutta', 'MN' => 'Asia/Choibalsan', 'CN' => 'Asia/Chongqing', - 'LK' => 'Asia/Colombo', 'SY' => 'Asia/Damascus', 'BD' => 'Asia/Dhaka', 'TL' => 'Asia/Dili', 'AE' => 'Asia/Dubai', - 'TJ' => 'Asia/Dushanbe', 'PS' => 'Asia/Gaza', 'HK' => 'Asia/Hong_Kong', 'ID' => 'Asia/Jakarta', 'IL' => 'Asia/Jerusalem', - 'AF' => 'Asia/Kabul', 'PK' => 'Asia/Karachi', 'NP' => 'Asia/Katmandu', 'MY' => 'Asia/Kuala_Lumpur', - 'KW' => 'Asia/Kuwait', 'MO' => 'Asia/Macau', 'PH' => 'Asia/Manila', 'OM' => 'Asia/Muscat', 'CY' => 'Asia/Nicosia', - 'KH' => 'Asia/Phnom_Penh', 'KP' => 'Asia/Pyongyang', 'QA' => 'Asia/Qatar', 'MM' => 'Asia/Rangoon', - 'SA' => 'Asia/Riyadh', 'VN' => 'Asia/Saigon', 'UZ' => 'Asia/Samarkand', 'KR' => 'Asia/Seoul', 'SG' => 'Asia/Singapore', - 'TW' => 'Asia/Taipei', 'GE' => 'Asia/Tbilisi', 'IR' => 'Asia/Tehran', 'BT' => 'Asia/Thimphu', 'JP' => 'Asia/Tokyo', - 'LA' => 'Asia/Vientiane', 'AM' => 'Asia/Yerevan', 'PT' => 'Atlantic/Azores', 'BM' => 'Atlantic/Bermuda', - 'CV' => 'Atlantic/Cape_Verde', 'FO' => 'Atlantic/Faeroe', 'IS' => 'Atlantic/Reykjavik', 'GS' => 'Atlantic/South_Georgia', - 'SH' => 'Atlantic/St_Helena', 'FK' => 'Atlantic/Stanley', 'AU' => 'Australia/Adelaide', '001' => 'Etc/GMT', - 'NL' => 'Europe/Amsterdam', 'AD' => 'Europe/Andorra', 'GR' => 'Europe/Athens', 'RS' => 'Europe/Belgrade', - 'DE' => 'Europe/Berlin', 'SK' => 'Europe/Bratislava', 'BE' => 'Europe/Brussels', 'RO' => 'Europe/Bucharest', - 'HU' => 'Europe/Budapest', 'MD' => 'Europe/Chisinau', 'DK' => 'Europe/Copenhagen', 'IE' => 'Europe/Dublin', - 'GI' => 'Europe/Gibraltar', 'GG' => 'Europe/Guernsey', 'FI' => 'Europe/Helsinki', 'IM' => 'Europe/Isle_of_Man', - 'TR' => 'Europe/Istanbul', 'JE' => 'Europe/Jersey', 'UA' => 'Europe/Kiev', 'SI' => 'Europe/Ljubljana', - 'GB' => 'Europe/London', 'LU' => 'Europe/Luxembourg', 'MT' => 'Europe/Malta', 'AX' => 'Europe/Mariehamn', - 'BY' => 'Europe/Minsk', 'MC' => 'Europe/Monaco', 'NO' => 'Europe/Oslo', 'FR' => 'Europe/Paris', 'ME' => 'Europe/Podgorica', - 'CZ' => 'Europe/Prague', 'LV' => 'Europe/Riga', 'IT' => 'Europe/Rome', 'SM' => 'Europe/San_Marino', - 'BA' => 'Europe/Sarajevo', 'MK' => 'Europe/Skopje', 'BG' => 'Europe/Sofia', 'SE' => 'Europe/Stockholm', - 'EE' => 'Europe/Tallinn', 'AL' => 'Europe/Tirane', 'LI' => 'Europe/Vaduz', 'VA' => 'Europe/Vatican', - 'AT' => 'Europe/Vienna', 'LT' => 'Europe/Vilnius', 'PL' => 'Europe/Warsaw', 'HR' => 'Europe/Zagreb', - 'CH' => 'Europe/Zurich', 'MG' => 'Indian/Antananarivo', 'IO' => 'Indian/Chagos', 'CX' => 'Indian/Christmas', - 'CC' => 'Indian/Cocos', 'KM' => 'Indian/Comoro', 'TF' => 'Indian/Kerguelen', 'SC' => 'Indian/Mahe', - 'MV' => 'Indian/Maldives', 'MU' => 'Indian/Mauritius', 'YT' => 'Indian/Mayotte', 'RE' => 'Indian/Reunion', - 'WS' => 'Pacific/Apia', 'NZ' => 'Pacific/Auckland', 'VU' => 'Pacific/Efate', 'KI' => 'Pacific/Enderbury', - 'TK' => 'Pacific/Fakaofo', 'FJ' => 'Pacific/Fiji', 'TV' => 'Pacific/Funafuti', 'PF' => 'Pacific/Gambier', - 'SB' => 'Pacific/Guadalcanal', 'GU' => 'Pacific/Guam', 'UM' => 'Pacific/Johnston', 'FM' => 'Pacific/Kosrae', - 'MH' => 'Pacific/Kwajalein', 'NR' => 'Pacific/Nauru', 'NU' => 'Pacific/Niue', 'NF' => 'Pacific/Norfolk', - 'NC' => 'Pacific/Noumea', 'AS' => 'Pacific/Pago_Pago', 'PW' => 'Pacific/Palau', 'PN' => 'Pacific/Pitcairn', - 'PG' => 'Pacific/Port_Moresby', 'CK' => 'Pacific/Rarotonga', 'MP' => 'Pacific/Saipan', 'TO' => 'Pacific/Tongatapu', - 'WF' => 'Pacific/Wallis'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'timezonetoterritory', 'FJ'); - $this->assertEquals("Pacific/Fiji", $value); - } - - /** - * test for reading citytotimezone from locale - * expected array - */ - public function testCityToTimezone() - { - $value = Zend_Locale_Data::getList('de_AT', 'citytotimezone'); - $result = array('Etc/Unknown' => 'Unbekannt', 'Europe/Tirane' => 'Tirana', 'Asia/Yerevan' => 'Erivan', - 'America/Curacao' => 'Curaçao', 'Antarctica/South_Pole' => 'Südpol', 'Antarctica/Vostok' => 'Wostok', - 'Antarctica/DumontDUrville' => "Dumont D'Urville", 'Europe/Vienna' => 'Wien', 'Europe/Brussels' => 'Brüssel', - 'Africa/Ouagadougou' => 'Wagadugu', 'Atlantic/Bermuda' => 'Bermudas', 'America/St_Johns' => "St. John's", - 'Europe/Zurich' => 'Zürich', 'Pacific/Easter' => 'Osterinsel', 'America/Havana' => 'Havanna', - 'Atlantic/Cape_Verde' => 'Kap Verde', 'Indian/Christmas' => 'Weihnachts-Inseln', 'Asia/Nicosia' => 'Nikosia', - 'Africa/Djibouti' => 'Dschibuti', 'Europe/Copenhagen' => 'Kopenhagen', 'Africa/Algiers' => 'Algier', - 'Africa/Cairo' => 'Kairo', 'Africa/El_Aaiun' => 'El Aaiún', 'Atlantic/Canary' => 'Kanaren', - 'Africa/Addis_Ababa' => 'Addis Abeba', 'Pacific/Fiji' => 'Fidschi', 'Atlantic/Faeroe' => 'Färöer', - 'Asia/Tbilisi' => 'Tiflis', 'Africa/Accra' => 'Akkra', - 'Europe/Athens' => 'Athen', 'Atlantic/South_Georgia' => 'Süd-Georgien', 'Asia/Hong_Kong' => 'Hongkong', - 'Asia/Baghdad' => 'Bagdad', 'Asia/Tehran' => 'Teheran', 'Europe/Rome' => 'Rom', 'America/Jamaica' => 'Jamaika', - 'Asia/Tokyo' => 'Tokio', 'Asia/Bishkek' => 'Bischkek', 'Indian/Comoro' => 'Komoren', 'America/St_Kitts' => 'St. Kitts', - 'Asia/Pyongyang' => 'Pjöngjang', 'America/Cayman' => 'Kaimaninseln', 'Asia/Aqtobe' => 'Aktobe', - 'America/St_Lucia' => 'St. Lucia', 'Europe/Vilnius' => 'Wilna', 'Europe/Luxembourg' => 'Luxemburg', - 'Africa/Tripoli' => 'Tripolis', 'Europe/Chisinau' => 'Kischinau', - 'Asia/Macau' => 'Macao', 'Indian/Maldives' => 'Malediven', 'America/Mexico_City' => 'Mexiko-Stadt', - 'Africa/Niamey' => 'Niger', 'Asia/Muscat' => 'Muskat', 'Europe/Warsaw' => 'Warschau', - 'Atlantic/Azores' => 'Azoren', 'Europe/Lisbon' => 'Lissabon', 'America/Asuncion' => 'Asunción', - 'Asia/Qatar' => 'Katar', 'Indian/Reunion' => 'Réunion', 'Europe/Bucharest' => 'Bukarest', - 'Europe/Moscow' => 'Moskau', 'Asia/Yekaterinburg' => 'Jekaterinburg', 'Asia/Novosibirsk' => 'Nowosibirsk', - 'Asia/Krasnoyarsk' => 'Krasnojarsk', 'Asia/Yakutsk' => 'Jakutsk', 'Asia/Vladivostok' => 'Wladiwostok', - 'Asia/Sakhalin' => 'Sachalin', 'Asia/Kamchatka' => 'Kamtschatka', 'Asia/Riyadh' => 'Riad', - 'Africa/Khartoum' => 'Khartum', 'Asia/Singapore' => 'Singapur', 'Atlantic/St_Helena' => 'St. Helena', - 'Africa/Mogadishu' => 'Mogadischu', 'Africa/Sao_Tome' => 'São Tomé', 'America/El_Salvador' => 'Salvador', - 'Asia/Damascus' => 'Damaskus', 'Asia/Dushanbe' => 'Duschanbe', 'America/Port_of_Spain' => 'Port-of-Spain', - 'Asia/Taipei' => 'Taipeh', 'Africa/Dar_es_Salaam' => 'Daressalam', 'Europe/Uzhgorod' => 'Uschgorod', - 'Europe/Kiev' => 'Kiew', 'Europe/Zaporozhye' => 'Saporischja', - 'Asia/Tashkent' => 'Taschkent', 'America/St_Vincent' => 'St. Vincent', 'America/St_Thomas' => 'St. Thomas'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'citytotimezone', 'Pacific/Fiji'); - $this->assertEquals("Fidschi", $value); - } - - /** - * test for reading timezonetocity from locale - * expected array - */ - public function testTimezoneToCity() - { - $value = Zend_Locale_Data::getList('de_AT', 'timezonetocity'); - $result = array('Unbekannt' => 'Etc/Unknown', 'Tirana' => 'Europe/Tirane', 'Erivan' => 'Asia/Yerevan', - 'Curaçao' => 'America/Curacao', 'Südpol' => 'Antarctica/South_Pole', 'Wostok' => 'Antarctica/Vostok', - "Dumont D'Urville" => 'Antarctica/DumontDUrville', 'Wien' => 'Europe/Vienna', 'Brüssel' => 'Europe/Brussels', - 'Wagadugu' => 'Africa/Ouagadougou', 'Bermudas' => 'Atlantic/Bermuda', "St. John's" => 'America/St_Johns', - 'Zürich' => 'Europe/Zurich', 'Osterinsel' => 'Pacific/Easter', 'Havanna' => 'America/Havana', - 'Kap Verde' => 'Atlantic/Cape_Verde', 'Weihnachts-Inseln' => 'Indian/Christmas', 'Nikosia' => 'Asia/Nicosia', - 'Dschibuti' => 'Africa/Djibouti', 'Kopenhagen' => 'Europe/Copenhagen', 'Algier' => 'Africa/Algiers', - 'Kairo' => 'Africa/Cairo', 'El Aaiún' => 'Africa/El_Aaiun', 'Kanaren' => 'Atlantic/Canary', - 'Addis Abeba' => 'Africa/Addis_Ababa', 'Fidschi' => 'Pacific/Fiji', 'Färöer' => 'Atlantic/Faeroe', - 'Tiflis' => 'Asia/Tbilisi', 'Akkra' => 'Africa/Accra', - 'Athen' => 'Europe/Athens', 'Süd-Georgien' => 'Atlantic/South_Georgia', 'Hongkong' => 'Asia/Hong_Kong', - 'Bagdad' => 'Asia/Baghdad', 'Teheran' => 'Asia/Tehran', 'Rom' => 'Europe/Rome', 'Jamaika' => 'America/Jamaica', - 'Tokio' => 'Asia/Tokyo', 'Bischkek' => 'Asia/Bishkek', 'Komoren' => 'Indian/Comoro', 'St. Kitts' => 'America/St_Kitts', - 'Pjöngjang' => 'Asia/Pyongyang', 'Kaimaninseln' => 'America/Cayman', 'Aktobe' => 'Asia/Aqtobe', - 'St. Lucia' => 'America/St_Lucia', 'Wilna' => 'Europe/Vilnius', 'Luxemburg' => 'Europe/Luxembourg', - 'Tripolis' => 'Africa/Tripoli', 'Kischinau' => 'Europe/Chisinau', - 'Macao' => 'Asia/Macau', 'Malediven' => 'Indian/Maldives', 'Mexiko-Stadt' => 'America/Mexico_City', - 'Niger' => 'Africa/Niamey', 'Muskat' => 'Asia/Muscat', 'Warschau' => 'Europe/Warsaw', 'Azoren' => 'Atlantic/Azores', - 'Lissabon' => 'Europe/Lisbon', 'Asunción' => 'America/Asuncion', 'Katar' => 'Asia/Qatar', - 'Réunion' => 'Indian/Reunion', 'Bukarest' => 'Europe/Bucharest', 'Moskau' => 'Europe/Moscow', - 'Jekaterinburg' => 'Asia/Yekaterinburg', 'Nowosibirsk' => 'Asia/Novosibirsk', 'Krasnojarsk' => 'Asia/Krasnoyarsk', - 'Jakutsk' => 'Asia/Yakutsk', 'Wladiwostok' => 'Asia/Vladivostok', 'Sachalin' => 'Asia/Sakhalin', - 'Kamtschatka' => 'Asia/Kamchatka', 'Riad' => 'Asia/Riyadh', 'Khartum' => 'Africa/Khartoum', - 'Singapur' => 'Asia/Singapore', 'St. Helena' => 'Atlantic/St_Helena', 'Mogadischu' => 'Africa/Mogadishu', - 'São Tomé' => 'Africa/Sao_Tome', 'Salvador' => 'America/El_Salvador', 'Damaskus' => 'Asia/Damascus', - 'Duschanbe' => 'Asia/Dushanbe', 'Port-of-Spain' => 'America/Port_of_Spain', 'Taipeh' => 'Asia/Taipei', - 'Daressalam' => 'Africa/Dar_es_Salaam', 'Uschgorod' => 'Europe/Uzhgorod', 'Kiew' => 'Europe/Kiev', - 'Saporischja' => 'Europe/Zaporozhye', 'Taschkent' => 'Asia/Tashkent', - 'St. Vincent' => 'America/St_Vincent', 'St. Thomas' => 'America/St_Thomas'); - $this->assertEquals($result, $value); - - $value = Zend_Locale_Data::getContent('de_AT', 'timezonetocity', 'Fidschi'); - $this->assertEquals("Pacific/Fiji", $value); - } -} \ No newline at end of file diff --git a/tests/Zend/Locale/FormatTest.php b/tests/Zend/Locale/FormatTest.php deleted file mode 100644 index 71ad105ac2b9a81d2ae121222417db573929297a..0000000000000000000000000000000000000000 --- a/tests/Zend/Locale/FormatTest.php +++ /dev/null @@ -1,919 +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_Format - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FormatTest.php 10113 2008-07-15 20:07:16Z thomas $ - */ - - -/** - * Zend_Locale_Format - */ -require_once 'Zend/Locale/Format.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Locale - * @subpackage UnitTests - */ -class Zend_Locale_FormatTest extends PHPUnit_Framework_TestCase -{ - - /** - * teardown / cleanup - */ - public function tearDown() - { - // if the setlocale option is enabled, then don't change the setlocale below - if (defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE') && TESTS_ZEND_LOCALE_FORMAT_SETLOCALE === false) { - // I'm anticipating possible platform inconsistencies, so I'm leaving some debug comments for now. - //echo '<<<', setlocale(LC_NUMERIC, '0'); // show locale before changing - setlocale(LC_ALL, 'C'); // attempt to restore global setting i.e. test teardown - //echo '>>>', setlocale(LC_NUMERIC, '0'); // show locale after changing - //echo "\n"; - } else if (defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE')) { - setlocale(LC_ALL, TESTS_ZEND_LOCALE_FORMAT_SETLOCALE); - } - } - - - /** - * test getNumber - * expected integer - */ - public function testGetNumber() - { - $this->assertEquals( 0, Zend_Locale_Format::getNumber( 0) ); - $this->assertEquals(-1234567, Zend_Locale_Format::getNumber(-1234567) ); - $this->assertEquals( 1234567, Zend_Locale_Format::getNumber( 1234567) ); - $this->assertEquals( 0.1234567, Zend_Locale_Format::getNumber( 0.1234567)); - $this->assertEquals(-1234567.12345, Zend_Locale_Format::getNumber(-1234567.12345) ); - $this->assertEquals( 1234567.12345, Zend_Locale_Format::getNumber(1234567.12345) ); - $options = array('locale' => 'de'); - $this->assertEquals( 0, Zend_Locale_Format::getNumber( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getNumber( '-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getNumber( '1234567', $options)); - $this->assertEquals( 0.1234567, Zend_Locale_Format::getNumber(' 0,1234567', $options)); - $this->assertEquals(-1234567.12345, Zend_Locale_Format::getNumber('-1.234.567,12345', $options)); - $this->assertEquals( 1234567.12345, Zend_Locale_Format::getNumber(' 1.234.567,12345', $options)); - $options = array('locale' => 'de_AT'); - $this->assertEquals( 0, Zend_Locale_Format::getNumber( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getNumber( '-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getNumber( '1.234.567', $options)); - $this->assertEquals( 0.1234567, Zend_Locale_Format::getNumber( '0,1234567', $options)); - $this->assertEquals(-1234567.12345, Zend_Locale_Format::getNumber('-1.234.567,12345', $options)); - $this->assertEquals( 1234567.12345, Zend_Locale_Format::getNumber( '1.234.567,12345', $options)); - } - - - /** - * test to number - * expected string - */ - public function testToNumber() - { - $this->assertEquals('0', Zend_Locale_Format::toNumber(0) ); - $this->assertEquals('0', Zend_Locale_Format::toNumber(0, array('locale' => 'de'))); - - $options = array('locale' => 'de_AT'); - $this->assertEquals( '0', Zend_Locale_Format::toNumber( 0, $options)); - $this->assertEquals( '-1.234.567', Zend_Locale_Format::toNumber(-1234567, $options)); - $this->assertEquals( '1.234.567', Zend_Locale_Format::toNumber( 1234567, $options)); - $this->assertEquals( '0,1234567', Zend_Locale_Format::toNumber( 0.1234567,$options)); - $this->assertEquals( '-1.234.567,12345', Zend_Locale_Format::toNumber(-1234567.12345, $options)); - $this->assertEquals( '1.234.567,12345', Zend_Locale_Format::toNumber( 1234567.12345, $options)); - $this->assertEquals( '1234567Ù«12345', Zend_Locale_Format::toNumber( 1234567.12345, array('locale' => 'ar_QA'))); - $this->assertEquals( '1234567Ù«12345-', Zend_Locale_Format::toNumber(-1234567.12345, array('locale' => 'ar_QA'))); - $this->assertEquals( '12,34,567.12345', Zend_Locale_Format::toNumber( 1234567.12345, array('locale' => 'dz_BT'))); - $this->assertEquals('-(1.234.567,12345)', Zend_Locale_Format::toNumber(-1234567.12345, array('locale' => 'mk_MK'))); - $this->assertEquals( '452.25', Zend_Locale_Format::toNumber( 452.25, array('locale' => 'en_US'))); - $this->assertEquals( '54,321.1234', Zend_Locale_Format::toNumber( 54321.1234, array('locale' => 'en_US'))); - $this->assertEquals( '1,23', Zend_Locale_Format::toNumber( 1.234567, array('locale' => 'de_DE', 'precision' => 2, 'number_format' => '0.00'))); - } - - - /** - * test isNumber - * expected boolean - */ - public function testIsNumber() - { - $this->assertTrue( Zend_Locale_Format::isNumber('-1.234.567,12345', array('locale' => 'de_AT'))); - $this->assertFalse(Zend_Locale_Format::isNumber('textwithoutnumber', array('locale' => 'de_AT'))); - } - - - /** - * test getFloat - * expected exception - */ - public function testgetFloat() - { - try { - $value = Zend_Locale_Format::getFloat('nocontent'); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $this->assertEquals( 0, Zend_Locale_Format::getFloat( 0 )); - $this->assertEquals(-1234567, Zend_Locale_Format::getFloat(-1234567 )); - $this->assertEquals( 1234567, Zend_Locale_Format::getFloat( 1234567 )); - $this->assertEquals( 0.1234567, Zend_Locale_Format::getFloat( 0.1234567)); - $this->assertEquals(-1234567.12345, Zend_Locale_Format::getFloat(-1234567.12345 )); - $this->assertEquals( 1234567.12345, Zend_Locale_Format::getFloat( 1234567.12345 )); - - $options = array('locale' => 'de'); - $this->assertEquals( 0, Zend_Locale_Format::getFloat( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getFloat( '-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getFloat( '1234567', $options)); - $this->assertEquals( 0.1234567, Zend_Locale_Format::getFloat( '0,1234567', $options)); - $this->assertEquals(-1234567.12345, Zend_Locale_Format::getFloat('-1.234.567,12345', $options)); - $this->assertEquals( 1234567.12345, Zend_Locale_Format::getFloat( '1.234.567,12345', $options)); - - $options = array('locale' => 'de_AT'); - $this->assertEquals( 0, Zend_Locale_Format::getFloat( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getFloat( '-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getFloat( '1.234.567', $options)); - $this->assertEquals( 0.1234567, Zend_Locale_Format::getFloat( '0,1234567', $options)); - $this->assertEquals(-1234567.12345, Zend_Locale_Format::getFloat('-1.234.567,12345', $options)); - $this->assertEquals( 1234567.12345, Zend_Locale_Format::getFloat( '1.234.567,12345', $options)); - - $options = array('precision' => 2, 'locale' => 'de_AT'); - $this->assertEquals( 0, Zend_Locale_Format::getFloat( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getFloat( '-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getFloat( '1.234.567', $options)); - $this->assertEquals( 0.12, Zend_Locale_Format::getFloat( '0,1234567', $options)); - $this->assertEquals(-1234567.12, Zend_Locale_Format::getFloat('-1.234.567,12345', $options)); - $this->assertEquals( 1234567.12, Zend_Locale_Format::getFloat( '1.234.567,12345', $options)); - - $options = array('precision' => 7, 'locale' => 'de_AT'); - $this->assertEquals('1234567.12345', Zend_Locale_Format::getFloat('1.234.567,12345', $options)); - } - - - /** - * test toFloat - * expected string - */ - public function testToFloat() - { - $this->assertEquals('0', Zend_Locale_Format::toFloat(0) ); - $this->assertEquals('0', Zend_Locale_Format::toFloat(0, array('locale' => 'de'))); - - $options = array('locale' => 'de_AT'); - $this->assertEquals( '0', Zend_Locale_Format::toFloat( 0, $options)); - $this->assertEquals('-1.234.567', Zend_Locale_Format::toFloat(-1234567, $options)); - $this->assertEquals( '1.234.567', Zend_Locale_Format::toFloat( 1234567, $options)); - $this->assertEquals( '0,1234567', Zend_Locale_Format::toFloat( 0.1234567, $options)); - $this->assertEquals('-1.234.567,12345', Zend_Locale_Format::toFloat(-1234567.12345, $options)); - $this->assertEquals( '1.234.567,12345', Zend_Locale_Format::toFloat( 1234567.12345, $options)); - - $options = array('locale' => 'ar_QA'); - $this->assertEquals( '1234567Ù«12345', Zend_Locale_Format::toFloat( 1234567.12345, $options )); - $this->assertEquals( '1234567Ù«12345-', Zend_Locale_Format::toFloat(-1234567.12345, $options )); - $this->assertEquals( '12,34,567.12345', Zend_Locale_Format::toFloat( 1234567.12345, array('locale' => 'dz_BT'))); - $this->assertEquals('-(1.234.567,12345)', Zend_Locale_Format::toFloat(-1234567.12345, array('locale' => 'mk_MK'))); - - $options = array('precision' => 2, 'locale' => 'de_AT'); - $this->assertEquals( '0,00', Zend_Locale_Format::toFloat( 0, $options)); - $this->assertEquals('-1.234.567,00', Zend_Locale_Format::toFloat(-1234567, $options)); - $this->assertEquals( '1.234.567,00', Zend_Locale_Format::toFloat( 1234567, $options)); - $this->assertEquals( '0,12', Zend_Locale_Format::toFloat( 0.1234567, $options)); - $this->assertEquals('-1.234.567,12', Zend_Locale_Format::toFloat(-1234567.12345, $options)); - $this->assertEquals( '1.234.567,12', Zend_Locale_Format::toFloat( 1234567.12345, $options)); - - $options = array('precision' => 7, 'locale' => 'de_AT'); - $this->assertEquals('1.234.567,1234500', Zend_Locale_Format::toFloat(1234567.12345, $options)); - } - - - /** - * test isFloat - * expected boolean - */ - public function testIsFloat() - { - $this->assertTrue( Zend_Locale_Format::isFloat('-1.234.567,12345', array('locale' => 'de_AT'))); - $this->assertFalse(Zend_Locale_Format::isFloat('textwithoutnumber', array('locale' => 'de_AT'))); - } - - - /** - * test getInteger - * expected integer - */ - public function testgetInteger() - { - $this->assertEquals( 0, Zend_Locale_Format::getInteger( 0 )); - $this->assertEquals(-1234567, Zend_Locale_Format::getInteger(-1234567 )); - $this->assertEquals( 1234567, Zend_Locale_Format::getInteger( 1234567 )); - $this->assertEquals( 0, Zend_Locale_Format::getInteger( 0.1234567)); - $this->assertEquals(-1234567, Zend_Locale_Format::getInteger(-1234567.12345 )); - $this->assertEquals( 1234567, Zend_Locale_Format::getInteger( 1234567.12345 )); - - $options = array('locale' => 'de'); - $this->assertEquals( 0, Zend_Locale_Format::getInteger( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getInteger('-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getInteger( '1234567', $options)); - $this->assertEquals( 0, Zend_Locale_Format::getInteger( '0,1234567', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getInteger('-1.234.567,12345', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getInteger( '1.234.567,12345', $options)); - - $options = array('locale' => 'de_AT'); - $this->assertEquals( 0, Zend_Locale_Format::getInteger( '0', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getInteger( '-1234567', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getInteger( '1.234.567', $options)); - $this->assertEquals( 0, Zend_Locale_Format::getInteger( '0,1234567', $options)); - $this->assertEquals(-1234567, Zend_Locale_Format::getInteger('-1.234.567,12345', $options)); - $this->assertEquals( 1234567, Zend_Locale_Format::getInteger( '1.234.567,12345', $options)); - } - - - /** - * test toInteger - * expected string - */ - public function testtoInteger() - { - $this->assertEquals('0', Zend_Locale_Format::toInteger(0 )); - $this->assertEquals('0', Zend_Locale_Format::toInteger(0, array('locale' => 'de'))); - - $options = array('locale' => 'de_AT'); - $this->assertEquals( '0', Zend_Locale_Format::toInteger( 0, $options)); - $this->assertEquals( '-1.234.567', Zend_Locale_Format::toInteger(-1234567, $options)); - $this->assertEquals( '1.234.567', Zend_Locale_Format::toInteger( 1234567, $options)); - $this->assertEquals( '0', Zend_Locale_Format::toInteger( 0.1234567, $options)); - $this->assertEquals( '-1.234.567', Zend_Locale_Format::toInteger(-1234567.12345, $options)); - $this->assertEquals( '1.234.567', Zend_Locale_Format::toInteger( 1234567.12345, $options)); - $this->assertEquals( '1234567', Zend_Locale_Format::toInteger( 1234567.12345, array('locale' => 'ar_QA'))); - $this->assertEquals( '1234567-', Zend_Locale_Format::toInteger(-1234567.12345, array('locale' => 'ar_QA'))); - $this->assertEquals( '12,34,567', Zend_Locale_Format::toInteger( 1234567.12345, array('locale' => 'dz_BT'))); - $this->assertEquals('-(1.234.567)', Zend_Locale_Format::toInteger(-1234567.12345, array('locale' => 'mk_MK'))); - } - - - /** - * test isInteger - * expected boolean - */ - public function testIsInteger() - { - $this->assertTrue( Zend_Locale_Format::isInteger('-1.234.567,12345', array('locale' => 'de_AT'))); - $this->assertFalse(Zend_Locale_Format::isInteger('textwithoutnumber', array('locale' => 'de_AT'))); - } - - - /** - * test getDate - * expected array - */ - public function testgetDate() - { - try { - $value = Zend_Locale_Format::getDate('no content'); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - $this->assertTrue(is_array(Zend_Locale_Format::getDate('10.10.06'))); - $this->assertEquals(5, count(Zend_Locale_Format::getDate('10.10.06', array('date_format' => 'dd.MM.yy')))); - - $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'dd.MM.yy')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(06, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10.11.2006', array('date_format' => 'dd.MM.yy')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('2006.13.01', array('date_format' => 'dd.MM.yy')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('2006.13.01', array('date_format' => 'dd.MM.yy', 'fix_date' => true)); - $this->assertEquals(13, $value['day'] ); - $this->assertEquals(1, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('2006.01.13', array('date_format' => 'dd.MM.yy')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('2006.01.13', array('date_format' => 'dd.MM.yy', 'fix_date' => true)); - $this->assertEquals(13, $value['day'] ); - $this->assertEquals(1, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('101106', array('date_format' => 'ddMMyy')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(6, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10112006', array('date_format' => 'ddMMyyyy')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10 Nov 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10 November 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('November 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('November 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - - try { - $value = Zend_Locale_Format::getDate('Nov 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('Nov 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - - try { - $value = Zend_Locale_Format::getDate('2006 10 Nov', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('2006 10 Nov', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('2006 Nov 10', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'yy.dd.MM')); - $this->assertEquals(11, $value['day'] ); - $this->assertEquals(6, $value['month']); - $this->assertEquals(10, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'dd.yy.MM')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(6, $value['month']); - $this->assertEquals(11, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10.11.06', array('locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(6, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10.11.2006', array('locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('2006.13.01', array('locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('2006.13.01', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(13, $value['day'] ); - $this->assertEquals(1, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('2006.01.13', array('locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('2006.01.13', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(13, $value['day'] ); - $this->assertEquals(1, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('101106', array('locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(6, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10112006', array('locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10 Nov 2006', array('locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10 November 2006', array('locale' => 'de_AT')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('November 10 2006', array('locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('November 10 2006', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('April 10 2006', array('locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('April 10 2006', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(4, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('Nov 10 2006', array('locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('Nov 10 2006', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - - try { - $value = Zend_Locale_Format::getDate('Nov 10 2006', array('locale' => 'de_AT')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); - // success - } - $value = Zend_Locale_Format::getDate('2006 10 Nov', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('01.April.2006', array('date_format' => 'dd.MMMM.yy', 'locale' => 'de_AT')); - $this->assertEquals(1, $value['day'] ); - $this->assertEquals(4, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('Montag, 01.April.2006', array('date_format' => 'EEEE, dd.MMMM.yy', 'locale' => 'de_AT')); - $this->assertEquals(1, $value['day'] ); - $this->assertEquals(4, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - try { - $value = Zend_Locale_Format::getDate('13.2006.11', array('date_format' => 'dd.MM.yy')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - Zend_Locale_Format::setOptions(array('format_type' => 'php')); - $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'd.m.Y')); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(6, $value['year'] ); - - $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'd.m.Y', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(6, $value['year'] ); - - $this->assertTrue(is_array(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss')))); - Zend_Locale_Format::setOptions(array('format_type' => 'iso')); - - $value = Zend_Locale_Format::getDate('2006 Nov 10', array('locale' => 'de_AT', 'fix_date' => true)); - $this->assertEquals(10, $value['day'] ); - $this->assertEquals(11, $value['month']); - $this->assertEquals(2006, $value['year'] ); - - $value = Zend_Locale_Format::getDate('anything February 31 2007.', array('date_format' => 'M d Y', 'locale'=>'en')); - $this->assertEquals(31, $value['day'] ); - $this->assertEquals(2, $value['month']); - $this->assertEquals(2007, $value['year'] ); - } - - - /** - * test getTime - * expected array - */ - public function testgetTime() - { - try { - $value = Zend_Locale_Format::getTime('no content'); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $this->assertTrue(is_array(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss')))); - $options = array('date_format' => 'h:mm:ss a', 'locale' => 'en'); - $this->assertTrue(is_array(Zend_Locale_Format::getTime('11:14:55 am', $options))); - $this->assertTrue(is_array(Zend_Locale_Format::getTime('12:14:55 am', $options))); - $this->assertTrue(is_array(Zend_Locale_Format::getTime('11:14:55 pm', $options))); - $this->assertTrue(is_array(Zend_Locale_Format::getTime('12:14:55 pm', $options))); - - try { - $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'nocontent')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - try { - $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'ZZZZ')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - try { - $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss.x')); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $this->assertEquals(5, count(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss')))); - - $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss')); - $this->assertEquals(13, $value['hour'] ); - $this->assertEquals(14, $value['minute']); - $this->assertEquals(55, $value['second']); - - $value = Zend_Locale_Format::getTime('131455', array('date_format' => 'HH:mm:ss')); - $this->assertEquals(13, $value['hour'] ); - $this->assertEquals(14, $value['minute']); - $this->assertEquals(55, $value['second']); - } - - - /** - * test isDate - * expected boolean - */ - public function testIsDate() - { - $this->assertTrue( Zend_Locale_Format::checkDateFormat('13.Nov.2006', array('locale' => 'de_AT'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('13.XXX.2006', array('locale' => 'ar_EG'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('nodate')); - - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20.01.2006', array('date_format' => 'M-d-y'))); - $this->assertTrue( Zend_Locale_Format::checkDateFormat('20.01.2006', array('date_format' => 'd-M-y'))); - - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20.April', array('date_format' => 'dd.MMMM.YYYY'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20.April', array('date_format' => 'MMMM.YYYY' ))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20', array('date_format' => 'dd.MMMM.YYYY'))); - $this->assertTrue( Zend_Locale_Format::checkDateFormat('April.2007', array('date_format' => 'MMMM.YYYY' ))); - $this->assertTrue( Zend_Locale_Format::checkDateFormat('20.April.2007', array('date_format' => 'dd.YYYY' ))); - - $this->assertFalse(Zend_Locale_Format::checkDateFormat('2006.04', array('date_format' => 'yyyy.MMMM.dd' ))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20.04.2007 10:11', array('date_format' => 'dd.MMMM.yyyy HH:mm:ss'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20.04.2007 10:20', array('date_format' => 'dd.MMMM.yyyy HH:ss:mm'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('20.04.2007 00:20', array('date_format' => 'dd.MMMM.yyyy ss:mm:HH'))); - } - - - /** - * test checkDateFormat -> time - * expected boolean - */ - public function testCheckTime() - { - $this->assertTrue( Zend_Locale_Format::checkDateFormat('13:10:55', array('date_format' => 'HH:mm:ss', 'locale' => 'de_AT'))); - $this->assertTrue( Zend_Locale_Format::checkDateFormat('11:10:55 am', array('date_format' => 'HH:mm:ss', 'locale' => 'ar_EG'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('notime')); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('13:10', array('date_format' => 'HH:mm:ss', 'locale' => 'de_AT'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('13', array('date_format' => 'HH:mm', 'locale' => 'de_AT'))); - $this->assertFalse(Zend_Locale_Format::checkDateFormat('00:13', array('date_format' => 'ss:mm:HH', 'locale' => 'de_AT'))); - } - - - /** - * test toNumberSystem - * expected string - */ - public function testToNumberSystem() - { - try { - $value = Zend_Locale_Format::convertNumerals('١١٠', 'xxxx'); - $this->fail("no conversion expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - try { - $value = Zend_Locale_Format::convertNumerals('١١٠', 'Arab', 'xxxx'); - $this->fail("no conversion expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $this->assertEquals('110', Zend_Locale_Format::convertNumerals('١١٠', 'Arab')); - $this->assertEquals('११०', Zend_Locale_Format::convertNumerals('١١٠', 'Arab', 'Deva')); - $this->assertEquals('११०', Zend_Locale_Format::convertNumerals('١١٠', 'arab', 'dEVa')); - $this->assertEquals('١١٠', Zend_Locale_Format::convertNumerals('110', 'Latn', 'Arab')); - $this->assertEquals('١١٠', Zend_Locale_Format::convertNumerals('110', 'latn', 'Arab')); - } - - /** - * test toNumberFormat - * expected string - */ - public function testToNumberFormat() - { - $locale = new Zend_Locale('de_AT'); - $this->assertEquals('0', Zend_Locale_Format::toNumber(0 )); - $this->assertEquals('0', Zend_Locale_Format::toNumber(0, array('locale' => 'de' ))); - $this->assertEquals('0', Zend_Locale_Format::toNumber(0, array('locale' => $locale))); - - $options = array('locale' => 'de_AT'); - $this->assertEquals('-1.234.567', Zend_Locale_Format::toNumber(-1234567, $options)); - $this->assertEquals( '1.234.567', Zend_Locale_Format::toNumber( 1234567, $options)); - $this->assertEquals( '0,1234567', Zend_Locale_Format::toNumber( 0.1234567, $options)); - $this->assertEquals('-1.234.567,12345', Zend_Locale_Format::toNumber(-1234567.12345, $options)); - $this->assertEquals( '1.234.567,12345', Zend_Locale_Format::toNumber( 1234567.12345, $options)); - $this->assertEquals( '1234567', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '##0', 'locale' => 'de_AT'))); - $this->assertEquals('1.23.45.67', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '#,#0', 'locale' => 'de_AT'))); - $this->assertEquals( '1234567,12', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '##0.00', 'locale' => 'de_AT'))); - $this->assertEquals( '1234567,12345', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '##0.###', 'locale' => 'de_AT'))); - $this->assertEquals('1.23.45.67', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '#,#0', 'locale' => 'de_AT'))); - $this->assertEquals( '12.34.567', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '#,##,##0', 'locale' => 'de_AT'))); - $this->assertEquals( '1.234.567,12', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '#,##0.00', 'locale' => 'de_AT'))); - $this->assertEquals('1.23.45.67,12', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '#,#0.00', 'locale' => 'de_AT'))); - $this->assertEquals( '1234567-', Zend_Locale_Format::toNumber(-1234567.12345, array('number_format' => '##0;##0-', 'locale' => 'de_AT'))); - $this->assertEquals( '1234567', Zend_Locale_Format::toNumber( 1234567.12345, array('number_format' => '##0;##0-', 'locale' => 'de_AT'))); - $this->assertEquals( '1.234.567,00', Zend_Locale_Format::toNumber( 1234567, array('number_format' => '#,##0.00', 'locale' => 'de_AT'))); - $this->assertEquals( '1.234.567,12', Zend_Locale_Format::toNumber( 1234567.123, array('precision' => 2, 'locale' => 'de_AT'))); - $this->assertEquals( '1234567,12-', Zend_Locale_Format::toNumber(-1234567.123, array('number_format' => '#0.00-', 'locale' => 'de_AT'))); - $this->assertEquals( '-12.345', Zend_Locale_Format::toNumber( -12345.67, array('precision' => 0, 'locale' => 'de_AT'))); - } - - /** - * test toNumberFormat2 - * expected string - */ - public function testToNumberFormat2() - { - $this->assertEquals((double) 1.7, (double) Zend_Locale_Format::toNumber(1.7, array('locale' => 'en'))); - $this->assertEquals((double) 2.3, (double) Zend_Locale_Format::toNumber(2.3, array('locale' => 'en'))); - } - - /** - * test setOption - * expected boolean - */ - public function testSetOption() - { - $this->assertEquals(7, count(Zend_Locale_Format::setOptions(array('format_type' => 'php')))); - $this->assertTrue(is_array(Zend_Locale_Format::setOptions())); - - try { - $this->assertTrue(Zend_Locale_Format::setOptions(array('format_type' => 'xxx'))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - try { - $this->assertTrue(Zend_Locale_Format::setOptions(array('myformat' => 'xxx'))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $format = Zend_Locale_Format::setOptions(array('locale' => 'de', 'number_format' => Zend_Locale_Format::STANDARD)); - $test = Zend_Locale_Data::getContent('de', 'decimalnumber'); - $this->assertEquals($test, $format['number_format']); - - try { - $this->assertFalse(Zend_Locale_Format::setOptions(array('number_format' => array('x' => 'x')))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $format = Zend_Locale_Format::setOptions(array('locale' => 'de', 'date_format' => Zend_Locale_Format::STANDARD)); - $test = Zend_Locale_Format::getDateFormat('de'); - $this->assertEquals($test, $format['date_format']); - - try { - $this->assertFalse(Zend_Locale_Format::setOptions(array('date_format' => array('x' => 'x')))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - try { - $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('fix_date' => 'no')))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - - $format = Zend_Locale_Format::setOptions(array('locale' => Zend_Locale_Format::STANDARD)); - $locale = new Zend_Locale(); - $this->assertEquals($locale, $format['locale']); - - try { - $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('locale' => 'nolocale')))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - try { - $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('precision' => 50)))); - $this->fail("exception expected"); - } catch (Zend_Locale_Exception $e) { - // success - } - // test interaction between class-wide default date format and using locale's default format - try { - $result = array('date_format' => 'MMM d, yyyy', 'locale' => 'en_US', 'month' => '7', - 'day' => '4', 'year' => '2007'); - Zend_Locale_Format::setOptions(array('format_type' => 'iso', 'date_format' => 'MMM d, yyyy', 'locale' => 'en_US')); // test setUp - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // uses global date_format with global locale - $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007')); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // uses global date_format with given locale - $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US'))); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // sets a new global date format - Zend_Locale_Format::setOptions(array('date_format' => 'M-d-y')); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // uses global date format with given locale - // but this date format differs from the original set... (MMMM d, yyyy != M-d-y) - $expected = Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US')); - $this->assertSame($expected['year'], $result['year'] ); - $this->assertSame($expected['month'], $result['month']); - $this->assertSame($expected['day'], $result['day'] ); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // the following should not be used... instead of null, Zend_Locale_Format::STANDARD should be used - // uses given local with standard format from this locale - $this->assertSame($result, - Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US', 'date_format' => null))); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // uses given locale with standard format from this locale - $this->assertSame($result, - Zend_Locale_Format::getDate('July 4, 2007', - array('locale' => 'en_US', 'date_format' => Zend_Locale_Format::STANDARD))); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - try { - // uses standard locale with standard format from this locale - $expect = Zend_Locale_Format::getDate('July 4, 2007', array('locale' => Zend_Locale_Format::STANDARD)); - $testlocale = new Zend_Locale(); - $this->assertEquals($testlocale, $expect['locale']); - } catch (Zend_Locale_Exception $e) { - $this->fail("exception expected"); - } - Zend_Locale_Format::setOptions(array('date_format' => null, 'locale' => null)); // test tearDown - } - - - /** - * test convertPhpToIso - * expected boolean - */ - public function testConvertPhpToIso() - { - $this->assertSame('dd', Zend_Locale_Format::convertPhpToIsoFormat('d')); - $this->assertSame('EE', Zend_Locale_Format::convertPhpToIsoFormat('D')); - $this->assertSame('d', Zend_Locale_Format::convertPhpToIsoFormat('j')); - $this->assertSame('EEEE', Zend_Locale_Format::convertPhpToIsoFormat('l')); - $this->assertSame('e', Zend_Locale_Format::convertPhpToIsoFormat('N')); - $this->assertSame('SS', Zend_Locale_Format::convertPhpToIsoFormat('S')); - $this->assertSame('eee', Zend_Locale_Format::convertPhpToIsoFormat('w')); - $this->assertSame('D', Zend_Locale_Format::convertPhpToIsoFormat('z')); - $this->assertSame('w', Zend_Locale_Format::convertPhpToIsoFormat('W')); - $this->assertSame('MMMM', Zend_Locale_Format::convertPhpToIsoFormat('F')); - $this->assertSame('MM', Zend_Locale_Format::convertPhpToIsoFormat('m')); - $this->assertSame('MMM', Zend_Locale_Format::convertPhpToIsoFormat('M')); - $this->assertSame('M', Zend_Locale_Format::convertPhpToIsoFormat('n')); - $this->assertSame('ddd', Zend_Locale_Format::convertPhpToIsoFormat('t')); - $this->assertSame('l', Zend_Locale_Format::convertPhpToIsoFormat('L')); - $this->assertSame('YYYY', Zend_Locale_Format::convertPhpToIsoFormat('o')); - $this->assertSame('yyyy', Zend_Locale_Format::convertPhpToIsoFormat('Y')); - $this->assertSame('yy', Zend_Locale_Format::convertPhpToIsoFormat('y')); - $this->assertSame('a', Zend_Locale_Format::convertPhpToIsoFormat('a')); - $this->assertSame('a', Zend_Locale_Format::convertPhpToIsoFormat('A')); - $this->assertSame('B', Zend_Locale_Format::convertPhpToIsoFormat('B')); - $this->assertSame('h', Zend_Locale_Format::convertPhpToIsoFormat('g')); - $this->assertSame('H', Zend_Locale_Format::convertPhpToIsoFormat('G')); - $this->assertSame('hh', Zend_Locale_Format::convertPhpToIsoFormat('h')); - $this->assertSame('HH', Zend_Locale_Format::convertPhpToIsoFormat('H')); - $this->assertSame('mm', Zend_Locale_Format::convertPhpToIsoFormat('i')); - $this->assertSame('ss', Zend_Locale_Format::convertPhpToIsoFormat('s')); - $this->assertSame('zzzz', Zend_Locale_Format::convertPhpToIsoFormat('e')); - $this->assertSame('I', Zend_Locale_Format::convertPhpToIsoFormat('I')); - $this->assertSame('Z', Zend_Locale_Format::convertPhpToIsoFormat('O')); - $this->assertSame('ZZZZ', Zend_Locale_Format::convertPhpToIsoFormat('P')); - $this->assertSame('z', Zend_Locale_Format::convertPhpToIsoFormat('T')); - $this->assertSame('X', Zend_Locale_Format::convertPhpToIsoFormat('Z')); - $this->assertSame('yyyy-MM-ddTHH:mm:ssZZZZ', Zend_Locale_Format::convertPhpToIsoFormat('c')); - $this->assertSame('r', Zend_Locale_Format::convertPhpToIsoFormat('r')); - $this->assertSame('U', Zend_Locale_Format::convertPhpToIsoFormat('U')); - $this->assertSame('HHmmss', Zend_Locale_Format::convertPhpToIsoFormat('His')); - } - - - /** - * Test toFloat()/toNumber() when a different setlocale() is in effect, - * where the locale does not use '.' as the decimal place separator. - * expected string - */ - public function testToFloatSetlocale() - { - setlocale(LC_ALL, 'fr_FR@euro'); // test setup - - //var_dump( setlocale(LC_NUMERIC, '0')); // this is the specific setting of interest - $locale_fr = new Zend_Locale('fr_FR'); - $locale_en = new Zend_Locale('en_US'); - $params_fr = array('precision' => 2, 'locale' => $locale_fr); - $params_en = array('precision' => 2, 'locale' => $locale_en); - $myFloat = 1234.5; - $test1 = Zend_Locale_Format::toFloat($myFloat, $params_fr); - $test2 = Zend_Locale_Format::toFloat($myFloat, $params_en); - $this->assertEquals("1 234,50", $test1); - $this->assertEquals("1,234.50", $test2); - // placing tearDown here (i.e. restoring locale) won't work, if test already failed/aborted above. - } -} diff --git a/tests/Zend/Locale/MathTest.php b/tests/Zend/Locale/MathTest.php deleted file mode 100644 index f364efc4055afaba0b22576d9c50a36768e7087c..0000000000000000000000000000000000000000 --- a/tests/Zend/Locale/MathTest.php +++ /dev/null @@ -1,1540 +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_Format - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MathTest.php 8760 2008-03-12 02:10:04Z alexander $ - */ - - -/** - * Zend_Locale_Format - */ -require_once 'Zend/Locale/Math.php'; -require_once 'Zend/Locale/Math/PhpMath.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Locale - * @subpackage UnitTests - */ -class Zend_Locale_MathTest extends PHPUnit_Framework_TestCase -{ - private static $savedLocale = 'C'; - - /** - * setup for tests (BCMath is not designed to normalize localized numbers) - */ - public function setUp() - { - self::$savedLocale = setlocale(LC_NUMERIC, '0'); - if (self::$savedLocale != 'C') { - setlocale(LC_NUMERIC, 'C'); - } - } - - /** - * teardown for tests (restore whatever setlocale was previously in place) - */ - public function tearDown() - { - if (self::$savedLocale != 'C') { - setlocale(LC_NUMERIC, self::$savedLocale); - } - } - - /* - * Note: All other aspects of Zend_Locale_Math receive extensive testing - * via unit tests in Zend_Date and Zend_Measure*. - */ - - /** - * test round() - * expect string when BCMath extension is enabled - */ - public function testRound() - { - $this->assertEquals( '3', Zend_Locale_Math::round('3.4')); - $this->assertEquals( round(3.4), Zend_Locale_Math::round('3.4')); - $this->assertEquals( '4', Zend_Locale_Math::round('3.5')); - $this->assertEquals( round(3.5), Zend_Locale_Math::round('3.5')); - $this->assertEquals( '4', Zend_Locale_Math::round('3.6')); - $this->assertEquals( round(3.6), Zend_Locale_Math::round('3.6')); - $this->assertEquals( '4', Zend_Locale_Math::round('3.6', 0)); - $this->assertEquals( round(3.6,0), Zend_Locale_Math::round('3.6', 0)); - $this->assertEquals( '1.96', Zend_Locale_Math::round('1.95583', 2 )); - $this->assertEquals( round(1.95583,2), Zend_Locale_Math::round('1.95583', 2 )); - $this->assertEquals( '1242000', Zend_Locale_Math::round('1241757', -3)); - $this->assertEquals(round(1241757, -3), Zend_Locale_Math::round('1241757', -3)); - $this->assertEquals( '5.05', Zend_Locale_Math::round('5.045', 2)); - $this->assertEquals( round(5.045, 2), Zend_Locale_Math::round('5.045', 2)); - $this->assertEquals( '5.06', Zend_Locale_Math::round('5.055', 2)); - $this->assertEquals( round(5.055, 2), Zend_Locale_Math::round('5.055', 2)); - } - - /** - * test round() - * expect string when BCMath extension is enabled - */ - public function testRound2() - { - if (!defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || TESTS_ZEND_I18N_EXTENDED_COVERAGE == false) { - $this->markTestSkipped('Extended I18N test skipped'); - return; - } - - $rounder = array( - '0.477051' => -12, '513695.36425' => 1, '89.85' => 4, '533.506' => 3, - '0.376139' => -2, '1784212419' => -9, '447878.429296' => -11, '79.31' => -2, - '941.543' => -5, '0.396850' => -10, '425271509' => 10, '220820.93233' => -2, - '13.36' => 4, '138.281' => -5, '0.289925' => 2, '1519168597' => 12, - '23387.294481' => -3, '88.100' => 1, '19.899' => -1, '0.60083' => 11, - '1807269979' => 4, '30808.137760' => -5, '16.63' => 0, '682.33' => 5, - '0.127627' => -8, '416684519' => 2, '508773.125117' => 11, '89.39' => -3, - '803.184' => 4, '0.398620' => 6, '849182084' => -5, '320473.238127' => 3, - '99.3' => -4, '946.410' => 4, '0.73955' => 10, '1075981461' => 4, - '316913.247175' => -4, '65.46' => -3, '299.308' => 3, '0.20681' => 12, - '625539733' => -11, '351290.473192' => -2, '0.88' => 0, '756.511' => 3, - '0.351428' => -9, '1709881316' => 4, '517636.210076' => -8, '52.29' => 1, - '96.318' => -5, '0.46457' => -4, '856460724' => -4, '415364.36099' => -3, - '60.28' => 0, '19.312' => -4, '0.84798' => 5, '714201053' => 12, - '80610.167713' => 11, '88.88' => 3, '900.179' => 4, '0.120498' => -7, - '1234420216' => -6, '339890.192448' => 3, '4.30' => 4, '470.236' => 1, - '0.78949' => 10, '1930996112' => -3, '186792.27756' => 0, '85.69' => 2, - '584.490' => 5, '0.419941' => -10, '819232149' => 6, '182934.15610' => -3, - '97.79' => 2, '396.818' => -4, '0.163940' => -2, '1745535129' => 12, - '236683.88660' => -7, '89.11' => -2, '47.522' => 0, '0.84264' => 12, - '1473190621' => -4, '366353.18312' => 1, '8.53' => -1, '711.629' => -1, - '0.65511' => -6, '461264361' => 11, '80405.349297' => 11, '92.100' => -1, - '466.580' => 4, '0.226480' => -3, '1512143953' => 6, '148397.211241' => -10, - '85.23' => 3, '663.98' => -5, '0.476893' => 5, '1390893395' => -7, - '84243.419979' => -9, '22.71' => -2, '571.725' => 3, '0.498972' => -4, - '156080671' => -9, '144016.186502' => 4, '21.91' => -2, '981.325' => 1, - '0.360149' => 5, '1973782312' => -7, '188196.41835' => -4, '35.35' => -3, - '106.431' => 1, '0.229880' => -4, '1046448903' => -3, '20467.399497' => 0, - '19.7' => -4, '676.982' => 4, '0.195086' => -8, '882554724' => 4, - '1780.403663' => -5, '92.72' => -3, '324.601' => 3, '0.343310' => -7, - '1277914818' => -12, '288455.332458' => -9, '73.9' => -4, '946.170' => 3, - '0.63718' => 5, '823941985' => 1, '437187.202938' => 1, '53.22' => -3, - '2.247' => -5, '0.112341' => 3, '1416720336' => 10, '23273.110046' => 8, - '63.17' => 4, '909.988' => -4, '0.326807' => -5, '1792810450' => -10, - '336225.350597' => -12, '88.92' => 4, '941.168' => 3, '0.294118' => -11, - '2032796853' => -3, '100492.519561' => -7, '94.5' => 1, '179.719' => 5, - '0.247127' => 12, '166770266' => -4, '183142.376940' => -5, '66.85' => 2, - '645.604' => 4, '0.361570' => 12, '813314439' => -8, '202182.299055' => 3, - '20.57' => 3, '548.53' => -5, '0.271132' => 6, '166087023' => 1, - '435424.223691' => 2, '17.98' => 3, '805.299' => 4, '0.420066' => -2, - '1294019654' => 12, '327747.518105' => -8, '81.96' => -2, '972.367' => 2, - '0.370667' => 6, '548609247' => 10, '251267.45074' => 7, '90.38' => 3, - '214.574' => 0, '0.342039' => 9, '1789816836' => -3, '291202.240426' => -6, - '71.4' => -2, '726.233' => 0, '0.239589' => 10, '1678730037' => 11, - '380074.136825' => 4, '5.69' => 4, '235.532' => 4, '0.41770' => -3, - '1660444329' => -8, '230203.172296' => 10, '64.8' => 2, '613.456' => 4, - '0.267306' => -9, '150903984' => 10, '327734.416916' => -5, '73.61' => -1, - '430.348' => -5, '0.433954' => 2, '1640566986' => -2, '178906.106444' => 3, - '89.56' => 1, '460.408' => 1, '0.309152' => -11, '2111984712' => 10, - '109862.319068' => 4, '3.18' => 2, '234.799' => -4, '0.426879' => 0, - '1979964791' => 3, '119122.138007' => 2, '98.67' => -3, '281.180' => 3, - '0.184761' => -8, '210096321' => 7, '225587.161155' => -4, '7.98' => 3, - '122.306' => -1, '0.322883' => -7, '1853238528' => -9, '366172.47285' => 1, - '24.78' => 0, '549.428' => 5, '0.382104' => -9, '1972761165' => 7, - '60782.182930' => 8, '23.20' => -4, '642.159' => -2, '0.460457' => 3, - '1572631121' => 7, '163894.225827' => 6, '91.7' => -3, '46.440' => -5, - '0.101855' => 0, '567173959' => -8, '521830.199253' => -10, '44.70' => -3, - '2.975' => 0, '0.322017' => 3, '882661445' => 9, '311363.379387' => -4, - '84.69' => -1, '744.550' => 3, '0.119550' => -8, '723180551' => 6, - '449221.174100' => 0, '46.31' => 3, '790.16' => 3, '0.223467' => 7, - '1334151870' => 3, '512572.112795' => 8, '64.40' => 2, '126.186' => -4, - '0.154390' => 5, '939837920' => -2, '475325.154386' => 3, '61.42' => 3, - '219.882' => 1, '0.517762' => 4, '592690249' => -5, '75942.132984' => 3, - '0.46' => 4, '609.230' => -1, '0.158459' => 3, '111563587' => 1, - '81793.502563' => 6, '74.65' => -3, '275.763' => 4, '0.482465' => 5, - '38064166' => 6, '188392.85235' => -8, '87.46' => -3, '910.256' => 5, - '0.286740' => -7, '1561805584' => 1, '156399.463093' => 2, '0.29' => 2, - '123.255' => 1, '0.437082' => -5, '129042096' => -8, '195012.219896' => 9, - '60.89' => 0, '855.189' => -3, '0.29867' => 0, '139602988' => 6, - '175877.190481' => 7, '70.67' => 4, '216.311' => -2, '0.275937' => 11, - '230515001' => -9, '522334.251290' => 2, '30.61' => -4, '859.747' => 1, - '0.191629' => 7, '1090159168' => 8, '308377.442029' => -2, '74.49' => -2, - '166.142' => 5, '0.51124' => -7, '815518430' => 4, '133830.197147' => -7, - '39.99' => -2, '567.729' => -2, '0.177050' => -12, '1781759241' => -10, - '275013.219089' => 9, '68.42' => -2, '348.975' => 1, '0.305648' => 6, - '882222353' => -11, '144939.349216' => 12, '93.73' => 4, '3.513' => 3, - '0.15497' => 1, '1330004472' => 9, '364678.75433' => 9, '46.96' => -1, - '550.156' => -3, '0.153132' => -6, '678841651' => 6, '368190.310672' => 5, - '55.29' => -4, '92.770' => 0, '0.324112' => -12, '1850715381' => 7, - '345338.292225' => -7, '95.85' => 4, '114.437' => 3, '0.188012' => 10, - '1387145934' => 6, '226297.182561' => 4, '39.82' => 3, '319.189' => -4, - '0.173574' => 11, '1556035741' => 8, '23778.200941' => -8, '32.69' => -1, - '441.384' => -3, '0.182397' => 4, '796735165' => 6, '219063.420812' => 12, - '60.73' => 2, '887.825' => 2, '0.425583' => 10, '1497714427' => -9, - '182965.389431' => 1, '17.24' => 4, '444.232' => -1, '0.45383' => 8, - '1218890312' => 2, '300990.516644' => -1, '67.87' => 4, '563.534' => -4, - '0.237510' => -12, '337619655' => -4, '462448.265391' => -9, '61.6' => 3, - '503.485' => -1, '0.171549' => 3, '448643907' => 2, '15061.410523' => 10, - '70.55' => -2, '727.716' => -2, '0.381646' => 10, '485956258' => -8, - '167378.56802' => 10, '91.100' => -3, '393.778' => 5, '0.11387' => -2, - '12977184' => -10, '524273.18229' => -7, '32.71' => 3, '59.157' => 0, - '0.492791' => -8, '774557136' => 10, '404139.356479' => -8, '90.18' => -3, - '134.552' => -4, '0.298695' => 11, '109079452' => 2, '421718.26616' => 2, - '94.94' => 3, '410.590' => -2, '0.315720' => 0, '870440545' => 1, - '365067.92361' => 12, '34.54' => 4, '703.290' => 0, '0.339982' => -11, - '1337929149' => 9, '228439.224073' => 5, '24.68' => -4, '42.391' => 3, - '0.294921' => -3, '1925153138' => 12, '501140.310787' => 12, '56.48' => 1, - '980.837' => 2, '0.15171' => -12, '1866705287' => 0, '96693.159889' => 4, - '35.32' => 4, '101.658' => -2, '0.245009' => 6, '1536424140' => -7, - '98922.351956' => -3, '27.52' => -2, '239.795' => -1, '0.130324' => -6, - '1558395489' => 8, '249345.477161' => -10, '85.78' => 0, '105.981' => 0, - '0.434193' => -10, '728314599' => -1, '425578.276733' => 1, '86.48' => 2, - '889.528' => 2, '0.67736' => -1, '631126221' => 7, '468815.403429' => 9, - '32.61' => -2, '69.196' => -3, '0.98505' => -8, '1358601844' => -12, - '298028.232980' => 1, '21.92' => 3, '591.157' => 0, '0.32092' => -12, - '1729465213' => -5, '73919.366759' => -4, '1.45' => 4, '653.585' => -4, - '0.439245' => -5, '706568548' => 7, '157303.470530' => -1, '68.12' => -1, - '629.862' => 5, '0.344800' => -10, '841981456' => 11, '145508.279481' => -1, - '44.18' => -1, '286.504' => 5, '0.309732' => 1, '671541317' => -4, - '425949.321253' => 10, '97.50' => 2, '447.483' => -3, '0.289988' => -10, - '46304377' => -9, '316706.156813' => 11, '70.92' => 2, '872.232' => 1, - '0.215806' => -11, '855811504' => 8, '389447.110599' => 6, '94.30' => 1, - '543.505' => 3, '0.336457' => -6, '896430071' => -11, '1879.11273' => 4, - '79.67' => 0, '216.271' => 3, '0.142853' => 12, '1694493658' => 5, - '213385.278854' => 4, '9.82' => 2, '613.591' => -4, '0.466328' => 4, - '1532833750' => -7, '469990.376106' => -5, '20.11' => 3, '851.739' => 1, - '0.427988' => 9, '1185585018' => -12, '357491.502835' => 3, '71.23' => 1, - '379.998' => 3, '0.18177' => -4, '1237929480' => 10, '101383.247931' => 6, - '33.67' => 0, '263.489' => 4, '0.69620' => 2, '1295904718' => -5, - '477234.149586' => 5, '85.35' => -4, '99.656' => -3, '0.231926' => -7, - '250380028' => 5, '230223.162511' => -12, '84.83' => 4, '678.834' => 0, - '0.141665' => 11, '565658786' => 12, '341314.91046' => 9, '22.0' => -2, - '241.741' => 0, '0.247073' => -9, '1813614696' => -8, '106060.148712' => 2, - '19.73' => 2, '199.195' => 3, '0.82872' => 2, '1198351802' => -1, - '177699.109593' => -2, '50.82' => 0, '314.747' => -4, '0.245384' => 10, - '151706729' => -7, '422706.143097' => -5, '543.633' => 0, '0.70901' => 4, - '310817463' => 7, '111502.253582' => 5, '99.41' => 3, '552.939' => 0, - '0.230433' => -7, '973071638' => -2, '376895.135985' => 0, '97.75' => -2, - '234.643' => -1, '0.479141' => -12, '1763890293' => 7, '247314.17852' => -11, - '85.52' => -1, '11.332' => 0, '0.129061' => -2, '1740619639' => 7, - '148015.277563' => 5, '85.93' => -4, '319.49' => 5, '0.183134' => 2, - '786094623' => 12, '11745.439232' => -8, '21.4' => 1, '513.100' => 5, - '0.480654' => -4, '208016871' => -4, '23840.198801' => 6, '44.10' => -4, - '45.245' => -3, '0.331976' => -5, '587815390' => 2, '401253.155255' => 12, - '86.4' => 4, '40.529' => 5, '0.191665' => -11, '849540417' => -1, - '90847.231247' => -1, '44.28' => -1, '546.577' => -1, '0.448907' => 3, - '454030751' => -7, '109715.512100' => -9, '95.28' => -4, '236.136' => 5, - '0.149792' => 0, '2015639148' => 0, '505388.58658' => 5, '54.57' => 3, - '939.638' => -5, '0.291381' => 4, '1846723436' => 0, '327283.36287' => 7, - '11.69' => -4, '654.574' => -3, '0.76996' => -4, '1821131976' => 9, - '283387.425713' => -10, '62.74' => 1, '813.169' => 2, '0.242363' => -4, - '1807590204' => 6, '258169.244302' => -4, '52.51' => -2, '718.581' => 4, - '0.33564' => -2, '614654309' => 6, '426594.433449' => 10, '49.34' => -4, - '50.563' => 2, '0.208860' => 10, '1320256804' => -12, '181967.56210' => -6, - '34.22' => 2, '75.963' => -3, '0.263642' => 9, '1246068123' => -12, - '492311.206522' => 7, '40.10' => 1, '826.55' => -4, '0.374927' => 5, - '1594733132' => -1, '363878.47018' => -4, '83.78' => -1, '51.699' => -5, - '0.473667' => -12, '136424545' => -7, '519175.1330' => 0, '67.28' => 3, - '438.537' => 2, '0.81496' => 6, '385982976' => -6, '305189.458112' => 10, - '27.82' => -4, '890.852' => 4, '0.485550' => 2, '1709031568' => 6, - '125027.412132' => 12, '39.66' => -3, '328.837' => -4, '0.28185' => 4, - '1917570138' => 12, '466503.249058' => -7, '49.38' => 3, '277.583' => -2, - '0.457270' => -9, '1933373722' => 0, '261480.72754' => 4, '25.85' => 0, - '950.477' => 2, '0.309669' => 0, '1033967919' => 1, '400503.194648' => 0, - '25.45' => 3, '747.530' => 5, '0.467982' => 1, '73608455' => -2, - '36720.279450' => 7, '2.18' => 0, '840.320' => -4, '0.172859' => 4, - '385764681' => 10, '206826.494684' => 8, '82.43' => -1, '373.553' => -5, - '0.471131' => 2, '2145228020' => -1, '125096.36169' => 11, '59.49' => -3, - '663.196' => 5, '0.163393' => -5, '417958569' => 1, '177016.308867' => 0, - '95.25' => 0, '316.325' => 3, '0.478939' => -5, '1604251943' => -7, - '81908.516759' => 10, '15.58' => 1, '538.775' => 0, '0.430828' => 5, - '506589845' => -10, '302671.300696' => -12, '9.55' => -4, '296.578' => -5, - '0.313157' => -3, '1273404167' => 0, '211916.392798' => -4, '37.49' => -1, - '999.498' => 0, '0.371216' => -6, '738010455' => -5, '176328.482849' => 11, - '94.61' => 4, '656.786' => -3, '0.13435' => 7, '568477995' => -3, - '381224.350704' => 3, '5.74' => -4, '222.542' => -5, '0.251694' => 0, - '1788665792' => -6, '101486.88726' => 8, '11.68' => 2, '873.979' => 1, - '0.338419' => -3, '1651069858' => -12, '326287.260029' => 10, '55.64' => 4, - '649.952' => -4, '0.84611' => 3, '1905458609' => -2, '133958.42398' => 12, - '79.27' => -4, '876.551' => -4, '0.136933' => -10, '205928650' => -8, - '55664.376562' => -12, '71.7' => -4, '175.968' => -1, '0.426143' => -3, - '1763415445' => -9, '64523.40192' => 5, '7.57' => -2, '687.436' => 3, - '0.408456' => -5, '1076514101' => 5, '381416.318485' => 9, '29.30' => -2, - '739.508' => 1, '0.67442' => 2, '1520147758' => -4, '10794.435652' => 11, - '11.10' => 3, '859.61' => 2, '0.85705' => -10, '1744771167' => 9, - '375072.283098' => 4, '80.57' => -2, '176.349' => -4, '0.396252' => 3, - '2049042840' => -1, '224324.511048' => -1, '78.41' => 0, '90.416' => -4, - '0.107923' => -7, '112842944' => 2, '127931.402622' => -12, '7.35' => 0, - '478.258' => 2, '0.58406' => -12, '1104295611' => -12, '250270.493928' => -11, - '40.82' => 2, '968.275' => 5, '0.94102' => -3, '2038106571' => 0, - '261684.101227' => -7, '763.887' => 3, '0.419104' => -11, '133351571' => 12, - '33468.282826' => -5, '31.65' => -4, '606.889' => 0, '0.511690' => 7, - '539608460' => -11, '157104.393425' => 11, '81.83' => -2, '618.139' => -3, - '0.349358' => -10, '219266259' => 11, '132301.87000' => 6, '27.58' => 0, - '74.767' => -3, '0.443174' => -11, '314832140' => 6, '349866.233967' => -10, - '75.66' => 3, '872.231' => -4, '0.511472' => -6, '429750945' => 10, - '327987.237221' => -11, '97.51' => 4, '705.548' => -4, '0.410789' => 10, - '1351303037' => -3, '256611.155486' => 11, '8.12' => -1, '244.863' => 2, - '0.265113' => 11, '1766929095' => 8, '480312.235078' => 5, '34.11' => -3, - '239.378' => 3, '0.66263' => -3, '1621617180' => -8, '48016.128226' => 6, - '58.13' => 0, '829.835' => 1, '0.395683' => -2, '587408316' => -4, - '24096.99434' => 2, '35.37' => -3, '182.562' => -5, '0.285531' => -2, - '1207286666' => 5, '232993.342764' => -5, '12.12' => 0, '698.460' => 2, - '0.69479' => 1, '1904090278' => -7, '415270.488962' => -2, '13.95' => 3, - '968.368' => 0, '0.193252' => -12, '1526701023' => 10, '111348.81435' => 11, - '65.71' => 2, '418.580' => -2, '0.505803' => 6, '2055498202' => 5, - '61865.392813' => 9, '57.93' => 2, '381.627' => 3, '0.211185' => -9, - '71999054' => 12, '485521.128926' => -10, '0.93' => 0, '203.635' => 4, - '0.496141' => -1, '377814566' => 2, '236623.154105' => 10, '0.22' => -2, - '973.537' => 2, '0.49074' => -5, '619293446' => 11, '27988.112428' => -9, - '73.37' => -2, '260.447' => 5, '0.379680' => 2, '380236521' => -3, - '155680.329454' => 10, '87.20' => 4, '868.142' => -5, '0.84534' => 1, - '1066107351' => -7, '190309.288268' => -1, '88.39' => 2, '331.372' => -4, - '0.476173' => 2, '2053624162' => -10, '522268.132766' => -10, '20.58' => -2, - '597.260' => -1, '0.80816' => 0, '1611741955' => -2, '456586.59512' => 4, - '85.7' => 0, '188.255' => 5, '0.393854' => -4, '921402161' => -8, - '130362.222931' => 5, '62.16' => 4, '536.137' => -5, '0.26585' => -6, - '1478673742' => -5, '493785.293303' => 8, '9.77' => -3, '726.403' => -5, - '0.30668' => -6, '938214830' => -9, '451958.359419' => 0, '65.53' => -4, - '536.522' => -3, '0.420885' => -4, '1322660686' => 2, '196287.292412' => 0, - '70.14' => -2, '163.779' => 5, '0.229146' => -5, '1015206824' => 8, - '170356.175523' => 9, '15.20' => -2, '395.301' => -4, '0.377290' => 4, - '514496980' => -10, '312183.321896' => -4, '91.59' => 1, '508.955' => 5, - '0.433249' => 6, '1230001569' => -3, '139399.470649' => -5, '13.79' => 3, - '936.428' => 4, '0.315546' => -7, '658623891' => -9, '253142.472980' => 9, - '55.36' => -1, '315.477' => -2, '0.26433' => -5, '1474209829' => -5, - '316116.499313' => 3, '78.66' => -2, '558.964' => 3, '0.398515' => -7, - '827700634' => 2, '213389.455217' => -11, '24.52' => -2, '857.536' => -3, - '0.79445' => 5, '2136820837' => 2, '109867.313513' => 8, '84.57' => 2, - '378.945' => 4, '0.323336' => 8, '842604404' => 5, '404292.419103' => -12, - '66.11' => 2, '328.114' => 4, '0.10305' => -2, '10843546' => -6, - '54463.112515' => -12, '95.45' => -4, '310.841' => -2, '0.72016' => -6, - '2105123959' => -1, '241075.393951' => 1, '49.100' => -2, '874.774' => 3, - '0.153247' => 9, '277109581' => 7, '423515.122116' => -5, '12.46' => -1, - '789.178' => 1, '0.33907' => -2, '1907352136' => -5, '443331.182449' => -11, - '68.29' => -3, '36.39' => -4, '0.471768' => 10, '1481206297' => -4, - '329700.260849' => -12, '92.39' => -3, '979.386' => 3, '0.214445' => 12, - '601901375' => -1, '260120.65992' => -5, '30.32' => -2, '447.617' => 0, - '0.179959' => 0, '1797183025' => 0, '286086.244178' => -12, '61.45' => 3, - '234.175' => -3, '0.104259' => 2, '90282551' => 2, '461979.282162' => -1, - '83.91' => 0, '372.296' => -1, '0.459854' => -12, '1169863468' => 3, - '352639.47409' => 5, '90.79' => -3, '991.886' => -4, '0.304837' => -6, - '1832184648' => -10, '295734.385002' => 3, '26.100' => -3, '403.446' => -4, - '0.226114' => -2, '99751977' => -4, '19645.376992' => 12, '93.97' => -3, - '58.995' => 1, '0.171894' => -1, '1169970566' => 2, '104292.57083' => -8, - '28.17' => -1, '286.756' => -2, '0.363514' => 7, '263041008' => -8, - '85743.83864' => 6, '38.38' => 4, '955.253' => -1, '0.217441' => -3, - '2040200029' => 2, '399450.78100' => 11, '51.34' => 2, '699.139' => 4, - '0.261091' => 3, '1731247537' => 8, '300414.508411' => 3, '20.15' => -4, - '538.368' => -1, '0.478543' => 4, '489449991' => 7, '389036.518944' => 9, - '67.52' => -2, '384.856' => 0, '0.1266' => 4, '1059654290' => -4, - '510813.34831' => 8, '9.98' => 2, '372.450' => 0, '0.10054' => 9, - '1420362962' => -3, '118494.211516' => -6, '424.142' => -1, '0.44364' => -7, - '1246325687' => -9, '500072.290803' => 2, '31.75' => 2, '254.82' => -3, - '0.69673' => 4, '76040964' => -10, '182733.137059' => 7, '50.41' => 3, - '783.914' => -3, '0.4661' => -2, '1173122397' => 12, '302235.262191' => 2, - '23.45' => -3, '675.217' => 5, '0.182047' => -12, '270733451' => -4, - '75972.248830' => -3, '6.14' => -1, '401.537' => 1, '0.420766' => -1, - '991403896' => 1, '70651.19989' => -4, '26.8' => -2, '23.407' => -3, - '0.25229' => -1, '1699002511' => 6, '71777.490768' => -8, '28.71' => 3, - '258.326' => -5, '0.378300' => 2, '247142413' => -9, '250124.130989' => -8, - '53.48' => -2, '703.431' => -3, '0.75403' => 4, '905866320' => -1, - '342322.292936' => 11, '34.15' => 4, '182.269' => -3, '0.394428' => 2, - '1541570625' => 12, '91033.102197' => 9, '52.65' => -4, '907.579' => 5, - '0.300857' => -4, '1798276914' => 6, '344701.257066' => 12, '79.90' => 0, - '158.861' => 3, '0.391954' => -11, '132938371' => 3, '252029.123488' => -1, - '63.18' => 1, '109.150' => 0, '0.245355' => -10, '1733130068' => 6, - '377224.243540' => -5, '100.59' => -2, '390.326' => 2, '0.242125' => 1, - '312684996' => -11, '282603.328369' => 1, '22.39' => -3, '896.490' => 0, - '0.513923' => 3, '733998996' => 11, '138071.32135' => 7, '33.24' => -4, - '917.37' => 0, '0.235102' => 8, '1938630497' => 0, '11864.231613' => 2, - '64.44' => 3, '913.67' => -5, '0.278156' => 0, '1008954246' => -11, - '437691.384397' => 9, '80.27' => -4, '772.247' => -1, '0.315186' => -1, - '2093728765' => 5, '152063.523028' => 0, '78.59' => 0, '609.868' => 5, - '0.63193' => -12, '141731881' => -3, '141788.472294' => 2, '99.11' => -3, - '555.245' => -2, '0.16140' => 2, '563758848' => 9, '183489.289699' => -12, - '6.79' => -2, '734.491' => -5, '0.394487' => 10, '608996993' => 3, - '105951.290469' => 8, '76.71' => 0, '25.196' => -3, '0.310455' => -1, - '691374395' => -7, '121976.352282' => 9, '97.47' => -2, '488.753' => 4, - '0.195856' => -4, '2046570908' => 0, '169693.81314' => 4, '68.97' => -4, - '200.776' => -2, '0.354494' => 0, '1600135021' => -3, '116435.512634' => 12, - '21.64' => 1, '488.588' => -3, '0.434626' => 12, '1053704434' => 12, - '324155.426945' => 7, '86.62' => 3, '940.999' => 1, '0.240201' => -3, - '1609688531' => 4, '352967.509426' => -7, '60.39' => -1, '628.469' => 2, - '0.321316' => -5, '534968446' => -5, '41696.454762' => -10, '70.78' => -4, - '382.574' => 0, '0.400636' => 0, '364465487' => -12, '123613.441948' => 0, - '18.8' => -1, '787.439' => -4, '0.39197' => 3, '2003904224' => -11, - '81505.6642' => -4, '2.89' => -4, '384.230' => 2, '0.460468' => -7, - '581064832' => 12, '266505.265475' => -11, '93.7' => 4, '244.867' => 3, - '0.461266' => -8, '484896921' => 11, '139172.199888' => 8, '45.86' => 0, - '519.729' => -2, '0.396722' => 1, '1133993792' => 3, '343304.19071' => -12, - '3.46' => 0, '191.867' => -4, '0.191609' => 12, '1972439949' => 6, - '293502.96437' => 2, '64.43' => -1, '730.759' => 5, '0.138194' => 5, - '688996186' => 0, '284626.511516' => 7, '52.86' => -4, '969.725' => -4, - '0.495512' => -12, '1628264257' => -10, '357366.166739' => 9, '71.69' => 1, - '674.812' => 5, '0.203279' => 5, '468804690' => -11, '454343.399080' => 5, - '84.20' => 2, '350.521' => -1, '0.189374' => -10, '399928338' => -1, - '172813.455004' => -10, '52.14' => -1, '84.739' => 1, '0.412801' => -2, - '1051319402' => -9, '437960.186725' => -12, '5.61' => 0, '976.75' => 1, - '0.37429' => -9, '1267813370' => -2, '291306.482338' => -6, '30.65' => 4, - '250.218' => -2, '0.348818' => -10, '490363689' => -12, '6116.33390' => -9, - '58.56' => 3, '165.358' => -2, '0.151838' => -3, '1760007733' => -2, - '360487.196707' => 9, '37.9' => -3, '460.711' => 0, '0.294223' => 6, - '1561003209' => -3, '278621.387220' => 7, '52.44' => -4, '745.770' => 4, - '0.67210' => -6, '1478844494' => -11, '492351.197245' => 11, '19.69' => 2, - '193.296' => 2, '0.479387' => -3, '1583916869' => 9, '338957.141031' => 4, - '31.90' => 0, '797.681' => 5, '0.29207' => 5, '1598371296' => 8, - '396866.358290' => 6, '42.31' => -4, '960.965' => -3, '0.168106' => 1, - '883436959' => 9, '272743.30352' => -11, '56.64' => 4, '554.594' => 0, - '0.125592' => -8, '2113137303' => 4, '206580.388481' => 12, '82.9' => 0, - '348.784' => 1, '0.473266' => 1, '935392589' => -10, '85395.501110' => -5, - '86.93' => 0, '423.683' => 2, '0.313619' => -6, '1925010508' => 11, - '475261.152265' => 2, '81.14' => 1, '736.11' => 1, '0.153447' => -2, - '1112693289' => 10, '119762.357049' => 6, '17.54' => 1, '192.954' => -2, - '0.230363' => 12, '1944695430' => 1, '70103.425752' => -4, '38.43' => 0, - '60.337' => -5, '0.248570' => -11, '2094265461' => 3, '187646.106769' => 12, - '81.85' => -4, '144.775' => -2, '0.66653' => -5, '1801456305' => -7, - '288179.509912' => -12, '43.23' => -3, '280.668' => -5, '0.178560' => -3, - '2141024139' => -9, '70304.186069' => -5, '40.32' => -1, '658.796' => 5, - '0.495359' => 6, '2076726873' => 11, '501097.270904' => 7, '69.18' => 3, - '0.305884' => 12, '234602643' => 4, '507072.127580' => 2, '5.33' => 0, - '311.468' => 2, '0.33579' => 0, '905015881' => -2, '102801.197760' => -12, - '540.354' => -3, '0.266050' => 0, '367126157' => 11, '271589.72414' => 3, - '63.91' => 0, '613.96' => -1, '0.58478' => 10, '675945896' => -8, - '100416.267827' => 1, '46.8' => 2, '296.520' => 1, '0.427965' => 11, - '1917770866' => -12, '337603.215506' => 12, '87.75' => 0, '185.27' => 2, - '0.45752' => 6, '1947135822' => -9, '352524.51503' => -2, '84.37' => 1, - '978.968' => 3, '0.489039' => -4, '782344762' => 7, '404044.4317' => 8, - '51.10' => 4, '751.831' => 5, '0.260782' => 11, '202303187' => 10, - '167916.401915' => -2, '35.34' => -2, '157.587' => -5, '0.259152' => 12, - '1653896744' => 0, '180937.283539' => 9, '44.38' => 1, '306.434' => -5, - '0.136697' => 10, '1786993865' => 11, '176069.79906' => -4, '38.47' => 3, - '490.335' => 5, '0.250091' => 2, '216053612' => 8, '360814.233684' => -6, - '2.22' => 0, '308.240' => 2, '0.116174' => -9, '165138471' => 0, - '448624.216386' => -11, '25.59' => 4, '587.939' => -1, '0.87944' => 7, - '1275347970' => -2, '347256.147890' => -6, '84.74' => 0, '453.983' => 3, - '0.313413' => -12, '1099410498' => -7, '135325.192746' => 4, '34.34' => 0, - '768.643' => 3, '0.278694' => 6, '313676060' => 8, '41131.423837' => -9, - '26.24' => 4, '15.987' => 5, '0.14174' => 10, '259911263' => 2, - '135969.198780' => 1, '85.25' => -1, '44.452' => 4, '0.406375' => 1, - '755430284' => 12, '57336.225562' => 11, '22.99' => 0, '923.778' => 3, - '0.439752' => 6, '705503397' => 8, '180033.308211' => 11, '94.18' => -2, - '81.546' => 1, '0.326787' => -11, '120116605' => -4, '126852.86661' => 12, - '68.63' => 1, '385.882' => -1, '0.67589' => -7, '54702997' => 6, - '356776.193388' => -1, '62.98' => -4, '600.283' => -4, '0.352127' => 4, - '2119195643' => 10, '462290.119946' => 6, '18.300' => -4, '0.125739' => -11, - '1638029921' => -2, '464779.232397' => -6, '46.25' => 4, '373.511' => 2, - '0.20672' => 11, '1835034875' => -8, '477385.386009' => -12, '2.45' => 4, - '616.397' => 5, '0.344731' => -7, '1433625609' => 3, '473078.290498' => -2, - '49.32' => 0, '991.163' => -1, '0.492057' => 10, '197460706' => -7, - '119850.1305' => 7, '81.55' => 0, '491.554' => -3, '0.382472' => 2, - '469326455' => -7, '331476.63372' => -3, '66.44' => 0, '835.813' => -1, - '0.389892' => 3, '1744041622' => 6, '285370.21353' => 8, '829.117' => 0, - '0.214876' => -12, '493303082' => 9, '127794.451912' => 3, '36.41' => -3, - '854.467' => -4, '0.242904' => 12, '1597315518' => -7, '24088.151051' => -6, - '36.84' => 3, '304.356' => 5, '0.168618' => -10, '2043698383' => 7, - '206882.102456' => 1, '39.77' => 2, '951.404' => -5, '0.494594' => 0, - '1501805237' => 9, '74836.390739' => 5, '63.34' => 0, '325.603' => -4, - '0.225366' => 0, '601135821' => 11, '249678.353643' => -3, '82.97' => 4, - '990.611' => -1, '0.250930' => 7, '1374761348' => 1, '126822.410471' => -8, - '24.55' => -3, '710.879' => 0, '0.117245' => -9, '149079574' => -5, - '361948.286074' => 0, '43.100' => -2, '365.224' => -4, '0.72458' => 5, - '562135537' => 5, '461771.264062' => 7, '72.81' => -1, '344.66' => -2, - '0.256308' => -9, '993879384' => -5, '416083.80306' => 1, '42.54' => 4, - '635.333' => 2, '0.179203' => 9, '1250027646' => -1, '131106.242666' => 3, - '26.83' => 3, '103.959' => 1, '0.134753' => 5, '2104213542' => -1, - '3125.405519' => 5, '75.29' => -4, '949.284' => 2, '0.434020' => -11, - '1113433931' => 3, '120118.402940' => -2, '58.14' => -1, '763.267' => -3, - '0.237367' => -9, '1290277516' => 1, '128085.318134' => -2, '72.96' => -3, - '665.359' => -1, '0.372937' => 4, '590423356' => -8, '313048.264264' => -7, - '84.58' => 0, '773.372' => -5, '0.485373' => -6, '1710904821' => 8, - '135132.21498' => 1, '15.85' => 0, '215.79' => 1, '0.453586' => 11, - '248315533' => 7, '10839.373672' => -9, '18.48' => -4, '489.370' => 3, - '0.399257' => -8, '2125156608' => -5, '431114.129681' => 1, '71.76' => 4, - '326.21' => -4, '0.133750' => -7, '2140171244' => 10, '14027.9054' => -3, - '3.26' => 2, '58.645' => 1, '0.116675' => -12, '642436874' => -2, - '505643.63671' => -7, '7.17' => 1, '297.648' => 4, '0.263478' => 10, - '1698877745' => 10, '143508.428792' => 0, '49.55' => -1, '186.682' => 2, - '0.99495' => -5, '1492587467' => 10, '60820.345756' => 0, '22.69' => 1, - '570.43' => 0, '0.248952' => -8, '204474556' => 1, '23410.193428' => -6, - '73.57' => 2, '216.300' => -2, '0.265031' => -12, '2006906410' => 0, - '513155.26500' => -7, '63.8' => 1, '628.847' => -1, '0.429799' => -2, - '2063015688' => -4, '308193.2788' => 10, '57.1' => 2, '359.461' => 2, - '0.204513' => 12, '1009417979' => 12, '87506.235307' => -4, '3.0' => -4, - '373.738' => -2, '0.413427' => -8, '1038395873' => 1, '247684.37420' => 6, - '75.32' => 2, '1.125' => 5, '0.514472' => -1, '889887830' => 0, - '440661.304764' => -1, '61.94' => 4, '252.590' => 2, '0.217230' => -1, - '28792678' => -3, '67123.254713' => 10, '24.71' => 3, '700.204' => -5, - '0.77310' => -9, '1396409395' => -8, '334049.257293' => 2, '71.75' => 0, - '470.728' => 5, '0.485319' => 0, '1916276590' => -9, '21114.10676' => 11, - '91.67' => -4, '676.421' => -4, '0.424692' => -5, '1066814307' => 2, - '68423.70214' => -1, '67.66' => -2, '581.495' => -4, '0.49407' => 9, - '36610481' => -2, '188456.30052' => 12, '6.91' => 3, '16.127' => 3, - '0.171556' => -7, '1671792944' => 11, '208369.476576' => 8, '18.63' => 4, - '776.587' => -3, '0.340977' => 5, '263522931' => 5, '349927.252792' => 4, - '26.79' => 2, '580.601' => 2, '0.414198' => 9, '1679807647' => 11, - '394111.94190' => 2, '53.66' => 2, '868.114' => 0, '0.298914' => -9, - '1721264409' => 7, '226615.245870' => 5, '14.44' => -3, '159.529' => 3, - '0.2404' => -4, '549275787' => -5, '465184.3924' => 7, '72.49' => -1, - '28.893' => -5, '0.78272' => -8, '2008199383' => -1, '81631.192610' => 11, - '52.56' => -2, '290.932' => 0, '0.324392' => -12, '688007865' => 11, - '379138.108867' => 9, '57.60' => 2, '655.213' => 1, '0.432680' => 0, - '2046378555' => -3, '164070.56947' => 7, '44.65' => 2, '125.587' => -3, - '0.66391' => -9, '171104136' => -7, '41802.420912' => -1, '49.22' => 4, - '825.215' => 2, '0.164887' => 10, '540281514' => -11, '420198.295975' => -6, - '30.82' => 4, '26.707' => 1, '0.89275' => -8, '826339363' => 8, - '146818.243545' => -6, '43.55' => 4, '222.987' => 5, '0.58368' => -7, - '523766319' => -5, '297859.23782' => -3, '98.22' => 4, '818.787' => 1, - '0.522888' => -6, '204898719' => 11, '108373.196842' => -3, '31.27' => -2, - '260.26' => 0, '0.242649' => -1, '1629568497' => -9, '262573.17145' => 4, - '27.73' => -1, '282.471' => -5, '0.285776' => 8, '1661847712' => -1, - '445735.514098' => 4, '24.32' => 2, '798.229' => -5, '0.134278' => -11, - '449337646' => 5, '209310.372274' => -12, '13.61' => -3, '644.160' => 3, - '0.241562' => -6, '1567747899' => 5, '181534.304198' => -7, '27.45' => -1, - '500.486' => -3, '0.299538' => -1, '362861591' => 6, '397051.297899' => 7, - '72.63' => -4, '420.356' => 1, '0.357673' => 6, '996312202' => 8, - '26839.424774' => -2, '17.27' => -2, '516.221' => 4, '0.520470' => -4, - '191718894' => 7, '300654.443857' => -8, '46.113' => 2, '0.422092' => -12, - '1783356979' => 7, '108889.462229' => -6, '14.25' => -3, '112.986' => 4, - '0.240723' => -10, '1898433085' => 12, '73569.239851' => 1, '52.34' => 3, - '999.366' => -3, '0.6640' => -4, '264666875' => -8, '230998.173505' => 9, - '53.88' => 0, '743.884' => -5, '0.436960' => 12, '2072927211' => -4, - '467248.55366' => 5, '98.70' => -2, '911.626' => -2, '0.125236' => 4, - '1789898610' => 3, '252502.143697' => -3, '80.22' => -3, '225.822' => 1, - '0.110900' => -1, '1700212496' => 4, '195178.358051' => -8, '97.26' => 0, - '554.154' => 1, '0.113013' => -7, '1847934343' => -3, '396236.179370' => -11, - '55.11' => 0, '682.898' => 1, '0.68808' => -1, '222761296' => -10, - '150027.249563' => 11, '2.58' => 1, '171.380' => -3, '0.206157' => -2, - '1750969343' => 2, '338182.299431' => -6, '2.14' => 4, '772.768' => 2, - '0.115753' => 2, '1503347218' => 10, '430797.517055' => -4, '56.83' => -1, - '90.173' => -1, '0.268636' => 7, '768770225' => 2, '430315.1582' => -4, - '98.92' => -1, '612.333' => -5, '0.106103' => 8, '1551619043' => 1, - '460368.285322' => 10, '98.44' => 2, '825.593' => 5, '0.307738' => -9, - '1535989049' => -10, '227090.281024' => 11, '96.92' => -2, '976.863' => 0, - '0.419062' => 9, '858784789' => -11, '507128.145744' => 1, '96.3' => 3, - '12.124' => 0, '0.84111' => -11, '337884600' => 5, '344032.309581' => 9, - '93.36' => 3, '878.499' => -4, '0.379685' => -12, '216021134' => -5, - '429868.35580' => -9, '818.936' => -3, '0.455889' => -4, '125812719' => -10, - '509654.374747' => -12, '32.54' => -1, '713.626' => 4, '0.392622' => -4, - '1372458626' => -4, '248639.240653' => 9, '34.84' => 3, '64.52' => -3, - '0.215750' => -7, '646614975' => 11, '497553.143231' => -1, '66.50' => 1, - '346.820' => -1, '0.360217' => -12, '818557945' => 2, '218973.448482' => -4, - '73.13' => -1, '399.240' => 5, '0.316427' => -12, '2021733384' => 4, - '63883.466852' => 10, '46.84' => -2, '240.156' => 1, '0.142031' => -3, - '2041302265' => 9, '89018.193049' => 4, '71.24' => 4, '206.484' => 4, - '0.118101' => -10, '1656259082' => -10, '520147.468243' => -8, '20.51' => -3, - '77.244' => -5, '0.240837' => -8, '22661163' => 0, '87869.94550' => -2, - '13.48' => 2, '360.120' => -3, '0.251709' => 5, '1700311736' => -4, - '268547.410974' => -6, '96.34' => 1, '354.160' => 5, '0.273448' => -7, - '1543387549' => 3, '15528.464673' => 1, '56.85' => 3, '68.650' => 0, - '0.404985' => 2, '2021731540' => -9, '199815.237845' => 2, '2.30' => 0, - '260.224' => -4, '0.243067' => -6, '1903548584' => 6, '145844.480262' => -8, - '73.63' => 4, '105.907' => -5, '0.367839' => 4, '1701400136' => 4, - '127503.90908' => 4, '70.12' => 1, '226.153' => 1, '0.258361' => 7, - '1158338032' => 3, '419193.428642' => -3, '81.1' => 3, '31.604' => 2, - '0.364043' => 1, '498427374' => -5, '497254.249190' => 0, '6.36' => -4, - '928.391' => 5, '0.378096' => -10, '1568974566' => 10, '137841.277955' => -6, - '40.89' => 1, '533.609' => 4, '0.45110' => 0, '1730110007' => -5, - '414170.395357' => -5, '80.86' => 0, '820.737' => 5, '0.489231' => -4, - '512635777' => -1, '376723.262996' => 4, '6.59' => 3, '489.216' => 2, - '0.518471' => -6, '1179397656' => -5, '325108.177821' => 7, '79.35' => -1, - '312.93' => 1, '0.349657' => -4, '1702896027' => -12, '361851.268181' => 10, - '31.47' => 3, '104.965' => 5, '0.183382' => -7, '1093187607' => 11, - '392383.67712' => 10, '54.2' => -2, '626.957' => 3, '0.503551' => 10, - '2009920130' => 3, '277542.328266' => 6, '51.57' => 4, '564.508' => 5, - '0.404436' => 11, '1944137870' => 9, '396520.342738' => -5, '96.96' => 4, - '769.647' => 1, '0.355473' => 1, '378439008' => 3, '189308.369935' => 3, - '64.75' => 1, '737.764' => -5, '0.360824' => 1, '882094495' => 1, - '427451.87587' => 2, '16.19' => -2, '794.946' => -3, '0.181493' => 8, - '940850155' => 3, '124604.419008' => 1, '42.87' => 0, '917.965' => 1, - '0.246162' => -3, '1981331646' => 4, '129251.386887' => 10, '97.21' => 0, - '392.485' => -4, '0.116678' => -10, '1523513817' => 8, '185621.496556' => 4, - '42.89' => 1, '509.368' => 2, '0.470392' => 3, '581189047' => 8, - '376510.271143' => 8, '1.52' => 2, '661.366' => 2, '0.391309' => -8, - '42659426' => 2, '130865.196036' => -1, '96.83' => 2, '481.104' => -1, - '0.51511' => 7, '1319418097' => -12, '430432.174345' => -3, '9.90' => -1, - '600.560' => -5, '0.413110' => -2, '59388480' => -5, '399584.145364' => 8, - '99.13' => -3, '546.473' => 1, '0.169033' => 5, '1473953001' => 2, - '493126.265996' => 11, '89.37' => 3, '440.323' => 3, '0.460527' => -4, - '1399637678' => -10, '481870.217004' => 10, '58.17' => -4, '752.785' => 1, - '0.228851' => -11, '1324738282' => -10, '22838.292260' => -9, '38.52' => -2, - '302.120' => -4, '0.339296' => -2, '1164571066' => 12, '474147.241901' => -5, - '56.29' => 2, '864.8' => 3, '0.476450' => 2, '1485601243' => -1, - '297976.385533' => 1, '4.47' => -3, '575.16' => 3, '0.3051' => 9, - '1818437869' => 4, '504714.393814' => 1, '372.831' => -4, '0.501972' => -10, - '1183210712' => 6, '139047.62558' => 4, '32.43' => -1, '161.390' => -5, - '0.5134' => -11, '1531338350' => -3, '495022.354288' => 9, '35.45' => 4, - '543.898' => -2, '0.340010' => -9, '1908876622' => 9, '264483.80794' => -8, - '50.64' => 0, '670.483' => -2, '0.376835' => 5, '223636098' => 0, - '183271.25333' => -2, '778.947' => 0, '0.485825' => -2, '602261949' => 2, - '416722.411520' => 8, '68.47' => -3, '790.420' => 5, '0.261060' => -1, - '2087347292' => -9, '299036.168589' => 3, '28.65' => 2, '179.915' => 2, - '0.317202' => 3, '482739664' => 9, '344080.10290' => 10, '13.34' => 1, - '340.888' => 4, '0.429461' => -5, '948997291' => -3, '517894.6437' => 7, - '69.39' => 1, '74.470' => 4, '0.368892' => 6, '1249602202' => -11, - '503777.124871' => 11, '87.8' => 1, '965.316' => 5, '0.140672' => 9, - '505868829' => -9, '485478.117109' => 5, '87.41' => -4, '240.504' => -4, - '0.514275' => 3, '1498883502' => -7, '71485.345428' => 2, '29.67' => -4, - '627.130' => -3, '0.250039' => 2, '1538141308' => -3, '57220.336712' => 5, - '68.80' => 3, '950.484' => -4, '0.299959' => 3, '1768189933' => -1, - '14596.503172' => -6, '4.22' => 3, '485.121' => -3, '0.34688' => -4, - '1587642883' => 2, '162705.444828' => 7, '68.10' => -2, '216.994' => 5, - '0.436235' => -2, '1876146837' => 2, '437984.472640' => 4, '73.66' => 2, - '869.468' => -3, '0.109800' => -4, '2025005363' => 1, '166063.132803' => 11, - '50.48' => 2, '402.63' => 0, '0.424841' => 1, '218027228' => 10, - '288899.491214' => 5, '70.31' => -3, '540.695' => 2, '0.464008' => -9, - '1475639948' => 10, '447032.2038' => 8, '75.58' => 1, '123.529' => 1, - '0.346077' => 4, '1184019054' => -4, '12103.53678' => 7, '27.40' => 1, - '84.464' => -4, '0.124402' => 7, '1486963062' => -4, '92925.285772' => 11, - '19.68' => -2, '266.964' => -2, '0.483152' => 9, '407763412' => 3, - '201784.111655' => -1, '82.85' => -4, '938.568' => 3, '0.380829' => -7, - '1201056638' => 8, '382395.386152' => -2, '100.16' => 1, '481.597' => 4, - '0.173792' => 7, '903673626' => 0, '519828.422408' => 1, '301.348' => -1, - '0.268273' => 11, '1599608892' => -11, '258818.248637' => -11, '13.81' => 0, - '637.97' => 0, '0.227801' => -11, '1243064059' => -2, '497988.299022' => 9, - '13.55' => 2, '923.542' => 1, '0.452093' => 10, '2085377358' => -11, - '65182.243656' => 3, '93.21' => 4, '677.371' => 0, '0.386274' => 3, - '137444033' => 8, '346631.7256' => -5, '70.2' => -2, '571.795' => 5, - '0.244844' => -1, '1144655586' => 4, '138428.344639' => -2, '59.83' => -1, - '363.235' => -2, '0.523837' => 5, '1075393121' => 12, '150813.84890' => -11, - '48.78' => -3, '713.768' => -2, '0.101016' => -9, '1734432063' => -7, - '352601.37585' => 6, '42.98' => 1, '296.764' => 5, '0.519424' => -7, - '393507553' => 7, '433235.246884' => 0, '65.13' => 4, '494.391' => 4, - '0.337903' => 3, '1810438038' => 2, '162358.270314' => -1, '9.95' => 2, - '917.961' => 0, '0.67151' => -6, '39971366' => 11, '232235.442994' => -5, - '75.43' => -4, '268.728' => -1, '0.459522' => 8, '862954172' => -3, - '432102.373040' => 5, '818.206' => -5, '0.38191' => -12, '2107478350' => -4, - '338317.222468' => -10, '52.69' => -1, '111.122' => 3, '0.487109' => 0, - '1834013192' => 12, '376481.355572' => -4, '516.96' => -2, '0.286139' => 1, - '1836245739' => -8, '136816.262331' => 1, '93.47' => -3, '226.994' => 3, - '0.371545' => 10, '1938609029' => 11, '132782.325486' => 2, '57.26' => -2, - '582.258' => 4, '0.54228' => 11, '256390013' => 8, '173622.199412' => 11, - '58.39' => -2, '168.982' => 0, '0.38263' => -1, '805954544' => 5, - '132532.329548' => 12, '93.17' => 0, '23.343' => 2, '0.510482' => 11, - '1565401625' => -1, '212368.31512' => -10, '34.5' => 3, '511.419' => -4, - '0.505317' => -11, '1651440077' => 0, '245443.11428' => -4, '52.90' => -4, - '559.259' => -2, '0.253523' => 3, '141653050' => -7, '170770.246951' => -7, - '33.62' => 3, '713.361' => 1, '0.415109' => -12, '1068283538' => -4, - '348137.506254' => 2, '3.9' => 1, '374.82' => -3, '0.520999' => 1, - '1625983934' => 2, '408082.43451' => -11, '89.87' => -4, '451.379' => 3, - '0.239213' => -10, '898144505' => -8, '383605.43123' => 11, '72.95' => -2, - '215.787' => -3, '0.387769' => -5, '1902150834' => 7, '440416.348186' => 0, - '72.46' => -1, '194.688' => -1, '0.150586' => 7, '2000212172' => -9, - '51177.347650' => 5, '98.50' => -4, '740.181' => -1, '0.31027' => -8, - '2054196733' => 11, '219176.417641' => 11, '16.32' => 4, '706.653' => -1, - '0.244336' => -10, '505184436' => 11, '338639.174513' => -3, '35.3' => -1, - '427.675' => -2, '0.316516' => 0, '900424870' => 6, '355808.439006' => 2, - '84.52' => -2, '928.317' => -2, '0.10098' => 11, '1907071721' => 7, - '94808.279944' => -6, '97.94' => -2, '253.707' => 4, '0.394018' => 2, - '668015293' => -5, '456502.518898' => -8, '28.85' => -2, '137.680' => 4, - '0.44647' => -7, '2125950054' => 5, '499868.89551' => 12, '41.47' => 0, - '377.732' => 2, '0.500638' => -3, '1521738398' => 0, '342789.303733' => -6, - '81.53' => 1, '422.643' => 1, '0.329752' => -7, '2012653703' => 6, - '367576.466950' => 3, '43.20' => -3, '894.60' => 5, '0.152840' => 4, - '265938546' => -12, '147516.407715' => -12, '44.39' => 0, '945.493' => 5, - '0.96094' => 2, '677379668' => -9, '388175.8664' => -9, '22.44' => 0, - '352.626' => 4, '0.520504' => 12, '2112410311' => 10, '480790.138953' => -10, - '81.33' => 0, '279.828' => 4, '0.454172' => -3, '1044105482' => -12, - '69007.118795' => -8, '76.42' => -1, '331.938' => 0, '0.156771' => -10, - '66590711' => 11, '24469.497047' => -5, '44.35' => 4, '222.554' => -2, - '0.307636' => -9, '357205628' => -2, '315383.156215' => -11, '44.5' => 2, - '545.554' => -5, '0.345555' => 12, '1918484847' => 9, '70896.492849' => 5, - '88.8' => 2, '410.255' => -4, '0.296371' => 5, '277649008' => 9, - '479467.383169' => 6, '53.47' => -3, '496.816' => 3, '0.240991' => -5, - '342371195' => -1, '86247.154483' => -4, '98.17' => 3, '330.295' => -5, - '0.20620' => -6, '229042716' => 9, '310539.11098' => -8, '23.43' => 1, - '183.589' => 0, '0.257068' => -4, '1707817704' => -11, '210345.503195' => 4, - '77.93' => 2, '933.198' => 2, '0.103522' => 11, '1726236577' => -7, - '212934.207695' => -5, '1.56' => -2, '66.920' => -4, '0.202865' => 5, - '1604010685' => -2, '31015.77661' => -8, '85.91' => -4, '552.858' => 2, - '0.259677' => 10, '314385167' => -11, '188461.289689' => -5, '86.72' => 2, - '824.311' => 1, '0.273825' => 0, '1980601777' => 5, '461612.514560' => -6, - '99.26' => -4, '971.479' => 5, '0.460995' => 7, '1769133465' => 12, - '143330.96090' => -12, '87.44' => 4, '30.506' => -4, '0.284701' => -2, - '263816881' => -12, '155717.1733' => -1, '2.43' => 2, '342.945' => 5, - '0.58090' => -2, '871310040' => 8, '445339.356053' => 11, '65.99' => -1, - '99.895' => -2, '0.274606' => 8, '1853484234' => -2, '473150.83940' => 4, - '88.68' => -1, '628.123' => 4, '0.31292' => 7, '1324370935' => -7, - '88469.244383' => -1, '90.80' => -2, '122.372' => 3, '0.501946' => 4, - '191147575' => 10, '284224.519817' => 8, '34.86' => -3, '704.496' => -4, - '0.260311' => -6, '1028953176' => 1, '11010.339678' => -10, '94.47' => -3, - '231.80' => -3, '0.462785' => 2, '1018518157' => -12, '449749.8598' => 12, - '21.30' => 3, '425.397' => -5, '0.351579' => 2, '274041092' => 10, - '3516.77914' => -9, '31.73' => 1, '940.290' => -3, '0.271575' => -4, - '836051772' => -8, '75690.129575' => 12, '8.21' => -4, '293.837' => 3, - '0.453657' => -8, '149238976' => 0, '344615.39951' => 12, '66.46' => 0, - '728.126' => 2, '0.41754' => -12, '395187825' => 4, '333714.172171' => -1, - '44.80' => 1, '581.155' => 4, '0.396718' => 5, '412133738' => -12, - '7195.445233' => 8, '30.57' => -3, '286.338' => 0, '0.155907' => 3, - '561921734' => -2, '465120.470902' => 0, '54.24' => 1, '93.986' => -1, - '0.407591' => 2, '1249904732' => 6, '298033.312347' => 12, '75.12' => 0, - '614.321' => -2, '0.121261' => 5, '254708221' => 3, '52547.3017' => 0, - '340.249' => -5, '0.472562' => 12, '1592989317' => -12, '521959.162658' => 0, - '78.83' => 3, '192.551' => 3, '0.467873' => -9, '1625277402' => 7, - '144121.449343' => -12, '77.63' => 1, '640.941' => 5, '0.335126' => -8, - '424836979' => 9, '170582.101391' => -3, '0.47' => -1, '289.427' => 5, - '0.223789' => 0, '594562283' => -5, '173007.289277' => -8, '21.81' => -1, - '731.612' => 4, '0.473011' => 6, '1290435715' => -6, '331557.485629' => -10, - '33.30' => -2, '245.84' => 1, '0.388037' => 12, '667701863' => 0, - '364550.336021' => -12, '99.79' => 2, '605.274' => 5, '0.190688' => 2, - '1769022812' => -8, '145053.239160' => 12, '78.22' => 1, '787.116' => 1, - '0.408386' => 4, '369832012' => 9, '457861.454841' => -10, '60.72' => 4, - '679.834' => -4, '0.131573' => -2, '1285317653' => -8, '84761.458851' => -11, - '44.31' => -4, '887.61' => -2, '0.286789' => -2, '620138832' => 9, - '487575.84974' => 5, '61.19' => 1, '338.57' => 4, '0.398293' => 4, - '1853436729' => -5, '201032.12972' => -4, '7.68' => 4, '995.111' => -2, - '0.224083' => -2, '542844334' => 4, '198015.95817' => 5, '85.48' => 4, - '315.493' => -3, '0.514361' => -5, '1265192214' => -6, '320077.509917' => 9, - '89.95' => 3, '297.518' => -4, '0.372414' => -7, '1893726623' => 11, - '346604.136063' => 12, '212.337' => -1, '0.258198' => 9, '265602359' => -5, - '84922.384921' => -10, '58.95' => -4, '53.274' => -4, '0.144928' => 3, - '1209193268' => 12, '497093.117529' => -9, '77.64' => -4, '20.295' => 3, - '0.467622' => -9, '944575541' => 7, '455870.315531' => -12, '63.33' => 4, - '428.918' => 1, '0.24464' => 10, '1867128508' => -8, '184864.428647' => 3, - '92.60' => -2, '383.433' => 5, '0.264602' => -5, '167980317' => -4, - '178358.496880' => 11, '88.18' => -4, '789.847' => 3, '0.352955' => 4, - '1822214055' => 10, '263576.105452' => 1, '98.27' => -1, '267.317' => -1, - '0.292079' => 8, '302626626' => 8, '401589.252241' => 3, '57.45' => -2, - '190.280' => 5, '0.443014' => 8, '1563902948' => 11, '260072.121101' => 5, - '57.87' => 3, '250.395' => 0, '0.34687' => 8, '1374092842' => 11, - '307900.212773' => -7, '72.26' => -3, '248.816' => -3, '0.43752' => 0, - '951652948' => 4, '185645.492410' => 8, '80.61' => -2, '112.365' => 5, - '0.487811' => -5, '580676605' => -2, '334490.449666' => 2, '2.70' => -2, - '904.834' => 2, '0.206374' => -1, '276934366' => 10, '382111.253256' => 8, - '495.494' => 4, '0.426504' => -7, '1379458592' => -2, '521413.146984' => -10, - '61.97' => 4, '622.569' => -3, '0.47569' => -12, '2024625708' => 12, - '419016.352116' => -7, '44.43' => 1, '281.642' => 4, '0.258311' => -5, - '1595476777' => -1, '282630.386646' => -9, '71.2' => 0, '214.72' => -1, - '0.125624' => 11, '1941944613' => -8, '200779.368835' => -8, '28.30' => -4, - '122.802' => -1, '0.231087' => -11, '1121413816' => -5, '225023.32125' => -8, - '54.63' => 3, '2.80' => 5, '0.495029' => -11, '489427620' => -4, - '263445.320268' => 9, '70.83' => -1, '256.776' => -3, '0.169346' => -12, - '670845041' => -7, '209785.388803' => 9, '59.45' => -2, '440.953' => -1, - '0.264834' => 1, '1832382586' => 10, '390924.186516' => 6, '257.384' => -1, - '0.144430' => -9, '768655589' => 5, '289651.397445' => 2, '8.92' => 0, - '368.348' => -5, '0.472663' => 12, '1890009262' => 9, '307229.328064' => 6, - '93.83' => 4, '188.227' => -5, '0.173105' => -2, '307398131' => 0, - '47681.364699' => 5, '15.53' => -1, '556.705' => -5, '0.282339' => -2, - '564058794' => 3, '189116.444939' => -2, '78.97' => 0, '19.483' => 3, - '0.238656' => 12, '1029908858' => 8, '262670.299124' => 2, '100.45' => 4, - '510.28' => -2, '0.482393' => -12, '1368468749' => 2, '516658.523215' => -8, - '47.81' => -4, '559.16' => 3, '0.280692' => -6, '126513357' => -1, - '36896.293557' => -12, '51.58' => -1, '904.323' => 5, '0.490065' => -12, - '1234720396' => -6, '223380.293815' => 2, '59.3' => 0, '803.827' => 1, - '0.25400' => 3, '164456613' => -3, '197469.77046' => -10, '51.17' => 4, - '154.442' => -2, '0.85115' => 4, '1912643615' => -3, '497374.166046' => 6, - '78.89' => 0, '476.360' => -5, '0.42048' => 9, '493031165' => -2, - '270519.317838' => -9, '57.82' => -3, '139.512' => -4, '0.412335' => 1, - '1987751232' => 4, '215733.458377' => 4, '810.72' => 5, '0.355213' => -5, - '1544886400' => -9, '162401.123400' => 10, '42.8' => 1, '188.568' => 3, - '0.386704' => -5, '2066402694' => -4, '16370.195938' => 4, '8.93' => -4, - '881.603' => 2, '0.100530' => 6, '1945153853' => -5, '98182.113004' => 10, - '83.57' => 2, '341.971' => -3, '0.330009' => 8, '385060738' => 5, - '194901.110379' => 2, '23.4' => 4, '729.721' => -5, '0.252272' => 3, - '1957296793' => 10, '431722.51750' => -3, '80.43' => 4, '689.877' => 1, - '0.269623' => 1, '560754700' => 0, '51164.331804' => 5, '54.14' => -4, - '168.840' => -1, '0.419207' => -10, '31234167' => -4, '371097.439348' => 5, - '81.61' => -2, '190.431' => -2, '0.389657' => -7, '1557769604' => 11, - '334885.431479' => -12, '89.18' => 0, '561.851' => 5, '0.347717' => 8, - '338970112' => 4, '189490.453853' => 4, '17.32' => -3, '667.971' => 5, - '0.464637' => -4, '631080581' => 5, '376623.488958' => 3, '48.32' => -1, - '318.95' => -4, '0.81195' => -12, '1415732807' => 6, '229014.10840' => -5, - '19.35' => 4, '272.943' => 5, '0.325493' => 11, '1410487228' => 8, - '231128.196692' => 10, '73.32' => 3, '481.514' => -3, '0.256699' => -3, - '258648844' => 4, '514580.292161' => -9, '51.36' => -3, '333.787' => 3, - '0.144779' => 6, '1198953939' => -2, '168742.523841' => 11, '88.3' => -3, - '304.973' => -5, '0.349067' => 2, '543917380' => -1, '320446.123084' => 7, - '39.86' => 3, '640.475' => 4, '0.193186' => 5, '219655785' => 6, - '358909.222369' => 11, '59.80' => 4, '871.336' => -5, '0.238886' => -11, - '1117326039' => -12, '413109.68943' => 5, '92.34' => -3, '247.624' => -5, - '0.494013' => 1, '604388635' => 12, '482024.506465' => -11, '96.6' => 3, - '147.517' => 5, '0.107571' => -4, '703997261' => 12, '357315.60695' => 6, - '24.77' => 1, '824.210' => -3, '0.185287' => 9, '1822528982' => -9, - '103514.402689' => 3, '61.56' => 1, '550.876' => -3, '0.459206' => 7, - '1608014464' => -10, '422553.225608' => -7, '5.57' => 1, '799.255' => -5, - '0.343237' => -7, '821588891' => 3, '127917.304097' => 0, '24.89' => 3, - '144.955' => 5, '0.482459' => 9, '1997193157' => 8, '17663.385861' => 4, - '40.15' => -1, '174.719' => 4, '0.211591' => -10, '1494458060' => -3, - '459503.492775' => 7, '79.61' => -3, '587.176' => -3, '0.228626' => -9, - '2090041883' => -10, '401566.3639' => -3, '36.50' => 3, '332.194' => -2, - '0.219563' => 12, '797537412' => 2, '201185.129926' => -10, '39.84' => 2, - '28.949' => -1, '0.90017' => 3, '1507444163' => -3, '393697.245306' => -9, - '33.51' => 3, '792.686' => -2, '0.414281' => 1, '310944923' => -10, - '115040.277099' => -8, '28.81' => -2, '233.141' => 2, '0.439580' => 2, - '2092212441' => -5, '240345.380203' => 1, '58.34' => 1, '695.915' => 5, - '0.126809' => 3, '1552125996' => 5, '453985.493977' => -3, '21.19' => -2, - '835.314' => -2, '0.222151' => -1, '1685322602' => -9, '363098.127513' => -3, - '86.70' => 2, '634.737' => 5, '0.131834' => 10, '1276312123' => 12, - '191584.241297' => 12, '74.13' => -2, '462.308' => 3, '0.489398' => -9, - '605075305' => 6, '68278.510821' => 5, '68.82' => -2, '791.588' => 2, - '0.356921' => -1, '929919464' => 8, '426669.418615' => -6, '7.47' => 2, - '287.325' => 1, '0.218276' => 9, '1275754734' => -6, '512048.379741' => 5, - '98.35' => 4, '65.544' => 5, '0.272214' => 1, '773380702' => -7, - '262015.91195' => 11, '91.83' => -2, '383.993' => 3, '0.128372' => -10, - '752359425' => -2, '56159.171441' => 8, '26.54' => 3, '473.192' => -5, - '0.521075' => 2, '1689479013' => 5, '347839.150197' => -4, '52.43' => -1, - '199.627' => -3, '0.152574' => -7, '1351329243' => 9, '372598.386073' => 4, - '52.23' => -2, '251.288' => 2, '0.426629' => 8, '1172920955' => -5, - '333459.109908' => 3, '63.41' => -3, '636.795' => 4, '0.448941' => 0, - '786612913' => -10, '381432.40354' => 0, '35.74' => 2, '381.181' => -4, - '0.113118' => -1, '1580207428' => 12, '312052.194964' => 7, '54.60' => 0, - '463.527' => -4, '0.502017' => 11, '28421197' => -3, '455359.388371' => -4, - '44.75' => -4, '918.209' => -1, '0.194597' => 1, '1163350661' => -2, - '97917.71785' => -10, '62.1' => -3, '146.216' => 0, '0.38631' => -12, - '900569107' => -8, '261095.150936' => -10, '38.26' => 4, '630.568' => -3, - '0.92956' => -2, '1804971260' => 11, '24094.14296' => 5, '18.47' => 0, - '985.686' => 5, '0.11043' => -9, '708948475' => 6, '443943.434178' => -1, - '73.10' => 3, '313.569' => -1, '0.382185' => 11, '1898592770' => 6, - '243998.487618' => 2, '45.79' => -2, '722.781' => 5, '0.460099' => 5, - '945769609' => 8, '127141.150556' => -7, '97.77' => 4, '140.391' => 4, - '0.44704' => -1, '463388026' => -10, '361326.357130' => 12, '0.35' => -2, - '349.790' => 3, '0.15362' => 2, '820198660' => 4, '458826.327385' => -1, - '619.814' => 2, '0.46267' => -11, '393398368' => 10, '455329.457371' => -5, - '15.99' => 3, '787.471' => -3, '0.192102' => -12, '1468529827' => 0, - '508533.293066' => 6, '47.97' => 2, '641.64' => -4, '0.369226' => 11, - '1839566271' => -9, '239288.380153' => 10, '49.92' => -1, '144.216' => 1, - '0.84409' => -10, '1259217342' => 2, '173336.291671' => 9, '28.88' => 2, - '17.312' => 3, '0.511154' => 7, '2029269530' => -12, '473889.210427' => 8, - '85.5' => 1, '665.727' => -3, '0.393714' => 0, '151233890' => 10, - '383876.210258' => -4, '10.17' => -3, '906.27' => 3, '0.365852' => -10, - '224382563' => -12, '437109.4381' => 4, '67.89' => -1, '159.104' => -3, - '0.339486' => 12, '1862914143' => 9, '101239.314401' => 5, '74.22' => -4, - '1000.168' => 3, '0.45778' => 7, '1663878468' => 9, '267035.319042' => -8, - '100.88' => 0, '126.600' => -1, '0.55631' => 1, '857937515' => -6, - '506127.310697' => 12, '68.31' => -4, '54.307' => 5, '0.433604' => -10, - '2100668704' => -3, '307303.255605' => 3, '4.21' => 3, '648.785' => 0, - '0.100605' => -10, '706157416' => 10, '453071.154241' => 2, '38.87' => -1, - '807.801' => 2, '0.481221' => 12, '832432926' => 3, '120398.510533' => 10, - '906.297' => -1, '0.517726' => -7, '200952545' => 0, '42316.502132' => -5, - '675.935' => -4, '0.350550' => 11, '1224345436' => 9, '392278.419310' => -11, - '24.79' => -3, '208.462' => 4, '0.215814' => -8, '1451226453' => -1, - '401728.396619' => 0, '2.86' => -1, '1000.41' => -4, '0.493887' => -10, - '2009460819' => 5, '401594.358581' => 0, '82.55' => 3, '441.795' => -1, - '0.328834' => 8, '610865731' => -7, '373058.26577' => -5, '43.8' => -3, - '230.32' => 3, '0.164383' => 8, '1168333968' => 12, '255056.162543' => -6, - '10.75' => 3, '121.791' => 2, '0.500997' => 0, '1488546354' => -2, - '378017.212184' => -6, '58.72' => 3, '511.91' => 1, '0.181246' => 4, - '1328228167' => -2, '342848.55043' => 10, '91.30' => 1, '998.457' => -3, - '0.254136' => -11, '992870908' => -2, '342217.96130' => -8, '97.16' => 4, - '774.173' => 4, '0.219060' => 10, '688916804' => 0, '214139.511040' => -12, - '56.4' => 1, '298.912' => 4, '0.179565' => -4, '1648744440' => -3, - '301225.220454' => 8, '36.96' => -3, '777.92' => -5, '0.363420' => -8, - '1540254552' => 0, '286658.65890' => -12, '74.55' => 2, '448.30' => 2, - '0.421306' => 1, '2054049169' => -3, '93475.278413' => 2, '69.35' => -3, - '381.896' => -5, '0.304011' => -10, '1310287670' => 2, '315980.82265' => -5, - '85.15' => 1, '805.591' => 1, '0.191051' => 3, '2109206142' => -3, - '506142.84130' => -4, '33.54' => 4, '547.694' => -1, '0.339179' => -4, - '1996535939' => -6, '299486.279127' => -6, '12.26' => 4, '837.956' => -3, - '0.233547' => 9, '537470584' => -5, '335813.113073' => -2, '17.92' => 0, - '360.580' => 0, '0.367785' => -8, '975514236' => -7, '253630.13361' => 3, - '1.29' => 4, '553.994' => -4, '0.214617' => -9, '955561142' => -2, - '454321.44816' => 4, '58.4' => 0, '534.730' => 1, '0.374423' => -8, - '895237981' => -2, '32973.472194' => -8, '80.21' => -2, '383.67' => 5, - '0.266785' => 11, '832156768' => -1, '71293.133197' => 11, '71.62' => -4, - '227.594' => -5, '0.219087' => 8, '515978774' => -5, '249592.158944' => 8, - '53.53' => 2, '489.267' => -5, '0.229370' => -10, '1260314162' => 7, - '382476.378986' => 8, '74.79' => 2, '867.614' => 3, '0.353751' => -3, - '1491936863' => -12, '454214.89546' => 10, '84.75' => 1, '792.625' => 2, - '0.472840' => 12, '1646314706' => -11, '464997.260120' => 0, '26.95' => 4, - '740.620' => 2, '0.66293' => -6, '636315921' => -5, '109877.85276' => 8, - '77.84' => -1, '557.967' => 4, '0.287182' => 1, '1258982012' => 9, - '187442.248077' => -5, '44.7' => 4, '727.254' => -3, '0.519671' => 8, - '230346146' => -3, '105834.166114' => -5, '75.21' => -3, '114.583' => 5, - '0.334914' => 10, '1623042297' => -9, '233591.59404' => -7, '68.13' => -2, - '330.58' => -3, '0.74911' => -1, '1787196074' => -11, '176538.17873' => -6, - '23.31' => 3, '231.115' => -3, '0.62236' => 8, '2081067983' => 6, - '513664.217376' => 9, '67.67' => 2, '868.145' => -5, '0.167298' => -11, - '235063451' => -5, '282355.233927' => -9, '23.41' => -4, '668.649' => -3, - '0.265170' => -4, '225569705' => 7, '336582.44447' => -1, '77.56' => 1, - '562.167' => 1, '0.326419' => 6, '25752866' => 0, '334487.288642' => 6, - '66.41' => 3, '646.905' => -5, '0.522260' => 6, '1051048962' => -2, - '464112.68898' => -10, '76.95' => 2, '527.898' => -5, '0.131253' => -7, - '1536377413' => 0, '132027.185291' => -6, '17.47' => -1, '542.487' => -1, - '0.138450' => -5, '1564553396' => 0, '306411.321795' => 6, '39.65' => 2, - '708.246' => 2, '0.490782' => 3, '301106405' => 0, '397681.205539' => 4, - '83.18' => 1, '595.583' => 2, '0.478934' => -9, '1361154939' => 9, - '314604.114436' => 4, '99.65' => 0, '367.839' => 2, '0.517998' => 11, - '965803321' => 7, '223362.109185' => -9, '78.34' => -1, '5.208' => 4, - '0.81985' => -2, '534815524' => -9, '400342.445174' => 7, '33.100' => -4, - '705.31' => 0, '0.345202' => -5, '167708690' => -12, '77320.264306' => -10, - '94.9' => 2, '916.15' => 1, '0.167018' => 6, '1884242836' => -8, - '504611.336074' => 2, '66.75' => 4, '216.673' => -2, '0.272397' => -4, - '804534093' => -4, '230442.273740' => 2, '19.3' => -2, '585.768' => -3, - '0.178557' => -7, '833374022' => -10, '343018.183783' => -7, '32.52' => -4, - '844.37' => -2, '0.104299' => 12, '631164853' => 1, '81230.384535' => 2, - '49.28' => -4, '485.879' => -2, '0.367677' => -10, '421212287' => -7, - '229033.445853' => -10, '93.76' => -2, '51.659' => 3, '0.7081' => 7, - '726125328' => 9, '226146.258507' => -5, '75.53' => 0, '872.298' => -5, - '0.514402' => 11, '301733263' => 12, '46503.302698' => -8, '88.95' => 0, - '692.341' => 2, '0.247996' => -4, '440384341' => -4, '347016.333662' => 8, - '16.5' => 2, '97.104' => 5, '0.9960' => -6, '587145931' => -10, - '137925.189849' => -9, '89.61' => -2, '298.932' => -4, '0.338602' => 1, - '1881453802' => -2, '113315.282068' => 9, '24.65' => 0, '627.672' => 0, - '0.472303' => 2, '1426268683' => 5, '445735.486135' => -8, '22.43' => 1, - '608.496' => 0, '0.67854' => -3, '1706716161' => -9, '520276.5705' => -12, - '53.79' => 0, '258.757' => -4, '0.438510' => 7, '1004776687' => 4, - '436364.166754' => 0, '91.65' => -1, '103.403' => -4, '0.258641' => 2, - '1587482095' => 1, '282317.383557' => -5, '21.83' => -4, '936.124' => -2, - '0.373783' => -10, '1625426089' => 12, '241840.308909' => -8, '96.40' => 4, - '506.639' => 3, '0.54486' => -9, '1481879732' => -9, '220079.119816' => 9, - '31.79' => 2, '127.485' => -4, '0.118745' => -5, '562468606' => -8, - '198378.379161' => 12, '61.53' => 3, '284.788' => -4, '0.231304' => 7, - '1969544595' => 10, '385061.176637' => -9, '5.67' => -2, '848.223' => 1, - '0.77794' => -10, '615691954' => -1, '226840.348693' => -2, '54.75' => -4, - '893.820' => 4, '0.355600' => 3, '1078526925' => -6, '205610.124085' => 2, - '55.99' => 2, '593.269' => 2, '0.357361' => 9, '672306509' => -2, - '434174.390977' => 12, '75.17' => 4, '1000.600' => -2, '0.319940' => -10, - '788933660' => -6, '458134.398221' => -10, '51.90' => 3, '536.386' => 5, - '0.209606' => -7, '1333578221' => -11, '19114.235467' => 5, '41.21' => 0, - '496.845' => -4, '0.315981' => 5, '2140386144' => -1, '297586.456401' => 12, - '68.24' => 4, '175.348' => 0, '0.198181' => 9, '1987222384' => 6, - '241378.504276' => 12, '63.86' => 4, '977.625' => 0, '0.364493' => -4, - '1669268745' => -7, '103573.180834' => 5, '710.343' => -5, '0.297275' => -2, - '362208538' => 6, '377524.329808' => 0, '55.8' => -3, '563.3' => 2, - '0.464184' => -5, '1135770879' => 5, '205055.380861' => 4, '66.27' => 4, - '342.903' => 4, '0.400438' => -8, '1902658601' => -1, '504249.317753' => 11, - '78.11' => -1, '786.65' => 3, '0.45893' => 8, '1083352314' => 11, - '321446.469545' => 3, '85.100' => 1, '819.232' => -5, '0.515486' => 11, - '888046360' => 12, '486962.196769' => 9, '79.25' => 0, '50.386' => -2, - '0.448836' => -4, '662933581' => -1, '47159.483295' => -3, '54.10' => -1, - '147.247' => -1, '0.47789' => 4, '1420380237' => -7, '52410.309447' => 0, - '8.67' => 1, '965.876' => 2, '0.169213' => -11, '1159443878' => 6, - '48355.330226' => 3, '6.9' => -1, '528.601' => 0, '0.101339' => 6, - '2083533883' => 5, '103030.36798' => 9, '206.712' => 0, '0.142726' => -4, - '166291914' => -12, '349423.88954' => 8, '52.50' => -3, '997.844' => 5, - '0.385892' => 2, '567429324' => -12, '467533.241563' => 5, '54.42' => -1, - '892.68' => -2, '0.124688' => 12, '69447445' => -4, '79880.366378' => -5, - '92.0' => -1, '975.95' => -3, '0.286829' => -11, '246664446' => 8, - '281997.3466' => 8, '34.81' => -2, '94.628' => -3, '0.48059' => -6, - '1317798191' => 9, '95061.401608' => -9, '36.74' => 1, '976.644' => 0, - '0.27918' => 1, '830145843' => -8, '1207.484669' => -8, '724.178' => 5, - '0.522648' => 3, '1007597492' => -6, '206406.341057' => 3, '31.74' => -3, - '196.934' => 5, '0.393853' => 3, '1762818530' => 12, '81088.431583' => -9, - '9.30' => -2, '276.571' => -4, '0.460856' => -4, '1350580999' => 2, - '93449.11849' => -4, '24.31' => 0, '301.488' => -3, '0.488295' => -9, - '250903215' => -7, '197613.142344' => 6, '60.67' => -1, '855.15' => -1, - '0.111877' => -12, '1260264928' => 10, '127501.401131' => 9, '32.10' => -2, - '301.859' => 1, '0.226112' => -10, '727090804' => 7, '284397.375125' => 1, - '15.42' => -3, '869.645' => 4, '0.465527' => 10, '1730135295' => 9, - '367342.25609' => -1, '29.56' => 1, '171.971' => 4, '0.141928' => 5, - '1067855866' => -2, '498043.20816' => 3, '15.48' => 2, '374.58' => 5, - '0.149323' => 2, '969946418' => 11, '221008.79857' => -10, '72.43' => 1, - '278.392' => -1, '0.516575' => -4, '1631715279' => 4, '142822.372123' => 0, - '48.68' => 1, '628.451' => 2, '0.116123' => 6, '1449499030' => 6, - '433070.50602' => 4, '76.54' => 4, '931.674' => 5, '0.151400' => -3, - '74388227' => 4, '74188.160983' => -11, '91.24' => 1, '907.972' => 5, - '0.333071' => -2, '358908368' => -8, '454233.520694' => -5, '96.16' => 2, - '143.166' => -2, '0.270170' => -12, '1474258062' => -1, '263898.434114' => 1, - '49.76' => -2, '742.406' => 4, '0.91057' => 8, '640336' => -11, - '184561.454389' => -4, '646.67' => 3, '0.353302' => 11, '890011967' => 2, - '69500.481186' => -3, '18.68' => 4, '515.493' => 2, '0.169110' => -10, - '273070130' => 4, '3876.251228' => -4, '24.75' => -1, '542.280' => -4, - '0.262921' => -7, '1742471373' => 11, '164807.494908' => 10, '94.1' => 0, - '692.699' => 2, '0.407652' => -8, '1812106610' => -12, '180231.446285' => 10, - '19.62' => 0, '784.823' => 4, '0.6358' => -10, '129737024' => -4, - '126119.196481' => 8, '88.70' => -4, '385.780' => -5, '0.294964' => 6, - '1674263192' => 1, '242150.64699' => -2, '66.45' => 3, '276.251' => 5, - '0.200806' => 7, '184299841' => -6, '45397.171114' => -1, '40.70' => 3, - '756.941' => 0, '0.269884' => -6, '1771565159' => 0, '476831.150373' => -5, - '13.7' => -3, '12.894' => 1, '0.405670' => 9, '245118583' => -6, - '377666.105240' => 9, '5.59' => 0, '74.991' => 1, '0.179576' => 1, - '114722185' => 0, '419113.504839' => -8, '13.59' => -3, '187.304' => 3, - '0.19958' => 4, '1971862231' => -11, '491572.334790' => -9, '17.41' => -3, - '17.785' => -1, '0.297809' => -2, '1946685997' => -9, '154595.370090' => 3, - '93.72' => 2, '462.523' => -3, '0.54041' => 0, '1282241176' => 2, - '373945.280331' => -12, '66.84' => -4, '248.492' => -1, '0.340641' => -9, - '602753459' => -11, '357078.301751' => 1, '32.18' => -2, '400.442' => 2, - '0.481857' => -8, '1599180253' => 1, '296730.240082' => 0, '52.71' => -2, - '77.311' => 5, '0.120984' => 0, '1179534686' => 12, '271019.120762' => 0, - '72.364' => 0, '0.134213' => 10, '991808417' => -5, '419154.14583' => -12, - '25.99' => 3, '981.637' => -2, '0.246613' => 3, '1262950106' => 9, - '198756.55068' => -12, '89.75' => 0, '221.951' => 4, '0.72611' => -7, - '1064876135' => -7, '108406.154846' => 3, '14.89' => 1, '198.629' => 2, - '0.432856' => -4, '450209192' => -10, '62292.308670' => -2, '5.40' => -1, - '251.336' => 5, '0.243109' => 10, '190677574' => -1, '39160.154958' => 11, - '97.40' => 2, '105.783' => 1, '0.234700' => -7, '723572270' => 3, - '11631.238945' => 4, '83.30' => 0, '233.195' => 5, '0.60889' => -6, - '1609060270' => 4, '324092.431997' => -7, '53.46' => 3, '70.379' => -4, - '0.161560' => 10, '1079758822' => 8, '253900.275244' => 4, '6.93' => 2, - '865.264' => -5, '0.73080' => -7, '1853635520' => -3, '307076.252351' => 10, - '35.24' => -4, '351.618' => 1, '0.128587' => -12, '1791732556' => 11, - '299489.167047' => 6, '4.34' => 2, '349.462' => -5, '0.290050' => -4, - '1558058269' => 3, '256893.163173' => -2, '40.25' => -3, '881.793' => 5, - '0.465314' => 2, '1050433131' => -12, '412265.31655' => 6, '169.747' => -2, - '0.269635' => 7, '844311209' => -5, '375718.463024' => -7, '8.95' => 1, - '894.747' => 0, '0.239334' => -4, '771235551' => 3, '186636.76267' => 11, - '20.74' => -1, '68.656' => 1, '0.451009' => -4, '1396818915' => -8, - '214698.192451' => -6, '99.22' => 4, '750.803' => 4, '0.37243' => 2, - '490909289' => -6, '107286.306487' => -2, '99.78' => -3, '384.17' => 0, - '0.384777' => -9, '627042627' => 9, '68753.367784' => -3, '66.74' => -2, - '581.240' => 1, '0.91844' => -3, '1358390352' => -5, '388694.438925' => -2, - '4.97' => -2, '436.481' => 5, '0.292863' => -12, '1915994911' => -7, - '314286.12237' => 9, '29.21' => -1, '785.665' => 3, '0.83220' => -12, - '713828588' => 8, '127598.38681' => 7, '39.68' => -2, '673.638' => 0, - '0.360560' => 12, '396425761' => -8, '24423.411070' => 2, '13.90' => 1, - '675.598' => -3, '0.365168' => 10, '1551896366' => 6, '287288.506478' => -12, - '19.49' => -3, '982.526' => -1, '0.498741' => -12, '498842326' => -7, - '416076.146210' => -9, '88.5' => -1, '273.967' => 2, '0.82083' => -5, - '96507945' => 4, '362738.310849' => 9, '77.4' => 3, '442.270' => 1, - '0.250705' => -9, '776729985' => -7, '187149.81419' => 5, '55.87' => -2, - '557.605' => 4, '0.443261' => 8, '1015175741' => 7, '336085.86296' => 10, - '96.25' => 0, '875.972' => -3, '0.11882' => 0, '1585025947' => -1, - '83806.49831' => -3, '936.573' => 2, '0.390534' => -5, '151911157' => -2, - '162070.373172' => -7, '20.34' => 3, '589.920' => 3, '0.55338' => 5, - '317649471' => 11, '171289.161357' => 9, '14.894' => 0, '0.169460' => -11, - '998696332' => 3, '448682.405892' => -3, '57.30' => -2, '31.168' => 1, - '0.382562' => 1, '1017199412' => -6, '61394.419628' => 9, '67.64' => -4, - '115.381' => 1, '0.84776' => 0, '335831848' => 5, '51310.6384' => 3, - '25.97' => -3, '579.539' => 4, '0.57923' => 12, '581829645' => -6, - '76440.203443' => 2, '676.88' => 3, '0.101913' => -8, '1921580350' => -6, - '459965.520446' => -4, '19.61' => -2, '443.825' => 2, '0.230763' => -6, - '1096029721' => 11, '272402.34425' => 5, '99.54' => 4, '353.632' => 5, - '0.285236' => -11, '644786723' => 8, '92638.93095' => -2, '46.63' => 0, - '331.596' => 2, '0.300748' => 1, '992008167' => -12, '391472.514592' => -10, - '89.73' => 3, '689.742' => 4, '0.386946' => -1, '640884548' => -5, - '379991.249104' => -12, '1.67' => -3, '373.115' => -4, '0.471745' => 7, - '1714925717' => 5, '405376.285867' => -3, '39.23' => 0, '69.930' => 3, - '0.284324' => 1, '1734248167' => 4, '369934.279103' => 9, '69.33' => 4, - '498.967' => 0, '0.136923' => 2, '595889189' => 9, '119482.26568' => -11, - '56.100' => 1, '776.870' => 3, '0.155946' => 6, '862253778' => -2, - '132540.56157' => -10, '2.32' => 1, '799.397' => 1, '0.202929' => 2, - '975505082' => 4, '376640.357642' => 4, '25.28' => -2, '84.95' => -5, - '0.429104' => 11, '719501086' => -3, '260910.308200' => -7, '15.35' => -3, - '978.260' => -5, '0.296448' => -1, '240455431' => 4, '163252.435345' => -12, - '15.96' => -4, '8.390' => 0, '0.488281' => 2, '2063595465' => -7, - '224670.240429' => -6, '59.1' => 2, '66.88' => -5, '0.272565' => -5, - '2064240053' => 4, '353224.142929' => 3, '30.62' => -1, '89.339' => 1, - '0.344641' => 12, '437521483' => -6, '281381.331487' => 3, '39.67' => -1, - '725.468' => 0, '0.20699' => 2, '519210309' => 12, '325015.479985' => -12, - '29.57' => -4, '177.787' => 1, '0.90600' => 12, '496186991' => -1, - '32893.402520' => -3, '16.40' => -3, '896.535' => 1, '0.253518' => -12, - '35522617' => 2, '301654.333687' => 6, '72.94' => 3, '554.599' => -1, - '0.269657' => -7, '1391964796' => 7, '77705.372729' => 6, '85.67' => -3, - '232.449' => 2, '0.136599' => -8, '1654464260' => 11, '345178.181287' => -6, - '19.63' => -2, '48.785' => 1, '0.132377' => -7, '2117933516' => -5, - '23278.70491' => 10, '29.46' => 1, '122.461' => 4, '0.167001' => -5, - '489022220' => 6, '523772.464568' => -10, '245.594' => -1, '0.240900' => -7, - '1073876604' => 9, '391436.285454' => -1, '10.88' => -1, '717.944' => -2, - '0.6014' => 7, '1105176714' => -6, '183800.269302' => -7, '43.31' => 3, - '727.660' => 5, '0.486536' => 2, '881050931' => -10, '296020.82249' => -2, - '52.7' => -3, '406.733' => -2, '0.104091' => -6, '1159938485' => 6, - '515845.466988' => 5, '68.65' => -4, '624.146' => -5, '0.98714' => 6, - '1865766716' => -11, '263588.227241' => 2, '58.27' => 0, '606.956' => 1, - '0.463708' => -4, '155865207' => -9, '454735.29610' => -2, '16.100' => -4, - '81.371' => 1, '0.436074' => 6, '1732624335' => 1, '82834.162304' => 5, - '79.71' => 4, '307.790' => -2, '0.332778' => -5, '954404878' => 4, - '51864.163456' => 5, '40.93' => -1, '515.487' => -4, '0.129485' => 1, - '179865788' => -5, '10314.126747' => -11, '15.14' => -3, '483.172' => -2, - '0.405335' => -9, '1725134882' => 8, '269876.473040' => -7, '31.94' => -2, - '88.723' => 2, '0.321245' => -7, '1134932876' => 12, '12366.287397' => 5, - '70.9' => -1, '432.18' => 1, '0.294402' => 6, '1176528959' => 7, - '4544.32826' => -3, '34.58' => 0, '305.562' => 1, '0.270004' => -6, - '519119598' => -8, '456581.139104' => -11, '65.29' => 3, '862.335' => -3, - '0.315414' => -7, '2140092333' => 10, '137059.2740' => -9, '54.55' => 0, - '102.418' => -5, '0.196226' => 2, '1615928903' => 11, '511813.326807' => 3, - '43.53' => 1, '721.723' => -2, '0.485730' => 4, '1216632514' => -4, - '248307.434089' => 11, '36.47' => 2, '488.341' => 0, '0.34604' => 10, - '1758910663' => 5, '173818.416947' => 8, '36.88' => -3, '209.467' => -3, - '0.460928' => 11, '582273698' => -3, '166175.390463' => -1, '43.63' => -2, - '98.204' => 2, '0.516467' => -12, '1559365444' => -6, '46679.30234' => 8, - '27.97' => 0, '187.614' => -5, '0.70257' => 0, '1886354324' => 0, - '492363.102423' => -2, '44.58' => -3, '249.942' => -4, '0.136477' => -3, - '1357889353' => 11, '383185.378195' => 12, '25.31' => -2, '331.480' => 2, - '0.427866' => -6, '1642764933' => 3, '9938.369141' => 5, '92.33' => -3, - '488.999' => 3, '0.445313' => 5, '1348858011' => -6, '128791.188208' => 0, - '69.45' => -2, '112.936' => 5, '0.201364' => -1, '162495054' => 6, - '234154.49610' => -9, '26.77' => -1, '530.154' => -5, '0.121155' => -12, - '581488470' => -12, '254555.270756' => 9, '81.91' => 2, '890.256' => -1, - '0.184203' => -4, '212067454' => 4, '413890.285928' => -2, '89.79' => 1, - '798.943' => 1, '0.424338' => 5, '1518296227' => -8, '17044.100945' => -10, - '88.40' => -2, '814.47' => -5, '0.83877' => -5, '1979121881' => -3, - '433033.372786' => -6, '35.69' => -1, '234.931' => 3, '0.491675' => 5, - '1893353723' => 6, '429908.479289' => 4, '16.72' => -1, '744.633' => -2, - '0.12874' => -3, '1652500606' => 7, '26939.312188' => 11, '95.1' => 3, - '777.776' => -5, '0.254411' => -12, '1602139214' => 5, '188034.296767' => -3, - '99.45' => -3, '769.658' => 3, '0.73128' => -2, '487927630' => 5, - '329514.146062' => 10, '13.45' => -2, '523.73' => 2, '0.277560' => -1, - '355146425' => 1, '485252.274739' => -6, '72.83' => -3, '626.421' => 1, - '0.31743' => -5, '2092908655' => 2, '246392.316190' => -5, '89.70' => 4, - '376.946' => -3, '0.433827' => -6, '1755052572' => -1, '393176.389443' => 12, - '95.23' => 1, '872.41' => 1, '0.85765' => -12, '1255127494' => -10, - '204365.28532' => -9, '2.63' => 4, '816.32' => -1, '0.38750' => -3, - '1868771565' => 9, '447108.325131' => 10, '21.58' => -1, '185.478' => 1, - '0.109531' => 4, '1654866032' => 4, '408753.84097' => 7, '11.88' => 0, - '327.967' => 3, '0.379086' => 8, '1429295707' => -11, '488263.271769' => 2, - '89.42' => 1, '52.334' => 0, '0.377803' => 12, '1318328164' => 1, - '176363.206322' => 0, '92.77' => -3, '541.388' => -5, '0.181873' => -12, - '153912328' => -10, '369317.1551' => -12, '57.42' => 4, '914.395' => 2, - '0.464426' => -11, '1275606463' => -10, '318052.487790' => 0, '11.81' => -2, - '873.568' => -4, '0.474255' => 2, '1448766956' => 10, '486044.198732' => 12, - '29.55' => 0, '264.790' => 2, '0.165316' => -12, '321934385' => 4, - '92094.396649' => 10, '1.96' => -4, '129.750' => -5, '0.363401' => 3, - '1124207770' => 4, '330513.236221' => -3, '91.4' => 1, '684.421' => 3, - '0.376355' => 2, '539466993' => 6, '338682.223800' => 9, '680.570' => -1, - '0.151635' => -9, '1666663786' => -6, '330571.213126' => 8, '1.17' => -1, - '957.104' => -4, '0.278996' => 2, '711170694' => 8, '361748.512307' => 7, - '46.71' => -2, '78.634' => 4, '0.104999' => -1, '1578756048' => 11, - '385689.191722' => 12, '75.40' => 4, '572.127' => -4, '0.87360' => -6, - '194691078' => 4, '232264.409280' => 0, '9.94' => 1, '841.437' => -5, - '0.164100' => 5, '1299079227' => 3, '322013.178559' => -11, '321.969' => 0, - '0.308985' => 3, '638463866' => -9, '331670.388139' => 5, '39.56' => -4, - '604.886' => 3, '0.149885' => -8, '1778392533' => -8, '129537.231903' => 10, - '44.57' => 1, '81.138' => 4, '0.376795' => 8, '2015329247' => 6, - '213926.299406' => -12, '68.15' => 3, '903.28' => 2, '0.48715' => 3, - '1736838292' => -5, '107381.29281' => 11, '638.88' => 0, '0.231656' => 4, - '861705318' => 8, '431381.424303' => -3, '354.632' => -4, '0.505326' => -9, - '954188025' => 6, '338440.340337' => 7, '8.55' => -4, '79.450' => -4, - '0.394793' => -8, '2120370310' => 10, '142616.424762' => -9, '39.64' => -2, - '744.207' => -4, '0.458267' => 6, '1018468383' => -8, '494834.62802' => -5, - '12.5' => 2, '145.397' => 5, '0.170869' => -3, '605361750' => -9, - '159681.290410' => -5, '78.51' => -2, '631.654' => 1, '0.199611' => 8, - '19995477' => 1, '443496.499715' => 9, '43.11' => -5, '0.227522' => -1, - '1268123310' => -4, '341246.469282' => 5, '16.4' => 2, '678.918' => -5, - '0.270488' => 6, '545052123' => -5, '80589.52277' => 1, '92.20' => -3, - '246.275' => 3, '0.360145' => 7, '276565302' => 5, '223106.408766' => -6, - '55.33' => 2, '409.420' => 4, '0.70752' => 6, '124029482' => 11, - '241885.110870' => -3, '34.40' => 4, '181.390' => 1, '0.509781' => 9, - '1196793147' => -11, '185890.515292' => -10, '68.43' => 0, '276.271' => -1, - '0.18264' => 9, '1668393853' => -2, '416898.124919' => -10, '17.65' => -2, - '216.867' => -2, '0.33306' => 5, '1693925058' => 8, '492757.75158' => 3, - '703.531' => 0, '0.284773' => 8, '453410602' => 2, '345315.3306' => -4, - '29.74' => 4, '57.823' => 5, '0.403424' => 9, '1461090654' => 10, - '265804.325180' => 1, '44.37' => -4, '906.94' => 2, '0.372266' => -7, - '1704091169' => 3, '502320.237065' => 11, '192.310' => -5, '0.17973' => 9, - '1568440410' => -10, '334644.124436' => 5, '35.78' => -1, '472.617' => 3, - '0.366749' => 8, '1016580040' => -4, '130283.226220' => 0, '95.36' => -3, - '382.586' => -3, '0.118419' => 0, '1269661192' => 3, '175634.120332' => 11, - '57.54' => 2, '282.918' => -2, '0.61553' => 10, '485269598' => 3, - '57798.248757' => 2, '65.97' => -4, '171.797' => -5, '0.357599' => 3, - '537426709' => -12, '513433.306841' => -6, '25.7' => -3, '353.997' => 2, - '0.132257' => 3, '506054940' => -10, '369460.181347' => -1, '40.60' => 2, - '647.868' => 3, '0.145186' => 3, '1368273320' => 1, '431677.323196' => 1, - '79.37' => -2, '68.752' => 0, '0.360084' => 0, '1318911357' => -12, - '252973.167172' => 11, '4.67' => -1, '487.686' => 3, '0.52781' => 3, - '345767518' => 12, '256618.516093' => 6, '31.14' => 1, '648.37' => 2, - '0.77394' => -1, '999084791' => 6, '339257.496890' => 7, '38.12' => 4, - '870.71' => -1, '0.251847' => -10, '148064284' => -8, '477213.292766' => 4, - '16.94' => -2, '645.55' => -4, '0.55673' => -8, '1916008879' => -7, - '505851.282744' => 2, '45.91' => -4, '323.41' => -5, '0.225493' => -10, - '609795303' => 1, '85495.101800' => 0, '46.21' => 3, '347.370' => 4, - '0.270065' => 11, '268889639' => -1, '25129.47210' => -2, '13.40' => 1, - '441.793' => -2, '0.289805' => -4, '1869358233' => -7, '378422.17593' => 8, - '83.49' => 3, '356.344' => 1, '0.145979' => 10, '846724011' => 9, - '139953.231849' => -2, '0.63' => -3, '937.56' => 0, '0.149658' => -6, - '1060686659' => 3, '233601.113091' => -9, '100.1' => 0, '559.322' => 5, - '0.250137' => -4, '421031725' => 3, '2274.242744' => 9, '68.32' => 0, - '802.63' => -2, '0.38081' => -4, '2053778662' => -4, '264919.210724' => 2, - '88.78' => 2, '769.266' => 4, '0.55346' => -8, '1647797972' => 6, - '322154.404569' => -5, '27.44' => 4, '733.52' => -1, '0.42017' => -1, - '1739861744' => -9, '362615.165402' => -12, '1.31' => 0, '161.20' => 2, - '0.171853' => 12, '1559012266' => -9, '224083.178484' => -10, '27.13' => -3, - '533.366' => 0, '0.521246' => 2, '1496801953' => -1, '252953.203757' => 8, - '87.13' => 4, '847.399' => -4, '0.435135' => -9, '557542360' => 6, - '430835.360202' => 1, '88.16' => 2, '685.358' => 0, '0.134357' => 9, - '695881783' => -4, '82260.422846' => 11, '73.20' => -2, '318.254' => 5, - '0.236925' => -3, '194660861' => -10, '335458.478360' => 5, '790.385' => -1, - '0.350204' => 7, '293539387' => 4, '311913.153924' => 12, '57.53' => 4, - '491.459' => 5, '0.448296' => -7, '676702556' => 10, '326500.500669' => 11, - '49.46' => -4, '885.88' => -3, '0.350773' => 2, '470837535' => 6, - '392572.426864' => 8, '75.67' => 0, '647.564' => 4, '0.460393' => -4, - '564421582' => -2, '191396.464298' => -8, '91.64' => -2, '832.567' => -3, - '0.214503' => -5, '110339611' => -7, '21932.419510' => 3, '35.19' => -3, - '85.458' => -1, '0.229354' => 12, '868322234' => -4, '277420.403389' => 5, - '100.49' => 2, '699.148' => 2, '0.520712' => -6, '1026256589' => 1, - '97377.272483' => -11, '66.19' => 1, '613.908' => 0, '0.313438' => 11, - '569881040' => -4, '23839.416551' => -12, '47.77' => 1, '439.823' => 3, - '0.356877' => 11, '1061041043' => 8, '451095.356420' => -9, '31.34' => 2, - '811.510' => -4, '0.388167' => -12, '822243100' => -10, '57744.224582' => -12, - '6.27' => 3, '60.84' => -3, '0.522899' => -12, '1765824910' => 7, - '484461.357917' => 0, '39.48' => 1, '609.753' => -2, '0.339243' => 7, - '1939477099' => 0, '261367.6961' => -12, '90.52' => -2, '702.632' => 0, - '0.371310' => 3, '839896957' => 3, '63058.165226' => 1, '886.380' => 4, - '0.357139' => 3, '223717296' => -12, '30014.315986' => 2, '91.49' => 0, - '33.736' => 0, '0.345573' => -10, '1573364975' => -1, '510675.447180' => -11, - '14.28' => -3, '141.674' => 5, '0.394923' => -5, '693454176' => -4, - '492663.199315' => 9, '90.36' => 0, '834.63' => 5, '0.491651' => 4, - '232172289' => 6, '405139.43069' => 4, '27.67' => -3, '583.563' => -5, - '0.460724' => 6, '186884682' => -5, '90980.14001' => -7, '407.830' => 1, - '0.37423' => 4, '815554087' => 7, '229295.79961' => -8, '29.53' => 4, - '589.211' => 2, '0.167863' => -6, '1268234610' => -10, '153127.400608' => -2, - '40.100' => 3, '592.759' => -1, '0.130577' => -7, '2124172267' => 8, - '4789.223603' => 3, '39.7' => -2, '784.390' => -5, '0.30447' => -7, - '682184859' => 5, '61682.319676' => 4, '48.81' => 0, '203.141' => 4, - '0.223201' => 2, '908398046' => -3, '10030.226566' => -2, '70.23' => 3, - '244.656' => 0, '0.247178' => 10, '1300114146' => 5, '190199.379092' => 7, - '27.89' => 2, '718.790' => 4, '0.163032' => 12, '763697413' => -7, - '330370.196479' => 6, '17.87' => 0, '374.945' => -5, '0.140864' => 5, - '897384185' => -2, '107363.409287' => 9, '56.88' => 1, '696.203' => -4, - '0.346641' => 11, '315672920' => 0, '130368.407439' => -12, '25.57' => -1, - '615.658' => 5, '0.166828' => 10, '662500778' => 11, '419572.269106' => 6, - '11.7' => -1, '215.966' => 1, '0.76981' => 8, '690359917' => 3, - '337115.298913' => -5, '99.32' => -4, '268.215' => -3, '0.84442' => 11, - '1830461013' => 1, '141583.342174' => -1, '5.10' => 3, '703.74' => -2, - '0.267173' => -5, '1955300868' => -7, '270237.290195' => 8, '59.38' => 1, - '655.174' => -3, '0.304600' => -2, '2016725871' => -4, '421952.109660' => -2, - '100.13' => 3, '455.590' => 4, '0.387782' => 11, '326443094' => -10, - '488051.349935' => 4, '25.79' => -2, '982.373' => -4, '0.202479' => -4, - '1437185531' => 11, '203056.248539' => -4, '26.53' => 0, '386.64' => -4, - '0.165902' => 6, '1802089567' => 8, '238281.403726' => -1, '10.39' => 1, - '550.431' => 4, '0.463228' => -8, '316156841' => 8, '74656.280243' => 1, - '438.593' => 1, '0.92801' => 5, '1044193208' => 10, '198279.493211' => -12, - '709.453' => -5, '0.472872' => -1, '637081832' => -4, '466448.230194' => -11, - '11.59' => 4, '208.643' => -2, '0.466927' => 10, '1774366832' => 8, - '438243.107186' => -3, '72.92' => 1, '966.219' => 1, '0.233141' => -11, - '886071886' => -9, '89226.158486' => 6, '22.29' => 2, '620.554' => -1, - '0.281044' => -11, '1903262225' => -1, '430692.378619' => -3, '34.28' => -3, - '908.20' => 4, '0.515546' => -11, '418400225' => -1, '108313.191374' => -3, - '12.92' => -1, '341.303' => 0, '0.213615' => -12, '994161677' => 8, - '105500.149119' => -5, '42.36' => 2, '215.961' => 0, '0.151327' => 0, - '2071739529' => 11, '178325.89821' => 0, '56.97' => -4, '432.296' => -3, - '0.235877' => 1, '823459397' => 5, '522933.306540' => 10, '35.62' => -4, - '99.588' => -1, '0.314118' => -3, '667770832' => 9, '188929.341355' => 2, - '69.29' => -3, '535.608' => 2, '0.41781' => 11, '1384659835' => -11, - '508848.336697' => -1, '66.40' => -3, '807.889' => -5, '0.90774' => 3, - '1060976301' => 0, '26839.447957' => 0, '6.83' => 3, '469.615' => -3, - '0.215229' => 9, '1943408411' => 5, '82774.459025' => -11, '4.35' => -3, - '382.412' => 4, '0.523800' => 6, '445411727' => 2, '36591.135582' => 0, - '4.41' => -3, '650.499' => -4, '0.260833' => 6, '933383067' => 10, - '505854.310651' => -2, '80.32' => 1, '153.397' => -1, '0.457857' => 8, - '864716751' => -3, '466315.247704' => -10, '68.38' => -2, '509.298' => 2, - '0.130576' => -7, '248206334' => 7, '103785.42163' => 5, '75.7' => 0, - '479.951' => 3, '0.155093' => -9, '1184600251' => 8, '474211.231236' => 5, - '68.85' => -2, '555.137' => -2, '0.399205' => 3, '900285806' => -3, - '36693.323581' => 9, '9.70' => -1, '458.900' => 4, '0.321701' => 9, - '1427377228' => -8, '468605.298404' => -8, '82.28' => -4, '610.468' => -1, - '0.122567' => 2, '2071388762' => -7, '56055.1825' => 3, '38.36' => -4, - '253.223' => 3, '0.49607' => 5, '1924595010' => 8, '849.414189' => 6, - '86.14' => 1, '583.502' => 3, '0.84266' => -7, '1001248538' => 6, - '203942.300501' => -9, '64.54' => 1, '342.276' => -1, '0.22490' => 3, - '990502631' => -3, '68229.242671' => 11, '7.58' => 0, '352.182' => 5, - '0.308290' => -1, '431852030' => -4, '245610.309375' => -11, '25.26' => 1, - '667.511' => -3, '0.152985' => 1, '1973200073' => 1, '258426.25679' => 6, - '51.28' => -3, '249.157' => -4, '0.374691' => -5, '1359777331' => 6, - '419342.53299' => 10, '73.76' => 2, '26.359' => 4, '0.301405' => -2, - '2069275744' => 4, '211798.239332' => 0, '68.5' => 1, '158.156' => 0, - '0.234814' => 4, '832155923' => 9, '412347.98217' => -10, '62.92' => -2, - '812.74' => -2, '0.116050' => 4, '680424040' => 4, '74953.377917' => -8, - '34.32' => 2, '805.894' => -3, '0.233956' => -2, '588372584' => -4, - '221640.31705' => 8, '35.64' => 1, '943.330' => -1, '0.318948' => -1, - '265975454' => 1, '385887.139888' => 11, '96.99' => -1, '234.502' => 2, - '0.334051' => 2, '1984107482' => 11, '409812.181753' => 10, '96.32' => 3, - '725.381' => 0, '0.104498' => 8, '754079843' => 12, '479393.45700' => -4, - '46.54' => 1, '231.781' => -4, '0.426330' => 4, '1313355869' => -2, - '172630.206167' => 6, '506.350' => 1, '0.160569' => -12, '9374862' => 1, - '457426.481681' => 4, '48.21' => 0, '371.236' => -5, '0.18262' => 8, - '483859935' => -11, '412138.290760' => 4, '86.23' => 3, '870.412' => 0, - '0.464076' => 8, '816125629' => 5, '196928.132387' => 10, '72.29' => -3, - '313.701' => 2, '0.63312' => 11, '10216986' => 6, '200164.414633' => -4, - '66.76' => -1, '237.527' => 1, '0.35438' => 12, '1495884017' => -2, - '158165.37846' => -1, '19.41' => -4, '135.711' => 0, '0.47582' => -7, - '2056545177' => 8, '93175.177962' => -10, '76.55' => -4, '113.71' => -1, - '0.48159' => 11, '766776723' => -9, '307529.345367' => 7, '77.5' => -2, - '575.837' => -4, '0.417865' => 9, '1521506019' => 11, '12107.464637' => 6, - '97.86' => 4, '273.570' => 3, '0.114173' => 9, '20096671' => 4, - '236082.312435' => 2, '89.0' => -2, '168.939' => 1, '0.23631' => -2, - '749143830' => 6, '257069.195003' => 6, '28.61' => 1, '403.712' => 3, - '0.143607' => -5, '2082566916' => 11, '264692.220233' => -5, '346.909' => -4, - '0.402410' => -12, '1651766620' => 11, '370943.136044' => -10, '85.77' => -1, - '508.355' => -2, '0.427580' => 12, '1987714863' => 3, '478356.225686' => 7, - '17.94' => 3, '31.900' => 5, '0.33942' => 8, '1658612685' => 4, - '410829.251590' => 8, '83.94' => -2, '220.549' => 3, '0.113337' => -9, - '1639086102' => -3, '78713.354235' => -9, '47.74' => -1, '651.323' => -5, - '0.245932' => 11, '1261711612' => -3, '116253.194576' => -6, '64.55' => -2, - '327.473' => 2, '0.241987' => -7, '1285865121' => 5, '435672.392645' => -7, - '10.37' => -1, '388.795' => -1, '0.161827' => 5, '230244765' => -6, - '265038.172466' => 10, '65.91' => -2, '595.102' => 4, '0.434638' => -3, - '126129840' => 2, '413719.466465' => -2, '29.28' => 2, '678.446' => -1, - '0.208034' => -7, '1065944072' => 6, '341032.990' => 0, '23.48' => 4, - '373.423' => -5, '0.389585' => -10, '1441107220' => -6, '356509.241264' => 8, - '422.816' => -3, '0.342884' => 4, '873838463' => -7, '375403.30084' => -9, - '98.38' => 0, '385.399' => 3, '0.257833' => -7, '1028034561' => -9, - '495168.83206' => -8, '1.78' => 1, '980.42' => -4, '0.331573' => 12, - '387462598' => 5, '443818.469998' => -12, '876.765' => 0, '0.53328' => 9, - '29407914' => -6, '219873.502347' => 2, '60.76' => -4, '908.795' => -3, - '0.459345' => -6, '2046247729' => -2, '244695.419102' => -11, '80.40' => 1, - '870.511' => -4, '0.388478' => 11, '427727793' => 3, '101019.324298' => 6, - '66.31' => 4, '522.594' => 0, '0.408007' => -6, '1499912745' => -1, - '276166.86597' => 6, '73.33' => 0, '506.748' => -1, '0.235478' => 9, - '1045213811' => 0, '127791.356198' => 4, '61.93' => 4, '404.785' => -2, - '0.353893' => 10, '776947132' => 2, '154285.465851' => -3, '37.26' => 3, - '631.660' => -3, '0.265100' => 12, '1038752775' => -10, '397025.381393' => 12, - '69.28' => -4, '581.356' => 5, '0.247522' => 6, '635005176' => -12, - '211983.309316' => 8, '41.9' => 4, '337.842' => 1, '0.173992' => -7, - '723221456' => -4, '177913.49305' => 8, '11.22' => -4, '174.875' => -5, - '0.475533' => -2, '981140567' => -4, '94672.451519' => -7, '81.20' => 4, - '776.331' => -5, '0.1686' => 9, '435229915' => 4, '250840.284170' => -4, - '55.55' => -4, '622.423' => 4, '0.25344' => 6, '146835656' => -4, - '279294.130521' => 0, '15.17' => -2, '185.308' => -4, '0.21281' => -1, - '299802106' => -5, '341504.324034' => -6, '64.34' => -4, '185.260' => 4, - '0.475653' => -5, '1376528125' => -5, '426514.91072' => 12, '50.38' => -3, - '522.535' => -5, '0.523764' => -4, '1398866761' => 2, '429538.158736' => -9, - '39.40' => 1, '284.128' => -5, '0.312023' => -5, '1275671412' => -12, - '5929.213670' => -7, '59.91' => -2, '941.134' => 5, '0.147235' => -1, - '106169053' => -9, '142750.455458' => 11, '47.62' => -4, '649.709' => -1, - '0.490043' => 1, '1246299209' => -5, '283381.310201' => 1, '83.52' => 4, - '462.800' => -1, '0.490291' => 2, '1520998937' => -10, '6895.514087' => 12, - '0.32' => -2, '743.520' => -1, '0.150701' => -9, '962438429' => -1, - '515717.518352' => 9, '94.28' => 4, '727.906' => 3, '0.158088' => 2, - '1458866058' => 9, '432610.363063' => -12, '95.100' => 2, '434.748' => 3, - '0.303128' => -4, '1690353126' => -12, '473459.404113' => -12, '69.96' => -1, - '753.376' => -4, '0.183909' => -12, '1890384328' => 4, '360580.369842' => -12, - '38.66' => 2, '475.112' => -1, '0.423296' => -9, '369343490' => 5, - '375810.39343' => 2, '190.438' => -5, '0.120623' => -1, '303710229' => 7, - '429459.434728' => -10, '51.20' => 0, '589.680' => -3, '0.380255' => -5, - '2121572252' => 0, '43009.369484' => 10, '44.41' => 0, '497.694' => -4, - '0.503517' => 2, '750917862' => 11, '17861.88501' => -10, '71.44' => 3, - '624.638' => 5, '0.482829' => 2, '178657038' => -3, '136615.86626' => 10, - '61.5' => -2, '172.139' => -4, '0.384425' => 8, '1574595991' => -10, - '105825.402284' => -10, '62.97' => -3, '878.194' => 2, '0.248212' => -5, - '1434390361' => -10, '12755.486808' => 1, '16.33' => 1, '450.861' => 3, - '0.136195' => 11, '94135708' => 2, '354832.128808' => 12, '44.769' => 5, - '0.182803' => -9, '557554733' => -6, '418674.148877' => -12, '93.10' => 0, - '911.305' => 1, '0.447984' => -1, '138482844' => 2, '292468.388641' => 10, - '472.740' => 1, '0.323103' => -4, '1226149205' => -10, '54987.193739' => 9, - '89.8' => -4, '692.67' => 3, '0.85097' => -11, '1319943123' => 11, - '429890.90431' => -7, '49.64' => 4, '198.959' => -3, '0.276511' => 11, - '30177090' => 2, '236303.62355' => -10, '17.36' => 1, '102.384' => -2, - '0.79893' => -3, '674979790' => 1, '405348.70392' => 7, '9.43' => 2, - '616.578' => 1, '0.284218' => 1, '253346959' => -10, '106539.298155' => 1, - '18.85' => 2, '169.131' => 4, '0.294728' => -6, '1722210543' => -5, - '26708.301522' => 9, '31.11' => 4, '694.36' => 2, '0.124103' => -6, - '810995233' => 2, '70871.304536' => -4, '25.10' => 3, '975.824' => -2, - '0.120505' => -2, '1495393117' => -3, '137570.391794' => -12, '74.93' => -2, - '619.75' => -4, '0.467372' => -8, '1662762076' => -5, '349689.476819' => -6, - '72.10' => 1, '383.667' => -1, '0.416946' => -8, '1253560206' => 10, - '486994.443615' => 0, '12.98' => 0, '135.77' => 0, '0.173148' => 2, - '1909493874' => 12, '124884.291587' => -10, '14.74' => -4, '107.573' => 4, - '0.160192' => 0, '867063434' => -3, '450761.174392' => 10, '87.86' => -4, - '356.210' => -2, '0.489071' => -2, '803631773' => 1, '338212.321083' => 8, - '70.52' => 1, '364.501' => 4, '0.456586' => -1, '1785975209' => 8, - '364576.362502' => -6, '79.48' => -1, '803.642' => 4, '0.109176' => -11, - '1323336416' => 2, '207735.137004' => 2, '92.90' => 2, '786.663' => -2, - '0.130848' => 8, '1331158018' => 1, '424006.165278' => -10, '75.56' => -1, - '428.695' => -5, '0.264127' => 4, '530578942' => 10, '254527.337271' => -9, - '42.30' => 2, '615.362' => 2, '0.224771' => -3, '1962960365' => 3, - '363152.378956' => -11, '14.11' => 0, '141.456' => -5, '0.426860' => 6, - '1349110264' => 11, '41910.59612' => -11, '80.12' => 0, '839.378' => -1, - '0.114787' => 6, '736831764' => 8, '448394.18754' => -9, '50.100' => -3, - '25.470' => 0, '0.393347' => 12, '2029781516' => -5, '181227.13175' => -3, - '656.11' => -3, '0.203296' => 3, '931979866' => -7, '190494.151640' => 6, - '51.27' => -3, '797.239' => 4, '0.410048' => -5, '1271106666' => 12, - '192689.491556' => 6, '99.24' => 3, '488.802' => -4, '0.60574' => -8, - '863081313' => -8, '482679.401208' => 1, '99.35' => 2, '184.752' => -3, - '0.257832' => -2, '914827407' => 1, '136969.416036' => -10, '65.0' => -4, - '169.741' => 3, '0.178673' => 3, '1698545278' => 9, '212734.373075' => 6, - '40.49' => -2, '691.776' => -2, '0.66820' => -10, '1373687051' => -6, - '184194.472342' => 1, '800.551' => -4, '0.210012' => 10, '1640724691' => 10 - ); - if (!Zend_Locale_Math::isBcmathDisabled()) { - // If no BCMath extension, the round below falls through to PHP's round(), - // which actually produces incorrect results, and fails these tests. - // There are many such examples ... - $this->assertEquals('56055.1812', Zend_Locale_Math::round('56055.18115', 4)); - $this->assertEquals( '639.80', Zend_Locale_Math::round('639.795', 2)); - $this->assertEquals( '267.84', Zend_Locale_Math::round('267.835', 2)); - $this->assertEquals( '0.30252', Zend_Locale_Math::round('0.302515', 5)); - $this->assertEquals( '0.3667', Zend_Locale_Math::round('0.36665', 4)); - } - - foreach ($rounder as $val => $precision) { - $this->assertEquals((string) round($val, $precision), (string)Zend_Locale_Math::round($val, $precision)); - } - } - - public function testAdd() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(3, Zend_Locale_Math_PhpMath::Add(1, 2 )); - $this->assertEquals(2, Zend_Locale_Math_PhpMath::Add(null, 2)); - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - //try { - // $this->assertEquals(9E+200, Zend_Locale_Math_PhpMath::Add(9E+100, 9E+200)); - // $this->fail("exception expected"); - //} catch (Zend_Locale_Math_Exception $e) { - // $this->assertEquals(array(9E+100, 9E+200, 9E+200), $e->getResults()); - // // success - //} - $this->assertEquals(15, Zend_Locale_Math_PhpMath::Add( 10.4444, 4.5556, 2)); - $this->assertEquals(15, Zend_Locale_Math_PhpMath::Add( 10.4444, 4.5556, 0)); - $this->assertEquals(-15, Zend_Locale_Math_PhpMath::Add(-10.4444, -4.5556, 0)); - } - - public function testSub() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(-1, Zend_Locale_Math_PhpMath::Sub( 1, 2)); - $this->assertEquals(-2, Zend_Locale_Math_PhpMath::Sub(null, 2)); - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - // $this->assertEquals(9E+300, Zend_Locale_Math_PhpMath::Sub(-9E+100, -9E+300)); - $this->assertEquals( 5.89, Zend_Locale_Math_PhpMath::Sub( 10.4444, 4.5556, 2)); - $this->assertEquals( 6, Zend_Locale_Math_PhpMath::Sub( 10.4444, 4.5556, 0)); - $this->assertEquals(-6, Zend_Locale_Math_PhpMath::Sub(-10.4444, -4.5556, 0)); - $this->assertEquals(-1, Zend_Locale_Math_PhpMath::Sub( 10, 11, 2)); - } - - public function testPow() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(1, Zend_Locale_Math_PhpMath::Pow( 1, 2)); - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Pow(null, 2)); - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - //try { - // $this->assertEquals(0, Zend_Locale_Math_PhpMath::Pow(9E+300, 9E+200)); - // $this->fail("exception expected"); - //} catch (Zend_Locale_Math_Exception $e) { - // // success - //} - $this->assertEquals( 11899.64, Zend_Locale_Math_PhpMath::Pow( 10.4444, 4.5556, 2)); - $this->assertEquals( 11900, Zend_Locale_Math_PhpMath::Pow( 10.4444, 4.5556, 0)); - $this->assertEquals( 11900, Zend_Locale_Math_PhpMath::Pow(-10.4444, 4, 0)); - $this->assertEquals(100000000000, Zend_Locale_Math_PhpMath::Pow( 10, 11, 2)); - } - - public function testMul() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(2, Zend_Locale_Math_PhpMath::Mul( 1, 2)); - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Mul(null, 2)); - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - //try { - // $this->assertEquals(0, Zend_Locale_Math_PhpMath::Mul(9E+300, 9E+200)); - // $this->fail("exception expected"); - //} catch (Zend_Locale_Math_Exception $e) { - // // success - //} - $this->assertEquals( 47.58, Zend_Locale_Math_PhpMath::Mul( 10.4444, 4.5556, 2)); - $this->assertEquals( 48, Zend_Locale_Math_PhpMath::Mul( 10.4444, 4.5556, 0)); - $this->assertEquals(-42, Zend_Locale_Math_PhpMath::Mul(-10.4444, 4, 0)); - $this->assertEquals(110, Zend_Locale_Math_PhpMath::Mul( 10, 11, 2)); - } - - public function testDiv() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(1, Zend_Locale_Math_PhpMath::Div( 1, 2)); - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Div(null, 2)); - try { - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Div(10, null)); - $this->fail("exception expected"); - } catch (Zend_Locale_Math_Exception $e) { - // success - } - - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - // $this->assertEquals(0, Zend_Locale_Math_PhpMath::Div(9E-300, 9E+200)); - $this->assertEquals( 2.29, Zend_Locale_Math_PhpMath::Div( 10.4444, 4.5556, 2)); - $this->assertEquals( 2, Zend_Locale_Math_PhpMath::Div( 10.4444, 4.5556, 0)); - $this->assertEquals(-3, Zend_Locale_Math_PhpMath::Div(-10.4444, 4, 0)); - $this->assertEquals( 0.91, Zend_Locale_Math_PhpMath::Div( 10, 11, 2)); - } - - public function testComp() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(-1, Zend_Locale_Math_PhpMath::Comp( 1, 2 )); - $this->assertEquals(-1, Zend_Locale_Math_PhpMath::Comp( null, 2 )); - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - // $this->assertEquals(-1, Zend_Locale_Math_PhpMath::Comp( 9E+100, 9E+200 )); - $this->assertEquals( 1, Zend_Locale_Math_PhpMath::Comp( 10.5556, 10.4444, 2)); - $this->assertEquals( 0, Zend_Locale_Math_PhpMath::Comp( 10.5556, 10.4444, 0)); - $this->assertEquals(-1, Zend_Locale_Math_PhpMath::Comp(-10.4444, -4.5556, 0)); - } - - public function testSqrt() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(1, Zend_Locale_Math_PhpMath::Sqrt( 1)); - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Sqrt( null)); - $this->assertEquals(3.25, Zend_Locale_Math_PhpMath::Sqrt(10.5556, 2)); - $this->assertEquals(3, Zend_Locale_Math_PhpMath::Sqrt(10.5556, 0)); - $this->assertEquals(NULL, Zend_Locale_Math_PhpMath::Sqrt(-10.4444)); - } - - public function testMod() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertEquals(1, Zend_Locale_Math_PhpMath::Mod( 1, 2)); - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Mod(null, 2)); - $this->assertEquals(null, Zend_Locale_Math_PhpMath::Mod(10, null)); - /** - * BCMath extension doesn't actually operatest with a scientific notation (e.g. 1.2e+100) - * So we shouldn't test numbers such as -9E+100, but probably should care about correct - * float => string conversion - * - * @todo provide correct behavior - */ - //$this->assertEquals(0, Zend_Locale_Math_PhpMath::Mod(9E-300, 9E+200)); - $this->assertEquals(2, Zend_Locale_Math_PhpMath::Mod( 10.4444, 4.5556)); - $this->assertEquals(2, Zend_Locale_Math_PhpMath::Mod( 10.4444, 4.5556)); - $this->assertEquals(-2, Zend_Locale_Math_PhpMath::Mod(-10.4444, 4 )); - $this->assertEquals(10, Zend_Locale_Math_PhpMath::Mod( 10, 11 )); - } - - public function testScale() - { - Zend_Locale_Math_PhpMath::disable(); - $this->assertTrue(Zend_Locale_Math_PhpMath::Scale(3)); - try { - $this->assertTrue(Zend_Locale_Math_PhpMath::Scale(10)); - $this->fail("exception expected"); - } catch (Zend_Locale_Math_Exception $e) { - // success - } - $this->assertEquals(1, Zend_Locale_Math_PhpMath::Comp(10.5556, 10.4444)); - $this->assertTrue(Zend_Locale_Math_PhpMath::Scale(0)); - $this->assertEquals(0, Zend_Locale_Math_PhpMath::Comp(10.5556, 10.4444)); - } -} diff --git a/tests/Zend/LocaleTest.php b/tests/Zend/LocaleTest.php deleted file mode 100644 index a9984dd1a01644ac7650612333bbc05e90fe61a6..0000000000000000000000000000000000000000 --- a/tests/Zend/LocaleTest.php +++ /dev/null @@ -1,619 +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_Locale - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -// define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', false); // uncomment to disable use of bcmath extension by Zend_Date - -/** - * Zend_Locale - */ -require_once 'Zend/Locale.php'; -require_once 'Zend/Cache.php'; - - -// echo "BCMATH is ", Zend_Locale_Math::isBcmathDisabled() ? 'disabled':'not disabled', "\n"; - -/** - * @category Zend - * @package Zend_Locale - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_LocaleTest extends PHPUnit_Framework_TestCase -{ - private $_cache = null; - - public function setUp() - { - require_once 'Zend/Cache.php'; - $this->_cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 120, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/_files/')); - Zend_Locale::setCache($this->_cache); - } - - public function tearDown() - { - $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL); - } - - /** - * test for object creation - * expected object instance - */ - public function testObjectCreation() - { - $this->assertTrue(is_string(Zend_Locale::isLocale('de')), 'true expected'); - - $this->assertTrue(new Zend_Locale() instanceof Zend_Locale); - $this->assertTrue(new Zend_Locale('root') instanceof Zend_Locale); - $this->assertTrue(new Zend_Locale(Zend_Locale::ENVIRONMENT) instanceof Zend_Locale); - $this->assertTrue(new Zend_Locale(Zend_Locale::BROWSER) instanceof Zend_Locale); - - $locale = new Zend_Locale('de'); - $this->assertTrue(new Zend_Locale($locale) instanceof Zend_Locale); - - $locale = new Zend_Locale('auto'); - $this->assertTrue(new Zend_Locale($locale) instanceof Zend_Locale); - } - - /** - * test for serialization - * expected string - */ - public function testSerialize() - { - $value = new Zend_Locale('de_DE'); - $serial = $value->serialize(); - $this->assertTrue(!empty($serial)); - - $newvalue = unserialize($serial); - $this->assertTrue($value->equals($newvalue)); - } - - /** - * test toString - * expected string - */ - public function testToString() - { - $value = new Zend_Locale('de_DE'); - $this->assertEquals('de_DE', $value->toString()); - $this->assertEquals('de_DE', $value->__toString()); - } - - /** - * test getDefault - * expected true - */ - public function testgetDefault() - { - Zend_Locale::setDefault('de'); - $value = new Zend_Locale(); - $default = $value->getDefault(); - $this->assertTrue(array_key_exists('de', $default)); - - $default = $value->getDefault(); - $this->assertTrue(is_array($default)); - - $default = $value->getDefault(Zend_Locale::BROWSER); - $this->assertTrue(is_array($default)); - - $default = $value->getDefault(Zend_Locale::ENVIRONMENT); - $this->assertTrue(is_array($default)); - - $default = $value->getDefault(Zend_Locale::FRAMEWORK); - $this->assertTrue(is_array($default)); - } - - /** - * test getEnvironment - * expected true - */ - public function testLocaleDetail() - { - $value = new Zend_Locale('de_AT'); - $this->assertEquals('de', $value->getLanguage()); - $this->assertEquals('AT', $value->getRegion()); - - $value = new Zend_Locale('en_US'); - $this->assertEquals('en', $value->getLanguage()); - $this->assertEquals('US', $value->getRegion()); - - $value = new Zend_Locale('en'); - $this->assertEquals('en', $value->getLanguage()); - $this->assertFalse($value->getRegion()); - } - - /** - * test getEnvironment - * expected true - */ - public function testEnvironment() - { - $value = new Zend_Locale(); - $default = $value->getEnvironment(); - $this->assertTrue(is_array($default)); - } - - /** - * test getBrowser - * expected true - */ - public function testBrowser() - { - $value = new Zend_Locale(); - $default = $value->getBrowser(); - $this->assertTrue(is_array($default)); - } - - /** - * test clone - * expected true - */ - public function testCloning() - { - $value = new Zend_Locale('de_DE'); - $newvalue = clone $value; - $this->assertEquals($value->toString(), $newvalue->toString()); - } - - /** - * test setLocale - * expected true - */ - public function testsetLocale() - { - $value = new Zend_Locale('de_DE'); - $value->setLocale('en_US'); - $this->assertEquals('en_US', $value->toString()); - - $value->setLocale('en_AA'); - $this->assertEquals('en', $value->toString()); - - $value->setLocale('xx_AA'); - $this->assertEquals('root', $value->toString()); - - $value->setLocale('auto'); - $this->assertTrue(is_string($value->toString())); - - $value->setLocale('browser'); - $this->assertTrue(is_string($value->toString())); - - $value->setLocale('environment'); - $this->assertTrue(is_string($value->toString())); - } - - /** - * test getLanguageTranslationList - * expected true - */ - public function testgetLanguageTranslationList() - { - $value = new Zend_Locale(); - $list = $value->getLanguageTranslationList(); - $this->assertTrue(is_array($list)); - $list = $value->getLanguageTranslationList('de'); - $this->assertTrue(is_array($list)); - } - - /** - * test getLanguageTranslation - * expected true - */ - public function testgetLanguageTranslation() - { - $value = new Zend_Locale('de_AT'); - $this->assertEquals('Deutsch', $value->getLanguageTranslation('de')); - $this->assertEquals('German', $value->getLanguageTranslation('de', 'en')); - $this->assertFalse($value->getLanguageTranslation('xyz')); - $this->assertTrue(is_string($value->getLanguageTranslation('de', 'auto'))); - } - - /** - * test getScriptTranslationList - * expected true - */ - public function testgetScriptTranslationList() - { - $value = new Zend_Locale(); - $list = $value->getScriptTranslationList(); - $this->assertTrue(is_array($list)); - - $list = $value->getScriptTranslationList('de'); - $this->assertTrue(is_array($list)); - } - - /** - * test getScriptTranslationList - * expected true - */ - public function testgetScriptTranslation() - { - $value = new Zend_Locale('de_AT'); - $this->assertEquals('Arabisch', $value->getScriptTranslation('Arab')); - $this->assertEquals('Arabic', $value->getScriptTranslation('Arab', 'en')); - $this->assertFalse($value->getScriptTranslation('xyz')); - } - - /** - * test getCountryTranslationList - * expected true - */ - public function testgetCountryTranslationList() - { - $value = new Zend_Locale(); - $list = $value->getCountryTranslationList(); - $this->assertTrue(is_array($list)); - - $list = $value->getCountryTranslationList('de'); - $this->assertEquals("Vereinigte Staaten", $list['US']); - } - - /** - * test getCountryTranslation - * expected true - */ - public function testgetCountryTranslation() - { - $value = new Zend_Locale('de_DE'); - $this->assertEquals('Deutschland', $value->getCountryTranslation('DE')); - $this->assertEquals('Germany', $value->getCountryTranslation('DE', 'en')); - $this->assertFalse($value->getCountryTranslation('xyz')); - } - - /** - * test getTerritoryTranslationList - * expected true - */ - public function testgetTerritoryTranslationList() - { - $value = new Zend_Locale(); - $list = $value->getTerritoryTranslationList(); - $this->assertTrue(is_array($list)); - - $list = $value->getTerritoryTranslationList('de'); - $this->assertTrue(is_array($list)); - } - - /** - * test getTerritoryTranslation - * expected true - */ - public function testgetTerritoryTranslation() - { - $value = new Zend_Locale('de_DE'); - $this->assertEquals('Afrika', $value->getTerritoryTranslation('002')); - $this->assertEquals('Africa', $value->getTerritoryTranslation('002', 'en')); - $this->assertFalse($value->getTerritoryTranslation('xyz')); - $this->assertTrue(is_string($value->getTerritoryTranslation('002', 'auto'))); - } - - /** - * test getTranslation - * expected true - */ - public function testgetTranslation() - { - $value = new Zend_Locale('de_DE'); - try { - $temp = $value->getTranslation('xx'); - $this->fail(); - } catch (Zend_Locale_Exception $e) { - $this->assertContains('Unknown detail (', $e->getMessage()); - } - - $this->assertEquals('Deutsch', $value->getTranslation('de', 'language')); - $this->assertEquals('German', $value->getTranslation('de', 'language', 'en')); - $this->assertFalse($value->getTranslation('xx', 'language')); - - $this->assertEquals('Lateinisch', $value->getTranslation('Latn', 'script')); - $this->assertEquals('Latin', $value->getTranslation('Latn', 'script', 'en')); - $this->assertFalse($value->getTranslation('xyxy', 'script')); - - $this->assertEquals('Österreich', $value->getTranslation('AT', 'country')); - $this->assertEquals('Austria', $value->getTranslation('AT', 'country', 'en')); - $this->assertFalse($value->getTranslation('xx', 'country')); - - $this->assertEquals('Afrika', $value->getTranslation('002', 'territory')); - $this->assertEquals('Africa', $value->getTranslation('002', 'territory', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'territory')); - - $this->assertEquals('Januar', $value->getTranslation('1', 'month')); - $this->assertEquals('January', $value->getTranslation('1', 'month', 'en')); - $this->assertFalse($value->getTranslation('x', 'month')); - - $this->assertEquals('Jan', $value->getTranslation(array('gregorian', 'format', 'abbreviated', '1'), 'month')); - $this->assertEquals('Jan', $value->getTranslation(array('gregorian', 'format', 'abbreviated', '1'), 'month', 'en')); - $this->assertFalse($value->getTranslation(array('gregorian', 'format', 'abbreviated', 'x'), 'month')); - - $this->assertEquals('J', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', '1'), 'month')); - $this->assertEquals('J', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', '1'), 'month', 'en')); - $this->assertFalse($value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'x'), 'month')); - - $this->assertEquals('Sonntag', $value->getTranslation('sun', 'day')); - $this->assertEquals('Sunday', $value->getTranslation('sun', 'day', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'day')); - - $this->assertEquals('So', $value->getTranslation(array('gregorian', 'format', 'abbreviated', 'sun'), 'day')); - $this->assertEquals('Sun', $value->getTranslation(array('gregorian', 'format', 'abbreviated', 'sun'), 'day', 'en')); - $this->assertFalse($value->getTranslation(array('gregorian', 'format', 'abbreviated', 'xxx'), 'day')); - - $this->assertEquals('S', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'sun'), 'day')); - $this->assertEquals('S', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'sun'), 'day', 'en')); - $this->assertFalse($value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'xxx'), 'day')); - - $this->assertEquals('EEEE, d. MMMM yyyy', $value->getTranslation('full', 'date')); - $this->assertEquals('EEEE, MMMM d, yyyy', $value->getTranslation('full', 'date', 'en')); - $this->assertFalse($value->getTranslation('xxxx', 'date')); - - $this->assertEquals("HH:mm:ss v", $value->getTranslation('full', 'time')); - $this->assertEquals('h:mm:ss a v', $value->getTranslation('full', 'time', 'en')); - $this->assertFalse($value->getTranslation('xxxx', 'time')); - - $this->assertEquals('Wien', $value->getTranslation('Europe/Vienna', 'citytotimezone')); - $this->assertEquals('St. John’s', $value->getTranslation('America/St_Johns', 'citytotimezone', 'en')); - $this->assertFalse($value->getTranslation('xxxx', 'citytotimezone')); - - $this->assertEquals('Euro', $value->getTranslation('EUR', 'nametocurrency')); - $this->assertEquals('Euro', $value->getTranslation('EUR', 'nametocurrency', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'nametocurrency')); - - $this->assertEquals('EUR', $value->getTranslation('Euro', 'currencytoname')); - $this->assertEquals('EUR', $value->getTranslation('Euro', 'currencytoname', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'currencytoname')); - - $this->assertEquals('SFr.', $value->getTranslation('CHF', 'currencysymbol')); - $this->assertEquals('SwF', $value->getTranslation('CHF', 'currencysymbol', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'currencysymbol')); - - $this->assertEquals('EUR', $value->getTranslation('AT', 'currencytoregion')); - $this->assertEquals('EUR', $value->getTranslation('AT', 'currencytoregion', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'currencytoregion')); - - $this->assertEquals('011 014 015 017 018', $value->getTranslation('002', 'regiontoterritory')); - $this->assertEquals('011 014 015 017 018', $value->getTranslation('002', 'regiontoterritory', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'regiontoterritory')); - - $this->assertEquals('AT BE CH DE LI LU', $value->getTranslation('de', 'territorytolanguage')); - $this->assertEquals('AT BE CH DE LI LU', $value->getTranslation('de', 'territorytolanguage', 'en')); - $this->assertFalse($value->getTranslation('xxx', 'territorytolanguage')); - } - - /** - * test getTranslationList - * expected true - */ - public function testgetTranslationList() - { - $value = new Zend_Locale('de_DE'); - try { - $temp = $value->getTranslationList(); - $this->fail(); - } catch (Zend_Locale_Exception $e) { - $this->assertContains('Unknown list (', $e->getMessage()); - } - - $this->assertTrue(in_array('Deutsch', $value->getTranslationList('language'))); - $this->assertTrue(in_array('German', $value->getTranslationList('language', 'en'))); - - $this->assertTrue(in_array('Lateinisch', $value->getTranslationList('script'))); - $this->assertTrue(in_array('Latin', $value->getTranslationList('script', 'en'))); - - $this->assertTrue(in_array('Afrika', $value->getTranslationList('territory'))); - $this->assertTrue(in_array('Africa', $value->getTranslationList('territory', 'en'))); - - $this->assertTrue(in_array('Chinesischer Kalender', $value->getTranslationList('type', null, 'calendar'))); - $this->assertTrue(in_array('Chinese Calendar', $value->getTranslationList('type', 'en', 'calendar'))); - - $this->assertTrue(in_array('Januar', $value->getTranslationList('month'))); - $this->assertTrue(in_array('January', $value->getTranslationList('month', 'en'))); - - $this->assertTrue(in_array('Jan', $value->getTranslationList('month', null, array('gregorian', 'format', 'abbreviated')))); - $this->assertTrue(in_array('Jan', $value->getTranslationList('month', 'en', array('gregorian', 'format', 'abbreviated')))); - - $this->assertTrue(in_array('J', $value->getTranslationList('month', null, array('gregorian', 'stand-alone', 'narrow')))); - $this->assertTrue(in_array('J', $value->getTranslationList('month', 'en', array('gregorian', 'stand-alone', 'narrow')))); - - $this->assertTrue(in_array('Sonntag', $value->getTranslationList('day'))); - $this->assertTrue(in_array('Sunday', $value->getTranslationList('day', 'en'))); - - $this->assertTrue(in_array('So', $value->getTranslationList('day', null, array('gregorian', 'format', 'abbreviated')))); - $this->assertTrue(in_array('Sun', $value->getTranslationList('day', 'en', array('gregorian', 'format', 'abbreviated')))); - - $this->assertTrue(in_array('S', $value->getTranslationList('day', null, array('gregorian', 'stand-alone', 'narrow')))); - $this->assertTrue(in_array('S', $value->getTranslationList('day', 'en', array('gregorian', 'stand-alone', 'narrow')))); - - $this->assertTrue(in_array('EEEE, d. MMMM yyyy', $value->getTranslationList('date'))); - $this->assertTrue(in_array('EEEE, MMMM d, yyyy', $value->getTranslationList('date', 'en'))); - - $this->assertTrue(in_array("HH:mm:ss v", $value->getTranslationList('time'))); - $this->assertTrue(in_array("h:mm:ss a z", $value->getTranslationList('time', 'en'))); - - $this->assertTrue(in_array('Wien', $value->getTranslationList('citytotimezone'))); - $this->assertTrue(in_array("St. John’s", $value->getTranslationList('citytotimezone', 'en'))); - - $this->assertTrue(in_array('Euro', $value->getTranslationList('nametocurrency'))); - $this->assertTrue(in_array('Euro', $value->getTranslationList('nametocurrency', 'en'))); - - $this->assertTrue(in_array('EUR', $value->getTranslationList('currencytoname'))); - $this->assertTrue(in_array('EUR', $value->getTranslationList('currencytoname', 'en'))); - - $this->assertTrue(in_array('SFr.', $value->getTranslationList('currencysymbol'))); - $this->assertTrue(in_array('SwF', $value->getTranslationList('currencysymbol', 'en'))); - - $this->assertTrue(in_array('EUR', $value->getTranslationList('currencytoregion'))); - $this->assertTrue(in_array('EUR', $value->getTranslationList('currencytoregion', 'en'))); - - $this->assertTrue(in_array('AU NF NZ', $value->getTranslationList('regiontoterritory'))); - $this->assertTrue(in_array('AU NF NZ', $value->getTranslationList('regiontoterritory', 'en'))); - - $this->assertTrue(in_array('CZ', $value->getTranslationList('territorytolanguage'))); - $this->assertTrue(in_array('CZ', $value->getTranslationList('territorytolanguage', 'en'))); - - $char = $value->getTranslationList('characters'); - $this->assertEquals("[a ä b-o ö p-s ß t u ü v-z]", $char['characters']); - $this->assertEquals("[á à ă â Ã¥ ä Ä Ã¦ ç é è Ä• ê ë Ä“ à ì Ä Ã® ï Ä« ñ ó ò Šô ö ø Å Å“ ß ú ù Šû ü Å« ÿ]", $char['auxiliary']); - $this->assertEquals("[\\$ £ Â¥ ₤ â‚§ € a-z]", $char['currencySymbol']); - $char = $value->getTranslationList('characters', 'en'); - $this->assertEquals("[a-z]", $char['characters']); - $this->assertEquals("[á à ă â Ã¥ ä Ä Ã¦ ç é è Ä• ê ë Ä“ à ì Ä Ã® ï Ä« ñ ó ò Šô ö ø Å Å“ ß ú ù Šû ü Å« ÿ]", $char['auxiliary']); - $this->assertEquals("[a-z]", $char['currencySymbol']); - } - - /** - * test for equality - * expected string - */ - public function testEquals() - { - $value = new Zend_Locale('de_DE'); - $serial = new Zend_Locale('de_DE'); - $serial2 = new Zend_Locale('de_AT'); - $this->assertTrue($value->equals($serial)); - $this->assertFalse($value->equals($serial2)); - } - - /** - * test getQuestion - * expected true - */ - public function testgetQuestion() - { - $value = new Zend_Locale(); - $list = $value->getQuestion(); - $this->assertTrue(isset($list['yes'])); - - $list = $value->getQuestion('de'); - $this->assertEquals('ja', $list['yes']); - - $this->assertTrue(is_array($value->getQuestion('auto'))); - $this->assertTrue(is_array($value->getQuestion('browser'))); - $this->assertTrue(is_array($value->getQuestion('environment'))); - } - - /** - * test getBrowser - * expected true - */ - public function testgetBrowser() - { - Zend_LocaleTestHelper::resetObject(); - putenv("HTTP_ACCEPT_LANGUAGE=,de,en-UK-US;q=0.5,fr_FR;q=0.2"); - $value = new Zend_LocaleTestHelper(); - $list = $value->getBrowser(); - $this->assertTrue(isset($list['de'])); - } - - /** - * test getHttpCharset - * expected true - */ - public function testgetHttpCharset() - { - Zend_LocaleTestHelper::resetObject(); - putenv("HTTP_ACCEPT_CHARSET="); - $value = new Zend_LocaleTestHelper(); - $list = $value->getHttpCharset(); - $this->assertTrue(empty($list)); - - Zend_LocaleTestHelper::resetObject(); - putenv("HTTP_ACCEPT_CHARSET=,iso-8859-1, utf-8, utf-16, *;q=0.1"); - $value = new Zend_LocaleTestHelper(); - $list = $value->getHttpCharset(); - $this->assertTrue(isset($list['utf-8'])); - } - - /** - * test isLocale - * expected boolean - */ - public function testIsLocale() - { - $locale = new Zend_Locale('ar'); - $this->assertEquals('ar', Zend_Locale::isLocale($locale)); - $this->assertEquals('de', Zend_Locale::isLocale('de')); - $this->assertEquals('de_AT', Zend_Locale::isLocale('de_AT')); - $this->assertEquals('de', Zend_Locale::isLocale('de_xx')); - $this->assertFalse(Zend_Locale::isLocale('yy')); - $this->assertFalse(Zend_Locale::isLocale(1234)); - $locale = Zend_Locale::isLocale('', true); - $this->assertTrue(is_string($locale)); - $this->assertTrue(is_string(Zend_Locale::isLocale('auto'))); - $this->assertTrue(is_string(Zend_Locale::isLocale('browser'))); - $this->assertTrue(is_string(Zend_Locale::isLocale('environment'))); - } - - /** - * test isLocale - * expected boolean - */ - public function testGetLocaleList() - { - $this->assertTrue(is_array(Zend_Locale::getLocaleList())); - } - - /** - * test setDefault - * expected true - */ - public function testsetDefault() - { - try { - Zend_Locale::setDefault('auto'); - $this->fail(); - } catch (Zend_Locale_Exception $e) { - $this->assertContains("full qualified locale", $e->getMessage()); - } - try { - Zend_Locale::setDefault('de_XX'); - $locale = new Zend_Locale(); - $this->assertTrue($locale instanceof Zend_Locale); // should defer to 'de' or any other standard locale - } catch (Zend_Locale_Exception $e) { - $this->fail(); // de_XX should automatically degrade to 'de' - } - try { - Zend_Locale::setDefault('xy_ZZ'); - $this->fail(); - } catch (Zend_Locale_Exception $e) { - $this->assertContains("Unknown locale", $e->getMessage()); - } - } -} - -class Zend_LocaleTestHelper extends Zend_Locale -{ - public static $_auto; - public static $_environment; - public static $_browser; - - public static function resetObject() - { - self::$_auto = null; - self::$_environment = null; - self::$_browser = null; - } -} diff --git a/tests/Zend/Log/AllTests.php b/tests/Zend/Log/AllTests.php deleted file mode 100644 index bbcad7cdcde3a921c15284bc2329c44daaa7a7ad..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/AllTests.php +++ /dev/null @@ -1,83 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 11840 2008-10-10 17:54:22Z alexander $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Log_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Log/LogTest.php'; -require_once 'Zend/Log/Filter/ChainingTest.php'; -require_once 'Zend/Log/Filter/PriorityTest.php'; -require_once 'Zend/Log/Filter/MessageTest.php'; -require_once 'Zend/Log/Filter/SuppressTest.php'; -require_once 'Zend/Log/Formatter/SimpleTest.php'; -require_once 'Zend/Log/Formatter/XmlTest.php'; -require_once 'Zend/Log/Writer/DbTest.php'; -require_once 'Zend/Log/Writer/FirebugTest.php'; -require_once 'Zend/Log/Writer/MockTest.php'; -require_once 'Zend/Log/Writer/NullTest.php'; -require_once 'Zend/Log/Writer/StreamTest.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 11840 2008-10-10 17:54:22Z alexander $ - */ -class Zend_Log_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - // hack to allow us to view code coverage for Log.php - PHPUnit_Util_Filter::removeFileFromFilter(dirname(__FILE__) . '/../../../library/Zend/Log.php', 'PEAR'); - - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Log'); - - $suite->addTestSuite('Zend_Log_LogTest'); - $suite->addTestSuite('Zend_Log_Filter_ChainingTest'); - $suite->addTestSuite('Zend_Log_Filter_PriorityTest'); - $suite->addTestSuite('Zend_Log_Filter_MessageTest'); - $suite->addTestSuite('Zend_Log_Filter_SuppressTest'); - $suite->addTestSuite('Zend_Log_Formatter_SimpleTest'); - $suite->addTestSuite('Zend_Log_Formatter_XmlTest'); - $suite->addTestSuite('Zend_Log_Writer_DbTest'); - $suite->addTestSuite('Zend_Log_Writer_FirebugTest'); - $suite->addTestSuite('Zend_Log_Writer_MockTest'); - $suite->addTestSuite('Zend_Log_Writer_NullTest'); - $suite->addTestSuite('Zend_Log_Writer_StreamTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Log_AllTests::main') { - Zend_Log_AllTests::main(); -} diff --git a/tests/Zend/Log/Filter/ChainingTest.php b/tests/Zend/Log/Filter/ChainingTest.php deleted file mode 100644 index b2db964c691bceaaf001577f936ab0d7657653e8..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Filter/ChainingTest.php +++ /dev/null @@ -1,88 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ChainingTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log */ -require_once 'Zend/Log.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ChainingTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Filter_ChainingTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->log = fopen('php://memory', 'w'); - $this->logger = new Zend_Log(); - $this->logger->addWriter(new Zend_Log_Writer_Stream($this->log)); - } - - public function tearDown() - { - fclose($this->log); - } - - public function testFilterAllWriters() - { - // filter out anything above a WARNing for all writers - $this->logger->addFilter(Zend_Log::WARN); - - $this->logger->info($ignored = 'info-message-ignored'); - $this->logger->warn($logged = 'warn-message-logged'); - - rewind($this->log); - $logdata = stream_get_contents($this->log); - - $this->assertNotContains($ignored, $logdata); - $this->assertContains($logged, $logdata); - } - - public function testFilterOnSpecificWriter() - { - $log2 = fopen('php://memory', 'w'); - $writer2 = new Zend_Log_Writer_Stream($log2); - $writer2->addFilter(Zend_Log::ERR); - - $this->logger->addWriter($writer2); - - $this->logger->warn($warn = 'warn-message'); - $this->logger->err($err = 'err-message'); - - rewind($this->log); - $logdata = stream_get_contents($this->log); - $this->assertContains($warn, $logdata); - $this->assertContains($err, $logdata); - - rewind($log2); - $logdata = stream_get_contents($log2); - $this->assertContains($err, $logdata); - $this->assertNotContains($warn, $logdata); - } - -} diff --git a/tests/Zend/Log/Filter/MessageTest.php b/tests/Zend/Log/Filter/MessageTest.php deleted file mode 100644 index de9b9dfbf4865e66d20bf400dbb3ba3f937ee07b..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Filter/MessageTest.php +++ /dev/null @@ -1,60 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MessageTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log */ -require_once 'Zend/Log.php'; - -/** Zend_Log_Filter_Message */ -require_once 'Zend/Log/Filter/Message.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MessageTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Filter_MessageTest extends PHPUnit_Framework_TestCase -{ - public function testMessageFilterRecognizesInvalidRegularExpression() - { - try { - $filter = new Zend_Log_Filter_Message('invalid regexp'); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegexp('/invalid reg/i', $e->getMessage()); - } - } - - public function testMessageFilter() - { - $filter = new Zend_Log_Filter_Message('/accept/'); - $this->assertTrue($filter->accept(array('message' => 'foo accept bar'))); - $this->assertFalse($filter->accept(array('message' => 'foo reject bar'))); - } - -} diff --git a/tests/Zend/Log/Filter/PriorityTest.php b/tests/Zend/Log/Filter/PriorityTest.php deleted file mode 100644 index c2a0fe5ab32c43cab98a71c0db28672be8b6ac83..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Filter/PriorityTest.php +++ /dev/null @@ -1,73 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PriorityTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log */ -require_once 'Zend/Log.php'; - -/** Zend_Log_Filter_Priority */ -require_once 'Zend/Log/Filter/Priority.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PriorityTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Filter_PriorityTest extends PHPUnit_Framework_TestCase -{ - public function testComparisonDefaultsToLessThanOrEqual() - { - // accept at or below priority 2 - $filter = new Zend_Log_Filter_Priority(2); - - $this->assertTrue($filter->accept(array('priority' => 2))); - $this->assertTrue($filter->accept(array('priority' => 1))); - $this->assertFalse($filter->accept(array('priority' => 3))); - } - - public function testComparisonOperatorCanBeChanged() - { - // accept above priority 2 - $filter = new Zend_Log_Filter_Priority(2, '>'); - - $this->assertTrue($filter->accept(array('priority' => 3))); - $this->assertFalse($filter->accept(array('priority' => 2))); - $this->assertFalse($filter->accept(array('priority' => 1))); - } - - public function testConstructorThrowsOnInvalidPriority() - { - try { - new Zend_Log_Filter_Priority('foo'); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/must be an integer/i', $e->getMessage()); - } - } - -} diff --git a/tests/Zend/Log/Filter/SuppressTest.php b/tests/Zend/Log/Filter/SuppressTest.php deleted file mode 100644 index 12e1dfa16272de25b99d62ceb90e4a01de648d36..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Filter/SuppressTest.php +++ /dev/null @@ -1,75 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SuppressTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log */ -require_once 'Zend/Log.php'; - -/** Zend_Log_Filter_Suppress */ -require_once 'Zend/Log/Filter/Suppress.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SuppressTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Filter_SuppressTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->filter = new Zend_Log_Filter_Suppress(); - } - - public function testSuppressIsInitiallyOff() - { - $this->assertTrue($this->filter->accept(array())); - } - - public function testSuppressOn() - { - $this->filter->suppress(true); - $this->assertFalse($this->filter->accept(array())); - $this->assertFalse($this->filter->accept(array())); - } - - public function testSuppressOff() - { - $this->filter->suppress(false); - $this->assertTrue($this->filter->accept(array())); - $this->assertTrue($this->filter->accept(array())); - } - - public function testSuppressCanBeReset() - { - $this->filter->suppress(true); - $this->assertFalse($this->filter->accept(array())); - $this->filter->suppress(false); - $this->assertTrue($this->filter->accept(array())); - $this->filter->suppress(true); - $this->assertFalse($this->filter->accept(array())); - } -} diff --git a/tests/Zend/Log/Formatter/SimpleTest.php b/tests/Zend/Log/Formatter/SimpleTest.php deleted file mode 100644 index 3bb4c365c01567522751896552fdca3d7e3a2316..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Formatter/SimpleTest.php +++ /dev/null @@ -1,118 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SimpleTest.php 10726 2008-08-06 16:38:09Z cadorn $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log_Formatter_Simple */ -require_once 'Zend/Log/Formatter/Simple.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SimpleTest.php 10726 2008-08-06 16:38:09Z cadorn $ - */ -class Zend_Log_Formatter_SimpleTest extends PHPUnit_Framework_TestCase -{ - public function testConstructorThrowsOnBadFormatString() - { - try { - new Zend_Log_Formatter_Simple(1); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/must be a string/i', $e->getMessage()); - } - } - - public function testDefaultFormat() - { - $fields = array('timestamp' => 0, - 'message' => 'foo', - 'priority' => 42, - 'priorityName' => 'bar'); - - $f = new Zend_Log_Formatter_Simple(); - $line = $f->format($fields); - - $this->assertContains((string)$fields['timestamp'], $line); - $this->assertContains($fields['message'], $line); - $this->assertContains($fields['priorityName'], $line); - $this->assertContains((string)$fields['priority'], $line); - } - - function testComplexValues() - { - $fields = array('timestamp' => 0, - 'priority' => 42, - 'priorityName' => 'bar'); - - $f = new Zend_Log_Formatter_Simple(); - - $fields['message'] = 'Foo'; - $line = $f->format($fields); - $this->assertContains($fields['message'], $line); - - $fields['message'] = 10; - $line = $f->format($fields); - $this->assertContains($fields['message'], $line); - - $fields['message'] = 10.5; - $line = $f->format($fields); - $this->assertContains($fields['message'], $line); - - $fields['message'] = true; - $line = $f->format($fields); - $this->assertContains('1', $line); - - $fields['message'] = fopen('php://stdout', 'w'); - $line = $f->format($fields); - $this->assertContains('Resource id ', $line); - fclose($fields['message']); - - $fields['message'] = range(1,10); - $line = $f->format($fields); - $this->assertContains('array', $line); - - $fields['message'] = new Zend_Log_Formatter_SimpleTest_TestObject1(); - $line = $f->format($fields); - $this->assertContains($fields['message']->__toString(), $line); - - $fields['message'] = new Zend_Log_Formatter_SimpleTest_TestObject2(); - $line = $f->format($fields); - $this->assertContains('object', $line); - } -} - -class Zend_Log_Formatter_SimpleTest_TestObject1 { - - public function __toString() - { - return 'Hello World'; - } -} - -class Zend_Log_Formatter_SimpleTest_TestObject2 { -} diff --git a/tests/Zend/Log/Formatter/XmlTest.php b/tests/Zend/Log/Formatter/XmlTest.php deleted file mode 100644 index 589d270d9f3523229660d942685ca4d36c95c56c..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Formatter/XmlTest.php +++ /dev/null @@ -1,72 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: XmlTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log_Formatter_Xml */ -require_once 'Zend/Log/Formatter/Xml.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: XmlTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Formatter_XmlTest extends PHPUnit_Framework_TestCase -{ - public function testDefaultFormat() - { - $f = new Zend_Log_Formatter_Xml(); - $line = $f->format(array('message' => 'foo', 'priority' => 42)); - - $this->assertContains('foo', $line); - $this->assertContains((string)42, $line); - } - - public function testConfiguringElementMapping() - { - $f = new Zend_Log_Formatter_Xml('log', array('foo' => 'bar')); - $line = $f->format(array('bar' => 'baz')); - $this->assertContains('<log><foo>baz</foo></log>', $line); - } - - public function testXmlDeclarationIsStripped() - { - $f = new Zend_Log_Formatter_Xml(); - $line = $f->format(array('message' => 'foo', 'priority' => 42)); - - $this->assertNotContains('<\?xml version=', $line); - } - - public function testXmlValidates() - { - $f = new Zend_Log_Formatter_Xml(); - $line = $f->format(array('message' => 'foo', 'priority' => 42)); - - $sxml = @simplexml_load_string($line); - $this->assertType('SimpleXMLElement', $sxml, 'Formatted XML is invalid'); - } - -} diff --git a/tests/Zend/Log/LogTest.php b/tests/Zend/Log/LogTest.php deleted file mode 100644 index be96c9928d214ef09778d2af396489b8a50d0155..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/LogTest.php +++ /dev/null @@ -1,204 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LogTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log */ -require_once 'Zend/Log.php'; - -/** Zend_Log_Writer_Mock */ -require_once 'Zend/Log/Writer/Mock.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LogTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_LogTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->log = fopen('php://memory', 'a'); - $this->writer = new Zend_Log_Writer_Stream($this->log); - } - - // Writers - - public function testWriterCanBeAddedWithConstructor() - { - $logger = new Zend_Log($this->writer); - $logger->log($message = 'message-to-long', Zend_Log::INFO); - - rewind($this->log); - $this->assertContains($message, stream_get_contents($this->log)); - } - - public function testAddWriter() - { - $logger = new Zend_Log(); - $logger->addWriter($this->writer); - $logger->log($message = 'message-to-log', Zend_Log::INFO); - - rewind($this->log); - $this->assertContains($message, stream_get_contents($this->log)); - } - - public function testAddWriterAddsMultipleWriters() - { - $logger = new Zend_Log(); - - // create writers for two separate streams of temporary memory - $log1 = fopen('php://memory', 'a'); - $writer1 = new Zend_Log_Writer_Stream($log1); - $log2 = fopen('php://memory', 'a'); - $writer2 = new Zend_Log_Writer_Stream($log2); - - // add the writers - $logger->addWriter($writer1); - $logger->addWriter($writer2); - - // log to both writers - $logger->log($message = 'message-sent-to-both-logs', Zend_Log::INFO); - - // verify both writers were called by the logger - rewind($log1); - $this->assertContains($message, stream_get_contents($log1)); - rewind($log2); - $this->assertContains($message, stream_get_contents($log2)); - - // prove the two memory streams are different - // and both writers were indeed called - fwrite($log1, 'foo'); - $this->assertNotEquals(ftell($log1), ftell($log2)); - } - - public function testLoggerThrowsWhenNoWriters() - { - $logger = new Zend_Log(); - try { - $logger->log('message', Zend_Log::INFO); - $this->fail(); - } catch (Zend_Log_Exception $e) { - $this->assertRegexp('/no writer/i', $e->getMessage()); - } - } - - public function testDestructorCallsShutdownOnEachWriter() - { - $writer1 = new Zend_Log_Writer_Mock(); - $writer2 = new Zend_Log_Writer_Mock(); - - $logger = new Zend_Log(); - $logger->addWriter($writer1); - $logger->addWriter($writer2); - - $this->assertFalse($writer1->shutdown); - $this->assertFalse($writer2->shutdown); - - $logger = null; - - $this->assertTrue($writer1->shutdown); - $this->assertTrue($writer2->shutdown); - } - - // Priorities - - public function testLogThrowsOnBadLogPriority() - { - $logger = new Zend_Log($this->writer); - try { - $logger->log('foo', 42); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/bad log priority/i', $e->getMessage()); - } - } - - public function testLogThrough__callThrowsOnBadLogPriority() - { - $logger = new Zend_Log($this->writer); - try { - $logger->nonexistantPriority(''); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/bad log priority/i', $e->getMessage()); - } - } - - public function testAddingPriorityThrowsWhenOverridingBuiltinLogPriority() - { - try { - $logger = new Zend_Log($this->writer); - $logger->addPriority('BOB', 0); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/existing priorities/i', $e->getMessage()); - } - - } - - public function testAddLogPriority() - { - $logger = new Zend_Log($this->writer); - $logger->addPriority('EIGHT', $priority = 8); - - $logger->eight($message = 'eight message'); - - rewind($this->log); - $logdata = stream_get_contents($this->log); - $this->assertContains((string)$priority, $logdata); - $this->assertContains($message, $logdata); - } - - // Fields - - public function testLogWritesStandardFields() { - $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock); - $logger->info('foo'); - - $this->assertEquals(1, count($mock->events)); - $event = array_shift($mock->events); - - $standardFields = array_flip(array('timestamp', 'priority', 'priorityName', 'message')); - $this->assertEquals(array(), array_diff_key($event, $standardFields)); - } - - public function testLogWritesAndOverwritesExtraFields() { - $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock); - $logger->setEventItem('foo', 42); - $logger->setEventItem($field = 'bar', $value = 43); - $logger->info('foo'); - - $this->assertEquals(1, count($mock->events)); - $event = array_shift($mock->events); - - $this->assertTrue(array_key_exists($field, $event)); - $this->assertEquals($value, $event[$field]); - } -} diff --git a/tests/Zend/Log/Writer/DbTest.php b/tests/Zend/Log/Writer/DbTest.php deleted file mode 100644 index 2b354d469130a977ba8df8741f23e3cba77023d9..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Writer/DbTest.php +++ /dev/null @@ -1,124 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log_Writer_Mock */ -require_once 'Zend/Log/Writer/Db.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Writer_DbTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->tableName = 'db-table-name'; - - $this->db = new Zend_Log_Writer_DbTest_MockDbAdapter(); - $this->writer = new Zend_Log_Writer_Db($this->db, $this->tableName); - } - - public function testFormattingIsNotSupported() - { - try { - $this->writer->setFormatter(new stdclass); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/does not support formatting/i', $e->getMessage()); - } - } - - public function testWriteWithDefaults() - { - // log to the mock db adapter - $fields = array('message' => 'foo', - 'priority' => 42); - - $this->writer->write($fields); - - // insert should be called once... - $this->assertContains('insert', array_keys($this->db->calls)); - $this->assertEquals(1, count($this->db->calls['insert'])); - - // ...with the correct table and binds for the database - $binds = array('message' => $fields['message'], - 'priority' => $fields['priority']); - $this->assertEquals(array($this->tableName, $binds), - $this->db->calls['insert'][0]); - } - - public function testWriteUsesOptionalCustomColumnNames() - { - $this->writer = new Zend_Log_Writer_Db($this->db, $this->tableName, - array('new-message-field' => 'message', - 'new-message-field' => 'priority')); - - // log to the mock db adapter - $message = 'message-to-log'; - $priority = 2; - $this->writer->write(array('message' => $message, 'priority' => $priority)); - - // insert should be called once... - $this->assertContains('insert', array_keys($this->db->calls)); - $this->assertEquals(1, count($this->db->calls['insert'])); - - // ...with the correct table and binds for the database - $binds = array('new-message-field' => $message, - 'new-message-field' => $priority); - $this->assertEquals(array($this->tableName, $binds), - $this->db->calls['insert'][0]); - } - - public function testShutdownRemovesReferenceToDatabaseInstance() - { - $this->writer->write(array('message' => 'this should not fail')); - $this->writer->shutdown(); - - try { - $this->writer->write(array('message' => 'this should fail')); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/shutdown$/i', $e->getMessage()); - } - } -} - - -class Zend_Log_Writer_DbTest_MockDbAdapter -{ - public $calls = array(); - - public function __call($method, $params) - { - $this->calls[$method][] = $params; - } - -} \ No newline at end of file diff --git a/tests/Zend/Log/Writer/FirebugTest.php b/tests/Zend/Log/Writer/FirebugTest.php deleted file mode 100644 index e0bba3598aaa284ed446adbdf5ab9730c3d373aa..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Writer/FirebugTest.php +++ /dev/null @@ -1,283 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 3980 2007-03-15 21:38:38Z mike $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log */ -require_once 'Zend/Log.php'; - -/** Zend_Log_Writer_Firebug */ -require_once 'Zend/Log/Writer/Firebug.php'; - -/** Zend_Wildfire_Channel_HttpHeaders */ -require_once 'Zend/Wildfire/Channel/HttpHeaders.php'; - -/** Zend_Wildfire_Plugin_FirePhp */ -require_once 'Zend/Wildfire/Plugin/FirePhp.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** Zend_Controller_Response_Http */ -require_once 'Zend/Controller/Response/Http.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 3980 2007-03-15 21:38:38Z mike $ - */ -class Zend_Log_Writer_FirebugTest extends PHPUnit_Framework_TestCase -{ - - - protected $_controller = null; - protected $_request = null; - protected $_response = null; - protected $_writer = null; - protected $_logger = null; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Log_Writer_FirebugTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - date_default_timezone_set('America/Los_Angeles'); - - // Reset front controller to reset registered plugins and - // registered request/response objects - Zend_Controller_Front::getInstance()->resetInstance(); - - $this->_request = new Zend_Log_Writer_FirebugTest_Request(); - $this->_response = new Zend_Log_Writer_FirebugTest_Response(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $channel->setRequest($this->_request); - $channel->setResponse($this->_response); - - $this->_writer = new Zend_Log_Writer_Firebug(); - - // Explicitly enable writer as it is disabled by default - // when running from the command line. - $this->_writer->setEnabled(true); - - $this->_logger = new Zend_Log($this->_writer); - } - - public function tearDown() - { - Zend_Wildfire_Channel_HttpHeaders::destroyInstance(); - Zend_Wildfire_Plugin_FirePhp::destroyInstance(); - } - - - /** - * Test for ZF-3960 - * - * Zend_Log_Writer_Firebug should be automatically disabled when - * run from the command line - */ - public function testZf3960() - { - Zend_Wildfire_Channel_HttpHeaders::destroyInstance(); - Zend_Wildfire_Plugin_FirePhp::destroyInstance(); - - $log = new Zend_Log(); - $writerFirebug = new Zend_Log_Writer_Firebug(); - $log->addWriter($writerFirebug); - $log->log('hi', 2); - } - - - public function testSetFormatter() - { - try { - $this->_writer->setFormatter(null); - $this->fail('Should not be able to setFormatter() on log writer'); - } catch (Exception $e) { - // success - } - } - - public function testLogStyling() - { - $this->assertEquals($this->_writer->getDefaultPriorityStyle(), - Zend_Wildfire_Plugin_FirePhp::LOG); - $this->assertEquals($this->_writer->setDefaultPriorityStyle(Zend_Wildfire_Plugin_FirePhp::WARN), - Zend_Wildfire_Plugin_FirePhp::LOG); - $this->assertEquals($this->_writer->getDefaultPriorityStyle(), - Zend_Wildfire_Plugin_FirePhp::WARN); - - $this->assertEquals($this->_writer->getPriorityStyle(9), - false); - $this->assertEquals($this->_writer->setPriorityStyle(9,Zend_Wildfire_Plugin_FirePhp::WARN), - true); - $this->assertEquals($this->_writer->getPriorityStyle(9), - Zend_Wildfire_Plugin_FirePhp::WARN); - $this->assertEquals($this->_writer->setPriorityStyle(9,Zend_Wildfire_Plugin_FirePhp::LOG), - Zend_Wildfire_Plugin_FirePhp::WARN); - } - - public function testBasicLogging() - { - $message = 'This is a log message!'; - - $this->_logger->log($message, Zend_Log::INFO); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $headers = array(); - $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.1'; - $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; - $headers['X-Wf-1-1-1-1'] = '|[{"Type":"INFO"},"This is a log message!"]|'; - $headers['X-Wf-1-Index'] = '1'; - - $this->assertTrue($this->_response->verifyHeaders($headers)); - } - - public function testAdvancedLogging() - { - $message = 'This is a log message!'; - $label = 'Test Label'; - $table = array('Summary line for the table', - array( - array('Column 1', 'Column 2'), - array('Row 1 c 1',' Row 1 c 2'), - array('Row 2 c 1',' Row 2 c 2') - ) - ); - - - $this->_logger->addPriority('TRACE', 8); - $this->_logger->addPriority('TABLE', 9); - $this->_writer->setPriorityStyle(8, 'TRACE'); - $this->_writer->setPriorityStyle(9, 'TABLE'); - - $this->_logger->trace($message); - $this->_logger->table($table); - - try { - throw new Exception('Test Exception'); - } catch (Exception $e) { - $this->_logger->err($e); - } - - try { - Zend_Wildfire_Plugin_FirePhp::send($message, $label, 'UNKNOWN'); - $this->fail('Should not be able to log with undefined log style'); - } catch (Exception $e) { - // success - } - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $messages = array(Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE=> - array(Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI=> - array(1=>'[{"Type":"TABLE"},["Summary line for the table",[["Column 1","Column 2"],["Row 1 c 1"," Row 1 c 2"],["Row 2 c 1"," Row 2 c 2"]]]]'))); - - $qued_messages = $protocol->getMessages(); - - unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0]); - unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][2]); - - $this->assertEquals(serialize($qued_messages), - serialize($messages)); - } -} - -class Zend_Log_Writer_FirebugTest_Request extends Zend_Controller_Request_Http -{ - public function getHeader($header) - { - if ($header == 'User-Agent') { - return 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 FirePHP/0.1.0'; - } - } -} - - -class Zend_Log_Writer_FirebugTest_Response extends Zend_Controller_Response_Http -{ - - public function canSendHeaders($throw = false) - { - return true; - } - - public function verifyHeaders($headers) - { - - $response_headers = $this->getHeaders(); - if (!$response_headers) { - return false; - } - - $keys1 = array_keys($headers); - sort($keys1); - $keys1 = serialize($keys1); - - $keys2 = array(); - foreach ($response_headers as $header ) { - $keys2[] = $header['name']; - } - sort($keys2); - $keys2 = serialize($keys2); - - if ($keys1 != $keys2) { - return false; - } - - $values1 = array_values($headers); - sort($values1); - $values1 = serialize($values1); - - $values2 = array(); - foreach ($response_headers as $header ) { - $values2[] = $header['value']; - } - sort($values2); - $values2 = serialize($values2); - - if ($values1 != $values2) { - return false; - } - - return true; - } - -} diff --git a/tests/Zend/Log/Writer/MockTest.php b/tests/Zend/Log/Writer/MockTest.php deleted file mode 100644 index 6703b82889c7285b14758b3852c8b9e1176a0e5e..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Writer/MockTest.php +++ /dev/null @@ -1,49 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 3980 2007-03-15 21:38:38Z mike $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log_Writer_Mock */ -require_once 'Zend/Log/Writer/Mock.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 3980 2007-03-15 21:38:38Z mike $ - */ -class Zend_Log_Writer_MockTest extends PHPUnit_Framework_TestCase -{ - public function testWrite() - { - $writer = new Zend_Log_Writer_Mock(); - $this->assertSame(array(), $writer->events); - - $fields = array('foo' => 'bar'); - $writer->write($fields); - $this->assertSame(array($fields), $writer->events); - } - -} diff --git a/tests/Zend/Log/Writer/NullTest.php b/tests/Zend/Log/Writer/NullTest.php deleted file mode 100644 index bb8d7c7d87afee8a263a0cac2aebadecfe5b3eb4..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Writer/NullTest.php +++ /dev/null @@ -1,45 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log_Writer_Null */ -require_once 'Zend/Log/Writer/Null.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Writer_NullTest extends PHPUnit_Framework_TestCase -{ - public function testWrite() - { - $writer = new Zend_Log_Writer_Null(); - $writer->write(array('message' => 'foo', 'priority' => 42)); - } - -} diff --git a/tests/Zend/Log/Writer/StreamTest.php b/tests/Zend/Log/Writer/StreamTest.php deleted file mode 100644 index 72f16f2faeac5754a04c33a9c1ebe6b95922239d..0000000000000000000000000000000000000000 --- a/tests/Zend/Log/Writer/StreamTest.php +++ /dev/null @@ -1,148 +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_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StreamTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** PHPUnit_Framework_TestCase */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Log_Writer_Mock */ -require_once 'Zend/Log/Writer/Stream.php'; - -/** - * @category Zend - * @package Zend_Log - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StreamTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Log_Writer_StreamTest extends PHPUnit_Framework_TestCase -{ - public function testConstructorThrowsWhenResourceIsNotStream() - { - $resource = xml_parser_create(); - try { - new Zend_Log_Writer_Stream($resource); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/not a stream/i', $e->getMessage()); - } - xml_parser_free($resource); - } - - public function testConstructorWithValidStream() - { - $stream = fopen('php://memory', 'a'); - new Zend_Log_Writer_Stream($stream); - } - - public function testConstructorWithValidUrl() - { - new Zend_Log_Writer_Stream('php://memory'); - } - - public function testConstructorThrowsWhenModeSpecifiedForExistingStream() - { - $stream = fopen('php://memory', 'a'); - try { - new Zend_Log_Writer_Stream($stream, 'w'); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/existing stream/i', $e->getMessage()); - } - } - - public function testConstructorThrowsWhenStreamCannotBeOpened() - { - try { - new Zend_Log_Writer_Stream(''); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/cannot be opened/i', $e->getMessage()); - } - } - - public function testWrite() - { - $stream = fopen('php://memory', 'a'); - $fields = array('message' => 'message-to-log'); - - $writer = new Zend_Log_Writer_Stream($stream); - $writer->write($fields); - - rewind($stream); - $contents = stream_get_contents($stream); - fclose($stream); - - $this->assertContains($fields['message'], $contents); - } - - public function testWriteThrowsWhenStreamWriteFails() - { - $stream = fopen('php://memory', 'a'); - $writer = new Zend_Log_Writer_Stream($stream); - fclose($stream); - - try { - $writer->write(array('message' => 'foo')); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/unable to write/i', $e->getMessage()); - } - } - - public function testShutdownClosesStreamResource() - { - $writer = new Zend_Log_Writer_Stream('php://memory', 'a'); - $writer->write(array('message' => 'this write should succeed')); - - $writer->shutdown(); - - try { - $writer->write(array('message' => 'this write should fail')); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Log_Exception', $e); - $this->assertRegExp('/unable to write/i', $e->getMessage()); - } - } - - public function testSettingNewFormatter() - { - $stream = fopen('php://memory', 'a'); - $writer = new Zend_Log_Writer_Stream($stream); - $expected = 'foo'; - - $formatter = new Zend_Log_Formatter_Simple($expected); - $writer->setFormatter($formatter); - - $writer->write(array('bar'=>'baz')); - rewind($stream); - $contents = stream_get_contents($stream); - fclose($stream); - - $this->assertContains($expected, $contents); - } -} diff --git a/tests/Zend/Mail/AllTests.php b/tests/Zend/Mail/AllTests.php deleted file mode 100644 index 1b21a2b8cfcb81c04b1ff2a58a0542a5f0bedea3..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/AllTests.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Mail_AllTests::main'); -} - -if (!defined('TESTS_ZEND_MAIL_POP3_ENABLED')) { - if (is_readable('TestConfiguration.php')) { - require_once 'TestConfiguration.php'; - } else { - require_once 'TestConfiguration.php.dist'; - } -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Mail/MboxTest.php'; -require_once 'Zend/Mail/MboxMessageOldTest.php'; -require_once 'Zend/Mail/MboxFolderTest.php'; -require_once 'Zend/Mail/MaildirTest.php'; -require_once 'Zend/Mail/MaildirMessageOldTest.php'; -require_once 'Zend/Mail/MaildirFolderTest.php'; -require_once 'Zend/Mail/MaildirWritableTest.php'; -require_once 'Zend/Mail/Pop3Test.php'; -require_once 'Zend/Mail/ImapTest.php'; -require_once 'Zend/Mail/InterfaceTest.php'; -require_once 'Zend/Mail/MessageTest.php'; -require_once 'Zend/Mail/SmtpTest.php'; - -class Zend_Mail_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Mail'); - - $suite->addTestSuite('Zend_Mail_MessageTest'); - $suite->addTestSuite('Zend_Mail_InterfaceTest'); - $suite->addTestSuite('Zend_Mail_MboxTest'); - $suite->addTestSuite('Zend_Mail_MboxMessageOldTest'); - $suite->addTestSuite('Zend_Mail_MboxFolderTest'); - if (defined('TESTS_ZEND_MAIL_POP3_ENABLED') && constant('TESTS_ZEND_MAIL_POP3_ENABLED') == true) { - $suite->addTestSuite('Zend_Mail_Pop3Test'); - } - if (defined('TESTS_ZEND_MAIL_IMAP_ENABLED') && constant('TESTS_ZEND_MAIL_IMAP_ENABLED') == true) { - $suite->addTestSuite('Zend_Mail_ImapTest'); - } - if (defined('TESTS_ZEND_MAIL_MAILDIR_ENABLED') && constant('TESTS_ZEND_MAIL_MAILDIR_ENABLED')) { - $suite->addTestSuite('Zend_Mail_MaildirTest'); - $suite->addTestSuite('Zend_Mail_MaildirMessageOldTest'); - $suite->addTestSuite('Zend_Mail_MaildirFolderTest'); - $suite->addTestSuite('Zend_Mail_MaildirWritableTest'); - } - if (defined('TESTS_ZEND_MAIL_SMTP_ENABLED') && constant('TESTS_ZEND_MAIL_SMTP_ENABLED') == true) { - $suite->addTestSuite('Zend_Mail_SmtpTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Mail_AllTests::main') { - Zend_Mail_AllTests::main(); -} diff --git a/tests/Zend/Mail/ImapTest.php b/tests/Zend/Mail/ImapTest.php deleted file mode 100644 index 33ffab7f361161c474e58f768277cd0fbe5270c8..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/ImapTest.php +++ /dev/null @@ -1,852 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Imap - */ -require_once 'Zend/Mail/Storage/Imap.php'; - -/** - * Zend_Mail_Protocol_Imap - */ -require_once 'Zend/Mail/Protocol/Imap.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_ImapTest extends PHPUnit_Framework_TestCase -{ - protected $_params; - - public function setUp() - { - $this->_params = array('host' => TESTS_ZEND_MAIL_IMAP_HOST, - 'user' => TESTS_ZEND_MAIL_IMAP_USER, - 'password' => TESTS_ZEND_MAIL_IMAP_PASSWORD); - if (defined('TESTS_ZEND_MAIL_SERVER_TESTDIR') && TESTS_ZEND_MAIL_SERVER_TESTDIR) { - if (!file_exists(TESTS_ZEND_MAIL_SERVER_TESTDIR . DIRECTORY_SEPARATOR . 'inbox') - && !file_exists(TESTS_ZEND_MAIL_SERVER_TESTDIR . DIRECTORY_SEPARATOR . 'INBOX')) { - $this->markTestSkipped('There is no file name "inbox" or "INBOX" in ' - . TESTS_ZEND_MAIL_SERVER_TESTDIR . '. I won\'t use it for testing. ' - . 'This is you safety net. If you think it is the right directory just ' - . 'create an empty file named INBOX or remove/deactived this message.'); - } - - $this->_cleanDir(TESTS_ZEND_MAIL_SERVER_TESTDIR); - $this->_copyDir(dirname(__FILE__) . '/_files/test.' . TESTS_ZEND_MAIL_SERVER_FORMAT, - TESTS_ZEND_MAIL_SERVER_TESTDIR); - } - } - - protected function _cleanDir($dir) - { - $dh = opendir($dir); - while (($entry = readdir($dh)) !== false) { - if ($entry == '.' || $entry == '..') { - continue; - } - $fullname = $dir . DIRECTORY_SEPARATOR . $entry; - if (is_dir($fullname)) { - $this->_cleanDir($fullname); - rmdir($fullname); - } else { - unlink($fullname); - } - } - closedir($dh); - } - - protected function _copyDir($dir, $dest) - { - $dh = opendir($dir); - while (($entry = readdir($dh)) !== false) { - if ($entry == '.' || $entry == '..' || $entry == '.svn') { - continue; - } - $fullname = $dir . DIRECTORY_SEPARATOR . $entry; - $destname = $dest . DIRECTORY_SEPARATOR . $entry; - if (is_dir($fullname)) { - mkdir($destname); - $this->_copyDir($fullname, $destname); - } else { - copy($fullname, $destname); - } - } - closedir($dh); - } - - public function testConnectOk() - { - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to imap server'); - } - } - - public function testConnectConfig() - { - try { - $mail = new Zend_Mail_Storage_Imap(new Zend_Config($this->_params)); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to imap server'); - } - } - - public function testConnectFailure() - { - $this->_params['host'] = 'example.example'; - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - return; // test ok - } - - // I can only hope noone installs a imap server there - $this->fail('no exception raised while connecting to example.example'); - } - - public function testNoParams() - { - try { - $mail = new Zend_Mail_Storage_Imap(array()); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised with empty params'); - } - - - public function testConnectSSL() - { - if (!TESTS_ZEND_MAIL_IMAP_SSL) { - return; - } - - $this->_params['ssl'] = 'SSL'; - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to imap server with SSL'); - } - } - - public function testConnectTLS() - { - if (!TESTS_ZEND_MAIL_IMAP_TLS) { - return; - } - - $this->_params['ssl'] = 'TLS'; - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to imap server with TLS'); - } - } - - public function testInvalidService() - { - $this->_params['port'] = TESTS_ZEND_MAIL_IMAP_INVALID_PORT; - - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while connection to invalid port'); - } - - public function testWrongService() - { - $this->_params['port'] = TESTS_ZEND_MAIL_IMAP_WRONG_PORT; - - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while connection to wrong port'); - } - - public function testWrongUsername() - { - // this also triggers ...{chars}<NL>token for coverage - $this->_params['user'] = "there is no\nnobody"; - - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while using wrong username'); - } - - public function testWithInstanceConstruction() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - // if $protocol is invalid the constructor fails while selecting INBOX - $mail = new Zend_Mail_Storage_Imap($protocol); - } - - public function testWithNotConnectedInstance() - { - $protocol = new Zend_Mail_Protocol_Imap(); - try { - $mail = new Zend_Mail_Storage_Imap($protocol); - } catch (Zend_Mail_Protocol_Exception $e) { - return; // test ok - } - - $this->fail('no exception while using not connected low-level class'); - } - - public function testWithNotLoggedInstance() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - try { - $mail = new Zend_Mail_Storage_Imap($protocol); - } catch (Zend_Mail_Storage_Exception $e) { - return; // test ok - } - - $this->fail('no exception while using not logged in low-level class'); - } - - public function testWrongFolder() - { - $this->_params['folder'] = 'this folder does not exist on your server'; - - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception with not existing folder'); - } - - - public function testClose() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - try { - $mail->close(); - } catch (Exception $e) { - $this->fail('exception raised while closing imap connection'); - } - } -/* - currently imap has no top - - public function testHasTop() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $this->assertTrue($mail->hasTop); - } -*/ - public function testHasCreate() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $this->assertFalse($mail->hasCreate); - } - - public function testNoop() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - try { - $mail->noop(); - } catch (Exception $e) { - $this->fail('exception raised while doing nothing (noop)'); - } - } - - public function testCount() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $count = $mail->countMessages(); - $this->assertEquals(6, $count); - } - - public function testSize() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $shouldSizes = array(1 => 397, 89, 694, 452, 497, 101); - - - $sizes = $mail->getSize(); - $this->assertEquals($shouldSizes, $sizes); - } - - public function testSingleSize() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $size = $mail->getSize(2); - $this->assertEquals(89, $size); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - -/* - currently imap has no top - - public function testFetchTopBody() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $content = $mail->getHeader(3, 1)->getContent(); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } -*/ - public function testFetchMessageHeader() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testFetchMessageBody() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $content = $mail->getMessage(3)->getContent(); - list($content, ) = explode("\n", $content, 2); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } - - public function testRemove() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $count = $mail->countMessages(); - $mail->removeMessage(1); - $this->assertEquals($mail->countMessages(), $count - 1); - } - - public function testTooLateCount() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $mail->close(); - // after closing we can't count messages - - try { - $mail->countMessages(); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while counting messages on closed connection'); - } - - public function testLoadUnkownFolder() - { - $this->_params['folder'] = 'UnknownFolder'; - try { - $mail = new Zend_Mail_Storage_Imap($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown folder'); - } - - public function testChangeFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - try { - $mail->selectFolder('subfolder/test'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder'); - } - - $this->assertEquals($mail->getCurrentFolder(), 'subfolder/test'); - } - - public function testUnknownFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - try { - $mail->selectFolder('/Unknown/Folder/'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while selecting unknown folder'); - } - - public function testGlobalName() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - try { - // explicit call of __toString() needed for PHP < 5.2 - $this->assertEquals($mail->getFolders()->subfolder->__toString(), 'subfolder'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder and getting global name'); - } - } - - public function testLocalName() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - try { - $this->assertEquals($mail->getFolders()->subfolder->key(), 'test'); - } catch (Zend_Mail_Exception $e) { - $this->fail('exception raised while selecting existing folder and getting local name'); - } - } - - public function testKeyLocalName() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - // we search for this folder because we can't assume a order while iterating - $search_folders = array('subfolder' => 'subfolder', - 'subfolder/test' => 'test', - 'INBOX' => 'INBOX'); - $found_folders = array(); - - foreach ($iterator as $localName => $folder) { - if (!isset($search_folders[$folder->getGlobalName()])) { - continue; - } - - // explicit call of __toString() needed for PHP < 5.2 - $found_folders[$folder->__toString()] = $localName; - } - - $this->assertEquals($search_folders, $found_folders); - } - - public function testSelectable() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - - foreach ($iterator as $localName => $folder) { - $this->assertEquals($localName, $folder->getLocalName()); - } - } - - - public function testCountFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $mail->selectFolder('subfolder/test'); - $count = $mail->countMessages(); - $this->assertEquals(1, $count); - } - - public function testSizeFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $mail->selectFolder('subfolder/test'); - $sizes = $mail->getSize(); - $this->assertEquals(array(1 => 410), $sizes); - } - - public function testFetchHeaderFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $mail->selectFolder('subfolder/test'); - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Message in subfolder', $subject); - } - - public function testHasFlag() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $this->assertTrue($mail->getMessage(1)->hasFlag(Zend_Mail_Storage::FLAG_RECENT)); - } - - public function testGetFlags() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $flags = $mail->getMessage(1)->getFlags(); - $this->assertTrue(isset($flags[Zend_Mail_Storage::FLAG_RECENT])); - $this->assertTrue(in_array(Zend_Mail_Storage::FLAG_RECENT, $flags)); - } - - public function testRawHeader() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $this->assertTrue(strpos($mail->getRawHeader(1), "\r\nSubject: Simple Message\r\n") > 0); - } - - public function testUniqueId() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $this->assertTrue($mail->hasUniqueId); - $this->assertEquals(1, $mail->getNumberByUniqueId($mail->getUniqueId(1))); - - $ids = $mail->getUniqueId(); - foreach ($ids as $num => $id) { - foreach ($ids as $inner_num => $inner_id) { - if ($num == $inner_num) { - continue; - } - if ($id == $inner_id) { - $this->fail('not all ids are unique'); - } - } - - if ($mail->getNumberByUniqueId($id) != $num) { - $this->fail('reverse lookup failed'); - } - } - } - - public function testWrongUniqueId() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - try { - $mail->getNumberByUniqueId('this_is_an_invalid_id'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while getting number for invalid id'); - } - - public function testCreateFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $mail->createFolder('subfolder/test1'); - $mail->createFolder('test2', 'subfolder'); - $mail->createFolder('test3', $mail->getFolders()->subfolder); - - try { - $mail->getFolders()->subfolder->test1; - $mail->getFolders()->subfolder->test2; - $mail->getFolders()->subfolder->test3; - } catch (Exception $e) { - $this->fail('could not get new folders'); - } - } - - public function testCreateExistingFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - try { - $mail->createFolder('subfolder/test'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('should not be able to create existing folder'); - } - - public function testRemoveFolderName() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $mail->removeFolder('subfolder/test'); - - try { - $mail->getFolders()->subfolder->test; - } catch (Exception $e) { - return; // ok - } - $this->fail('folder still exists'); - } - - public function testRemoveFolderInstance() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $mail->removeFolder($mail->getFolders()->subfolder->test); - - try { - $mail->getFolders()->subfolder->test; - } catch (Exception $e) { - return; // ok - } - $this->fail('folder still exists'); - } - - public function testRemoveInvalidFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - try { - $mail->removeFolder('thisFolderDoestNotExist'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while removing invalid folder'); - } - - public function testRenameFolder() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - try { - $mail->renameFolder('subfolder/test', 'subfolder/test1'); - $mail->renameFolder($mail->getFolders()->subfolder->test1, 'subfolder/test'); - } catch (Exception $e) { - $this->fail('renaming failed'); - } - - try { - $mail->renameFolder('subfolder/test', 'INBOX'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while renaming folder to INBOX'); - } - - public function testAppend() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $count = $mail->countMessages(); - - $message = ''; - $message .= "From: me@example.org\r\n"; - $message .= "To: you@example.org\r\n"; - $message .= "Subject: append test\r\n"; - $message .= "\r\n"; - $message .= "This is a test\r\n"; - $mail->appendMessage($message); - - $this->assertEquals($count + 1, $mail->countMessages()); - $this->assertEquals($mail->getMessage($count + 1)->subject, 'append test'); - - try { - $mail->appendMessage(''); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while appending empty message'); - } - - public function testCopy() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $mail->selectFolder('subfolder/test'); - $count = $mail->countMessages(); - $mail->selectFolder('INBOX'); - $message = $mail->getMessage(1); - - $mail->copyMessage(1, 'subfolder/test'); - $mail->selectFolder('subfolder/test'); - $this->assertEquals($count + 1, $mail->countMessages()); - $this->assertEquals($mail->getMessage($count + 1)->subject, $message->subject); - $this->assertEquals($mail->getMessage($count + 1)->from, $message->from); - $this->assertEquals($mail->getMessage($count + 1)->to, $message->to); - - try { - $mail->copyMessage(1, 'justARandomFolder'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while copying to wrong folder'); - } - - public function testSetFlags() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN)); - $message = $mail->getMessage(1); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_FLAGGED)); - $message = $mail->getMessage(1); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_FLAGGED)); - $message = $mail->getMessage(1); - $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - - $mail->setFlags(1, array('myflag')); - $message = $mail->getMessage(1); - $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - $this->assertTrue($message->hasFlag('myflag')); - - try { - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_RECENT)); - } catch (Exception $e) { - return; // ok - } - $this->fail('should not be able to set recent flag'); - } - - public function testCapability() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - $capa = $protocol->capability(); - $this->assertTrue(is_array($capa)); - $this->assertEquals($capa[0], 'CAPABILITY'); - } - - public function testSelect() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - $status = $protocol->select('INBOX'); - $this->assertTrue(is_array($status['flags'])); - $this->assertEquals($status['exists'], 6); - } - - - public function testExamine() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - $status = $protocol->examine('INBOX'); - $this->assertTrue(is_array($status['flags'])); - $this->assertEquals($status['exists'], 6); - } - - public function testClosedSocketNewlineToken() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - $protocol->logout(); - - try { - $protocol->select("foo\nbar"); - } catch (Exception $e) { - return; // ok - } - $this->fail('no exception while using procol with closed socket'); - } - - public function testEscaping() - { - $protocol = new Zend_Mail_Protocol_Imap(); - $this->assertEquals($protocol->escapeString('foo'), '"foo"'); - $this->assertEquals($protocol->escapeString('f\\oo'), '"f\\\\oo"'); - $this->assertEquals($protocol->escapeString('f"oo'), '"f\\"oo"'); - $this->assertEquals($protocol->escapeString('foo', 'bar'), array('"foo"', '"bar"')); - $this->assertEquals($protocol->escapeString("f\noo"), array('{4}', "f\noo")); - $this->assertEquals($protocol->escapeList(array('foo')), '(foo)'); - $this->assertEquals($protocol->escapeList(array(array('foo'))), '((foo))'); - $this->assertEquals($protocol->escapeList(array('foo', 'bar')), '(foo bar)'); - } - - public function testFetch() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - $protocol->select('INBOX'); - - $range = array_combine(range(1, 6), range(1, 6)); - $this->assertEquals($protocol->fetch('UID', 1, INF), $range); - $this->assertEquals($protocol->fetch('UID', 1, 6), $range); - $this->assertEquals($protocol->fetch('UID', range(1, 6)), $range); - $this->assertTrue(is_numeric($protocol->fetch('UID', 1))); - - $result = $protocol->fetch(array('UID', 'FLAGS'), 1, INF); - foreach ($result as $k => $v) { - $this->assertEquals($k, $v['UID']); - $this->assertTrue(is_array($v['FLAGS'])); - } - - try { - $protocol->fetch('UID', 99); - } catch (Exception $e) { - return; // ok - } - $this->fail('no exception while fetching message'); - } - - public function testStore() - { - $protocol = new Zend_Mail_Protocol_Imap($this->_params['host']); - $protocol->login($this->_params['user'], $this->_params['password']); - $protocol->select('INBOX'); - - $this->assertTrue($protocol->store(array('\Flagged'), 1)); - $this->assertTrue($protocol->store(array('\Flagged'), 1, null, '-')); - $this->assertTrue($protocol->store(array('\Flagged'), 1, null, '+')); - - $result = $protocol->store(array('\Flagged'), 1, null, '', false); - $this->assertTrue(in_array('\Flagged', $result[1])); - $result = $protocol->store(array('\Flagged'), 1, null, '-', false); - $this->assertFalse(in_array('\Flagged', $result[1])); - $result = $protocol->store(array('\Flagged'), 1, null, '+', false); - $this->assertTrue(in_array('\Flagged', $result[1])); - } - - public function testMove() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - $mail->selectFolder('subfolder/test'); - $toCount = $mail->countMessages(); - $mail->selectFolder('INBOX'); - $fromCount = $mail->countMessages(); - $mail->moveMessage(1, 'subfolder/test'); - - - $this->assertEquals($fromCount - 1, $mail->countMessages()); - $mail->selectFolder('subfolder/test'); - $this->assertEquals($toCount + 1, $mail->countMessages()); - } - - public function testCountFlags() - { - $mail = new Zend_Mail_Storage_Imap($this->_params); - foreach ($mail as $id => $message) { - $mail->setFlags($id, array()); - } - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_SEEN), 0); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_ANSWERED), 0); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_FLAGGED), 0); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_ANSWERED)); - $mail->setFlags(2, array(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_SEEN), 2); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_ANSWERED), 1); - $this->assertEquals($mail->countMessages(array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_ANSWERED)), 1); - $this->assertEquals($mail->countMessages(array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_FLAGGED)), 0); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_FLAGGED), 0); - } -} diff --git a/tests/Zend/Mail/InterfaceTest.php b/tests/Zend/Mail/InterfaceTest.php deleted file mode 100644 index b4226a40857feecf1597b3155c7551c71cb48933..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/InterfaceTest.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Mbox - */ -require_once 'Zend/Mail/Storage/Mbox.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_InterfaceTest extends PHPUnit_Framework_TestCase -{ - protected $_mboxFile; - - public function setUp() - { - $this->_mboxFile = dirname(__FILE__) . '/_files/test.mbox/INBOX'; - } - - public function testCount() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = count($list); - $this->assertEquals(6, $count); - } - - public function testIsset() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $this->assertTrue(isset($list[1])); - } - - public function testNotIsset() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $this->assertFalse(isset($list[10])); - } - - public function testArrayGet() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $subject = $list[1]->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testArraySetFail() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $list[1] = 'test'; - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception thrown while writing to array access'); - } - - public function testIterationKey() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $pos = 1; - foreach ($list as $key => $message) { - $this->assertEquals($key, $pos, "wrong key in iteration $pos"); - ++$pos; - } - } - - public function testIterationIsMessage() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - foreach ($list as $key => $message) { - $this->assertTrue($message instanceof Zend_Mail_Message_Interface, 'value in iteration is not a mail message'); - } - } - - public function testIterationRounds() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = 0; - foreach ($list as $key => $message) { - ++$count; - } - - $this->assertEquals(6, $count); - } - - public function testIterationWithSeek() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = 0; - foreach (new LimitIterator($list, 1, 3) as $key => $message) { - ++$count; - } - - $this->assertEquals(3, $count); - } - - public function testIterationWithSeekCapped() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = 0; - foreach (new LimitIterator($list, 3, 6) as $key => $message) { - ++$count; - } - - $this->assertEquals(4, $count); - } - - public function testFallback() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $result = $list->noop(); - $this->assertTrue($result); - } catch (Exception $e) { - $this->fail('exception raised while calling noop thru fallback'); - } - } - - public function testWrongVariable() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $list->thisdoesnotexist; - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception thrown while reading wrong variable (via __get())'); - } - - public function testGetHeaders() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - $headers = $list[1]->getHeaders(); - $this->assertTrue(count($headers) > 0); - } - - public function testWrongHeader() - { - $list = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $list[1]->thisdoesnotexist; - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception thrown while reading wrong header'); - } -} diff --git a/tests/Zend/Mail/MaildirFolderTest.php b/tests/Zend/Mail/MaildirFolderTest.php deleted file mode 100644 index 877d1b406e55bb18db9bacbe4aeeda02218a2bc4..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MaildirFolderTest.php +++ /dev/null @@ -1,438 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Folder_Maildir - */ -require_once 'Zend/Mail/Storage/Folder/Maildir.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_MaildirFolderTest extends PHPUnit_Framework_TestCase -{ - protected $_params; - protected $_originalDir; - protected $_tmpdir; - protected $_subdirs = array('.', '.subfolder', '.subfolder.test'); - - public function setUp() - { - $this->_originalDir = dirname(__FILE__) . '/_files/test.maildir/'; - - if (!is_dir($this->_originalDir . '/cur/')) { - $this->markTestSkipped('You have to unpack maildir.tar in Zend/Mail/_files/test.maildir/ ' - . 'directory before enabling the maildir tests'); - return; - } - - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_params = array(); - $this->_params['dirname'] = $this->_tmpdir; - - foreach ($this->_subdirs as $dir) { - if ($dir != '.') { - mkdir($this->_tmpdir . $dir); - } - foreach (array('cur', 'new') as $subdir) { - if (!file_exists($this->_originalDir . $dir . '/' . $subdir)) { - continue; - } - mkdir($this->_tmpdir . $dir . '/' . $subdir); - $dh = opendir($this->_originalDir . $dir . '/' . $subdir); - while (($entry = readdir($dh)) !== false) { - $entry = $dir . '/' . $subdir . '/' . $entry; - if (!is_file($this->_originalDir . $entry)) { - continue; - } - copy($this->_originalDir . $entry, $this->_tmpdir . $entry); - } - closedir($dh); - } - } - } - - public function tearDown() - { - foreach (array_reverse($this->_subdirs) as $dir) { - foreach (array('cur', 'new') as $subdir) { - if (!file_exists($this->_tmpdir . $dir . '/' . $subdir)) { - continue; - } - $dh = opendir($this->_tmpdir . $dir . '/' . $subdir); - while (($entry = readdir($dh)) !== false) { - $entry = $this->_tmpdir . $dir . '/' . $subdir . '/' . $entry; - if (!is_file($entry)) { - continue; - } - unlink($entry); - } - closedir($dh); - rmdir($this->_tmpdir . $dir . '/' . $subdir); - } - if ($dir != '.') { - rmdir($this->_tmpdir . $dir); - } - } - } - - public function testLoadOk() - { - try { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading Maildir folder'); - } - } - - public function testLoadConfig() - { - try { - $mail = new Zend_Mail_Storage_Folder_Maildir(new Zend_Config($this->_params)); - } catch (Exception $e) { - $this->fail('exception raised while loading Maildir folder'); - } - } - - public function testNoParams() - { - try { - $mail = new Zend_Mail_Storage_Folder_Maildir(array()); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised with empty params'); - } - - public function testLoadFailure() - { - try { - $mail = new Zend_Mail_Storage_Folder_Maildir(array('dirname' => 'This/Folder/Does/Not/Exist')); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown dirname'); - } - - public function testLoadUnkownFolder() - { - $this->_params['folder'] = 'UnknownFolder'; - try { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown folder'); - } - - public function testChangeFolder() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - try { - $mail->selectFolder('subfolder.test'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder'); - } - - $this->assertEquals($mail->getCurrentFolder(), 'subfolder.test'); - } - - public function testUnknownFolder() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - try { - $mail->selectFolder('/Unknown/Folder/'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while selecting unknown folder'); - } - - public function testGlobalName() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - try { - // explicit call of __toString() needed for PHP < 5.2 - $this->assertEquals($mail->getFolders()->subfolder->__toString(), 'subfolder'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder and getting global name'); - } - } - - public function testLocalName() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - try { - $this->assertEquals($mail->getFolders()->subfolder->key(), 'test'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder and getting local name'); - } - } - - public function testIterator() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - // we search for this folder because we can't assume a order while iterating - $search_folders = array('subfolder' => 'subfolder', - 'subfolder.test' => 'test', - 'INBOX' => 'INBOX'); - $found_folders = array(); - - foreach ($iterator as $localName => $folder) { - if (!isset($search_folders[$folder->getGlobalName()])) { - continue; - } - - // explicit call of __toString() needed for PHP < 5.2 - $found_folders[$folder->__toString()] = $localName; - } - - $this->assertEquals($search_folders, $found_folders); - } - - public function testKeyLocalName() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - // we search for this folder because we can't assume a order while iterating - $search_folders = array('subfolder' => 'subfolder', - 'subfolder.test' => 'test', - 'INBOX' => 'INBOX'); - $found_folders = array(); - - foreach ($iterator as $localName => $folder) { - if (!isset($search_folders[$folder->getGlobalName()])) { - continue; - } - - // explicit call of __toString() needed for PHP < 5.2 - $found_folders[$folder->__toString()] = $localName; - } - - $this->assertEquals($search_folders, $found_folders); - } - - public function testInboxEquals() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders('INBOX.subfolder'), RecursiveIteratorIterator::SELF_FIRST); - // we search for this folder because we can't assume a order while iterating - $search_folders = array('subfolder.test' => 'test'); - $found_folders = array(); - - foreach ($iterator as $localName => $folder) { - if (!isset($search_folders[$folder->getGlobalName()])) { - continue; - } - - // explicit call of __toString() needed for PHP < 5.2 - $found_folders[$folder->__toString()] = $localName; - } - - $this->assertEquals($search_folders, $found_folders); - } - - public function testSelectable() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - - foreach ($iterator as $localName => $folder) { - $this->assertEquals($localName, $folder->getLocalName()); - } - } - - - public function testCount() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - - $count = $mail->countMessages(); - $this->assertEquals(5, $count); - - $mail->selectFolder('subfolder.test'); - $count = $mail->countMessages(); - $this->assertEquals(1, $count); - } - - public function testSize() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $shouldSizes = array(1 => 397, 89, 694, 452, 497); - - $sizes = $mail->getSize(); - $this->assertEquals($shouldSizes, $sizes); - - $mail->selectFolder('subfolder.test'); - $sizes = $mail->getSize(); - $this->assertEquals(array(1 => 467), $sizes); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - - $mail->selectFolder('subfolder.test'); - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Message in subfolder', $subject); - } - - public function testNotReadableFolder() - { - $stat = stat($this->_params['dirname'] . '.subfolder'); - chmod($this->_params['dirname'] . '.subfolder', 0); - clearstatcache(); - $statcheck = stat($this->_params['dirname'] . '.subfolder'); - if ($statcheck['mode'] % (8 * 8 * 8) !== 0) { - chmod($this->_params['dirname'] . '.subfolder', $stat['mode']); - $this->markTestSkipped('cannot remove read rights, which makes this test useless (maybe you are using Windows?)'); - return; - } - - $check = false; - try { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - } catch (Exception $e) { - $check = true; - // test ok - } - - chmod($this->_params['dirname'] . '.subfolder', $stat['mode']); - - if (!$check) { - $this->fail('no exception while loading invalid dir with subfolder not readable'); - } - } - - public function testNotReadableMaildir() - { - $stat = stat($this->_params['dirname']); - chmod($this->_params['dirname'], 0); - clearstatcache(); - $statcheck = stat($this->_params['dirname']); - if ($statcheck['mode'] % (8 * 8 * 8) !== 0) { - chmod($this->_params['dirname'], $stat['mode']); - $this->markTestSkipped('cannot remove read rights, which makes this test useless (maybe you are using Windows?)'); - return; - } - - $check = false; - try { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - } catch (Exception $e) { - $check = true; - // test ok - } - - chmod($this->_params['dirname'], $stat['mode']); - - if (!$check) { - $this->fail('no exception while loading not readable maildir'); - } - } - - public function testGetInvalidFolder() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $root = $mail->getFolders(); - $root->foobar = new Zend_Mail_Storage_Folder('foobar', DIRECTORY_SEPARATOR . 'foobar'); - - try { - $mail->selectFolder('foobar'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no error while getting invalid folder'); - } - - public function testGetVanishedFolder() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $root = $mail->getFolders(); - $root->foobar = new Zend_Mail_Storage_Folder('foobar', 'foobar'); - - try { - $mail->selectFolder('foobar'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no error while getting vanished folder'); - } - - public function testGetNotSelectableFolder() - { - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $root = $mail->getFolders(); - $root->foobar = new Zend_Mail_Storage_Folder('foobar', 'foobar', false); - - try { - $mail->selectFolder('foobar'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no error while getting not selectable folder'); - } - - public function testWithAdditionalFolder() - { - mkdir($this->_params['dirname'] . '.xyyx'); - mkdir($this->_params['dirname'] . '.xyyx/cur'); - - $mail = new Zend_Mail_Storage_Folder_Maildir($this->_params); - $mail->selectFolder('xyyx'); - $this->assertEquals($mail->countMessages(), 0); - - rmdir($this->_params['dirname'] . '.xyyx/cur'); - rmdir($this->_params['dirname'] . '.xyyx'); - } -} diff --git a/tests/Zend/Mail/MaildirMessageOldTest.php b/tests/Zend/Mail/MaildirMessageOldTest.php deleted file mode 100644 index ef96c3f884497315d6587a3ce16b8700bf1d1138..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MaildirMessageOldTest.php +++ /dev/null @@ -1,181 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Maildir - */ -require_once 'Zend/Mail/Storage/Maildir.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Maildir class, which uses old message class - * - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Mail_Storage_Maildir_OldMessage extends Zend_Mail_Storage_Maildir -{ - /** - * used message class - * @var string - */ - protected $_messageClass = 'Zend_Mail_Message'; -} - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_MaildirMessageOldTest extends PHPUnit_Framework_TestCase -{ - protected $_originalMaildir; - protected $_maildir; - protected $_tmpdir; - - public function setUp() - { - $this->_originalMaildir = dirname(__FILE__) . '/_files/test.maildir/'; - if (!is_dir($this->_originalMaildir . '/cur/')) { - $this->markTestSkipped('You have to unpack maildir.tar in Zend/Mail/_files/test.maildir/ ' - . 'directory before enabling the maildir tests'); - return; - } - - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_maildir = $this->_tmpdir; - - foreach (array('cur', 'new') as $dir) { - mkdir($this->_tmpdir . $dir); - $dh = opendir($this->_originalMaildir . $dir); - while (($entry = readdir($dh)) !== false) { - $entry = $dir . '/' . $entry; - if (!is_file($this->_originalMaildir . $entry)) { - continue; - } - copy($this->_originalMaildir . $entry, $this->_tmpdir . $entry); - } - closedir($dh); - } - } - - public function tearDown() - { - foreach (array('cur', 'new') as $dir) { - $dh = opendir($this->_tmpdir . $dir); - while (($entry = readdir($dh)) !== false) { - $entry = $this->_tmpdir . $dir . '/' . $entry; - if (!is_file($entry)) { - continue; - } - unlink($entry); - } - closedir($dh); - rmdir($this->_tmpdir . $dir); - } - } - - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - -/* - public function testFetchTopBody() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - - $content = $mail->getHeader(3, 1)->getContent(); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } -*/ - public function testFetchMessageHeader() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testFetchMessageBody() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - - $content = $mail->getMessage(3)->getContent(); - list($content, ) = explode("\n", $content, 2); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } - - public function testHasFlag() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - - $this->assertFalse($mail->getMessage(5)->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertTrue($mail->getMessage(5)->hasFlag(Zend_Mail_Storage::FLAG_RECENT)); - $this->assertTrue($mail->getMessage(2)->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - $this->assertFalse($mail->getMessage(2)->hasFlag(Zend_Mail_Storage::FLAG_ANSWERED)); - } - - public function testGetFlags() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - - $flags = $mail->getMessage(1)->getFlags(); - $this->assertTrue(isset($flags[Zend_Mail_Storage::FLAG_SEEN])); - $this->assertTrue(in_array(Zend_Mail_Storage::FLAG_SEEN, $flags)); - } - - public function testFetchPart() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - $this->assertEquals($mail->getMessage(4)->getPart(2)->contentType, 'text/x-vertical'); - } - - public function testPartSize() - { - $mail = new Zend_Mail_Storage_Maildir_OldMessage(array('dirname' => $this->_maildir)); - $this->assertEquals($mail->getMessage(4)->getPart(2)->getSize(), 88); - } -} diff --git a/tests/Zend/Mail/MaildirTest.php b/tests/Zend/Mail/MaildirTest.php deleted file mode 100644 index d1740ec9bd4bf29a9a576b6834c662a5fe20456e..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MaildirTest.php +++ /dev/null @@ -1,416 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Maildir - */ -require_once 'Zend/Mail/Storage/Maildir.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_MaildirTest extends PHPUnit_Framework_TestCase -{ - protected $_originalMaildir; - protected $_maildir; - protected $_tmpdir; - - public function setUp() - { - $this->_originalMaildir = dirname(__FILE__) . '/_files/test.maildir/'; - if (!is_dir($this->_originalMaildir . '/cur/')) { - $this->markTestSkipped('You have to unpack maildir.tar in Zend/Mail/_files/test.maildir/ ' - . 'directory before enabling the maildir tests'); - return; - } - - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_maildir = $this->_tmpdir; - - foreach (array('cur', 'new') as $dir) { - mkdir($this->_tmpdir . $dir); - $dh = opendir($this->_originalMaildir . $dir); - while (($entry = readdir($dh)) !== false) { - $entry = $dir . '/' . $entry; - if (!is_file($this->_originalMaildir . $entry)) { - continue; - } - copy($this->_originalMaildir . $entry, $this->_tmpdir . $entry); - } - closedir($dh); - } - } - - public function tearDown() - { - foreach (array('cur', 'new') as $dir) { - $dh = opendir($this->_tmpdir . $dir); - while (($entry = readdir($dh)) !== false) { - $entry = $this->_tmpdir . $dir . '/' . $entry; - if (!is_file($entry)) { - continue; - } - unlink($entry); - } - closedir($dh); - rmdir($this->_tmpdir . $dir); - } - } - - public function testLoadOk() - { - try { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - } catch (Exception $e) { - $this->fail('exception raised while loading maildir'); - } - } - - public function testLoadConfig() - { - try { - $mail = new Zend_Mail_Storage_Maildir(new Zend_Config(array('dirname' => $this->_maildir))); - } catch (Exception $e) { - $this->fail('exception raised while loading maildir'); - } - } - - public function testLoadFailure() - { - try { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => '/This/Dir/Does/Not/Exist')); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown dir'); - } - - public function testLoadInvalid() - { - try { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => dirname(__FILE__))); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while loading invalid dir'); - } - - public function testClose() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - try { - $mail->close(); - } catch (Exception $e) { - $this->fail('exception raised while closing maildir'); - } - } - - public function testHasTop() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $this->assertTrue($mail->hasTop); - } - - public function testHasCreate() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $this->assertFalse($mail->hasCreate); - } - - public function testNoop() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - try { - $mail->noop(); - } catch (Exception $e) { - $this->fail('exception raised while doing nothing (noop)'); - } - } - - public function testCount() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $count = $mail->countMessages(); - $this->assertEquals(5, $count); - } - - public function testSize() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - $shouldSizes = array(1 => 397, 89, 694, 452, 497); - - - $sizes = $mail->getSize(); - $this->assertEquals($shouldSizes, $sizes); - } - - public function testSingleSize() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $size = $mail->getSize(2); - $this->assertEquals(89, $size); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - -/* - public function testFetchTopBody() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $content = $mail->getHeader(3, 1)->getContent(); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } -*/ - public function testFetchMessageHeader() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testFetchMessageBody() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $content = $mail->getMessage(3)->getContent(); - list($content, ) = explode("\n", $content, 2); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } - - public function testFetchWrongSize() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - try { - $mail->getSize(0); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while getting size for message 0'); - } - - public function testFetchWrongMessageBody() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - try { - $mail->getMessage(0); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while fetching message 0'); - } - - public function testFailedRemove() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - try { - $mail->removeMessage(1); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while deleting message (maildir is read-only)'); - } - - public function testHasFlag() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $this->assertFalse($mail->getMessage(5)->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertTrue($mail->getMessage(5)->hasFlag(Zend_Mail_Storage::FLAG_RECENT)); - $this->assertTrue($mail->getMessage(2)->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - $this->assertFalse($mail->getMessage(2)->hasFlag(Zend_Mail_Storage::FLAG_ANSWERED)); - } - - public function testGetFlags() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $flags = $mail->getMessage(1)->getFlags(); - $this->assertTrue(isset($flags[Zend_Mail_Storage::FLAG_SEEN])); - $this->assertTrue(in_array(Zend_Mail_Storage::FLAG_SEEN, $flags)); - } - - public function testUniqueId() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - - $this->assertTrue($mail->hasUniqueId); - $this->assertEquals(1, $mail->getNumberByUniqueId($mail->getUniqueId(1))); - - $ids = $mail->getUniqueId(); - $should_ids = array(1 => '1000000000.P1.example.org', '1000000001.P1.example.org', '1000000002.P1.example.org', - '1000000003.P1.example.org', '1000000004.P1.example.org'); - foreach ($ids as $num => $id) { - $this->assertEquals($id, $should_ids[$num]); - - if ($mail->getNumberByUniqueId($id) != $num) { - $this->fail('reverse lookup failed'); - } - } - } - - public function testWrongUniqueId() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - try { - $mail->getNumberByUniqueId('this_is_an_invalid_id'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while getting number for invalid id'); - } - - public function isFileTest($dir) - { - if (file_exists($this->_maildir . '/' . $dir)) { - rename($this->_maildir . '/' . $dir, $this->_maildir . '/' . $dir . 'bak'); - } - touch($this->_maildir . '/' . $dir); - - $check = false; - try { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - } catch (Exception $e) { - $check = true; - // test ok - } - - unlink($this->_maildir . '/' . $dir); - if (file_exists($this->_maildir . '/' . $dir . 'bak')) { - rename($this->_maildir . '/' . $dir . 'bak', $this->_maildir . '/' . $dir); - } - - if (!$check) { - $this->fail('no exception while loading invalid dir with ' . $dir . ' as file'); - } - } - - public function testCurIsFile() - { - $this->isFileTest('cur'); - } - - public function testNewIsFile() - { - $this->isFileTest('new'); - } - - public function testTmpIsFile() - { - $this->isFileTest('tmp'); - } - - public function notReadableTest($dir) - { - $stat = stat($this->_maildir . '/' . $dir); - chmod($this->_maildir . '/' . $dir, 0); - - $check = false; - try { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - } catch (Exception $e) { - $check = true; - // test ok - } - - chmod($this->_maildir . '/' . $dir, $stat['mode']); - - if (!$check) { - $this->fail('no exception while loading invalid dir with ' . $dir . ' not readable'); - } - } - - public function testNotReadableCur() - { - $this->notReadableTest('cur'); - } - - public function testNotReadableNew() - { - $this->notReadableTest('new'); - } - - public function testCountFlags() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_DELETED), 0); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_RECENT), 1); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_FLAGGED), 1); - $this->assertEquals($mail->countMessages(Zend_Mail_Storage::FLAG_SEEN), 4); - $this->assertEquals($mail->countMessages(array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_FLAGGED)), 1); - $this->assertEquals($mail->countMessages(array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_RECENT)), 0); - } - - public function testFetchPart() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - $this->assertEquals($mail->getMessage(4)->getPart(2)->contentType, 'text/x-vertical'); - } - - public function testPartSize() - { - $mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->_maildir)); - $this->assertEquals($mail->getMessage(4)->getPart(2)->getSize(), 88); - } -} diff --git a/tests/Zend/Mail/MaildirWritableTest.php b/tests/Zend/Mail/MaildirWritableTest.php deleted file mode 100644 index 3302875797af63402e315630b75b22cc7c18d442..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MaildirWritableTest.php +++ /dev/null @@ -1,607 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Folder_Maildir - */ -require_once 'Zend/Mail/Storage/Writable/Maildir.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_MaildirWritableTest extends PHPUnit_Framework_TestCase -{ - protected $_params; - protected $_originalDir; - protected $_tmpdir; - protected $_subdirs = array('.', '.subfolder', '.subfolder.test'); - - public function setUp() - { - $this->_originalDir = dirname(__FILE__) . '/_files/test.maildir/'; - - if (!is_dir($this->_originalDir . '/cur/')) { - $this->markTestSkipped('You have to unpack maildir.tar in Zend/Mail/_files/test.maildir/ ' - . 'directory before enabling the maildir tests'); - return; - } - - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_params = array(); - $this->_params['dirname'] = $this->_tmpdir; - - foreach ($this->_subdirs as $dir) { - if ($dir != '.') { - mkdir($this->_tmpdir . $dir); - } - foreach (array('cur', 'new') as $subdir) { - if (!file_exists($this->_originalDir . $dir . '/' . $subdir)) { - continue; - } - mkdir($this->_tmpdir . $dir . '/' . $subdir); - $dh = opendir($this->_originalDir . $dir . '/' . $subdir); - while (($entry = readdir($dh)) !== false) { - $entry = $dir . '/' . $subdir . '/' . $entry; - if (!is_file($this->_originalDir . $entry)) { - continue; - } - copy($this->_originalDir . $entry, $this->_tmpdir . $entry); - } - closedir($dh); - } - copy($this->_originalDir . 'maildirsize', $this->_tmpdir . 'maildirsize'); - } - } - - public function tearDown() - { - foreach (array_reverse($this->_subdirs) as $dir) { - if (!file_exists($this->_tmpdir . $dir)) { - continue; - } - foreach (array('cur', 'new', 'tmp') as $subdir) { - if (!file_exists($this->_tmpdir . $dir . '/' . $subdir)) { - continue; - } - $dh = opendir($this->_tmpdir . $dir . '/' . $subdir); - while (($entry = readdir($dh)) !== false) { - $entry = $this->_tmpdir . $dir . '/' . $subdir . '/' . $entry; - if (!is_file($entry)) { - continue; - } - unlink($entry); - } - closedir($dh); - rmdir($this->_tmpdir . $dir . '/' . $subdir); - } - if ($dir != '.') { - rmdir($this->_tmpdir . $dir); - } - } - @unlink($this->_tmpdir . 'maildirsize'); - } - - public function testCreateFolder() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->createFolder('subfolder.test1'); - $mail->createFolder('test2', 'INBOX.subfolder'); - $mail->createFolder('test3', $mail->getFolders()->subfolder); - $mail->createFolder('foo.bar'); - - try { - $mail->selectFolder($mail->getFolders()->subfolder->test1); - $mail->selectFolder($mail->getFolders()->subfolder->test2); - $mail->selectFolder($mail->getFolders()->subfolder->test3); - $mail->selectFolder($mail->getFolders()->foo->bar); - } catch (Exception $e) { - $this->fail('could not get new folders'); - } - - // to tear down - $this->_subdirs[] = '.subfolder.test1'; - $this->_subdirs[] = '.subfolder.test2'; - $this->_subdirs[] = '.subfolder.test3'; - $this->_subdirs[] = '.foo'; - $this->_subdirs[] = '.foo.bar'; - } - - public function testCreateFolderEmtpyPart() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - try { - $mail->createFolder('foo..bar'); - } catch (Exception $e) { - return; //ok - } - - $this->fail('no exception while creating folder with empty part name'); - } - - public function testCreateFolderSlash() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - try { - $mail->createFolder('foo/bar'); - } catch (Exception $e) { - return; //ok - } - - $this->fail('no exception while creating folder with slash'); - } - - public function testCreateFolderDirectorySeparator() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - try { - $mail->createFolder('foo' . DIRECTORY_SEPARATOR . 'bar'); - } catch (Exception $e) { - return; //ok - } - - $this->fail('no exception while creating folder with DIRECTORY_SEPARATOR'); - } - - public function testCreateFolderExistingDir() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - unset($mail->getFolders()->subfolder->test); - - try { - $mail->createFolder('subfolder.test'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('should not be able to create existing folder'); - } - - public function testCreateExistingFolder() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - - try { - $mail->createFolder('subfolder.test'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('should not be able to create existing folder'); - } - - public function testRemoveFolderName() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->removeFolder('INBOX.subfolder.test'); - - try { - $mail->selectFolder($mail->getFolders()->subfolder->test); - } catch (Exception $e) { - return; // ok - } - $this->fail('folder still exists'); - } - - public function testRemoveFolderInstance() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->removeFolder($mail->getFolders()->subfolder->test); - - try { - $mail->selectFolder($mail->getFolders()->subfolder->test); - } catch (Exception $e) { - return; // ok - } - $this->fail('folder still exists'); - } - - public function testRemoveFolderWithChildren() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - - try { - $mail->removeFolder($mail->getFolders()->subfolder); - } catch (Exception $e) { - return; // ok - } - - $this->fail('should not be able to remove a folder with children'); - } - - public function testRemoveSelectedFolder() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->selectFolder('subfolder.test'); - - try { - $mail->removeFolder('subfolder.test'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while removing selected folder'); - } - - public function testRemoveInvalidFolder() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - - try { - $mail->removeFolder('thisFolderDoestNotExist'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while removing invalid folder'); - } - - public function testRenameFolder() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - try { - $mail->renameFolder('INBOX.subfolder', 'INBOX.foo'); - $mail->renameFolder($mail->getFolders()->foo, 'subfolder'); - } catch (Exception $e) { - $this->fail('renaming failed'); - } - - try { - $mail->renameFolder('INBOX', 'foo'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while renaming INBOX'); - } - - public function testRenameSelectedFolder() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->selectFolder('subfolder.test'); - - try { - $mail->renameFolder('subfolder.test', 'foo'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while renaming selected folder'); - } - - public function testRenameToChild() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - - try { - $mail->renameFolder('subfolder.test', 'subfolder.test.foo'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while renaming folder to child of old'); - } - - public function testAppend() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $count = $mail->countMessages(); - - $message = ''; - $message .= "From: me@example.org\r\n"; - $message .= "To: you@example.org\r\n"; - $message .= "Subject: append test\r\n"; - $message .= "\r\n"; - $message .= "This is a test\r\n"; - $mail->appendMessage($message); - - $this->assertEquals($count + 1, $mail->countMessages()); - $this->assertEquals($mail->getMessage($count + 1)->subject, 'append test'); - } - - public function testCopy() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - - $mail->selectFolder('subfolder.test'); - $count = $mail->countMessages(); - $mail->selectFolder('INBOX'); - $message = $mail->getMessage(1); - - $mail->copyMessage(1, 'subfolder.test'); - $mail->selectFolder('subfolder.test'); - $this->assertEquals($count + 1, $mail->countMessages()); - $this->assertEquals($mail->getMessage($count + 1)->subject, $message->subject); - $this->assertEquals($mail->getMessage($count + 1)->from, $message->from); - $this->assertEquals($mail->getMessage($count + 1)->to, $message->to); - - try { - $mail->copyMessage(1, 'justARandomFolder'); - } catch (Exception $e) { - return; // ok - } - $this->fail('no error while copying to wrong folder'); - } - - public function testSetFlags() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN)); - $message = $mail->getMessage(1); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_SEEN, Zend_Mail_Storage::FLAG_FLAGGED)); - $message = $mail->getMessage(1); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_FLAGGED)); - $message = $mail->getMessage(1); - $this->assertFalse($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)); - $this->assertTrue($message->hasFlag(Zend_Mail_Storage::FLAG_FLAGGED)); - - try { - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_RECENT)); - } catch (Exception $e) { - return; // ok - } - $this->fail('should not be able to set recent flag'); - } - - public function testSetFlagsRemovedFile() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - unlink($this->_params['dirname'] . 'cur/1000000000.P1.example.org:2,S'); - - try { - $mail->setFlags(1, array(Zend_Mail_Storage::FLAG_FLAGGED)); - } catch (Exception $e) { - return; // ok - } - - $this->fail('should not be able to set flags with removed file'); - } - - public function testRemove() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $count = $mail->countMessages(); - - $mail->removeMessage(1); - $this->assertEquals($mail->countMessages(), --$count); - - unset($mail[2]); - $this->assertEquals($mail->countMessages(), --$count); - } - - public function testRemoveRemovedFile() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - unlink($this->_params['dirname'] . 'cur/1000000000.P1.example.org:2,S'); - - try { - $mail->removeMessage(1); - } catch (Exception $e) { - return; // ok - } - - $this->fail('should not be able to remove message which is already removed in fs'); - } - - public function testCheckQuota() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $this->assertFalse($mail->checkQuota()); - } - - public function testCheckQuotaDetailed() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $quotaResult = array( - 'size' => 2596, - 'count' => 6, - 'quota' => array( - 'count' => 10, - 'L' => 1, - 'size' => 3000 - ), - 'over_quota' => false - ); - $this->assertEquals($mail->checkQuota(true), $quotaResult); - } - - public function testSetQuota() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $this->assertNull($mail->getQuota()); - - $mail->setQuota(true); - $this->assertTrue($mail->getQuota()); - - $mail->setQuota(false); - $this->assertFalse($mail->getQuota()); - - $mail->setQuota(array('size' => 100, 'count' => 2, 'X' => 0)); - $this->assertEquals($mail->getQuota(), array('size' => 100, 'count' => 2, 'X' => 0)); - $this->assertEquals($mail->getQuota(true), array('size' => 3000, 'L' => 1, 'count' => 10)); - - $quotaResult = array( - 'size' => 2596, - 'count' => 6, - 'quota' => array( - 'size' => 100, - 'count' => 2, - 'X' => 0 - ), - 'over_quota' => true - ); - $this->assertEquals($mail->checkQuota(true, true), $quotaResult); - - $this->assertEquals($mail->getQuota(true), array('size' => 100, 'count' => 2, 'X' => 0)); - } - - public function testMissingMaildirsize() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $this->assertEquals($mail->getQuota(true), array('size' => 3000, 'L' => 1, 'count' => 10)); - - unlink($this->_tmpdir . 'maildirsize'); - - $this->assertNull($mail->getQuota()); - - try { - $mail->getQuota(true); - } catch(Zend_Mail_Exception $e) { - // ok - return; - } - $this->fail('get quota from file should fail if file is missing'); - } - - public function testMissingMaildirsizeWithFixedQuota() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - unlink($this->_tmpdir . 'maildirsize'); - $mail->setQuota(array('size' => 100, 'count' => 2, 'X' => 0)); - - $quotaResult = array( - 'size' => 2596, - 'count' => 6, - 'quota' => array( - 'size' => 100, - 'count' => 2, - 'X' => 0 - ), - 'over_quota' => true - ); - $this->assertEquals($mail->checkQuota(true), $quotaResult); - - $this->assertEquals($mail->getQuota(true), $quotaResult['quota']); - } - - public function testAppendMessage() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->setQuota(array('size' => 3000, 'count' => 6, 'X' => 0)); - $this->assertFalse($mail->checkQuota(false, true)); - $mail->appendMessage("Subject: test\r\n\r\n"); - $quotaResult = array( - 'size' => 2613, - 'count' => 7, - 'quota' => array( - 'size' => 3000, - 'count' => 6, - 'X' => 0 - ), - 'over_quota' => true - ); - $this->assertEquals($mail->checkQuota(true), $quotaResult); - - $mail->setQuota(false); - $this->assertTrue($mail->checkQuota()); - try { - $mail->appendMessage("Subject: test\r\n\r\n"); - } catch(Zend_Mail_Exception $e) { - $this->fail('appending should not fail if quota check is not active'); - } - - $mail->setQuota(true); - $this->assertTrue($mail->checkQuota()); - try { - $mail->appendMessage("Subject: test\r\n\r\n"); - } catch(Zend_Mail_Exception $e) { - // ok - return; - } - $this->fail('appending after being over quota should fail'); - } - - public function testRemoveMessage() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->setQuota(array('size' => 3000, 'count' => 5, 'X' => 0)); - $this->assertTrue($mail->checkQuota(false, true)); - - $mail->removeMessage(1); - $this->assertFalse($mail->checkQuota()); - } - - public function testCopyMessage() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $mail->setQuota(array('size' => 3000, 'count' => 6, 'X' => 0)); - $this->assertFalse($mail->checkQuota(false, true)); - $mail->copyMessage(1, 'subfolder'); - $quotaResult = array( - 'size' => 2993, - 'count' => 7, - 'quota' => array( - 'size' => 3000, - 'count' => 6, - 'X' => 0 - ), - 'over_quota' => true - ); - $this->assertEquals($mail->checkQuota(true), $quotaResult); - } - - public function testAppendStream() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $fh = fopen('php://memory', 'rw'); - fputs($fh, "Subject: test\r\n\r\n"); - fseek($fh, 0); - $mail->appendMessage($fh); - fclose($fh); - - $this->assertEquals($mail->getMessage($mail->countMessages())->subject, 'test'); - } - - public function testMove() - { - $mail = new Zend_Mail_Storage_Writable_Maildir($this->_params); - $target = $mail->getFolders()->subfolder->test; - $mail->selectFolder($target); - $toCount = $mail->countMessages(); - $mail->selectFolder('INBOX'); - $fromCount = $mail->countMessages(); - $mail->moveMessage(1, $target); - - - $this->assertEquals($fromCount - 1, $mail->countMessages()); - $mail->selectFolder($target); - $this->assertEquals($toCount + 1, $mail->countMessages()); - } - -} diff --git a/tests/Zend/Mail/MboxFolderTest.php b/tests/Zend/Mail/MboxFolderTest.php deleted file mode 100644 index 718c352e4f36fcf8a96ad2dc14dc2418158ddaf4..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MboxFolderTest.php +++ /dev/null @@ -1,422 +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_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MboxFolderTest.php 9276 2008-04-22 15:39:06Z nico $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Mail_Storage_Folder_Mbox - */ -require_once 'Zend/Mail/Storage/Folder/Mbox.php'; - -/** - * @see Zend_Config - */ -require_once 'Zend/Config.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Mail_MboxFolderTest extends PHPUnit_Framework_TestCase -{ - protected $_params; - protected $_originalDir; - protected $_tmpdir; - protected $_subdirs = array('.', 'subfolder'); - - public function setUp() - { - $this->_originalDir = dirname(__FILE__) . '/_files/test.mbox/'; - - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_params = array(); - $this->_params['dirname'] = $this->_tmpdir; - $this->_params['folder'] = 'INBOX'; - - foreach ($this->_subdirs as $dir) { - if ($dir != '.') { - mkdir($this->_tmpdir . $dir); - } - $dh = opendir($this->_originalDir . $dir); - while (($entry = readdir($dh)) !== false) { - $entry = $dir . '/' . $entry; - if (!is_file($this->_originalDir . $entry)) { - continue; - } - copy($this->_originalDir . $entry, $this->_tmpdir . $entry); - } - closedir($dh); - } - } - - public function tearDown() - { - foreach (array_reverse($this->_subdirs) as $dir) { - $dh = opendir($this->_tmpdir . $dir); - while (($entry = readdir($dh)) !== false) { - $entry = $this->_tmpdir . $dir . '/' . $entry; - if (!is_file($entry)) { - continue; - } - unlink($entry); - } - closedir($dh); - if ($dir != '.') { - rmdir($this->_tmpdir . $dir); - } - } - } - - public function testLoadOk() - { - try { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading mbox folder'); - } - } - - public function testLoadConfig() - { - try { - $mail = new Zend_Mail_Storage_Folder_Mbox(new Zend_Config($this->_params)); - } catch (Exception $e) { - $this->fail('exception raised while loading mbox folder'); - } - } - - public function testNoParams() - { - try { - $mail = new Zend_Mail_Storage_Folder_Mbox(array()); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised with empty params'); - } - - public function testFilenameParam() - { - try { - // filename is not allowed in this subclass - $mail = new Zend_Mail_Storage_Folder_Mbox(array('filename' => 'foobar')); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised with filename as param'); - } - - public function testLoadFailure() - { - try { - $mail = new Zend_Mail_Storage_Folder_Mbox(array('dirname' => 'This/Folder/Does/Not/Exist')); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown dirname'); - } - - public function testLoadUnkownFolder() - { - $this->_params['folder'] = 'UnknownFolder'; - try { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown folder'); - } - - public function testChangeFolder() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - try { - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder'); - } - - $this->assertEquals($mail->getCurrentFolder(), DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - } - - public function testChangeFolderUnselectable() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - try { - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while selecting unselectable folder'); - } - - public function testUnknownFolder() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - try { - $mail->selectFolder('/Unknown/Folder/'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while selecting unknown folder'); - } - - public function testGlobalName() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - try { - // explicit call of __toString() needed for PHP < 5.2 - $this->assertEquals($mail->getFolders()->subfolder->__toString(), DIRECTORY_SEPARATOR . 'subfolder'); - } catch (Zend_Mail_Exception $e) { - $this->fail('exception raised while selecting existing folder and getting global name'); - } - } - - public function testLocalName() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - try { - $this->assertEquals($mail->getFolders()->subfolder->key(), 'test'); - } catch (Exception $e) { - $this->fail('exception raised while selecting existing folder and getting local name'); - } - } - - public function testIterator() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - // we search for this folder because we can't assume a order while iterating - $search_folders = array(DIRECTORY_SEPARATOR . 'subfolder' => 'subfolder', - DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test' => 'test', - DIRECTORY_SEPARATOR . 'INBOX' => 'INBOX'); - $found_folders = array(); - - foreach ($iterator as $localName => $folder) { - if (!isset($search_folders[$folder->getGlobalName()])) { - continue; - } - - // explicit call of __toString() needed for PHP < 5.2 - $found_folders[$folder->__toString()] = $localName; - } - - $this->assertEquals($search_folders, $found_folders); - } - - public function testKeyLocalName() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - // we search for this folder because we can't assume a order while iterating - $search_folders = array(DIRECTORY_SEPARATOR . 'subfolder' => 'subfolder', - DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test' => 'test', - DIRECTORY_SEPARATOR . 'INBOX' => 'INBOX'); - $found_folders = array(); - - foreach ($iterator as $localName => $folder) { - if (!isset($search_folders[$folder->getGlobalName()])) { - continue; - } - - // explicit call of __toString() needed for PHP < 5.2 - $found_folders[$folder->__toString()] = $localName; - } - - $this->assertEquals($search_folders, $found_folders); - } - - public function testSelectable() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - $iterator = new RecursiveIteratorIterator($mail->getFolders(), RecursiveIteratorIterator::SELF_FIRST); - - foreach ($iterator as $localName => $folder) { - $this->assertEquals($localName, $folder->getLocalName()); - } - } - - - public function testCount() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - - $count = $mail->countMessages(); - $this->assertEquals(6, $count); - - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - $count = $mail->countMessages(); - $this->assertEquals(1, $count); - } - - public function testSize() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - $shouldSizes = array(1 => 397, 89, 694, 452, 497, 103); - - $sizes = $mail->getSize(); - $this->assertEquals($shouldSizes, $sizes); - - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - $sizes = $mail->getSize(); - $this->assertEquals(array(1 => 410), $sizes); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Message in subfolder', $subject); - } - - public function testSleepWake() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - $count = $mail->countMessages(); - $content = $mail->getMessage(1)->getContent(); - - $serialzed = serialize($mail); - $mail = null; - $mail = unserialize($serialzed); - - $this->assertEquals($mail->countMessages(), $count); - $this->assertEquals($mail->getMessage(1)->getContent(), $content); - - $mail->selectFolder(DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'test'); - $this->assertEquals($mail->countMessages(), $count); - $this->assertEquals($mail->getMessage(1)->getContent(), $content); - } - - public function testNotMboxFile() - { - touch($this->_params['dirname'] . 'foobar'); - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - - try { - $mail->getFolders()->foobar; - } catch (Exception $e) { - return; // ok - } - - $this->fail('file, which is not mbox, got parsed'); - } - - public function testNotReadableFolder() - { - $stat = stat($this->_params['dirname'] . 'subfolder'); - chmod($this->_params['dirname'] . 'subfolder', 0); - clearstatcache(); - $statcheck = stat($this->_params['dirname'] . 'subfolder'); - if ($statcheck['mode'] % (8 * 8 * 8) !== 0) { - chmod($this->_params['dirname'] . 'subfolder', $stat['mode']); - $this->markTestSkipped('cannot remove read rights, which makes this test useless (maybe you are using Windows?)'); - return; - } - - $check = false; - try { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - } catch (Exception $e) { - $check = true; - // test ok - } - - chmod($this->_params['dirname'] . 'subfolder', $stat['mode']); - - if (!$check) { - if (function_exists('posix_getuid') && posix_getuid() === 0) { - $this->markTestSkipped('seems like you are root and we therefore cannot test the error handling'); - } - $this->fail('no exception while loading invalid dir with subfolder not readable'); - } - } - - public function testGetInvalidFolder() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - $root = $mail->getFolders(); - $root->foobar = new Zend_Mail_Storage_Folder('x', 'x'); - try { - $mail->getFolders('foobar'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no error while getting invalid folder'); - } - - public function testGetVanishedFolder() - { - $mail = new Zend_Mail_Storage_Folder_Mbox($this->_params); - $root = $mail->getFolders(); - $root->foobar = new Zend_Mail_Storage_Folder('foobar', DIRECTORY_SEPARATOR . 'foobar'); - - try { - $mail->selectFolder('foobar'); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no error while getting vanished folder'); - } -} diff --git a/tests/Zend/Mail/MboxMessageOldTest.php b/tests/Zend/Mail/MboxMessageOldTest.php deleted file mode 100644 index 58c71145cc415ea55980e584604081ee884d2d87..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MboxMessageOldTest.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Mbox - */ -require_once 'Zend/Mail/Storage/Mbox.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Maildir class, which uses old message class - * - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Mail_Storage_Mbox_OldMessage extends Zend_Mail_Storage_Mbox -{ - /** - * used message class - * @var string - */ - protected $_messageClass = 'Zend_Mail_Message'; -} - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_MboxMessageOldTest extends PHPUnit_Framework_TestCase -{ - protected $_mboxOriginalFile; - protected $_mboxFile; - protected $_tmpdir; - - public function setUp() - { - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_mboxOriginalFile = dirname(__FILE__) . '/_files/test.mbox/INBOX'; - $this->_mboxFile = $this->_tmpdir . 'INBOX'; - - copy($this->_mboxOriginalFile, $this->_mboxFile); - } - - public function tearDown() - { - unlink($this->_mboxFile); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Mbox_OldMessage(array('filename' => $this->_mboxFile)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - -/* - public function testFetchTopBody() - { - $mail = new Zend_Mail_Storage_Mbox_OldMessage(array('filename' => $this->_mboxFile)); - - $content = $mail->getHeader(3, 1)->getContent(); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } -*/ - - public function testFetchMessageHeader() - { - $mail = new Zend_Mail_Storage_Mbox_OldMessage(array('filename' => $this->_mboxFile)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testFetchMessageBody() - { - $mail = new Zend_Mail_Storage_Mbox_OldMessage(array('filename' => $this->_mboxFile)); - - $content = $mail->getMessage(3)->getContent(); - list($content, ) = explode("\n", $content, 2); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } - - - public function testShortMbox() - { - $fh = fopen($this->_mboxFile, 'w'); - fputs($fh, "From \r\nSubject: test\r\nFrom \r\nSubject: test2\r\n"); - fclose($fh); - $mail = new Zend_Mail_Storage_Mbox_OldMessage(array('filename' => $this->_mboxFile)); - $this->assertEquals($mail->countMessages(), 2); - $this->assertEquals($mail->getMessage(1)->subject, 'test'); - $this->assertEquals($mail->getMessage(1)->getContent(), ''); - $this->assertEquals($mail->getMessage(2)->subject, 'test2'); - $this->assertEquals($mail->getMessage(2)->getContent(), ''); - } - -} diff --git a/tests/Zend/Mail/MboxTest.php b/tests/Zend/Mail/MboxTest.php deleted file mode 100644 index 660effee23f479d44b41249b2838a7f53f86925f..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MboxTest.php +++ /dev/null @@ -1,367 +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_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MboxTest.php 9276 2008-04-22 15:39:06Z nico $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Mail_Storage_Mbox - */ -require_once 'Zend/Mail/Storage/Mbox.php'; - -/** - * @see Zend_Config - */ -require_once 'Zend/Config.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Mail_MboxTest extends PHPUnit_Framework_TestCase -{ - protected $_mboxOriginalFile; - protected $_mboxFile; - protected $_tmpdir; - - public function setUp() - { - if ($this->_tmpdir == null) { - if (TESTS_ZEND_MAIL_TEMPDIR != null) { - $this->_tmpdir = TESTS_ZEND_MAIL_TEMPDIR; - } else { - $this->_tmpdir = dirname(__FILE__) . '/_files/test.tmp/'; - } - if (!file_exists($this->_tmpdir)) { - mkdir($this->_tmpdir); - } - $count = 0; - $dh = opendir($this->_tmpdir); - while (readdir($dh) !== false) { - ++$count; - } - closedir($dh); - if ($count != 2) { - $this->markTestSkipped('Are you sure your tmp dir is a valid empty dir?'); - return; - } - } - - $this->_mboxOriginalFile = dirname(__FILE__) . '/_files/test.mbox/INBOX'; - $this->_mboxFile = $this->_tmpdir . 'INBOX'; - - copy($this->_mboxOriginalFile, $this->_mboxFile); - } - - public function tearDown() - { - unlink($this->_mboxFile); - } - - public function testLoadOk() - { - try { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - } catch (Exception $e) { - $this->fail('exception raised while loading mbox file'); - } - } - - public function testLoadConfig() - { - try { - $mail = new Zend_Mail_Storage_Mbox(new Zend_Config(array('filename' => $this->_mboxFile))); - } catch (Exception $e) { - $this->fail('exception raised while loading mbox folder'); - } - } - - public function testNoParams() - { - try { - $mail = new Zend_Mail_Storage_Mbox(array()); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised with empty params'); - } - - public function testLoadFailure() - { - try { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => 'ThisFileDoesNotExist')); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while loading unknown file'); - } - - public function testLoadInvalid() - { - try { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => __FILE__)); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while loading invalid file'); - } - - public function testClose() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $mail->close(); - } catch (Exception $e) { - $this->fail('exception raised while closing mbox file'); - } - } - - public function testHasTop() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $this->assertTrue($mail->hasTop); - } - - public function testHasCreate() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $this->assertFalse($mail->hasCreate); - } - - public function testNoop() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $mail->noop(); - } catch (Exception $e) { - $this->fail('exception raised while doing nothing (noop)'); - } - } - - public function testCount() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = $mail->countMessages(); - $this->assertEquals(6, $count); - } - - public function testSize() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - $shouldSizes = array(1 => 397, 89, 694, 452, 497, 103); - - - $sizes = $mail->getSize(); - $this->assertEquals($shouldSizes, $sizes); - } - - public function testSingleSize() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $size = $mail->getSize(2); - $this->assertEquals(89, $size); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - -/* - public function testFetchTopBody() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $content = $mail->getHeader(3, 1)->getContent(); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } -*/ - - public function testFetchMessageHeader() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testFetchMessageBody() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $content = $mail->getMessage(3)->getContent(); - list($content, ) = explode("\n", $content, 2); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } - - public function testFailedRemove() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $mail->removeMessage(1); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while deleting message (mbox is read-only)'); - } - - public function testCapa() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - $capa = $mail->getCapabilities(); - $this->assertTrue(isset($capa['uniqueid'])); - } - - public function testValid() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $this->assertFalse($mail->valid()); - $mail->rewind(); - $this->assertTrue($mail->valid()); - } - - - public function testOutOfBounds() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - try { - $mail->seek(INF); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while seeking to not invalid id'); - } - - public function testSleepWake() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = $mail->countMessages(); - $content = $mail->getMessage(1)->getContent(); - - $serialzed = serialize($mail); - $mail = null; - unlink($this->_mboxFile); - // otherwise this test is to fast for a mtime change - sleep(2); - copy($this->_mboxOriginalFile, $this->_mboxFile); - $mail = unserialize($serialzed); - - $this->assertEquals($mail->countMessages(), $count); - $this->assertEquals($mail->getMessage(1)->getContent(), $content); - } - - public function testSleepWakeRemoved() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $count = $mail->countMessages(); - $content = $mail->getMessage(1)->getContent(); - - $serialzed = serialize($mail); - $mail = null; - - $stat = stat($this->_mboxFile); - chmod($this->_mboxFile, 0); - clearstatcache(); - $statcheck = stat($this->_mboxFile); - if ($statcheck['mode'] % (8 * 8 * 8) !== 0) { - chmod($this->_mboxFile, $stat['mode']); - $this->markTestSkipped('cannot remove read rights, which makes this test useless (maybe you are using Windows?)'); - return; - } - - - - $check = false; - try { - $mail = unserialize($serialzed); - } catch (Exception $e) { - $check = true; - // test ok - } - - chmod($this->_mboxFile, $stat['mode']); - - if (!$check) { - if (function_exists('posix_getuid') && posix_getuid() === 0) { - $this->markTestSkipped('seems like you are root and we therefore cannot test the error handling'); - } - $this->fail('no exception while waking with non readable file'); - } - } - - public function testUniqueId() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - - $this->assertFalse($mail->hasUniqueId); - $this->assertEquals(1, $mail->getNumberByUniqueId($mail->getUniqueId(1))); - - $ids = $mail->getUniqueId(); - foreach ($ids as $num => $id) { - $this->assertEquals($num, $id); - - if ($mail->getNumberByUniqueId($id) != $num) { - $this->fail('reverse lookup failed'); - } - } - } - - public function testShortMbox() - { - $fh = fopen($this->_mboxFile, 'w'); - fputs($fh, "From \r\nSubject: test\r\nFrom \r\nSubject: test2\r\n"); - fclose($fh); - $mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->_mboxFile)); - $this->assertEquals($mail->countMessages(), 2); - $this->assertEquals($mail->getMessage(1)->subject, 'test'); - $this->assertEquals($mail->getMessage(1)->getContent(), ''); - $this->assertEquals($mail->getMessage(2)->subject, 'test2'); - $this->assertEquals($mail->getMessage(2)->getContent(), ''); - } - -} diff --git a/tests/Zend/Mail/MessageTest.php b/tests/Zend/Mail/MessageTest.php deleted file mode 100644 index acb7c1fc2b0adb721af70aa48bed37aa3379e47b..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/MessageTest.php +++ /dev/null @@ -1,421 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Message - */ -require_once 'Zend/Mail/Message.php'; - -/** - * Zend_Mail_Storage_Mbox - */ -require_once 'Zend/Mail/Storage/Mbox.php'; - -/** - * Zend_Mime_Decode - */ -require_once 'Zend/Mime/Decode.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_MessageTest extends PHPUnit_Framework_TestCase -{ - protected $_file; - - public function setUp() - { - $this->_file = dirname(__FILE__) . '/_files/mail.txt'; - } - - public function testInvalidFile() - { - try { - $message = new Zend_Mail_Message(array('file' => '/this/file/does/not/exists')); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no exception raised while loading unknown file'); - } - - public function testIsMultipart() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertTrue($message->isMultipart()); - } - - public function testGetHeader() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertEquals($message->subject, 'multipart'); - } - - public function testGetDecodedHeader() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertEquals($message->from, iconv('UTF-8', iconv_get_encoding('internal_encoding'), - '"Peter Müller" <peter-mueller@example.com>')); - } - - public function testGetHeaderAsArray() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertEquals($message->getHeader('subject', 'array'), array('multipart')); - } - - public function testGetHeaderFromOpenFile() - { - $fh = fopen($this->_file, 'r'); - $message = new Zend_Mail_Message(array('file' => $fh)); - - $this->assertEquals($message->subject, 'multipart'); - } - - public function testGetFirstPart() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertEquals(substr($message->getPart(1)->getContent(), 0, 14), 'The first part'); - } - - public function testGetFirstPartTwice() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $message->getPart(1); - $this->assertEquals(substr($message->getPart(1)->getContent(), 0, 14), 'The first part'); - } - - - public function testGetWrongPart() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - try { - $message->getPart(-1); - } catch (Exception $e) { - return; // ok - } - - $this->fail('no exception raised while fetching unknown part'); - } - - public function testNoHeaderMessage() - { - $message = new Zend_Mail_Message(array('file' => __FILE__)); - - $this->assertEquals(substr($message->getContent(), 0, 5), '<?php'); - - $raw = file_get_contents(__FILE__); - $raw = "\t" . $raw; - $message = new Zend_Mail_Message(array('raw' => $raw)); - - $this->assertEquals(substr($message->getContent(), 0, 6), "\t<?php"); - } - - public function testMultipleHeader() - { - $raw = file_get_contents($this->_file); - $raw = "sUBject: test\nSubJect: test2\n" . $raw; - $message = new Zend_Mail_Message(array('raw' => $raw)); - - $this->assertEquals($message->getHeader('subject', 'string'), - 'test' . Zend_Mime::LINEEND . 'test2' . Zend_Mime::LINEEND . 'multipart'); - $this->assertEquals($message->getHeader('subject'), array('test', 'test2', 'multipart')); - } - - public function testContentTypeDecode() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertEquals(Zend_Mime_Decode::splitContentType($message->ContentType), - array('type' => 'multipart/alternative', 'boundary' => 'crazy-multipart')); - } - - public function testSplitEmptyMessage() - { - $this->assertEquals(Zend_Mime_Decode::splitMessageStruct('', 'xxx'), null); - } - - public function testSplitInvalidMessage() - { - try { - Zend_Mime_Decode::splitMessageStruct("--xxx\n", 'xxx'); - } catch (Zend_Exception $e) { - return; // ok - } - - $this->fail('no exception raised while decoding invalid message'); - } - - public function testInvalidMailHandler() - { - try { - $message = new Zend_Mail_Message(array('handler' => 1)); - } catch (Zend_Exception $e) { - return; // ok - } - - $this->fail('no exception raised while using invalid mail handler'); - - } - - public function testMissingId() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => dirname(__FILE__) . '/_files/test.mbox/INBOX')); - - try { - $message = new Zend_Mail_Message(array('handler' => $mail)); - } catch (Zend_Exception $e) { - return; // ok - } - - $this->fail('no exception raised while mail handler without id'); - - } - - public function testIterator() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - foreach (new RecursiveIteratorIterator($message) as $num => $part) { - if ($num == 1) { - // explicit call of __toString() needed for PHP < 5.2 - $this->assertEquals(substr($part->__toString(), 0, 14), 'The first part'); - } - } - $this->assertEquals($part->contentType, 'text/x-vertical'); - } - - public function testDecodeString() - { - $is = Zend_Mime_Decode::decodeQuotedPrintable('=?UTF-8?Q?"Peter M=C3=BCller"?= <peter-mueller@example.com>'); - $should = iconv('UTF-8', iconv_get_encoding('internal_encoding'), - '"Peter Müller" <peter-mueller@example.com>'); - $this->assertEquals($is, $should); - } - - public function testSplitHeader() - { - $header = 'foo; x=y; y="x"'; - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header), array('foo', 'x' => 'y', 'y' => 'x')); - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'x'), 'y'); - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'y'), 'x'); - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'foo', 'foo'), 'foo'); - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'foo'), null); - } - - public function testSplitInvalidHeader() - { - $header = ''; - try { - Zend_Mime_Decode::splitHeaderField($header); - } catch (Zend_Exception $e) { - return; // ok - } - - $this->fail('no exception raised while decoding invalid header field'); - } - - public function testSplitMessage() - { - $header = 'Test: test'; - $body = 'body'; - $newlines = array("\r\n", "\n\r", "\n", "\r"); - - foreach ($newlines as $contentEOL) { - foreach ($newlines as $decodeEOL) { - $content = $header . $contentEOL . $contentEOL . $body; - $decoded = Zend_Mime_Decode::splitMessage($content, $decoded_header, $decoded_body, $decodeEOL); - $this->assertEquals(array('test' => 'test'), $decoded_header); - $this->assertEquals($body, $decoded_body); - } - } - } - - public function testToplines() - { - $message = new Zend_Mail_Message(array('headers' => file_get_contents($this->_file))); - $this->assertTrue(strpos($message->getToplines(), 'multipart message') === 0); - } - - public function testNoContent() - { - $message = new Zend_Mail_Message(array('raw' => 'Subject: test')); - - try { - $message->getContent(); - } catch (Zend_Exception $e) { - return; // ok - } - - $this->fail('no exception raised while getting content of message without body'); - } - - public function testEmptyMessage() - { - $message = new Zend_Mail_Message(array()); - $this->assertEquals(array(), $message->getHeaders()); - - $message = new Zend_Mail_Message(array()); - $subject = null; - try { - $subject = $message->subject; - } catch (Zend_Exception $e) { - // ok - } - if ($subject) { - $this->fail('no exception raised while getting header from empty message'); - } - - $message = new Zend_Mail_Message(array()); - $part = null; - try { - $part = $message->getPart(1); - } catch (Zend_Exception $e) { - // ok - } - if ($part) { - $this->fail('no exception raised while getting part from empty message'); - } - - $message = new Zend_Mail_Message(array()); - $this->assertTrue($message->countParts() == 0); - } - - public function testWrongMultipart() - { - $message = new Zend_Mail_Message(array('raw' => "Content-Type: multipart/mixed\r\n\r\ncontent")); - - try { - $message->getPart(1); - } catch (Zend_Exception $e) { - return; // ok - } - $this->fail('no exception raised while getting part from message without boundary'); - } - - public function testLateFetch() - { - $mail = new Zend_Mail_Storage_Mbox(array('filename' => dirname(__FILE__) . '/_files/test.mbox/INBOX')); - - $message = new Zend_Mail_Message(array('handler' => $mail, 'id' => 5)); - $this->assertEquals($message->countParts(), 2); - $this->assertEquals($message->countParts(), 2); - - $message = new Zend_Mail_Message(array('handler' => $mail, 'id' => 5)); - $this->assertEquals($message->subject, 'multipart'); - - $message = new Zend_Mail_Message(array('handler' => $mail, 'id' => 5)); - $this->assertTrue(strpos($message->getContent(), 'multipart message') === 0); - } - - public function testManualIterator() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - - $this->assertTrue($message->valid()); - $this->assertEquals($message->getChildren(), $message->current()); - $this->assertEquals($message->key(), 1); - - $message->next(); - $this->assertTrue($message->valid()); - $this->assertEquals($message->getChildren(), $message->current()); - $this->assertEquals($message->key(), 2); - - $message->next(); - $this->assertFalse($message->valid()); - - $message->rewind(); - $this->assertTrue($message->valid()); - $this->assertEquals($message->getChildren(), $message->current()); - $this->assertEquals($message->key(), 1); - } - - public function testMessageFlagsAreSet() - { - $origFlags = array( - 'foo' => 'bar', - 'baz' => 'bat' - ); - $message = new Zend_Mail_Message(array('flags' => $origFlags)); - - $messageFlags = $message->getFlags(); - $this->assertTrue($message->hasFlag('bar'), var_export($messageFlags, 1)); - $this->assertTrue($message->hasFlag('bat'), var_export($messageFlags, 1)); - $this->assertEquals(array('bar' => 'bar', 'bat' => 'bat'), $messageFlags); - } - - public function testGetHeaderFieldSingle() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - $this->assertEquals($message->getHeaderField('subject'), 'multipart'); - } - - public function testGetHeaderFieldDefault() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - $this->assertEquals($message->getHeaderField('content-type'), 'multipart/alternative'); - } - - public function testGetHeaderFieldNamed() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - $this->assertEquals($message->getHeaderField('content-type', 'boundary'), 'crazy-multipart'); - } - - public function testGetHeaderFieldMissing() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - $this->assertNull($message->getHeaderField('content-type', 'foo')); - } - - public function testGetHeaderFieldInvalid() - { - $message = new Zend_Mail_Message(array('file' => $this->_file)); - try { - $message->getHeaderField('fake-header-name', 'foo'); - } catch (Zend_Mail_Exception $e) { - return; - } - $this->fail('No exception thrown while requesting invalid field name'); - } - - public function testCaseInsensitiveMultipart() - { - $message = new Zend_Mail_Message(array('raw' => "coNTent-TYpe: muLTIpaRT/x-empty\r\n\r\n")); - $this->assertTrue($message->isMultipart()); - } - - public function testCaseInsensitiveField() - { - $header = 'test; fOO="this is a test"'; - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'Foo'), 'this is a test'); - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'bar'), null); - } - - public function testSpaceInFieldName() - { - $header = 'test; foo =bar; baz =42'; - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'foo'), 'bar'); - $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'baz'), 42); - } -} diff --git a/tests/Zend/Mail/Pop3Test.php b/tests/Zend/Mail/Pop3Test.php deleted file mode 100644 index 0c07328fea0ef2cfacf58b3592d1f3c34f1c5968..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/Pop3Test.php +++ /dev/null @@ -1,419 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Storage_Pop3 - */ -require_once 'Zend/Mail/Storage/Pop3.php'; - -/** - * Zend_Mail_Protocol_Pop3 - */ -require_once 'Zend/Mail/Protocol/Pop3.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_Pop3Test extends PHPUnit_Framework_TestCase -{ - protected $_params; - - public function setUp() - { - $this->_params = array('host' => TESTS_ZEND_MAIL_POP3_HOST, - 'user' => TESTS_ZEND_MAIL_POP3_USER, - 'password' => TESTS_ZEND_MAIL_POP3_PASSWORD); - - if (defined('TESTS_ZEND_MAIL_SERVER_TESTDIR') && TESTS_ZEND_MAIL_SERVER_TESTDIR) { - if (!file_exists(TESTS_ZEND_MAIL_SERVER_TESTDIR . DIRECTORY_SEPARATOR . 'inbox') - && !file_exists(TESTS_ZEND_MAIL_SERVER_TESTDIR . DIRECTORY_SEPARATOR . 'INBOX')) { - $this->markTestSkipped('There is no file name "inbox" or "INBOX" in ' - . TESTS_ZEND_MAIL_SERVER_TESTDIR . '. I won\'t use it for testing. ' - . 'This is you safety net. If you think it is the right directory just ' - . 'create an empty file named INBOX or remove/deactived this message.'); - } - - $this->_cleanDir(TESTS_ZEND_MAIL_SERVER_TESTDIR); - $this->_copyDir(dirname(__FILE__) . '/_files/test.' . TESTS_ZEND_MAIL_SERVER_FORMAT, - TESTS_ZEND_MAIL_SERVER_TESTDIR); - } - } - - protected function _cleanDir($dir) - { - $dh = opendir($dir); - while (($entry = readdir($dh)) !== false) { - if ($entry == '.' || $entry == '..') { - continue; - } - $fullname = $dir . DIRECTORY_SEPARATOR . $entry; - if (is_dir($fullname)) { - $this->_cleanDir($fullname); - rmdir($fullname); - } else { - unlink($fullname); - } - } - closedir($dh); - } - - protected function _copyDir($dir, $dest) - { - $dh = opendir($dir); - while (($entry = readdir($dh)) !== false) { - if ($entry == '.' || $entry == '..' || $entry == '.svn') { - continue; - } - $fullname = $dir . DIRECTORY_SEPARATOR . $entry; - $destname = $dest . DIRECTORY_SEPARATOR . $entry; - if (is_dir($fullname)) { - mkdir($destname); - $this->_copyDir($fullname, $destname); - } else { - copy($fullname, $destname); - } - } - closedir($dh); - } - - public function testConnectOk() - { - try { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to pop3 server'); - } - } - - public function testConnectConfig() - { - try { - $mail = new Zend_Mail_Storage_Pop3(new Zend_Config($this->_params)); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to pop3 server'); - } - } - - - public function testConnectFailure() - { - $this->_params['host'] = 'example.example'; - try { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - } catch (Exception $e) { - return; // test ok - } - - // I can only hope noone installs a POP3 server there - $this->fail('no exception raised while connecting to example.example'); - } - - public function testNoParams() - { - try { - $mail = new Zend_Mail_Storage_Pop3(array()); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised with empty params'); - } - - public function testConnectSSL() - { - if (!TESTS_ZEND_MAIL_POP3_SSL) { - return; - } - - $this->_params['ssl'] = 'SSL'; - try { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to pop3 server with SSL'); - } - } - - public function testConnectTLS() - { - if (!TESTS_ZEND_MAIL_POP3_TLS) { - return; - } - - $this->_params['ssl'] = 'TLS'; - try { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - } catch (Exception $e) { - $this->fail('exception raised while loading connection to pop3 server with TLS'); - } - } - - public function testInvalidService() - { - $this->_params['port'] = TESTS_ZEND_MAIL_POP3_INVALID_PORT; - - try { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while connection to invalid port'); - } - - public function testWrongService() - { - $this->_params['port'] = TESTS_ZEND_MAIL_POP3_WRONG_PORT; - - try { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while connection to wrong port'); - } - - public function testClose() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - try { - $mail->close(); - } catch (Exception $e) { - $this->fail('exception raised while closing pop3 connection'); - } - } - - public function testHasTop() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $this->assertTrue($mail->hasTop); - } - - public function testHasCreate() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $this->assertFalse($mail->hasCreate); - } - - public function testNoop() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - try { - $mail->noop(); - } catch (Exception $e) { - $this->fail('exception raised while doing nothing (noop)'); - } - } - - public function testCount() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $count = $mail->countMessages(); - $this->assertEquals(6, $count); - } - - public function testSize() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - $shouldSizes = array(1 => 397, 89, 694, 452, 497, 101); - - - $sizes = $mail->getSize(); - $this->assertEquals($shouldSizes, $sizes); - } - - public function testSingleSize() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $size = $mail->getSize(2); - $this->assertEquals(89, $size); - } - - public function testFetchHeader() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - -/* - public function testFetchTopBody() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $content = $mail->getHeader(3, 1)->getContent(); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } -*/ - - public function testFetchMessageHeader() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $subject = $mail->getMessage(1)->subject; - $this->assertEquals('Simple Message', $subject); - } - - public function testFetchMessageBody() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $content = $mail->getMessage(3)->getContent(); - list($content, ) = explode("\n", $content, 2); - $this->assertEquals('Fair river! in thy bright, clear flow', trim($content)); - } - -/* - public function testFailedRemove() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - try { - $mail->removeMessage(1); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while deleting message (mbox is read-only)'); - } -*/ - - public function testWithInstanceConstruction() - { - $protocol = new Zend_Mail_Protocol_Pop3($this->_params['host']); - $mail = new Zend_Mail_Storage_Pop3($protocol); - try { - // because we did no login this has to throw an exception - $mail->getMessage(1); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while fetching with wrong transport'); - } - - public function testRequestAfterClose() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - $mail->close(); - try { - $mail->getMessage(1); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception raised while requesting after closing connection'); - } - - public function testServerCapa() - { - $mail = new Zend_Mail_Protocol_Pop3($this->_params['host']); - $this->assertTrue(is_array($mail->capa())); - } - - public function testServerUidl() - { - $mail = new Zend_Mail_Protocol_Pop3($this->_params['host']); - $mail->login($this->_params['user'], $this->_params['password']); - - $uids = $mail->uniqueid(); - $this->assertEquals(count($uids), 6); - - $this->assertEquals($uids[1], $mail->uniqueid(1)); - } - - public function testRawHeader() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $this->assertTrue(strpos($mail->getRawHeader(1), "\r\nSubject: Simple Message\r\n") > 0); - } - - public function testUniqueId() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - - $this->assertTrue($mail->hasUniqueId); - $this->assertEquals(1, $mail->getNumberByUniqueId($mail->getUniqueId(1))); - - $ids = $mail->getUniqueId(); - foreach ($ids as $num => $id) { - foreach ($ids as $inner_num => $inner_id) { - if ($num == $inner_num) { - continue; - } - if ($id == $inner_id) { - $this->fail('not all ids are unique'); - } - } - - if ($mail->getNumberByUniqueId($id) != $num) { - $this->fail('reverse lookup failed'); - } - } - } - - public function testWrongUniqueId() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - try { - $mail->getNumberByUniqueId('this_is_an_invalid_id'); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while getting number for invalid id'); - } - - public function testReadAfterClose() - { - $protocol = new Zend_Mail_Protocol_Pop3($this->_params['host']); - $protocol->logout(); - - try { - $protocol->readResponse(); - } catch (Exception $e) { - return; // test ok - } - - $this->fail('no exception while reading from closed socket'); - } - - public function testRemove() - { - $mail = new Zend_Mail_Storage_Pop3($this->_params); - $count = $mail->countMessages(); - - $mail->removeMessage(1); - $this->assertEquals($mail->countMessages(), --$count); - - unset($mail[2]); - $this->assertEquals($mail->countMessages(), --$count); - } -} diff --git a/tests/Zend/Mail/SmtpTest.php b/tests/Zend/Mail/SmtpTest.php deleted file mode 100644 index 55bb8c9e85ce556cdb5dc14fa5537fb6daac9763..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/SmtpTest.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ - - -/** - * Zend_Mail_Protocol_Smtp - */ -require_once 'Zend/Mail/Protocol/Smtp.php'; - - -/** - * Zend_Mail_Transport_Smtp - */ -require_once 'Zend/Mail/Transport/Smtp.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - */ -class Zend_Mail_SmtpTest extends PHPUnit_Framework_TestCase -{ - protected $_params; - protected $_transport; - protected $_connection; - - public function setUp() - { - $this->_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST, - 'port' => TESTS_ZEND_MAIL_SMTP_PORT, - 'username' => TESTS_ZEND_MAIL_SMTP_USER, - 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD, - 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH); - } - - public function testTransportSetup() - { - try { - $this->_transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params); - } catch (Exception $e) { - $this->fail('exception raised while creating smtp transport'); - } - - try { - $this->_connection = new Zend_Mail_Protocol_Smtp($this->_params['host'], $this->_params['port']); - $this->_transport->setConnection($this->_connection); - } catch (Exception $e) { - $this->fail('exception raised while setting smtp transport connection'); - } - - $this->_connection = $this->_transport->getConnection(); - if (!($this->_connection instanceof Zend_Mail_Protocol_Abstract)) { - $this->fail('smtp transport connection is not an instance of protocol abstract'); - } - } -} diff --git a/tests/Zend/Mail/_files/mail.txt b/tests/Zend/Mail/_files/mail.txt deleted file mode 100644 index 5bba233961544feba5b2615b89f4cf6b315d53b7..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/_files/mail.txt +++ /dev/null @@ -1,26 +0,0 @@ -To: foo@example.com -Subject: multipart -Date: Sun, 01 Jan 2000 00:00:00 +0000 -From: =?UTF-8?Q?"Peter M=C3=BCller"?= <peter-mueller@example.com> -ContENT-type: multipart/alternative; boUNDary="crazy-multipart" -MIME-version: 1.0 - -multipart message ---crazy-multipart -Content-type: text/plain - -The first part -is horizontal - ---crazy-multipart -Content-type: text/x-vertical - -T s p i v -h e a s e -e c r r - o t t - n i - d c - a - l ---crazy-multipart-- diff --git a/tests/Zend/Mail/_files/test.maildir/maildir.tar b/tests/Zend/Mail/_files/test.maildir/maildir.tar deleted file mode 100644 index a43a41d0df1cb0b06fcc1046b6bbad5566155f0d..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Mail/_files/test.maildir/maildir.tar and /dev/null differ diff --git a/tests/Zend/Mail/_files/test.mbox/INBOX b/tests/Zend/Mail/_files/test.mbox/INBOX deleted file mode 100644 index 357b0365fe204de85e8fcde35870c398fa1332d6..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/_files/test.mbox/INBOX +++ /dev/null @@ -1,105 +0,0 @@ -From next-message@example.com Mon Jan 00 00:00:00 0000 -Return-Path: <from@example.com> -Delivered-To: to@example.com -Received: by example.com - id 1; Sun, 30 Apr 2006 19:00:00 +0200 (CEST) -Received: by localhost - id 1; Sun, 30 Apr 2006 19:10:00 +0200 (CEST) -To: to@example.com -Subject: Simple Message -Message-Id: <20060430185000.1@example.com> -Date: Sun, 30 Apr 2006 18:50:00 +0200 (CEST) -From: from@example.com - -This is a simple test message -From next-message@example.com Mon Jan 00 00:00:00 0000 -To: bar@example.com -Subject: A Really Simple Message -From: foo@example.com - -Message - -From next-message@example.com Mon Jan 00 00:00:00 0000 -To: river@example.com -Subject: To the River -Date: Sun, 01 Jan 1829 00:00:00 +0000 -From: poe@example.com -Message-Id: <18290101000000.0000@example.com> -Content-type: text/plain -MIME-version: 1.0 -X-Twin: the good -X-Twin: the evil - -Fair river! in thy bright, clear flow -Of crystal, wandering water, -Thou art an emblem of the glow -Of beautythe unhidden heart -The playful maziness of art -In old Alberto's daughter; - -But when within thy wave she looks -Which glistens then, and trembles -Why, then, the prettiest of brooks -Her worshipper resembles; -For in his heart, as in thy stream, -Her image deeply lies -His heart which trembles at the beam -Of her soul-searching eyes. - -From next-message@example.com Mon Jan 00 00:00:00 0000 -To: foo@example.com -Subject: multipart -Date: Sun, 01 Jan 2000 00:00:00 +0000 -From: crazy@example.com -Content-type: multipart/alternative; boundary="crazy-multipart" -MIME-version: 1.0 - -multipart message ---crazy-multipart -Content-type: text/plain - -The first part -is horizontal - ---crazy-multipart -Content-type: text/x-vertical - -T s p i v -h e a s e -e c r r - o t t - n i - d c - a - l ---crazy-multipart-- - -From next-message@example.com Mon Jan 00 00:00:00 0000 -To: foo@example.com -Subject: multipart -Date: Sun, 01 Jan 2000 01:00:00 +0000 -From: normal@example.com -Content-type: multipart/alternative; boundary="normal-multipart" -MIME-version: 1.0 - -multipart message ---normal-multipart -Content-type: text/html - -<html> -<head><style> -body{background:#008;color:white} -em{color:#f88} -</style></head> -<body>Again a <em>simple</em> message</body> -</html> ---normal-multipart -Content-type: text/plain - -Again a simple message ---normal-multipart-- -From next-message@example.com Mon Jan 00 00:00:00 0000 -To: foo@example.com -Subject: no body -Date: Sun, 01 Jan 2000 01:00:00 +0000 -From: short@example.com diff --git a/tests/Zend/Mail/_files/test.mbox/subfolder/test b/tests/Zend/Mail/_files/test.mbox/subfolder/test deleted file mode 100644 index c59490e452161bf8472d4a8951fc479ffd36c8a1..0000000000000000000000000000000000000000 --- a/tests/Zend/Mail/_files/test.mbox/subfolder/test +++ /dev/null @@ -1,14 +0,0 @@ -From next-message@example.com Mon Jan 00 00:00:00 0000 -Return-Path: <from@example.com> -Delivered-To: to@example.com -Received: by example.com - id 1; Sun, 30 May 2006 19:00:00 +0200 (CEST) -Received: by localhost - id 1; Sun, 30 May 2006 19:10:00 +0200 (CEST) -To: to@example.com -Subject: Message in subfolder -Message-Id: <20060530185000.1@example.com> -Date: Sun, 30 May 2006 18:50:00 +0200 (CEST) -From: from@example.com - -This is the message in the subfolder \ No newline at end of file diff --git a/tests/Zend/MailTest.php b/tests/Zend/MailTest.php deleted file mode 100644 index 430a775c225d2d405a814dd8c54d34afca73971d..0000000000000000000000000000000000000000 --- a/tests/Zend/MailTest.php +++ /dev/null @@ -1,652 +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_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * Zend_Mail - */ -require_once 'Zend/Mail.php'; - -/** - * Zend_Mail_Transport_Abstract - */ -require_once 'Zend/Mail/Transport/Abstract.php'; - -/** - * Zend_Mail_Transport_Sendmail - */ -require_once 'Zend/Mail/Transport/Sendmail.php'; - -/** - * Zend_Mail_Transport_Smtp - */ -require_once 'Zend/Mail/Transport/Smtp.php'; - -/** - * Zend_Date - */ -require_once 'Zend/Date.php'; - -/** - * Mock mail transport class for testing purposes - * - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Mail_Transport_Mock extends Zend_Mail_Transport_Abstract -{ - /** - * @var Zend_Mail - */ - public $mail = null; - public $returnPath = null; - public $subject = null; - public $from = null; - public $headers = null; - public $called = false; - - public function _sendMail() - { - $this->mail = $this->_mail; - $this->subject = $this->_mail->getSubject(); - $this->from = $this->_mail->getFrom(); - $this->returnPath = $this->_mail->getReturnPath(); - $this->headers = $this->_headers; - $this->called = true; - } -} - -/** - * Mock mail transport class for testing Sendmail transport - * - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Mail_Transport_Sendmail_Mock extends Zend_Mail_Transport_Sendmail -{ - /** - * @var Zend_Mail - */ - public $mail = null; - public $from = null; - public $subject = null; - public $called = false; - - public function _sendMail() - { - $this->mail = $this->_mail; - $this->from = $this->_mail->getFrom(); - $this->subject = $this->_mail->getSubject(); - $this->called = true; - } -} - - -/** - * @category Zend - * @package Zend_Mail - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_MailTest extends PHPUnit_Framework_TestCase -{ - - /** - * Test case for a simple email text message with - * multiple recipients. - * - */ - public function testOnlyText() - { - $mail = new Zend_Mail(); - $res = $mail->setBodyText('This is a test.'); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('My Subject'); - $mail->addTo('recipient1@example.com'); - $mail->addTo('recipient2@example.com'); - $mail->addBcc('recipient1_bcc@example.com'); - $mail->addBcc('recipient2_bcc@example.com'); - $mail->addCc('recipient1_cc@example.com', 'Example no. 1 for cc'); - $mail->addCc('recipient2_cc@example.com', 'Example no. 2 for cc'); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertEquals('My Subject', $mock->subject); - $this->assertEquals('testmail@example.com', $mock->from); - $this->assertContains('recipient1@example.com', $mock->recipients); - $this->assertContains('recipient2@example.com', $mock->recipients); - $this->assertContains('recipient1_bcc@example.com', $mock->recipients); - $this->assertContains('recipient2_bcc@example.com', $mock->recipients); - $this->assertContains('recipient1_cc@example.com', $mock->recipients); - $this->assertContains('recipient2_cc@example.com', $mock->recipients); - $this->assertContains('This is a test.', $mock->body); - $this->assertContains('Content-Transfer-Encoding: quoted-printable', $mock->header); - $this->assertContains('Content-Type: text/plain', $mock->header); - $this->assertContains('From: "test Mail User" <testmail@example.com>', $mock->header); - $this->assertContains('Subject: My Subject', $mock->header); - $this->assertContains('To: <recipient1@example.com>', $mock->header); - $this->assertContains('Cc: "Example no. 1 for cc" <recipient1_cc@example.com>', $mock->header); - } - - /** - * Check if Header Fields are encoded correctly and if - * header injection is prevented. - */ - public function testHeaderEncoding() - { - $mail = new Zend_Mail(); - $mail->setBodyText('My Nice Test Text'); - // try header injection: - $mail->addTo("testmail@example.com\nCc:foobar@example.com"); - $mail->addHeader('X-MyTest', "Test\nCc:foobar2@example.com", true); - // try special Chars in Header Fields: - $mail->setFrom('mymail@example.com', 'äüößÄÖÜ'); - $mail->addTo('testmail2@example.com', 'äüößÄÖÜ'); - $mail->addCc('testmail3@example.com', 'äüößÄÖÜ'); - $mail->setSubject('äüößÄÖÜ'); - $mail->addHeader('X-MyTest', 'Test-äüößÄÖÜ', true); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertContains('From: =?iso-8859-1?Q?"=E4=FC=F6=DF=C4=D6=DC"?=', $mock->header); - $this->assertNotContains("\nCc:foobar@example.com", $mock->header); - $this->assertContains('=?iso-8859-1?Q?=E4=FC=F6=DF=C4=D6=DC?=" <testmail2@example.com>', $mock->header); - $this->assertContains('Cc: "=?iso-8859-1?Q?=E4=FC=F6=DF=C4=D6=DC?=" <testmail3@example.com>', $mock->header); - $this->assertContains('Subject: =?iso-8859-1?Q?=E4=FC=F6=DF=C4=D6=DC?=', $mock->header); - $this->assertContains('X-MyTest:', $mock->header); - $this->assertNotContains("\nCc:foobar2@example.com", $mock->header); - $this->assertContains('=?iso-8859-1?Q?Test-=E4=FC=F6=DF=C4=D6=DC?=', $mock->header); - } - - /** - * Check if Header Fields are stripped accordingly in sendmail transport; - * also check for header injection - * @todo Determine why this fails in Windows (testmail3@example.com example) - */ - public function testHeaderEncoding2() - { - throw new PHPUnit_Framework_IncompleteTestError('still working on cross-platform tests'); - $mail = new Zend_Mail(); - $mail->setBodyText('My Nice Test Text'); - // try header injection: - $mail->addTo("testmail@example.com\nCc:foobar@example.com"); - $mail->addHeader('X-MyTest', "Test\nCc:foobar2@example.com", true); - // try special Chars in Header Fields: - $mail->setFrom('mymail@example.com', 'äüößÄÖÜ'); - $mail->addTo('testmail2@example.com', 'äüößÄÖÜ'); - $mail->addCc('testmail3@example.com', 'äüößÄÖÜ'); - $mail->setSubject('äüößÄÖÜ'); - $mail->addHeader('X-MyTest', 'Test-äüößÄÖÜ', true); - - $mock = new Zend_Mail_Transport_Sendmail_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertContains('From: =?iso-8859-1?Q?"=E4=FC=F6=DF=C4=D6=DC"?=', $mock->header); - $this->assertNotContains("\nCc:foobar@example.com", $mock->header); - $this->assertContains('Cc: "=?iso-8859-1?Q?=E4=FC=F6=DF=C4=D6=DC?=" <testmail3@example.com>', $mock->header); - $this->assertContains('X-MyTest:', $mock->header); - $this->assertNotContains("\nCc:foobar2@example.com", $mock->header); - $this->assertContains('=?iso-8859-1?Q?Test-=E4=FC=F6=DF=C4=D6=DC?=', $mock->header); - - $this->assertNotContains('Subject: ', $mock->header); - $this->assertContains('=?iso-8859-1?Q?=E4=FC=F6=DF=C4=D6=DC?=', $mock->subject); - $this->assertContains('"=?iso-8859-1?Q?=E4=FC=F6=DF=C4=D6=DC?=" <testmail2@example.com>', $mock->recipients, $mock->recipients); - } - - /** - * Check if Mails with HTML and Text Body are generated correctly. - * - */ - public function testMultipartAlternative() - { - $mail = new Zend_Mail(); - $mail->setBodyText('My Nice Test Text'); - $mail->setBodyHtml('My Nice <b>Test</b> Text'); - $mail->addTo('testmail@example.com', 'Test Recipient'); - $mail->setFrom('mymail@example.com', 'Test Sender'); - $mail->setSubject('Test: Alternate Mail with Zend_Mail'); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - // check headers - $this->assertTrue($mock->called); - $this->assertContains('multipart/alternative', $mock->header); - $boundary = $mock->boundary; - $this->assertContains('boundary="' . $boundary . '"', $mock->header); - $this->assertContains('MIME-Version: 1.0', $mock->header); - - // check body - // search for first boundary - $p1 = strpos($mock->body, "--$boundary\n"); - $this->assertNotNull($p1, $boundary . ': ' . $mock->body); - - // cut out first (Text) part - $start1 = $p1 + 3 + strlen($boundary); - $p2 = strpos($mock->body, "--$boundary\n", $start1); - $this->assertNotNull($p2); - - $partBody1 = substr($mock->body, $start1, ($p2 - $start1)); - $this->assertContains('Content-Type: text/plain', $partBody1); - $this->assertContains('My Nice Test Text', $partBody1); - - // check second (HTML) part - // search for end boundary - $start2 = $p2 + 3 + strlen($boundary); - $p3 = strpos($mock->body, "--$boundary--"); - $this->assertNotNull($p3); - - $partBody2 = substr($mock->body, $start2, ($p3 - $start2)); - $this->assertContains('Content-Type: text/html', $partBody2); - $this->assertContains('My Nice <b>Test</b> Text', $partBody2); - } - - /** - * check if attachment handling works - * - */ - public function testAttachment() - { - $mail = new Zend_Mail(); - $mail->setBodyText('My Nice Test Text'); - $mail->addTo('testmail@example.com', 'Test Recipient'); - $mail->setFrom('mymail@example.com', 'Test Sender'); - $mail->setSubject('Test: Attachment Test with Zend_Mail'); - $at = $mail->createAttachment('abcdefghijklmnopqrstuvexyz'); - $at->type = 'image/gif'; - $at->id = 12; - $at->filename = 'test.gif'; - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - // now check what was generated by Zend_Mail. - // first the mail headers: - $this->assertContains('Content-Type: multipart/mixed', $mock->header, $mock->header); - $boundary = $mock->boundary; - $this->assertContains('boundary="' . $boundary . '"', $mock->header); - $this->assertContains('MIME-Version: 1.0', $mock->header); - - // check body - // search for first boundary - $p1 = strpos($mock->body, "--$boundary\n"); - $this->assertNotNull($p1); - - // cut out first (Text) part - $start1 = $p1 + 3 + strlen($boundary); - $p2 = strpos($mock->body, "--$boundary\n", $start1); - $this->assertNotNull($p2); - - $partBody1 = substr($mock->body, $start1, ($p2 - $start1)); - $this->assertContains('Content-Type: text/plain', $partBody1); - $this->assertContains('My Nice Test Text', $partBody1); - - // check second (HTML) part - // search for end boundary - $start2 = $p2 + 3 + strlen($boundary); - $p3 = strpos($mock->body, "--$boundary--"); - $this->assertNotNull($p3); - - $partBody2 = substr($mock->body, $start2, ($p3 - $start2)); - $this->assertContains('Content-Type: image/gif', $partBody2); - $this->assertContains('Content-Transfer-Encoding: base64', $partBody2); - $this->assertContains('Content-ID: <12>', $partBody2); - } - - /** - * Check if Mails with HTML and Text Body are generated correctly. - * - */ - public function testMultipartAlternativePlusAttachment() - { - $mail = new Zend_Mail(); - $mail->setBodyText('My Nice Test Text'); - $mail->setBodyHtml('My Nice <b>Test</b> Text'); - $mail->addTo('testmail@example.com', 'Test Recipient'); - $mail->setFrom('mymail@example.com', 'Test Sender'); - $mail->setSubject('Test: Alternate Mail with Zend_Mail'); - - $at = $mail->createAttachment('abcdefghijklmnopqrstuvexyz'); - $at->type = 'image/gif'; - $at->id = 12; - $at->filename = 'test.gif'; - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - // check headers - $this->assertTrue($mock->called); - $this->assertContains('multipart/mixed', $mock->header); - $boundary = $mock->boundary; - $this->assertContains('boundary="' . $boundary . '"', $mock->header); - $this->assertContains('MIME-Version: 1.0', $mock->header); - - // check body - // search for first boundary - $p1 = strpos($mock->body, "--$boundary\n"); - $this->assertNotNull($p1); - - // cut out first (multipart/alternative) part - $start1 = $p1 + 3 + strlen($boundary); - $p2 = strpos($mock->body, "--$boundary\n", $start1); - $this->assertNotNull($p2); - - $partBody1 = substr($mock->body, $start1, ($p2 - $start1)); - $this->assertContains('Content-Type: multipart/alternative', $partBody1); - $this->assertContains('Content-Type: text/plain', $partBody1); - $this->assertContains('Content-Type: text/html', $partBody1); - $this->assertContains('My Nice Test Text', $partBody1); - $this->assertContains('My Nice <b>Test</b> Text', $partBody1); - - // check second (image) part - // search for end boundary - $start2 = $p2 + 3 + strlen($boundary); - $p3 = strpos($mock->body, "--$boundary--"); - $this->assertNotNull($p3); - - $partBody2 = substr($mock->body, $start2, ($p3 - $start2)); - $this->assertContains('Content-Type: image/gif', $partBody2); - $this->assertContains('Content-Transfer-Encoding: base64', $partBody2); - $this->assertContains('Content-ID: <12>', $partBody2); - } - - public function testReturnPath() - { - $mail = new Zend_Mail(); - $res = $mail->setBodyText('This is a test.'); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('My Subject'); - $mail->addTo('recipient1@example.com'); - $mail->addTo('recipient2@example.com'); - $mail->addBcc('recipient1_bcc@example.com'); - $mail->addBcc('recipient2_bcc@example.com'); - $mail->addCc('recipient1_cc@example.com', 'Example no. 1 for cc'); - $mail->addCc('recipient2_cc@example.com', 'Example no. 2 for cc'); - - // First example: from and return-path should be equal - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - $this->assertTrue($mock->called); - $this->assertEquals($mail->getFrom(), $mock->returnPath); - - // Second example: from and return-path should not be equal - $mail->setReturnPath('sender2@example.com'); - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - $this->assertTrue($mock->called); - $this->assertNotEquals($mail->getFrom(), $mock->returnPath); - $this->assertEquals($mail->getReturnPath(), $mock->returnPath); - $this->assertNotEquals($mock->returnPath, $mock->from); - } - - public function testNoBody() - { - $mail = new Zend_Mail(); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('My Subject'); - $mail->addTo('recipient1@example.com'); - - // First example: from and return-path should be equal - $mock = new Zend_Mail_Transport_Mock(); - try { - $mail->send($mock); - $this->assertTrue($mock->called); - } catch (Exception $e) { - // success - $this->assertContains('No body specified', $e->getMessage()); - } - } - - /** - * Helper method for {@link testZf928ToAndBccHeadersShouldNotMix()}; extracts individual header lines - * - * @param Zend_Mail_Transport_Abstract $mock - * @param string $type - * @return string - */ - protected function _getHeader(Zend_Mail_Transport_Abstract $mock, $type = 'To') - { - $headers = str_replace("\r\n", "\n", $mock->header); - $headers = explode("\n", $mock->header); - $return = ''; - foreach ($headers as $header) { - if (!empty($return)) { - // Check for header continuation - if (!preg_match('/^[a-z-]+:/i', $header)) { - $return .= "\r\n" . $header; - continue; - } else { - break; - } - } - if (preg_match('/^' . $type . ': /', $header)) { - $return = $header; - } - } - - return $return; - } - - public function testZf928ToAndBccHeadersShouldNotMix() - { - $mail = new Zend_Mail(); - $mail->setSubject('my subject'); - $mail->setBodyText('my body'); - $mail->setFrom('info@onlime.ch'); - $mail->addTo('to.address@email.com'); - $mail->addBcc('first.bcc@email.com'); - $mail->addBcc('second.bcc@email.com'); - - // test with generic transport - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - $to = $this->_getHeader($mock); - $bcc = $this->_getHeader($mock, 'Bcc'); - $this->assertContains('to.address@email.com', $to, $to); - $this->assertNotContains('second.bcc@email.com', $to, $bcc); - - // test with sendmail-like transport - $mock = new Zend_Mail_Transport_Sendmail_Mock(); - $mail->send($mock); - $to = $this->_getHeader($mock); - $bcc = $this->_getHeader($mock, 'Bcc'); - // Remove the following line due to fixes by Simon - // $this->assertNotContains('to.address@email.com', $to, $mock->header); - $this->assertNotContains('second.bcc@email.com', $to, $bcc); - } - - public function testZf927BlankLinesShouldPersist() - { - $mail = new Zend_Mail(); - $mail->setSubject('my subject'); - $mail->setBodyText("my body\r\n\r\n...after two newlines"); - $mail->setFrom('test@email.com'); - $mail->addTo('test@email.com'); - - // test with generic transport - $mock = new Zend_Mail_Transport_Sendmail_Mock(); - $mail->send($mock); - $body = quoted_printable_decode($mock->body); - $this->assertContains("\r\n\r\n...after", $body, $body); - } - - public function testGetJustBodyText() - { - $text = "my body\r\n\r\n...after two newlines"; - $mail = new Zend_Mail(); - $mail->setBodyText($text); - - $this->assertContains('my body', $mail->getBodyText(true)); - $this->assertContains('after two newlines', $mail->getBodyText(true)); - } - - public function testGetJustBodyHtml() - { - $text = "<html><head></head><body><p>Some body text</p></body></html>"; - $mail = new Zend_Mail(); - $mail->setBodyHtml($text); - - $this->assertContains('Some body text', $mail->getBodyHtml(true)); - } - - public function testTypeAccessor() - { - $mail = new Zend_Mail(); - $this->assertNull($mail->getType()); - - $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE); - $this->assertEquals(Zend_Mime::MULTIPART_ALTERNATIVE, $mail->getType()); - - $mail->setType(Zend_Mime::MULTIPART_RELATED); - $this->assertEquals(Zend_Mime::MULTIPART_RELATED, $mail->getType()); - - try { - $mail->setType('text/plain'); - $this->fail('Invalid Zend_Mime type should throw an exception'); - } catch (Exception $e) { - } - } - - public function testDateSet() - { - $mail = new Zend_Mail(); - $res = $mail->setBodyText('Date Test'); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('Date Test'); - $mail->addTo('recipient@example.com'); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertTrue(isset($mock->headers['Date'])); - $this->assertTrue(isset($mock->headers['Date'][0])); - $this->assertTrue(strlen($mock->headers['Date'][0]) > 0); - } - - public function testSetDateInt() - { - $mail = new Zend_Mail(); - $res = $mail->setBodyText('Date Test'); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('Date Test'); - $mail->addTo('recipient@example.com'); - $mail->setDate(362656800); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertTrue(strpos(implode('', $mock->headers['Date']), 'Mon, 29 Jun 1981') === 0); - } - - public function testSetDateString() - { - $mail = new Zend_Mail(); - $res = $mail->setBodyText('Date Test'); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('Date Test'); - $mail->addTo('recipient@example.com'); - $mail->setDate('1981-06-29T12:00:00'); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertTrue(strpos(implode('', $mock->headers['Date']), 'Mon, 29 Jun 1981') === 0); - } - - public function testSetDateObject() - { - $mail = new Zend_Mail(); - $res = $mail->setBodyText('Date Test'); - $mail->setFrom('testmail@example.com', 'test Mail User'); - $mail->setSubject('Date Test'); - $mail->addTo('recipient@example.com'); - $mail->setDate(new Zend_Date('1981-06-29T12:00:00', Zend_Date::ISO_8601)); - - $mock = new Zend_Mail_Transport_Mock(); - $mail->send($mock); - - $this->assertTrue($mock->called); - $this->assertTrue(strpos(implode('', $mock->headers['Date']), 'Mon, 29 Jun 1981') === 0); - } - - public function testSetDateInvalidString() - { - $mail = new Zend_Mail(); - - try { - $mail->setDate('invalid date'); - $this->fail('Invalid date should throw an exception'); - } catch (Exception $e) { - } - } - - public function testSetDateInvalidType() - { - $mail = new Zend_Mail(); - - try { - $mail->setDate(true); - $this->fail('Invalid date should throw an exception'); - } catch (Exception $e) { - } - } - - public function testSetDateInvalidObject() - { - $mail = new Zend_Mail(); - - try { - $mail->setDate($mail); - $this->fail('Invalid date should throw an exception'); - } catch (Exception $e) { - } - } - - public function testSetDateTwice() - { - $mail = new Zend_Mail(); - - $mail->setDate(); - try { - $mail->setDate(123456789); - $this->fail('setting date twice should throw an exception'); - } catch (Exception $e) { - } - } -} diff --git a/tests/Zend/Measure/AccelerationTest.php b/tests/Zend/Measure/AccelerationTest.php deleted file mode 100644 index b121d62a674bf1fa1ec0fbb506e36151c6628dc7..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/AccelerationTest.php +++ /dev/null @@ -1,275 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AccelerationTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - -/** - * Zend_Measure_Acceleration - */ -require_once 'Zend/Measure/Acceleration.php'; -require_once 'Zend/Locale.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_AccelerationTest extends PHPUnit_Framework_TestCase -{ - - /** - * test for new object - * expected instance - */ - public function testAccelerationInit() - { - $value = new Zend_Measure_Acceleration('100',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Acceleration,'Zend_Measure_Acceleration Object not returned'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); - // no type - $value = new Zend_Measure_Acceleration('100','de'); - $this->assertTrue($value instanceof Zend_Measure_Acceleration,'Zend_Measure_Acceleration Object not returned'); - // unknown type - try { - $value = new Zend_Measure_Acceleration('100','Acceleration::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - // no value - try { - $value = new Zend_Measure_Acceleration('novalue',Zend_Measure_Acceleration::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - // false locale - try { - $value = new Zend_Measure_Acceleration('100',Zend_Measure_Acceleration::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - // no locale - $value = new Zend_Measure_Acceleration('100',Zend_Measure_Acceleration::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Acceleration value expected'); - - // negative value - $locale = new Zend_Locale('de'); - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,$locale); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a negative integer'); - // seperated value - $value = new Zend_Measure_Acceleration('-100,200',Zend_Measure_Acceleration::STANDARD,$locale); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a decimal value'); - // negative seperated value - $value = new Zend_Measure_Acceleration('-100.100,200',Zend_Measure_Acceleration::STANDARD,$locale); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Acceleration Object not returned'); - // value with string - $value = new Zend_Measure_Acceleration('string -100.100,200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Acceleration Object not returned'); - } - - - /** - * test for equals() - * expected true - */ - public function testAccelerationEquals() - { - $value = new Zend_Measure_Acceleration('string -100.100,200',Zend_Measure_Acceleration::STANDARD,'de'); - $newvalue = new Zend_Measure_Acceleration('otherstring -100.100,200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Acceleration Object should be equal'); - - $value = new Zend_Measure_Acceleration('string -100.100,200',Zend_Measure_Acceleration::STANDARD,'de'); - $newvalue = new Zend_Measure_Acceleration('otherstring -100,200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Acceleration Object should be not equal'); - } - - - /** - * test for setvalue() - * expected integer - */ - public function testAccelerationSetValue() - { - $value = new Zend_Measure_Acceleration('100',Zend_Measure_Acceleration::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); - - $locale = new Zend_Locale('de_AT'); - $value->setValue('200',$locale); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); - $value->setValue('200','de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); - $value->setValue('-200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a negative integer'); - $value->setValue('-200,200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a decimal value'); - $value->setValue('-200.200,200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Acceleration Object not returned'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Acceleration Object not returned'); - $value->setValue('200', Zend_Measure_Acceleration::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Acceleration value expected to be a positive integer'); - - try { - $value->setValue('otherstring -200.200,200','Acceleration::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - - try { - $value->setValue('novalue',Zend_Measure_Acceleration::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - - try { - $value = new Zend_Measure_Acceleration('100',Zend_Measure_Acceleration::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Acceleration::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test setting type - * expected new type - */ - public function testAccelerationSetType() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $value->setType(Zend_Measure_Acceleration::GRAV); - $this->assertEquals(Zend_Measure_Acceleration::GRAV, $value->getType(), 'Zend_Measure_Acceleration type expected'); - - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::MILE_PER_HOUR_MINUTE,'de'); - $value->setType(Zend_Measure_Acceleration::GRAV); - $this->assertEquals(Zend_Measure_Acceleration::GRAV, $value->getType(), 'Zend_Measure_Acceleration type expected'); - - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::GRAV,'de'); - $value->setType(Zend_Measure_Acceleration::MILE_PER_HOUR_MINUTE); - $this->assertEquals(Zend_Measure_Acceleration::MILE_PER_HOUR_MINUTE, $value->getType(), 'Zend_Measure_Acceleration type expected'); - - try { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $value->setType('Acceleration::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testAccelerationToString() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals('-100 m/s²', $value->toString(), 'Value -100 m/s² expected'); - } - - - /** - * test __toString - * expected string - */ - public function testAcceleration_ToString() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals('-100 m/s²', $value->__toString(), 'Value -100 m/s² expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testAccelerationConversionList() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } - - - /** - * test convertTo - * expected array - */ - public function testAccelerationConvertTo() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $unit = $value->convertTo(Zend_Measure_Acceleration::GRAV); - $this->assertEquals(Zend_Measure_Acceleration::GRAV, $value->getType(), 'Zend_Measure_Acceleration type expected'); - } - - - /** - * test add - * expected array - */ - public function testAccelerationAdd() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $value2 = new Zend_Measure_Acceleration('200',Zend_Measure_Acceleration::STANDARD,'de'); - $value->add($value2); - $this->assertEquals(100, $value->getValue(), 'value 100 expected'); - } - - - /** - * test add - * expected array - */ - public function testAccelerationSub() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $value2 = new Zend_Measure_Acceleration('200',Zend_Measure_Acceleration::STANDARD,'de'); - $value->sub($value2); - $this->assertEquals(-300, $value->getValue(), 'value -300 expected'); - } - - - /** - * test add - * expected array - */ - public function testAccelerationCompare() - { - $value = new Zend_Measure_Acceleration('-100',Zend_Measure_Acceleration::STANDARD,'de'); - $value2 = new Zend_Measure_Acceleration('200',Zend_Measure_Acceleration::STANDARD,'de'); - $value3 = new Zend_Measure_Acceleration('200',Zend_Measure_Acceleration::STANDARD,'de'); - $this->assertEquals(-1, $value->compare( $value2)); - $this->assertEquals( 1, $value2->compare($value )); - $this->assertEquals( 0, $value2->compare($value3)); - } -} diff --git a/tests/Zend/Measure/AllTests.php b/tests/Zend/Measure/AllTests.php deleted file mode 100644 index 76902297ee6b6846adc7f4790d081b4e0c8cefc0..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/AllTests.php +++ /dev/null @@ -1,117 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 9848 2008-06-30 21:41:35Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Measure_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -error_reporting( E_ALL | E_STRICT ); // now required for each test suite -// define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', false); // uncomment to disable use of bcmath extension by Zend_Date - -require_once 'Zend/Measure/Cooking/VolumeTest.php'; -require_once 'Zend/Measure/Cooking/WeightTest.php'; - -require_once 'Zend/Measure/Flow/MassTest.php'; -require_once 'Zend/Measure/Flow/MoleTest.php'; -require_once 'Zend/Measure/Flow/VolumeTest.php'; - -require_once 'Zend/Measure/Viscosity/DynamicTest.php'; -require_once 'Zend/Measure/Viscosity/KinematicTest.php'; -require_once 'Zend/Measure/AccelerationTest.php'; -require_once 'Zend/Measure/AngleTest.php'; -require_once 'Zend/Measure/AreaTest.php'; -require_once 'Zend/Measure/BinaryTest.php'; -require_once 'Zend/Measure/CapacitanceTest.php'; -require_once 'Zend/Measure/CurrentTest.php'; -require_once 'Zend/Measure/DensityTest.php'; -require_once 'Zend/Measure/EnergyTest.php'; -require_once 'Zend/Measure/ForceTest.php'; -require_once 'Zend/Measure/FrequencyTest.php'; -require_once 'Zend/Measure/IlluminationTest.php'; -require_once 'Zend/Measure/LengthTest.php'; -require_once 'Zend/Measure/LightnessTest.php'; -require_once 'Zend/Measure/NumberTest.php'; -require_once 'Zend/Measure/PowerTest.php'; -require_once 'Zend/Measure/PressureTest.php'; -require_once 'Zend/Measure/SpeedTest.php'; -require_once 'Zend/Measure/TemperatureTest.php'; -require_once 'Zend/Measure/TimeTest.php'; -require_once 'Zend/Measure/TorqueTest.php'; -require_once 'Zend/Measure/VolumeTest.php'; -require_once 'Zend/Measure/WeightTest.php'; - -// echo "BCMATH is ", Zend_Locale_Math::isBcmathDisabled() ? 'disabled':'not disabled', "\n"; - -class Zend_Measure_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Measure'); - - $suite->addTestSuite('Zend_Measure_Cooking_VolumeTest'); - $suite->addTestSuite('Zend_Measure_Cooking_WeightTest'); - - $suite->addTestSuite('Zend_Measure_Flow_MassTest'); - $suite->addTestSuite('Zend_Measure_Flow_MoleTest'); - $suite->addTestSuite('Zend_Measure_Flow_VolumeTest'); - - $suite->addTestSuite('Zend_Measure_Viscosity_DynamicTest'); - $suite->addTestSuite('Zend_Measure_Viscosity_KinematicTest'); - - $suite->addTestSuite('Zend_Measure_AccelerationTest'); - $suite->addTestSuite('Zend_Measure_AngleTest'); - $suite->addTestSuite('Zend_Measure_AreaTest'); - $suite->addTestSuite('Zend_Measure_BinaryTest'); - $suite->addTestSuite('Zend_Measure_CapacitanceTest'); - $suite->addTestSuite('Zend_Measure_CurrentTest'); - $suite->addTestSuite('Zend_Measure_DensityTest'); - $suite->addTestSuite('Zend_Measure_EnergyTest'); - $suite->addTestSuite('Zend_Measure_ForceTest'); - $suite->addTestSuite('Zend_Measure_FrequencyTest'); - $suite->addTestSuite('Zend_Measure_IlluminationTest'); - $suite->addTestSuite('Zend_Measure_LengthTest'); - $suite->addTestSuite('Zend_Measure_LightnessTest'); - $suite->addTestSuite('Zend_Measure_NumberTest'); - $suite->addTestSuite('Zend_Measure_PowerTest'); - $suite->addTestSuite('Zend_Measure_PressureTest'); - $suite->addTestSuite('Zend_Measure_SpeedTest'); - $suite->addTestSuite('Zend_Measure_TemperatureTest'); - $suite->addTestSuite('Zend_Measure_TimeTest'); - $suite->addTestSuite('Zend_Measure_TorqueTest'); - $suite->addTestSuite('Zend_Measure_VolumeTest'); - $suite->addTestSuite('Zend_Measure_WeightTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Measure_AllTests::main') { - Zend_Measure_AllTests::main(); -} diff --git a/tests/Zend/Measure/AngleTest.php b/tests/Zend/Measure/AngleTest.php deleted file mode 100644 index 3ad4857f1f56a75ab6d8f297df950f737f54cba6..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/AngleTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AngleTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Angle - */ -require_once 'Zend/Measure/Angle.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_AngleTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Angle initialisation - * expected instance - */ - public function testAngleInit() - { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Angle,'Zend_Measure_Angle Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testAngleUnknownType() - { - try { - $value = new Zend_Measure_Angle('100','Angle::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testAngleUnknownValue() - { - try { - $value = new Zend_Measure_Angle('novalue',Zend_Measure_Angle::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testAngleUnknownLocale() - { - try { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testAngleNoLocale() - { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Angle value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testAngleValuePositive() - { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Angle value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testAngleValueNegative() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Angle value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testAngleValueDecimal() - { - $value = new Zend_Measure_Angle('-100,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Angle value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testAngleValueDecimalSeperated() - { - $value = new Zend_Measure_Angle('-100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Angle Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testAngleValueString() - { - $value = new Zend_Measure_Angle('string -100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Angle Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testAngleEquality() - { - $value = new Zend_Measure_Angle('string -100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $newvalue = new Zend_Measure_Angle('otherstring -100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Angle Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testAngleNoEquality() - { - $value = new Zend_Measure_Angle('string -100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $newvalue = new Zend_Measure_Angle('otherstring -100,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Angle Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testAngleSetPositive() - { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Angle value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testAngleSetNegative() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Angle value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testAngleSetDecimal() - { - $value = new Zend_Measure_Angle('-100,200',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Angle value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testAngleSetDecimalSeperated() - { - $value = new Zend_Measure_Angle('-100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Angle Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testAngleSetString() - { - $value = new Zend_Measure_Angle('string -100.100,200',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Angle Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testAngleSetUnknownType() - { - try { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Angle::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testAngleSetUnknownValue() - { - try { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Angle::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testAngleSetUnknownLocale() - { - try { - $value = new Zend_Measure_Angle('100',Zend_Measure_Angle::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Angle::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testAngleSetWithNoLocale() - { - $value = new Zend_Measure_Angle('100', Zend_Measure_Angle::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Angle::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Angle value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testAngleSetType() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $value->setType(Zend_Measure_Angle::GRAD); - $this->assertEquals(Zend_Measure_Angle::GRAD, $value->getType(), 'Zend_Measure_Angle type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testAngleSetComputedType1() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::RADIAN,'de'); - $value->setType(Zend_Measure_Angle::MINUTE); - $this->assertEquals(Zend_Measure_Angle::MINUTE, $value->getType(), 'Zend_Measure_Angle type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testAngleSetComputedType2() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::MINUTE,'de'); - $value->setType(Zend_Measure_Angle::RADIAN); - $this->assertEquals(Zend_Measure_Angle::RADIAN, $value->getType(), 'Zend_Measure_Angle type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testAngleSetTypeFailed() - { - try { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $value->setType('Angle::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testAngleToString() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals('-100 rad', $value->toString(), 'Value -100 rad expected'); - } - - - /** - * test __toString - * expected string - */ - public function testAngle_ToString() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $this->assertEquals('-100 rad', $value->__toString(), 'Value -100 rad expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testAngleConversionList() - { - $value = new Zend_Measure_Angle('-100',Zend_Measure_Angle::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/AreaTest.php b/tests/Zend/Measure/AreaTest.php deleted file mode 100644 index 80a60b41cb512da90549c1718109b741ff9001cb..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/AreaTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AreaTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Area - */ -require_once 'Zend/Measure/Area.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_AreaTest extends PHPUnit_Framework_TestCase -{ - /** - * test for area initialisation - * expected instance - */ - public function testAreaInit() - { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Area,'Zend_Measure_Area Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testAreaUnknownType() - { - try { - $value = new Zend_Measure_Area('100','Area::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testAreaUnknownValue() - { - try { - $value = new Zend_Measure_Area('novalue',Zend_Measure_Area::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testAreaUnknownLocale() - { - try { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testAreaNoLocale() - { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Area value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testAreaValuePositive() - { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Area value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testAreaValueNegative() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Area value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testAreaValueDecimal() - { - $value = new Zend_Measure_Area('-100,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Area value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testAreaValueDecimalSeperated() - { - $value = new Zend_Measure_Area('-100.100,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Area Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testAreaValueString() - { - $value = new Zend_Measure_Area('string -100.100,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Area Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testAreaEquality() - { - $value = new Zend_Measure_Area('string -100.100,200',Zend_Measure_Area::STANDARD,'de'); - $newvalue = new Zend_Measure_Area('otherstring -100.100,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Area Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testAreaNoEquality() - { - $value = new Zend_Measure_Area('string -100.100,200',Zend_Measure_Area::STANDARD,'de'); - $newvalue = new Zend_Measure_Area('otherstring -100,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Area Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testAreaSetPositive() - { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Area value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testAreaSetNegative() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Area value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testAreaSetDecimal() - { - $value = new Zend_Measure_Area('-100,200',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Area value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testAreaSetDecimalSeperated() - { - $value = new Zend_Measure_Area('-100.100,200',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Area Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testAreaSetString() - { - $value = new Zend_Measure_Area('string -100.100,200',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Area Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testAreaSetUnknownType() - { - try { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Area::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testAreaSetUnknownValue() - { - try { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Area::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testAreaSetUnknownLocale() - { - try { - $value = new Zend_Measure_Area('100',Zend_Measure_Area::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Area::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testAreaSetWithNoLocale() - { - $value = new Zend_Measure_Area('100', Zend_Measure_Area::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Area::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Area value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testAreaSetType() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $value->setType(Zend_Measure_Area::MORGEN); - $this->assertEquals(Zend_Measure_Area::MORGEN, $value->getType(), 'Zend_Measure_Area type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testAreaSetComputedType1() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::SQUARE_MILE,'de'); - $value->setType(Zend_Measure_Area::SQUARE_INCH); - $this->assertEquals(Zend_Measure_Area::SQUARE_INCH, $value->getType(), 'Zend_Measure_Area type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testAreaSetComputedType2() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::SQUARE_INCH,'de'); - $value->setType(Zend_Measure_Area::SQUARE_MILE); - $this->assertEquals(Zend_Measure_Area::SQUARE_MILE, $value->getType(), 'Zend_Measure_Area type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testAreaSetTypeFailed() - { - try { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $value->setType('Area::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testAreaToString() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals('-100 m²', $value->toString(), 'Value -100 m² expected'); - } - - - /** - * test __toString - * expected string - */ - public function testArea_ToString() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $this->assertEquals('-100 m²', $value->__toString(), 'Value -100 m² expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testAreaConversionList() - { - $value = new Zend_Measure_Area('-100',Zend_Measure_Area::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/BinaryTest.php b/tests/Zend/Measure/BinaryTest.php deleted file mode 100644 index b9c976f76504015cec3d39517fc36755161d0c41..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/BinaryTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BinaryTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Binary - */ -require_once 'Zend/Measure/Binary.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_BinaryTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Binary initialisation - * expected instance - */ - public function testBinaryInit() - { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Binary,'Zend_Measure_Binary Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testBinaryUnknownType() - { - try { - $value = new Zend_Measure_Binary('100','Binary::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testBinaryUnknownValue() - { - try { - $value = new Zend_Measure_Binary('novalue',Zend_Measure_Binary::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testBinaryUnknownLocale() - { - try { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception no locale - * expected root value - */ - public function testBinaryNoLocale() - { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD); - $this->assertTrue(is_object($value),'Object expected because of standard locale'); - } - - - /** - * test for positive value - * expected integer - */ - public function testBinaryValuePositive() - { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Binary value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testBinaryValueNegative() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Binary value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testBinaryValueDecimal() - { - $value = new Zend_Measure_Binary('-100,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Binary value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testBinaryValueDecimalSeperated() - { - $value = new Zend_Measure_Binary('-100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Binary Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testBinaryValueString() - { - $value = new Zend_Measure_Binary('string -100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Binary Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testBinaryEquality() - { - $value = new Zend_Measure_Binary('string -100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $newvalue = new Zend_Measure_Binary('otherstring -100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Binary Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testBinaryNoEquality() - { - $value = new Zend_Measure_Binary('string -100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $newvalue = new Zend_Measure_Binary('otherstring -100,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Binary Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testBinarySetPositive() - { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Binary value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testBinarySetNegative() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Binary value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testBinarySetDecimal() - { - $value = new Zend_Measure_Binary('-100,200',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Binary value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testBinarySetDecimalSeperated() - { - $value = new Zend_Measure_Binary('-100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Binary Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testBinarySetString() - { - $value = new Zend_Measure_Binary('string -100.100,200',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Binary Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testBinarySetUnknownType() - { - try { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Binary::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testBinarySetUnknownValue() - { - try { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Binary::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testBinarySetUnknownLocale() - { - try { - $value = new Zend_Measure_Binary('100',Zend_Measure_Binary::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Binary::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testBinarySetWithNoLocale() - { - $value = new Zend_Measure_Binary('100', Zend_Measure_Binary::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Binary::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Binary value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testBinarySetType() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $value->setType(Zend_Measure_Binary::GIGABYTE); - $this->assertEquals(Zend_Measure_Binary::GIGABYTE, $value->getType(), 'Zend_Measure_Binary type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testBinarySetComputedType1() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::MEGABYTE,'de'); - $value->setType(Zend_Measure_Binary::TERABYTE); - $this->assertEquals(Zend_Measure_Binary::TERABYTE, $value->getType(), 'Zend_Measure_Binary type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testBinarySetComputedType2() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::TERABYTE,'de'); - $value->setType(Zend_Measure_Binary::KILOBYTE); - $this->assertEquals(Zend_Measure_Binary::KILOBYTE, $value->getType(), 'Zend_Measure_Binary type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testBinarySetTypeFailed() - { - try { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $value->setType('Binary::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testBinaryToString() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals('-100 B', $value->toString(), 'Value -100 B expected'); - } - - - /** - * test __toString - * expected string - */ - public function testBinary_ToString() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $this->assertEquals('-100 B', $value->__toString(), 'Value -100 B expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testBinaryConversionList() - { - $value = new Zend_Measure_Binary('-100',Zend_Measure_Binary::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/CapacitanceTest.php b/tests/Zend/Measure/CapacitanceTest.php deleted file mode 100644 index d7f91e847126ac8f3af9bf4804179502a074478c..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/CapacitanceTest.php +++ /dev/null @@ -1,367 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CapacitanceTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - -/** - * Zend_Measure_Capacitance - */ -require_once 'Zend/Measure/Capacitance.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_CapacitanceTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Capacitance initialisation - * expected instance - */ - public function testCapacitanceInit() - { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Capacitance,'Zend_Measure_Capacitance Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCapacitanceUnknownType() - { - try { - $value = new Zend_Measure_Capacitance('100','Capacitance::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCapacitanceUnknownValue() - { - try { - $value = new Zend_Measure_Capacitance('novalue',Zend_Measure_Capacitance::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testCapacitanceUnknownLocale() - { - try { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testCapacitanceNoLocale() - { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Capacitance value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testCapacitanceValuePositive() - { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testCapacitanceValueNegative() - { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testCapacitanceValueDecimal() - { - $value = new Zend_Measure_Capacitance('-100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testCapacitanceValueDecimalSeperated() - { - $value = new Zend_Measure_Capacitance('-100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Capacitance Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testCapacitanceValueString() - { - $value = new Zend_Measure_Capacitance('string -100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Capacitance Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testCapacitanceEquality() - { - $value = new Zend_Measure_Capacitance('string -100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $newvalue = new Zend_Measure_Capacitance('otherstring -100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Capacitance Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testCapacitanceNoEquality() - { - $value = new Zend_Measure_Capacitance('string -100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $newvalue = new Zend_Measure_Capacitance('otherstring -100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Capacitance Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testCapacitanceSetPositive() - { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testCapacitanceSetNegative() - { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testCapacitanceSetDecimal() - { - $value = new Zend_Measure_Capacitance('-100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testCapacitanceSetDecimalSeperated() - { - $value = new Zend_Measure_Capacitance('-100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Capacitance Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testCapacitanceSetString() - { - $value = new Zend_Measure_Capacitance('string -100.100,200',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Capacitance Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCapacitanceSetUnknownType() - { - try { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Capacitance::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCapacitanceSetUnknownValue() - { - try { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Capacitance::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCapacitanceSetUnknownLocale() - { - try { - $value = new Zend_Measure_Capacitance('100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Capacitance::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCapacitanceSetWithNoLocale() - { - $value = new Zend_Measure_Capacitance('100', Zend_Measure_Capacitance::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Capacitance::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Capacitance value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testCapacitanceSetType() - { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setType(Zend_Measure_Capacitance::NANOFARAD); - $this->assertEquals(Zend_Measure_Capacitance::NANOFARAD, $value->getType(), 'Zend_Measure_Capacitance type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testCapacitanceSetTypeFailed() - { - try { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $value->setType('Capacitance::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testCapacitanceToString() - { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals('-100 F', $value->toString(), 'Value -100 F expected'); - } - - - /** - * test __toString - * expected string - */ - public function testCapacitance_ToString() - { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $this->assertEquals('-100 F', $value->__toString(), 'Value -100 F expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testCapacitanceConversionList() - { - $value = new Zend_Measure_Capacitance('-100',Zend_Measure_Capacitance::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Cooking/VolumeTest.php b/tests/Zend/Measure/Cooking/VolumeTest.php deleted file mode 100644 index b0cd970dddc599007a85bfddfc87f4269352a932..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Cooking/VolumeTest.php +++ /dev/null @@ -1,374 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Cooking_Volume - */ -require_once 'Zend/Measure/Cooking/Volume.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Cooking_VolumeTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Mass initialisation - * expected instance - */ - public function testMassInit() - { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Cooking_Volume,'Zend_Measure_Cooking_Volume Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCooking_VolumeUnknownType() - { - try { - $value = new Zend_Measure_Cooking_Volume('100','Cooking_Volume::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCooking_VolumeUnknownValue() - { - try { - $value = new Zend_Measure_Cooking_Volume('novalue',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testCooking_VolumeUnknownLocale() - { - try { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testCooking_VolumeNoLocale() - { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Cooking_Volume value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testCooking_VolumeValuePositive() - { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testCooking_VolumeValueNegative() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testCooking_VolumeValueDecimal() - { - $value = new Zend_Measure_Cooking_Volume('-100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testCooking_VolumeValueDecimalSeperated() - { - $value = new Zend_Measure_Cooking_Volume('-100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Cooking_Volume Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testCooking_VolumeValueString() - { - $value = new Zend_Measure_Cooking_Volume('string -100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Cooking_Volume Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testCooking_VolumeEquality() - { - $value = new Zend_Measure_Cooking_Volume('string -100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $newvalue = new Zend_Measure_Cooking_Volume('otherstring -100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Cooking_Volume Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testCooking_VolumeNoEquality() - { - $value = new Zend_Measure_Cooking_Volume('string -100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $newvalue = new Zend_Measure_Cooking_Volume('otherstring -100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Cooking_Volume Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testCooking_VolumeSetPositive() - { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testCooking_VolumeSetNegative() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testCooking_VolumeSetDecimal() - { - $value = new Zend_Measure_Cooking_Volume('-100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testCooking_VolumeSetDecimalSeperated() - { - $value = new Zend_Measure_Cooking_Volume('-100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Cooking_Volume Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testCooking_VolumeSetString() - { - $value = new Zend_Measure_Cooking_Volume('string -100.100,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Cooking_Volume Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCooking_VolumeSetUnknownType() - { - try { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Cooking_Volume::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCooking_VolumeSetUnknownValue() - { - try { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCooking_VolumeSetUnknownLocale() - { - try { - $value = new Zend_Measure_Cooking_Volume('100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Cooking_Volume::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCooking_VolumeSetWithNoLocale() - { - $value = new Zend_Measure_Cooking_Volume('100', Zend_Measure_Cooking_Volume::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Cooking_Volume::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Cooking_Volume value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testCooking_VolumeSetType() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setType(Zend_Measure_Cooking_Volume::DRAM); - $this->assertEquals(Zend_Measure_Cooking_Volume::DRAM, $value->getType(), 'Zend_Measure_Cooking_Volume type expected'); } - - - /** - * test setting computed type - * expected new type - */ - public function testCooking_VolumeSetComputedType1() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setType(Zend_Measure_Cooking_Volume::DRAM); - $this->assertEquals(Zend_Measure_Cooking_Volume::DRAM, $value->getType(), 'Zend_Measure_Cooking_Volume type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testCooking_VolumeSetComputedType2() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::DRAM,'de'); - $value->setType(Zend_Measure_Cooking_Volume::STANDARD); - $this->assertEquals(Zend_Measure_Cooking_Volume::STANDARD, $value->getType(), 'Zend_Measure_Cooking_Volume type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testCooking_VolumeSetTypeFailed() - { - try { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $value->setType('Cooking_Volume::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testCooking_VolumeToString() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals('-100 m³', $value->toString(), 'Value -100 m³ expected'); - } - - - /** - * test __toString - * expected string - */ - public function testCooking_Volume_ToString() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $this->assertEquals('-100 m³', $value->__toString(), 'Value -100 m³ expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testCooking_VolumeConversionList() - { - $value = new Zend_Measure_Cooking_Volume('-100',Zend_Measure_Cooking_Volume::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Cooking/WeightTest.php b/tests/Zend/Measure/Cooking/WeightTest.php deleted file mode 100644 index de51327c9e3188c25da9a32baa71fc3694f4465c..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Cooking/WeightTest.php +++ /dev/null @@ -1,374 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Cooking_Weight - */ -require_once 'Zend/Measure/Cooking/Weight.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Cooking_WeightTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Mass initialisation - * expected instance - */ - public function testCooking_WeightInit() - { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Cooking_Weight,'Zend_Measure_Cooking_Weight Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCooking_WeightUnknownType() - { - try { - $value = new Zend_Measure_Cooking_Weight('100','Cooking_Weight::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCooking_WeightUnknownValue() - { - try { - $value = new Zend_Measure_Cooking_Weight('novalue',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testCooking_WeightUnknownLocale() - { - try { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testCooking_WeightNoLocale() - { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Cooking_Weight value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testCooking_WeightValuePositive() - { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testCooking_WeightValueNegative() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testCooking_WeightValueDecimal() - { - $value = new Zend_Measure_Cooking_Weight('-100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testCooking_WeightValueDecimalSeperated() - { - $value = new Zend_Measure_Cooking_Weight('-100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Cooking_Weight Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testCooking_WeightValueString() - { - $value = new Zend_Measure_Cooking_Weight('string -100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Cooking_Weight Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testCooking_WeightEquality() - { - $value = new Zend_Measure_Cooking_Weight('string -100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $newvalue = new Zend_Measure_Cooking_Weight('otherstring -100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Cooking_Weight Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testCooking_WeightNoEquality() - { - $value = new Zend_Measure_Cooking_Weight('string -100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $newvalue = new Zend_Measure_Cooking_Weight('otherstring -100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Cooking_Weight Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testCooking_WeightSetPositive() - { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testCooking_WeightSetNegative() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testCooking_WeightSetDecimal() - { - $value = new Zend_Measure_Cooking_Weight('-100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testCooking_WeightSetDecimalSeperated() - { - $value = new Zend_Measure_Cooking_Weight('-100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Cooking_Weight Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testCooking_WeightSetString() - { - $value = new Zend_Measure_Cooking_Weight('string -100.100,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Cooking_Weight Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCooking_WeightSetUnknownType() - { - try { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Cooking_Weight::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCooking_WeightSetUnknownValue() - { - try { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCooking_WeightSetUnknownLocale() - { - try { - $value = new Zend_Measure_Cooking_Weight('100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Cooking_Weight::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCooking_WeightSetWithNoLocale() - { - $value = new Zend_Measure_Cooking_Weight('100', Zend_Measure_Cooking_Weight::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Cooking_Weight::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Cooking_Weight value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testCooking_WeightSetType() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setType(Zend_Measure_Cooking_Weight::CUP); - $this->assertEquals(Zend_Measure_Cooking_Weight::CUP, $value->getType(), 'Zend_Measure_Cooking_Weight type expected'); } - - - /** - * test setting computed type - * expected new type - */ - public function testCooking_WeightSetComputedType1() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setType(Zend_Measure_Cooking_Weight::CUP); - $this->assertEquals(Zend_Measure_Cooking_Weight::CUP, $value->getType(), 'Zend_Measure_Cooking_Weight type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testCooking_WeightSetComputedType2() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::CUP,'de'); - $value->setType(Zend_Measure_Cooking_Weight::STANDARD); - $this->assertEquals(Zend_Measure_Cooking_Weight::STANDARD, $value->getType(), 'Zend_Measure_Cooking_Weight type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testCooking_WeightSetTypeFailed() - { - try { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $value->setType('Cooking_Weight::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testCooking_WeightToString() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals('-100 g', $value->toString(), 'Value -100 g expected'); - } - - - /** - * test __toString - * expected string - */ - public function testCooking_Weight_ToString() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $this->assertEquals('-100 g', $value->__toString(), 'Value -100 g expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testCooking_WeightConversionList() - { - $value = new Zend_Measure_Cooking_Weight('-100',Zend_Measure_Cooking_Weight::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/CurrentTest.php b/tests/Zend/Measure/CurrentTest.php deleted file mode 100644 index ce4d9fd00e1436dc967c6dde3d306e0a4c6e2cb8..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/CurrentTest.php +++ /dev/null @@ -1,367 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CurrentTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - -/** - * Zend_Measure_Current - */ -require_once 'Zend/Measure/Current.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_CurrentTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Current initialisation - * expected instance - */ - public function testCurrentInit() - { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Current,'Zend_Measure_Current Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCurrentUnknownType() - { - try { - $value = new Zend_Measure_Current('100','Current::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCurrentUnknownValue() - { - try { - $value = new Zend_Measure_Current('novalue',Zend_Measure_Current::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testCurrentUnknownLocale() - { - try { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testCurrentNoLocale() - { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Current value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testCurrentValuePositive() - { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Current value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testCurrentValueNegative() - { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Current value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testCurrentValueDecimal() - { - $value = new Zend_Measure_Current('-100,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Current value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testCurrentValueDecimalSeperated() - { - $value = new Zend_Measure_Current('-100.100,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Current Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testCurrentValueString() - { - $value = new Zend_Measure_Current('string -100.100,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Current Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testCurrentEquality() - { - $value = new Zend_Measure_Current('string -100.100,200',Zend_Measure_Current::STANDARD,'de'); - $newvalue = new Zend_Measure_Current('otherstring -100.100,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Current Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testCurrentNoEquality() - { - $value = new Zend_Measure_Current('string -100.100,200',Zend_Measure_Current::STANDARD,'de'); - $newvalue = new Zend_Measure_Current('otherstring -100,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Current Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testCurrentSetPositive() - { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Current value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testCurrentSetNegative() - { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Current value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testCurrentSetDecimal() - { - $value = new Zend_Measure_Current('-100,200',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Current value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testCurrentSetDecimalSeperated() - { - $value = new Zend_Measure_Current('-100.100,200',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Current Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testCurrentSetString() - { - $value = new Zend_Measure_Current('string -100.100,200',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Current Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testCurrentSetUnknownType() - { - try { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Current::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testCurrentSetUnknownValue() - { - try { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Current::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCurrentSetUnknownLocale() - { - try { - $value = new Zend_Measure_Current('100',Zend_Measure_Current::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Current::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testCurrentSetWithNoLocale() - { - $value = new Zend_Measure_Current('100', Zend_Measure_Current::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Current::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Current value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testCurrentSetType() - { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $value->setType(Zend_Measure_Current::NANOAMPERE); - $this->assertEquals(Zend_Measure_Current::NANOAMPERE, $value->getType(), 'Zend_Measure_Current type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testCurrentSetTypeFailed() - { - try { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $value->setType('Current::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testCurrentToString() - { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals('-100 A', $value->toString(), 'Value -100 A expected'); - } - - - /** - * test __toString - * expected string - */ - public function testCurrent_ToString() - { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $this->assertEquals('-100 A', $value->__toString(), 'Value -100 A expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testCurrentConversionList() - { - $value = new Zend_Measure_Current('-100',Zend_Measure_Current::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/DensityTest.php b/tests/Zend/Measure/DensityTest.php deleted file mode 100644 index f0d26563242137a7f1b5037b280e69a4cc49e133..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/DensityTest.php +++ /dev/null @@ -1,391 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DensityTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - -/** - * Zend_Measure_Density - */ -require_once 'Zend/Measure/Density.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_DensityTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Density initialisation - * expected instance - */ - public function testDensityInit() - { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Density,'Zend_Measure_Density Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testDensityUnknownType() - { - try { - $value = new Zend_Measure_Density('100','Density::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testDensityUnknownValue() - { - try { - $value = new Zend_Measure_Density('novalue',Zend_Measure_Density::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testDensityUnknownLocale() - { - try { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testDensityNoLocale() - { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Density value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testDensityValuePositive() - { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Density value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testDensityValueNegative() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Density value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testDensityValueDecimal() - { - $value = new Zend_Measure_Density('-100,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Density value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testDensityValueDecimalSeperated() - { - $value = new Zend_Measure_Density('-100.100,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Density Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testDensityValueString() - { - $value = new Zend_Measure_Density('string -100.100,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Density Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testDensityEquality() - { - $value = new Zend_Measure_Density('string -100.100,200',Zend_Measure_Density::STANDARD,'de'); - $newvalue = new Zend_Measure_Density('otherstring -100.100,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Density Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testDensityNoEquality() - { - $value = new Zend_Measure_Density('string -100.100,200',Zend_Measure_Density::STANDARD,'de'); - $newvalue = new Zend_Measure_Density('otherstring -100,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Density Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testDensitySetPositive() - { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Density value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testDensitySetNegative() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Density value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testDensitySetDecimal() - { - $value = new Zend_Measure_Density('-100,200',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Density value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testDensitySetDecimalSeperated() - { - $value = new Zend_Measure_Density('-100.100,200',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Density Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testDensitySetString() - { - $value = new Zend_Measure_Density('string -100.100,200',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Density Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testDensitySetUnknownType() - { - try { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Density::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testDensitySetUnknownValue() - { - try { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Density::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testDensitySetUnknownLocale() - { - try { - $value = new Zend_Measure_Density('100',Zend_Measure_Density::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Density::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testDensitySetWithNoLocale() - { - $value = new Zend_Measure_Density('100', Zend_Measure_Density::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Density::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Density value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testDensitySetType() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $value->setType(Zend_Measure_Density::GOLD); - $this->assertEquals(Zend_Measure_Density::GOLD, $value->getType(), 'Zend_Measure_Density type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testDensitySetComputedType1() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::SILVER,'de'); - $value->setType(Zend_Measure_Density::TONNE_PER_MILLILITER); - $this->assertEquals(Zend_Measure_Density::TONNE_PER_MILLILITER, $value->getType(), 'Zend_Measure_Density type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testDensitySetComputedType2() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::TONNE_PER_MILLILITER,'de'); - $value->setType(Zend_Measure_Density::GOLD); - $this->assertEquals(Zend_Measure_Density::GOLD, $value->getType(), 'Zend_Measure_Density type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testDensitySetTypeFailed() - { - try { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $value->setType('Density::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testDensityToString() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals('-100 kg/m³', $value->toString(), 'Value -100 kg/m³ expected'); - } - - - /** - * test __toString - * expected string - */ - public function testDensity_ToString() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $this->assertEquals('-100 kg/m³', $value->__toString(), 'Value -100 kg/m³ expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testDensityConversionList() - { - $value = new Zend_Measure_Density('-100',Zend_Measure_Density::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/EnergyTest.php b/tests/Zend/Measure/EnergyTest.php deleted file mode 100644 index 1f01447b3a2c28d1f8e3fcaab3e46e628c356546..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/EnergyTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EnergyTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Energy - */ -require_once 'Zend/Measure/Energy.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_EnergyTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Energy initialisation - * expected instance - */ - public function testEnergyInit() - { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Energy,'Zend_Measure_Energy Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testEnergyUnknownType() - { - try { - $value = new Zend_Measure_Energy('100','Energy::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testEnergyUnknownValue() - { - try { - $value = new Zend_Measure_Energy('novalue',Zend_Measure_Energy::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testEnergyUnknownLocale() - { - try { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testEnergyNoLocale() - { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Energy value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testEnergyValuePositive() - { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Energy value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testEnergyValueNegative() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Energy value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testEnergyValueDecimal() - { - $value = new Zend_Measure_Energy('-100,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Energy value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testEnergyValueDecimalSeperated() - { - $value = new Zend_Measure_Energy('-100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Energy Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testEnergyValueString() - { - $value = new Zend_Measure_Energy('string -100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Energy Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testEnergyEquality() - { - $value = new Zend_Measure_Energy('string -100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $newvalue = new Zend_Measure_Energy('otherstring -100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Energy Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testEnergyNoEquality() - { - $value = new Zend_Measure_Energy('string -100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $newvalue = new Zend_Measure_Energy('otherstring -100,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Energy Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testEnergySetPositive() - { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Energy value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testEnergySetNegative() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Energy value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testEnergySetDecimal() - { - $value = new Zend_Measure_Energy('-100,200',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Energy value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testEnergySetDecimalSeperated() - { - $value = new Zend_Measure_Energy('-100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Energy Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testEnergySetString() - { - $value = new Zend_Measure_Energy('string -100.100,200',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Energy Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testEnergySetUnknownType() - { - try { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Energy::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testEnergySetUnknownValue() - { - try { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Energy::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testEnergySetUnknownLocale() - { - try { - $value = new Zend_Measure_Energy('100',Zend_Measure_Energy::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Energy::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testEnergySetWithNoLocale() - { - $value = new Zend_Measure_Energy('100', Zend_Measure_Energy::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Energy::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Energy value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testEnergySetType() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $value->setType(Zend_Measure_Energy::ERG); - $this->assertEquals(Zend_Measure_Energy::ERG, $value->getType(), 'Zend_Measure_Energy type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testEnergySetComputedType1() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::ERG,'de'); - $value->setType(Zend_Measure_Energy::KILOTON); - $this->assertEquals(Zend_Measure_Energy::KILOTON, $value->getType(), 'Zend_Measure_Energy type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testEnergySetComputedType2() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::KILOTON,'de'); - $value->setType(Zend_Measure_Energy::ERG); - $this->assertEquals(Zend_Measure_Energy::ERG, $value->getType(), 'Zend_Measure_Energy type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testEnergySetTypeFailed() - { - try { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $value->setType('Energy::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testEnergyToString() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals('-100 J', $value->toString(), 'Value -100 J expected'); - } - - - /** - * test __toString - * expected string - */ - public function testEnergy_ToString() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $this->assertEquals('-100 J', $value->__toString(), 'Value -100 J expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testEnergyConversionList() - { - $value = new Zend_Measure_Energy('-100',Zend_Measure_Energy::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Flow/MassTest.php b/tests/Zend/Measure/Flow/MassTest.php deleted file mode 100644 index d41f5fe6af688990932eae0d0ef29e03efb968a4..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Flow/MassTest.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Flow_Mass - */ -require_once 'Zend/Measure/Flow/Mass.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Flow_MassTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Mass initialisation - * expected instance - */ - public function testMassInit() - { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Flow_Mass,'Zend_Measure_Flow_Mass Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFlow_MassUnknownType() - { - try { - $value = new Zend_Measure_Flow_Mass('100','Flow_Mass::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFlow_MassUnknownValue() - { - try { - $value = new Zend_Measure_Flow_Mass('novalue',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testFlow_MassUnknownLocale() - { - try { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testFlow_MassNoLocale() - { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Flow_Mass value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testFlow_MassValuePositive() - { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testFlow_MassValueNegative() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testFlow_MassValueDecimal() - { - $value = new Zend_Measure_Flow_Mass('-100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testFlow_MassValueDecimalSeperated() - { - $value = new Zend_Measure_Flow_Mass('-100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Flow_Mass Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testFlow_MassValueString() - { - $value = new Zend_Measure_Flow_Mass('string -100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Flow_Mass Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testFlow_MassEquality() - { - $value = new Zend_Measure_Flow_Mass('string -100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $newvalue = new Zend_Measure_Flow_Mass('otherstring -100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Flow_Mass Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testFlow_MassNoEquality() - { - $value = new Zend_Measure_Flow_Mass('string -100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $newvalue = new Zend_Measure_Flow_Mass('otherstring -100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Flow_Mass Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testFlow_MassSetPositive() - { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testFlow_MassSetNegative() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testFlow_MassSetDecimal() - { - $value = new Zend_Measure_Flow_Mass('-100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testFlow_MassSetDecimalSeperated() - { - $value = new Zend_Measure_Flow_Mass('-100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Flow_Mass Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testFlow_MassSetString() - { - $value = new Zend_Measure_Flow_Mass('string -100.100,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Flow_Mass Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFlow_MassSetUnknownType() - { - try { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Flow_Mass::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFlow_MassSetUnknownValue() - { - try { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFlow_MassSetUnknownLocale() - { - try { - $value = new Zend_Measure_Flow_Mass('100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Flow_Mass::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFlow_MassSetWithNoLocale() - { - $value = new Zend_Measure_Flow_Mass('100', Zend_Measure_Flow_Mass::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Flow_Mass::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Flow_Mass value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testFlow_MassSetType() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setType(Zend_Measure_Flow_Mass::GRAM_PER_DAY); - $this->assertEquals(Zend_Measure_Flow_Mass::GRAM_PER_DAY, $value->getType(), 'Zend_Measure_Flow_Mass type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFlow_MassSetComputedType1() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setType(Zend_Measure_Flow_Mass::GRAM_PER_DAY); - $this->assertEquals(Zend_Measure_Flow_Mass::GRAM_PER_DAY, $value->getType(), 'Zend_Measure_Flow_Mass type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFlow_MassSetComputedType2() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::GRAM_PER_DAY,'de'); - $value->setType(Zend_Measure_Flow_Mass::STANDARD); - $this->assertEquals(Zend_Measure_Flow_Mass::STANDARD, $value->getType(), 'Zend_Measure_Flow_Mass type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testFlow_MassSetTypeFailed() - { - try { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $value->setType('Flow_Mass::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testFlow_MassToString() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals('-100 kg/s', $value->toString(), 'Value -100 kg/s expected'); - } - - - /** - * test __toString - * expected string - */ - public function testFlow_Mass_ToString() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $this->assertEquals('-100 kg/s', $value->__toString(), 'Value -100 kg/s expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testFlow_MassConversionList() - { - $value = new Zend_Measure_Flow_Mass('-100',Zend_Measure_Flow_Mass::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Flow/MoleTest.php b/tests/Zend/Measure/Flow/MoleTest.php deleted file mode 100644 index 31a7b557fe68c22d195116858065fa3d78d1360a..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Flow/MoleTest.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Flow_Mole - */ -require_once 'Zend/Measure/Flow/Mole.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Flow_MoleTest extends PHPUnit_Framework_TestCase -{ - /** - * test for mole initialisation - * expected instance - */ - public function testMoleInit() - { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Flow_Mole,'Zend_Measure_Flow_Mole Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFlow_MoleUnknownType() - { - try { - $value = new Zend_Measure_Flow_Mole('100','Flow_Mole::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFlow_MoleUnknownValue() - { - try { - $value = new Zend_Measure_Flow_Mole('novalue',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testFlow_MoleUnknownLocale() - { - try { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testFlow_MoleNoLocale() - { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Flow_Mole value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testFlow_MoleValuePositive() - { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testFlow_MoleValueNegative() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testFlow_MoleValueDecimal() - { - $value = new Zend_Measure_Flow_Mole('-100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testFlow_MoleValueDecimalSeperated() - { - $value = new Zend_Measure_Flow_Mole('-100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Flow_Mole Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testFlow_MoleValueString() - { - $value = new Zend_Measure_Flow_Mole('string -100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Flow_Mole Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testFlow_MoleEquality() - { - $value = new Zend_Measure_Flow_Mole('string -100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $newvalue = new Zend_Measure_Flow_Mole('otherstring -100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Flow_Mole Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testFlow_MoleNoEquality() - { - $value = new Zend_Measure_Flow_Mole('string -100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $newvalue = new Zend_Measure_Flow_Mole('otherstring -100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Flow_Mole Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testFlow_MoleSetPositive() - { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testFlow_MoleSetNegative() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testFlow_MoleSetDecimal() - { - $value = new Zend_Measure_Flow_Mole('-100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testFlow_MoleSetDecimalSeperated() - { - $value = new Zend_Measure_Flow_Mole('-100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Flow_Mole Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testFlow_MoleSetString() - { - $value = new Zend_Measure_Flow_Mole('string -100.100,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Flow_Mole Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFlow_MoleSetUnknownType() - { - try { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Flow_Mole::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFlow_MoleSetUnknownValue() - { - try { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFlow_MoleSetUnknownLocale() - { - try { - $value = new Zend_Measure_Flow_Mole('100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Flow_Mole::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFlow_MoleSetWithNoLocale() - { - $value = new Zend_Measure_Flow_Mole('100', Zend_Measure_Flow_Mole::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Flow_Mole::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Flow_Mole value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testFlow_MoleSetType() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setType(Zend_Measure_Flow_Mole::MILLIMOLE_PER_DAY); - $this->assertEquals(Zend_Measure_Flow_Mole::MILLIMOLE_PER_DAY, $value->getType(), 'Zend_Measure_Flow_Mole type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFlow_MoleSetComputedType1() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setType(Zend_Measure_Flow_Mole::MILLIMOLE_PER_DAY); - $this->assertEquals(Zend_Measure_Flow_Mole::MILLIMOLE_PER_DAY, $value->getType(), 'Zend_Measure_Flow_Mole type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFlow_MoleSetComputedType2() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::MILLIMOLE_PER_DAY,'de'); - $value->setType(Zend_Measure_Flow_Mole::STANDARD); - $this->assertEquals(Zend_Measure_Flow_Mole::STANDARD, $value->getType(), 'Zend_Measure_Flow_Mole type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testFlow_MoleSetTypeFailed() - { - try { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $value->setType('Flow_Mole::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testFlow_MoleToString() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals('-100 mol/s', $value->toString(), 'Value -100 mol/s expected'); - } - - - /** - * test __toString - * expected string - */ - public function testFlow_Mole_ToString() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $this->assertEquals('-100 mol/s', $value->__toString(), 'Value -100 mol/s expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testFlow_MoleConversionList() - { - $value = new Zend_Measure_Flow_Mole('-100',Zend_Measure_Flow_Mole::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Flow/VolumeTest.php b/tests/Zend/Measure/Flow/VolumeTest.php deleted file mode 100644 index 633ea325e97af37f526a3d38c4c27a20a1ce873f..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Flow/VolumeTest.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Flow_Volume - */ -require_once 'Zend/Measure/Flow/Volume.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Flow_VolumeTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Volume initialisation - * expected instance - */ - public function testFlow_VolumeInit() - { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Flow_Volume,'Zend_Measure_Flow_Volume Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFlow_VolumeUnknownType() - { - try { - $value = new Zend_Measure_Flow_Volume('100','Flow_Volume::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFlow_VolumeUnknownValue() - { - try { - $value = new Zend_Measure_Flow_Volume('novalue',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testFlow_VolumeUnknownLocale() - { - try { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testFlow_VolumeNoLocale() - { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Flow_Volume value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testFlow_VolumeValuePositive() - { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testFlow_VolumeValueNegative() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testFlow_VolumeValueDecimal() - { - $value = new Zend_Measure_Flow_Volume('-100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testFlow_VolumeValueDecimalSeperated() - { - $value = new Zend_Measure_Flow_Volume('-100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Flow_Volume Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testFlow_VolumeValueString() - { - $value = new Zend_Measure_Flow_Volume('string -100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Flow_Volume Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testFlow_VolumeEquality() - { - $value = new Zend_Measure_Flow_Volume('string -100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $newvalue = new Zend_Measure_Flow_Volume('otherstring -100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Flow_Volume Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testFlow_VolumeNoEquality() - { - $value = new Zend_Measure_Flow_Volume('string -100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $newvalue = new Zend_Measure_Flow_Volume('otherstring -100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Flow_Volume Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testFlow_VolumeSetPositive() - { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testFlow_VolumeSetNegative() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testFlow_VolumeSetDecimal() - { - $value = new Zend_Measure_Flow_Volume('-100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testFlow_VolumeSetDecimalSeperated() - { - $value = new Zend_Measure_Flow_Volume('-100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Flow_Volume Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testFlow_VolumeSetString() - { - $value = new Zend_Measure_Flow_Volume('string -100.100,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Flow_Volume Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFlow_VolumeSetUnknownType() - { - try { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Flow_Volume::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFlow_VolumeSetUnknownValue() - { - try { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFlow_VolumeSetUnknownLocale() - { - try { - $value = new Zend_Measure_Flow_Volume('100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Flow_Volume::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFlow_VolumeSetWithNoLocale() - { - $value = new Zend_Measure_Flow_Volume('100', Zend_Measure_Flow_Volume::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Flow_Volume::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Flow_Volume value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testFlow_VolumeSetType() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setType(Zend_Measure_Flow_Volume::CUSEC); - $this->assertEquals(Zend_Measure_Flow_Volume::CUSEC, $value->getType(), 'Zend_Measure_Flow_Volume type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFlow_VolumeSetComputedType1() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setType(Zend_Measure_Flow_Volume::BARREL_PER_DAY); - $this->assertEquals(Zend_Measure_Flow_Volume::BARREL_PER_DAY, $value->getType(), 'Zend_Measure_Flow_Volume type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFlow_VolumeSetComputedType2() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::BARREL_PER_DAY,'de'); - $value->setType(Zend_Measure_Flow_Volume::STANDARD); - $this->assertEquals(Zend_Measure_Flow_Volume::STANDARD, $value->getType(), 'Zend_Measure_Flow_Volume type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testFlow_VolumeSetTypeFailed() - { - try { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $value->setType('Flow_Volume::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testFlow_VolumeToString() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals('-100 m³/s', $value->toString(), 'Value -100 m³/s expected'); - } - - - /** - * test __toString - * expected string - */ - public function testFlow_Volume_ToString() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $this->assertEquals('-100 m³/s', $value->__toString(), 'Value -100 m³/s expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testFlow_VolumeConversionList() - { - $value = new Zend_Measure_Flow_Volume('-100',Zend_Measure_Flow_Volume::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/ForceTest.php b/tests/Zend/Measure/ForceTest.php deleted file mode 100644 index 770712656c9dddd3f7134504cfe593f05bf67b6c..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/ForceTest.php +++ /dev/null @@ -1,368 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ForceTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Force - */ -require_once 'Zend/Measure/Force.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_ForceTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Force initialisation - * expected instance - */ - public function testForceInit() - { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Force,'Zend_Measure_Force Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testForceUnknownType() - { - try { - $value = new Zend_Measure_Force('100','Force::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testForceUnknownValue() - { - try { - $value = new Zend_Measure_Force('novalue',Zend_Measure_Force::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testForceUnknownLocale() - { - try { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testForceNoLocale() - { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Force value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testForceValuePositive() - { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Force value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testForceValueNegative() - { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Force value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testForceValueDecimal() - { - $value = new Zend_Measure_Force('-100,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Force value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testForceValueDecimalSeperated() - { - $value = new Zend_Measure_Force('-100.100,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Force Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testForceValueString() - { - $value = new Zend_Measure_Force('string -100.100,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Force Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testForceEquality() - { - $value = new Zend_Measure_Force('string -100.100,200',Zend_Measure_Force::STANDARD,'de'); - $newvalue = new Zend_Measure_Force('otherstring -100.100,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Force Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testForceNoEquality() - { - $value = new Zend_Measure_Force('string -100.100,200',Zend_Measure_Force::STANDARD,'de'); - $newvalue = new Zend_Measure_Force('otherstring -100,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Force Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testForceSetPositive() - { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Force value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testForceSetNegative() - { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Force value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testForceSetDecimal() - { - $value = new Zend_Measure_Force('-100,200',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Force value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testForceSetDecimalSeperated() - { - $value = new Zend_Measure_Force('-100.100,200',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Force Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testForceSetString() - { - $value = new Zend_Measure_Force('string -100.100,200',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Force Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testForceSetUnknownType() - { - try { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Force::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testForceSetUnknownValue() - { - try { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Force::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testForceSetUnknownLocale() - { - try { - $value = new Zend_Measure_Force('100',Zend_Measure_Force::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Force::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testForceSetWithNoLocale() - { - $value = new Zend_Measure_Force('100', Zend_Measure_Force::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Force::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Force value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testForceSetType() - { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $value->setType(Zend_Measure_Force::NANONEWTON); - $this->assertEquals(Zend_Measure_Force::NANONEWTON, $value->getType(), 'Zend_Measure_Force type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testForceSetTypeFailed() - { - try { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $value->setType('Force::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testForceToString() - { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals('-100 N', $value->toString(), 'Value -100 N expected'); - } - - - /** - * test __toString - * expected string - */ - public function testForce_ToString() - { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $this->assertEquals('-100 N', $value->__toString(), 'Value -100 N expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testForceConversionList() - { - $value = new Zend_Measure_Force('-100',Zend_Measure_Force::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/FrequencyTest.php b/tests/Zend/Measure/FrequencyTest.php deleted file mode 100644 index cf476ae3d4cca0a59753dd2c791e2d63b5070967..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/FrequencyTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FrequencyTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Frequency - */ -require_once 'Zend/Measure/Frequency.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_FrequencyTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Frequency initialisation - * expected instance - */ - public function testFrequencyInit() - { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Frequency,'Zend_Measure_Frequency Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFrequencyUnknownType() - { - try { - $value = new Zend_Measure_Frequency('100','Frequency::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFrequencyUnknownValue() - { - try { - $value = new Zend_Measure_Frequency('novalue',Zend_Measure_Frequency::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testFrequencyUnknownLocale() - { - try { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testFrequencyNoLocale() - { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Frequency value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testFrequencyValuePositive() - { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Frequency value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testFrequencyValueNegative() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Frequency value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testFrequencyValueDecimal() - { - $value = new Zend_Measure_Frequency('-100,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Frequency value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testFrequencyValueDecimalSeperated() - { - $value = new Zend_Measure_Frequency('-100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Frequency Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testFrequencyValueString() - { - $value = new Zend_Measure_Frequency('string -100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Frequency Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testFrequencyEquality() - { - $value = new Zend_Measure_Frequency('string -100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $newvalue = new Zend_Measure_Frequency('otherstring -100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Frequency Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testFrequencyNoEquality() - { - $value = new Zend_Measure_Frequency('string -100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $newvalue = new Zend_Measure_Frequency('otherstring -100,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Frequency Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testFrequencySetPositive() - { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Frequency value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testFrequencySetNegative() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Frequency value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testFrequencySetDecimal() - { - $value = new Zend_Measure_Frequency('-100,200',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Frequency value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testFrequencySetDecimalSeperated() - { - $value = new Zend_Measure_Frequency('-100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Frequency Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testFrequencySetString() - { - $value = new Zend_Measure_Frequency('string -100.100,200',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Frequency Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testFrequencySetUnknownType() - { - try { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Frequency::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testFrequencySetUnknownValue() - { - try { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Frequency::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFrequencySetUnknownLocale() - { - try { - $value = new Zend_Measure_Frequency('100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Frequency::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testFrequencySetWithNoLocale() - { - $value = new Zend_Measure_Frequency('100', Zend_Measure_Frequency::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Frequency::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Frequency value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testFrequencySetType() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setType(Zend_Measure_Frequency::KILOHERTZ); - $this->assertEquals(Zend_Measure_Frequency::KILOHERTZ, $value->getType(), 'Zend_Measure_Frequency type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFrequencySetComputedType1() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::RADIAN_PER_HOUR,'de'); - $value->setType(Zend_Measure_Frequency::RPM); - $this->assertEquals(Zend_Measure_Frequency::RPM, $value->getType(), 'Zend_Measure_Frequency type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testFrequencySetComputedType2() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::RPM,'de'); - $value->setType(Zend_Measure_Frequency::RADIAN_PER_HOUR); - $this->assertEquals(Zend_Measure_Frequency::RADIAN_PER_HOUR, $value->getType(), 'Zend_Measure_Frequency type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testFrequencySetTypeFailed() - { - try { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $value->setType('Frequency::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testFrequencyToString() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals('-100 Hz', $value->toString(), 'Value -100 Hz expected'); - } - - - /** - * test __toString - * expected string - */ - public function testFrequency_ToString() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $this->assertEquals('-100 Hz', $value->__toString(), 'Value -100 Hz expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testFrequencyConversionList() - { - $value = new Zend_Measure_Frequency('-100',Zend_Measure_Frequency::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/IlluminationTest.php b/tests/Zend/Measure/IlluminationTest.php deleted file mode 100644 index 9fcc2889fc419f02508bb1ddb185f264b7285d36..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/IlluminationTest.php +++ /dev/null @@ -1,368 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IlluminationTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Illumination - */ -require_once 'Zend/Measure/Illumination.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_IlluminationTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Illumination initialisation - * expected instance - */ - public function testIlluminationInit() - { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Illumination,'Zend_Measure_Illumination Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testIlluminationUnknownType() - { - try { - $value = new Zend_Measure_Illumination('100','Illumination::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testIlluminationUnknownValue() - { - try { - $value = new Zend_Measure_Illumination('novalue',Zend_Measure_Illumination::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testIlluminationUnknownLocale() - { - try { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testIlluminationNoLocale() - { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Illumination value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testIlluminationValuePositive() - { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Illumination value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testIlluminationValueNegative() - { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Illumination value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testIlluminationValueDecimal() - { - $value = new Zend_Measure_Illumination('-100,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Illumination value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testIlluminationValueDecimalSeperated() - { - $value = new Zend_Measure_Illumination('-100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Illumination Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testIlluminationValueString() - { - $value = new Zend_Measure_Illumination('string -100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_v Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testIlluminationEquality() - { - $value = new Zend_Measure_Illumination('string -100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $newvalue = new Zend_Measure_Illumination('otherstring -100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Illumination Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testIlluminationNoEquality() - { - $value = new Zend_Measure_Illumination('string -100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $newvalue = new Zend_Measure_Illumination('otherstring -100,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Illumination Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testIlluminationSetPositive() - { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Illumination value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testIlluminationSetNegative() - { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Illumination value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testIlluminationSetDecimal() - { - $value = new Zend_Measure_Illumination('-100,200',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Illumination value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testIlluminationSetDecimalSeperated() - { - $value = new Zend_Measure_Illumination('-100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Illumination Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testIlluminationSetString() - { - $value = new Zend_Measure_Illumination('string -100.100,200',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Illumination Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testIlluminationSetUnknownType() - { - try { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Illumination::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testIlluminationSetUnknownValue() - { - try { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Illumination::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testIlluminationSetUnknownLocale() - { - try { - $value = new Zend_Measure_Illumination('100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Illumination::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testIlluminationSetWithNoLocale() - { - $value = new Zend_Measure_Illumination('100', Zend_Measure_Illumination::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Illumination::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Illumination value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testIlluminationSetType() - { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setType(Zend_Measure_Illumination::NOX); - $this->assertEquals(Zend_Measure_Illumination::NOX, $value->getType(), 'Zend_Measure_Illumination type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testIlluminationSetTypeFailed() - { - try { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $value->setType('Illumination::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testIlluminationToString() - { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals('-100 lx', $value->toString(), 'Value -100 lx expected'); - } - - - /** - * test __toString - * expected string - */ - public function testIllumination_ToString() - { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $this->assertEquals('-100 lx', $value->__toString(), 'Value -100 lx expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testIlluminationConversionList() - { - $value = new Zend_Measure_Illumination('-100',Zend_Measure_Illumination::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/LengthTest.php b/tests/Zend/Measure/LengthTest.php deleted file mode 100644 index b7358736e05bec7dbba8e7f69003ce966b4a574a..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/LengthTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LengthTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Length - */ -require_once 'Zend/Measure/Length.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_LengthTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Length initialisation - * expected instance - */ - public function testLengthInit() - { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Length,'Zend_Measure_Length Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testLengthUnknownType() - { - try { - $value = new Zend_Measure_Length('100','Length::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testLengthUnknownValue() - { - try { - $value = new Zend_Measure_Length('novalue',Zend_Measure_Length::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testLengthUnknownLocale() - { - try { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testLengthNoLocale() - { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Length value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testLengthValuePositive() - { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Length value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testLengthValueNegative() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Length value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testLengthValueDecimal() - { - $value = new Zend_Measure_Length('-100,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Length value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testLengthValueDecimalSeperated() - { - $value = new Zend_Measure_Length('-100.100,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Length Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testLengthValueString() - { - $value = new Zend_Measure_Length('string -100.100,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Length Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testLengthEquality() - { - $value = new Zend_Measure_Length('string -100.100,200',Zend_Measure_Length::STANDARD,'de'); - $newvalue = new Zend_Measure_Length('otherstring -100.100,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Length Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testLengthNoEquality() - { - $value = new Zend_Measure_Length('string -100.100,200',Zend_Measure_Length::STANDARD,'de'); - $newvalue = new Zend_Measure_Length('otherstring -100,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Length Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testLengthSetPositive() - { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Length value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testLengthSetNegative() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Length value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testLengthSetDecimal() - { - $value = new Zend_Measure_Length('-100,200',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Length value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testLengthSetDecimalSeperated() - { - $value = new Zend_Measure_Length('-100.100,200',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Length Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testLengthSetString() - { - $value = new Zend_Measure_Length('string -100.100,200',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Length Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testLengthSetUnknownType() - { - try { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Length::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testLengthSetUnknownValue() - { - try { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Length::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Exception $e) { - return; // Test OK - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testLengthSetUnknownLocale() - { - try { - $value = new Zend_Measure_Length('100',Zend_Measure_Length::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Length::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testLengthSetWithNoLocale() - { - $value = new Zend_Measure_Length('100', Zend_Measure_Length::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Length::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Length value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testLengthSetType() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $value->setType(Zend_Measure_Length::MILE); - $this->assertEquals(Zend_Measure_Length::MILE, $value->getType(), 'Zend_Measure_Length type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testLengthSetComputedType1() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $value->setType(Zend_Measure_Length::LINK); - $this->assertEquals(Zend_Measure_Length::LINK, $value->getType(), 'Zend_Measure_Length type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testLengthSetComputedType2() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::LINK,'de'); - $value->setType(Zend_Measure_Length::KEN); - $this->assertEquals(Zend_Measure_Length::KEN, $value->getType(), 'Zend_Measure_Length type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testLengthSetTypeFailed() - { - try { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $value->setType('Length::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testLengthToString() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals('-100 m', $value->toString(), 'Value -100 m expected'); - } - - - /** - * test __toString - * expected string - */ - public function testLength_ToString() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $this->assertEquals('-100 m', $value->__toString(), 'Value -100 m expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testLengthConversionList() - { - $value = new Zend_Measure_Length('-100',Zend_Measure_Length::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/LightnessTest.php b/tests/Zend/Measure/LightnessTest.php deleted file mode 100644 index 6c83cf59951e29efb07634532754330c56658758..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/LightnessTest.php +++ /dev/null @@ -1,368 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LightnessTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Lightness - */ -require_once 'Zend/Measure/Lightness.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_LightnessTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Lightness initialisation - * expected instance - */ - public function testLightnessInit() - { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Lightness,'Zend_Measure_Lightness Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testLightnessUnknownType() - { - try { - $value = new Zend_Measure_Lightness('100','Lightness::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testLightnessUnknownValue() - { - try { - $value = new Zend_Measure_Lightness('novalue',Zend_Measure_Lightness::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testLightnessUnknownLocale() - { - try { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testLightnessNoLocale() - { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Lightness value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testLightnessValuePositive() - { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Lightness value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testLightnessValueNegative() - { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Lightness value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testLightnessValueDecimal() - { - $value = new Zend_Measure_Lightness('-100,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Lightness value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testLightnessValueDecimalSeperated() - { - $value = new Zend_Measure_Lightness('-100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Lightness Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testLightnessValueString() - { - $value = new Zend_Measure_Lightness('string -100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Lightness Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testLightnessEquality() - { - $value = new Zend_Measure_Lightness('string -100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $newvalue = new Zend_Measure_Lightness('otherstring -100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Lightness Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testLightnessNoEquality() - { - $value = new Zend_Measure_Lightness('string -100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $newvalue = new Zend_Measure_Lightness('otherstring -100,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Lightness Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testLightnessSetPositive() - { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Lightness value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testLightnessSetNegative() - { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Lightness value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testLightnessSetDecimal() - { - $value = new Zend_Measure_Lightness('-100,200',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Lightness value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testLightnessSetDecimalSeperated() - { - $value = new Zend_Measure_Lightness('-100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Lightness Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testLightnessSetString() - { - $value = new Zend_Measure_Lightness('string -100.100,200',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Lightness Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testLightnessSetUnknownType() - { - try { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Lightness::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testLightnessSetUnknownValue() - { - try { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Lightness::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testLightnessSetUnknownLocale() - { - try { - $value = new Zend_Measure_Lightness('100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Lightness::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testLightnessSetWithNoLocale() - { - $value = new Zend_Measure_Lightness('100', Zend_Measure_Lightness::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Lightness::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Lightness value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testLightnessSetType() - { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setType(Zend_Measure_Lightness::STILB); - $this->assertEquals(Zend_Measure_Lightness::STILB, $value->getType(), 'Zend_Measure_Lightness type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testLightnessSetTypeFailed() - { - try { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $value->setType('Lightness::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testLightnessToString() - { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals('-100 cd/m²', $value->toString(), 'Value -100 cd/m² expected'); - } - - - /** - * test __toString - * expected string - */ - public function testLightness_ToString() - { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $this->assertEquals('-100 cd/m²', $value->__toString(), 'Value -100 cd/m² expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testLightnessConversionList() - { - $value = new Zend_Measure_Lightness('-100',Zend_Measure_Lightness::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/NumberTest.php b/tests/Zend/Measure/NumberTest.php deleted file mode 100644 index e2f71fccf7a834bbe2d7bb876736c28fcd515355..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/NumberTest.php +++ /dev/null @@ -1,260 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NumberTest.php 7047 2007-12-06 07:46:26Z thomas $ - */ - - -/** - * Zend_Measure_Number - */ -require_once 'Zend/Measure/Number.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_NumberTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Number initialisation - * expected instance - */ - public function testNumberInit() - { - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Number,'Zend_Measure_Number Object not returned'); - $value = new Zend_Measure_Number('100','de'); - $this->assertTrue($value instanceof Zend_Measure_Number,'Zend_Measure_Number Object not returned'); - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Number value expected'); - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Number value expected to be a positive integer'); - $value = new Zend_Measure_Number('-100',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Number value expected to be a negative integer'); - $value = new Zend_Measure_Number('-100,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Number value expected to be a decimal value'); - $value = new Zend_Measure_Number('-100.100,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(100100, $value->getValue(),'Zend_Measure_Number Object not returned'); - $value = new Zend_Measure_Number('string -100.100,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(100100, $value->getValue(),'Zend_Measure_Number Object not returned'); - - try { - $value = new Zend_Measure_Number('100','Number::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - try { - $value = new Zend_Measure_Number('novalue',Zend_Measure_Number::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - try { - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for equality - * expected true - */ - public function testNumberEquality() - { - $value = new Zend_Measure_Number('string -100.100,200',Zend_Measure_Number::STANDARD,'de'); - $newvalue = new Zend_Measure_Number('otherstring -100.100,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Number Object should be equal'); - - $value = new Zend_Measure_Number('string -100.100,200',Zend_Measure_Number::STANDARD,'de'); - $newvalue = new Zend_Measure_Number('otherstring -100,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Number Object should be not equal'); - } - - - /** - * test for setValue - * expected integer - */ - public function testNumberSetValue() - { - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Number value expected to be a positive integer'); - $value->setValue('-200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Number value expected to be a negative integer'); - $value->setValue('-200,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Number value expected to be a decimal value'); - $value->setValue('-200.200,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(200200, $value->getValue(),'Zend_Measure_Number Object not returned'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals(200200, $value->getValue(),'Zend_Measure_Number Object not returned'); - - try { - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Number::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - try { - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Number::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - try { - $value = new Zend_Measure_Number('100',Zend_Measure_Number::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Number::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - - $value->setValue('200', Zend_Measure_Number::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Number value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testNumberSetType() - { - $value = new Zend_Measure_Number('-100',Zend_Measure_Number::STANDARD,'de'); - $value->setType(Zend_Measure_Number::BINARY); - $this->assertEquals(Zend_Measure_Number::BINARY, $value->getType(), 'Zend_Measure_Number type expected'); - $value->setType(Zend_Measure_Number::ROMAN); - $this->assertEquals(Zend_Measure_Number::ROMAN, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1001020',Zend_Measure_Number::BINARY,'de'); - $value->setType(Zend_Measure_Number::HEXADECIMAL); - $this->assertEquals(Zend_Measure_Number::HEXADECIMAL, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('MCXVII',Zend_Measure_Number::ROMAN,'de'); - $value->setType(Zend_Measure_Number::HEXADECIMAL); - $this->assertEquals(Zend_Measure_Number::HEXADECIMAL, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('102122',Zend_Measure_Number::TERNARY,'de'); - $value->setType(Zend_Measure_Number::OCTAL); - $this->assertEquals(Zend_Measure_Number::OCTAL, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1032402',Zend_Measure_Number::QUATERNARY,'de'); - $value->setType(Zend_Measure_Number::QUINARY); - $this->assertEquals(Zend_Measure_Number::QUINARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1052402',Zend_Measure_Number::QUINARY,'de'); - $value->setType(Zend_Measure_Number::QUATERNARY); - $this->assertEquals(Zend_Measure_Number::QUATERNARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1632402',Zend_Measure_Number::SENARY,'de'); - $value->setType(Zend_Measure_Number::SEPTENARY); - $this->assertEquals(Zend_Measure_Number::SEPTENARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1632702', Zend_Measure_Number::SEPTENARY, 'de'); - $value->setType(Zend_Measure_Number::SENARY); - $this->assertEquals(Zend_Measure_Number::SENARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1832402',Zend_Measure_Number::NONARY,'de'); - $value->setType(Zend_Measure_Number::SEPTENARY); - $this->assertEquals(Zend_Measure_Number::SEPTENARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1632402',Zend_Measure_Number::DUODECIMAL,'de'); - $value->setType(Zend_Measure_Number::SEPTENARY); - $this->assertEquals(Zend_Measure_Number::SEPTENARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1234ACE',Zend_Measure_Number::HEXADECIMAL,'de'); - $value->setType(Zend_Measure_Number::TERNARY); - $this->assertEquals(Zend_Measure_Number::TERNARY, $value->getType(), 'Zend_Measure_Number type expected'); - - $value = new Zend_Measure_Number('1234075',Zend_Measure_Number::OCTAL,'de'); - $value->setType(Zend_Measure_Number::TERNARY); - $this->assertEquals(Zend_Measure_Number::TERNARY, $value->getType(), 'Zend_Measure_Number type expected'); - - try { - $value = new Zend_Measure_Number('-100',Zend_Measure_Number::STANDARD,'de'); - $value->setType('Number::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testNumberToString() - { - $value = new Zend_Measure_Number('-100',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals('100 ⑽', $value->toString(), 'Value 100 ⑽ expected'); - } - - - /** - * test __toString - * expected string - */ - public function testNumber_ToString() - { - $value = new Zend_Measure_Number('-100',Zend_Measure_Number::STANDARD,'de'); - $this->assertEquals('100 ⑽', $value->__toString(), 'Value 100 ⑽ expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testNumberConversionList() - { - $value = new Zend_Measure_Number('-100',Zend_Measure_Number::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } - - /** - * test convertTo - */ - public function testConvertTo() - { - $value = new Zend_Measure_Number('III',Zend_Measure_Number::ROMAN, 'en'); - $this->assertEquals('3 ⑽', $value->convertTo(Zend_Measure_Number::DECIMAL)); - - $value = new Zend_Measure_Number('XXV',Zend_Measure_Number::ROMAN, 'en'); - $this->assertEquals('25 ⑽', $value->convertTo(Zend_Measure_Number::DECIMAL)); - - $value = new Zend_Measure_Number('_X',Zend_Measure_Number::ROMAN, 'en'); - $this->assertEquals('10000 ⑽', $value->convertTo(Zend_Measure_Number::DECIMAL)); - } -} diff --git a/tests/Zend/Measure/PowerTest.php b/tests/Zend/Measure/PowerTest.php deleted file mode 100644 index 1b84b7aeee67a6336c571b32ca2c9770979cc567..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/PowerTest.php +++ /dev/null @@ -1,404 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PowerTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Power - */ -require_once 'Zend/Measure/Power.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_PowerTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Power initialisation - * expected instance - */ - public function testPowerInit() - { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Power,'Zend_Measure_Power Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testPowerUnknownType() - { - try { - $value = new Zend_Measure_Power('100','Power::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testPowerUnknownValue() - { - try { - $value = new Zend_Measure_Power('novalue',Zend_Measure_Power::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testPowerUnknownLocale() - { - try { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testPowerNoLocale() - { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Power value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testPowerValuePositive() - { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Power value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testPowerValueNegative() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Power value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testPowerValueDecimal() - { - $value = new Zend_Measure_Power('-100,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Power value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testPowerValueDecimalSeperated() - { - $value = new Zend_Measure_Power('-100.100,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Power Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testPowerValueString() - { - $value = new Zend_Measure_Power('string -100.100,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Power Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testPowerEquality() - { - $value = new Zend_Measure_Power('string -100.100,200',Zend_Measure_Power::STANDARD,'de'); - $newvalue = new Zend_Measure_Power('otherstring -100.100,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Power Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testPowerNoEquality() - { - $value = new Zend_Measure_Power('string -100.100,200',Zend_Measure_Power::STANDARD,'de'); - $newvalue = new Zend_Measure_Power('otherstring -100,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Power Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testPowerSetPositive() - { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Power value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testPowerSetNegative() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Power value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testPowerSetDecimal() - { - $value = new Zend_Measure_Power('-100,200',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Power value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testPowerSetDecimalSeperated() - { - $value = new Zend_Measure_Power('-100.100,200',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Power Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testPowerSetString() - { - $value = new Zend_Measure_Power('string -100.100,200',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Power Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testPowerSetUnknownType() - { - try { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Power::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testPowerSetUnknownValue() - { - try { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Power::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testPowerSetUnknownLocale() - { - try { - $value = new Zend_Measure_Power('100',Zend_Measure_Power::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Power::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testPowerSetWithNoLocale() - { - $value = new Zend_Measure_Power('100', Zend_Measure_Power::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Power::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Power value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testPowerSetType() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $value->setType(Zend_Measure_Power::CALORIE_PER_HOUR); - $this->assertEquals(Zend_Measure_Power::CALORIE_PER_HOUR, $value->getType(), 'Zend_Measure_Power type expected'); - } - - - /** - * test setting type2 - * expected new type - */ - public function testPowerSetType2() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::CALORIE_PER_HOUR,'de'); - $value->setType(Zend_Measure_Power::STANDARD); - $this->assertEquals(Zend_Measure_Power::STANDARD, $value->getType(), 'Zend_Measure_Power type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testPowerSetComputedType1() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::CALORIE_PER_HOUR,'de'); - $value->setType(Zend_Measure_Power::JOULE_PER_HOUR); - $this->assertEquals(Zend_Measure_Power::JOULE_PER_HOUR, $value->getType(), 'Zend_Measure_Power type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testPowerSetComputedType2() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::JOULE_PER_HOUR,'de'); - $value->setType(Zend_Measure_Power::CALORIE_PER_HOUR); - $this->assertEquals(Zend_Measure_Power::CALORIE_PER_HOUR, $value->getType(), 'Zend_Measure_Power type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testPowerSetTypeFailed() - { - try { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $value->setType('Power::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testPowerToString() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals('-100 W', $value->toString(), 'Value -100 W expected'); - } - - - /** - * test __toString - * expected string - */ - public function testPower_ToString() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $this->assertEquals('-100 W', $value->__toString(), 'Value -100 W expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testPowerConversionList() - { - $value = new Zend_Measure_Power('-100',Zend_Measure_Power::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/PressureTest.php b/tests/Zend/Measure/PressureTest.php deleted file mode 100644 index 619e7b2efe502af25271861222f28ea8e6dc5c73..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/PressureTest.php +++ /dev/null @@ -1,404 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PressureTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Pressure - */ -require_once 'Zend/Measure/Pressure.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_PressureTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Pressure initialisation - * expected instance - */ - public function testPressureInit() - { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Pressure,'Zend_Measure_Pressure Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testPressureUnknownType() - { - try { - $value = new Zend_Measure_Pressure('100','Pressure::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testPressureUnknownValue() - { - try { - $value = new Zend_Measure_Pressure('novalue',Zend_Measure_Pressure::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testPressureUnknownLocale() - { - try { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testPressureNoLocale() - { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Pressure value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testPressureValuePositive() - { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Pressure value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testPressureValueNegative() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Pressure value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testPressureValueDecimal() - { - $value = new Zend_Measure_Pressure('-100,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Pressure value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testPressureValueDecimalSeperated() - { - $value = new Zend_Measure_Pressure('-100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Pressure Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testPressureValueString() - { - $value = new Zend_Measure_Pressure('string -100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Pressure Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testPressureEquality() - { - $value = new Zend_Measure_Pressure('string -100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $newvalue = new Zend_Measure_Pressure('otherstring -100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Pressure Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testPressureNoEquality() - { - $value = new Zend_Measure_Pressure('string -100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $newvalue = new Zend_Measure_Pressure('otherstring -100,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Pressure Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testPressureSetPositive() - { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Pressure value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testPressureSetNegative() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Pressure value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testPressureSetDecimal() - { - $value = new Zend_Measure_Pressure('-100,200',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Pressure value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testPressureSetDecimalSeperated() - { - $value = new Zend_Measure_Pressure('-100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Pressure Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testPressureSetString() - { - $value = new Zend_Measure_Pressure('string -100.100,200',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Pressure Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testPressureSetUnknownType() - { - try { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Pressure::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testPressureSetUnknownValue() - { - try { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Pressure::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testPressureSetUnknownLocale() - { - try { - $value = new Zend_Measure_Pressure('100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Pressure::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testPressureSetWithNoLocale() - { - $value = new Zend_Measure_Pressure('100', Zend_Measure_Pressure::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Pressure::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Pressure value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testPressureSetType() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setType(Zend_Measure_Pressure::TON_PER_SQUARE_FOOT); - $this->assertEquals(Zend_Measure_Pressure::TON_PER_SQUARE_FOOT, $value->getType(), 'Zend_Measure_Pressure type expected'); - } - - - /** - * test setting type2 - * expected new type - */ - public function testPressureSetType2() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::TON_PER_SQUARE_FOOT,'de'); - $value->setType(Zend_Measure_Pressure::STANDARD); - $this->assertEquals(Zend_Measure_Pressure::STANDARD, $value->getType(), 'Zend_Measure_Pressure type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testPressureSetComputedType1() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::TON_PER_SQUARE_FOOT,'de'); - $value->setType(Zend_Measure_Pressure::TON_PER_SQUARE_INCH); - $this->assertEquals(Zend_Measure_Pressure::TON_PER_SQUARE_INCH, $value->getType(), 'Zend_Measure_Pressure type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testPressureSetComputedType2() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::TON_PER_SQUARE_INCH,'de'); - $value->setType(Zend_Measure_Pressure::TON_PER_SQUARE_FOOT); - $this->assertEquals(Zend_Measure_Pressure::TON_PER_SQUARE_FOOT, $value->getType(), 'Zend_Measure_Pressure type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testPressureSetTypeFailed() - { - try { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $value->setType('Pressure::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testPressureToString() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals('-100 N/m²', $value->toString(), 'Value -100 N/m² expected'); - } - - - /** - * test __toString - * expected string - */ - public function testPressure_ToString() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $this->assertEquals('-100 N/m²', $value->__toString(), 'Value -100 N/m² expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testPressureConversionList() - { - $value = new Zend_Measure_Pressure('-100',Zend_Measure_Pressure::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/SpeedTest.php b/tests/Zend/Measure/SpeedTest.php deleted file mode 100644 index e4d3b1fce2a957ae65ab8e2ecf34caf763571a0e..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/SpeedTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SpeedTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Speed - */ -require_once 'Zend/Measure/Speed.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_SpeedTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Speed initialisation - * expected instance - */ - public function testSpeedInit() - { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Speed,'Zend_Measure_Speed Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testSpeedUnknownType() - { - try { - $value = new Zend_Measure_Speed('100','Speed::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testSpeedUnknownValue() - { - try { - $value = new Zend_Measure_Speed('novalue',Zend_Measure_Speed::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testSpeedUnknownLocale() - { - try { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testSpeedNoLocale() - { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Speed value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testSpeedValuePositive() - { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Speed value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testSpeedValueNegative() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Speed value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testSpeedValueDecimal() - { - $value = new Zend_Measure_Speed('-100,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Speed value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testSpeedValueDecimalSeperated() - { - $value = new Zend_Measure_Speed('-100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Speed Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testSpeedValueString() - { - $value = new Zend_Measure_Speed('string -100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Speed Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testSpeedEquality() - { - $value = new Zend_Measure_Speed('string -100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $newvalue = new Zend_Measure_Speed('otherstring -100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Speed Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testSpeedNoEquality() - { - $value = new Zend_Measure_Speed('string -100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $newvalue = new Zend_Measure_Speed('otherstring -100,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Speed Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testSpeedSetPositive() - { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Speed value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testSpeedSetNegative() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Speed value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testSpeedSetDecimal() - { - $value = new Zend_Measure_Speed('-100,200',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Speed value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testSpeedSetDecimalSeperated() - { - $value = new Zend_Measure_Speed('-100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Speed Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testSpeedSetString() - { - $value = new Zend_Measure_Speed('string -100.100,200',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Speed Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testSpeedSetUnknownType() - { - try { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Speed::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testSpeedSetUnknownValue() - { - try { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Speed::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testSpeedSetUnknownLocale() - { - try { - $value = new Zend_Measure_Speed('100',Zend_Measure_Speed::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Speed::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testSpeedSetWithNoLocale() - { - $value = new Zend_Measure_Speed('100', Zend_Measure_Speed::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Speed::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Speed value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testSpeedSetType() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $value->setType(Zend_Measure_Speed::METER_PER_HOUR); - $this->assertEquals(Zend_Measure_Speed::METER_PER_HOUR, $value->getType(), 'Zend_Measure_Speed type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testSpeedSetComputedType1() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $value->setType(Zend_Measure_Speed::METER_PER_HOUR); - $this->assertEquals(Zend_Measure_Speed::METER_PER_HOUR, $value->getType(), 'Zend_Measure_Speed type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testSpeedSetComputedType2() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::METER_PER_HOUR,'de'); - $value->setType(Zend_Measure_Speed::STANDARD); - $this->assertEquals(Zend_Measure_Speed::STANDARD, $value->getType(), 'Zend_Measure_Speed type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testSpeedSetTypeFailed() - { - try { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $value->setType('Speed::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testSpeedToString() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals('-100 m/s', $value->toString(), 'Value -100 m/s expected'); - } - - - /** - * test __toString - * expected string - */ - public function testSpeed_ToString() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $this->assertEquals('-100 m/s', $value->__toString(), 'Value -100 m/s expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testSpeedConversionList() - { - $value = new Zend_Measure_Speed('-100',Zend_Measure_Speed::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/TemperatureTest.php b/tests/Zend/Measure/TemperatureTest.php deleted file mode 100644 index 68a84471811262e3aae09e6962ebf9667b8a2ceb..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/TemperatureTest.php +++ /dev/null @@ -1,406 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TemperatureTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Temperature - */ -require_once 'Zend/Measure/Temperature.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_TemperatureTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Temperature initialisation - * expected instance - */ - public function testTemperatureInit() - { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Temperature,'Zend_Measure_Temperature Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testTemperatureUnknownType() - { - try { - $value = new Zend_Measure_Temperature('100','Temperature::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testTemperatureUnknownValue() - { - try { - $value = new Zend_Measure_Temperature('novalue',Zend_Measure_Temperature::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testTemperatureUnknownLocale() - { - try { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testTemperatureNoLocale() - { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Temperature value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testTemperatureValuePositive() - { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Temperature value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testTemperatureValueNegative() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Temperature value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testTemperatureValueDecimal() - { - $value = new Zend_Measure_Temperature('-100,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Temperature value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testTemperatureValueDecimalSeperated() - { - $value = new Zend_Measure_Temperature('-100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Temperature Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testTemperatureValueString() - { - $value = new Zend_Measure_Temperature('string -100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Temperature Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testTemperatureEquality() - { - $value = new Zend_Measure_Temperature('string -100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $newvalue = new Zend_Measure_Temperature('otherstring -100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Temperature Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testTemperatureNoEquality() - { - $value = new Zend_Measure_Temperature('string -100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $newvalue = new Zend_Measure_Temperature('otherstring -100,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Temperature Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testTemperatureSetPositive() - { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Temperature value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testTemperatureSetNegative() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Temperature value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testTemperatureSetDecimal() - { - $value = new Zend_Measure_Temperature('-100,200',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Temperature value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testTemperatureSetDecimalSeperated() - { - $value = new Zend_Measure_Temperature('-100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Temperature Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testTemperatureSetString() - { - $value = new Zend_Measure_Temperature('string -100.100,200',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Temperature Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testTemperatureSetUnknownType() - { - try { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Temperature::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testTemperatureSetUnknownValue() - { - try { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Temperature::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testTemperatureSetUnknownLocale() - { - try { - $value = new Zend_Measure_Temperature('100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Temperature::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testTemperatureSetWithNoLocale() - { - $value = new Zend_Measure_Temperature('100', Zend_Measure_Temperature::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Temperature::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Temperature value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testTemperatureSetType() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setType(Zend_Measure_Temperature::KELVIN); - $this->assertEquals(Zend_Measure_Temperature::KELVIN, $value->getType(), 'Zend_Measure_Temperature type expected'); - } - - - /** - * test setting type - * expected new type - */ - public function testTemperatureSetType1() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::FAHRENHEIT,'de'); - $value->setType(Zend_Measure_Temperature::REAUMUR); - $this->assertEquals(Zend_Measure_Temperature::REAUMUR, $value->getType(), 'Zend_Measure_Temperature type expected'); - } - - - /** - * test setting type - * expected new type - */ - public function testTemperatureSetType2() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::REAUMUR,'de'); - $value->setType(Zend_Measure_Temperature::FAHRENHEIT); - $this->assertEquals(Zend_Measure_Temperature::FAHRENHEIT, $value->getType(), 'Zend_Measure_Temperature type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testTemperatureSetTypeFailed() - { - try { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $value->setType('Temperature::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testTemperatureToString() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals('-100 °K', $value->toString(), 'Value -100 °K expected'); - } - - - /** - * test __toString - * expected string - */ - public function testTemperature_ToString() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $this->assertEquals('-100 °K', $value->__toString(), 'Value -100 °K expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testTemperatureConversionList() - { - $value = new Zend_Measure_Temperature('-100',Zend_Measure_Temperature::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } - - - /** - * test Detail conversions which often fail - * - */ - public function testDetailConversion() - { - $unit= new Zend_Measure_Temperature(100, Zend_Measure_Temperature::KELVIN); - $this->assertSame('-279.67 °F', $unit->convertTo(Zend_Measure_Temperature::FAHRENHEIT)); - - $unit= new Zend_Measure_Temperature(100, Zend_Measure_Temperature::FAHRENHEIT); - $this->assertSame('310.93 °K', $unit->convertTo(Zend_Measure_Temperature::KELVIN)); - } -} diff --git a/tests/Zend/Measure/TimeTest.php b/tests/Zend/Measure/TimeTest.php deleted file mode 100644 index 604b3958efd55363c33d50d3ac9ed8781cb7b065..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/TimeTest.php +++ /dev/null @@ -1,385 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -/** - * Zend_Measure_Time - */ -require_once 'Zend/Measure/Time.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_TimeTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Time initialisation - * expected instance - */ - public function testTimeInit() - { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Time,'Zend_Measure_Time Object not returned'); - } - - /** - * test for exception unknown type - * expected exception - */ - public function testTimeUnknownType() - { - try { - $value = new Zend_Measure_Time('100','Time::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Exception $e) { - return true; // Test OK - } - } - - /** - * test for exception unknown value - * expected exception - */ - public function testTimeUnknownValue() - { - try { - $value = new Zend_Measure_Time('novalue',Zend_Measure_Time::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Exception $e) { - return true; // Test OK - } - } - - /** - * test for exception unknown locale - * expected root value - */ - public function testTimeUnknownLocale() - { - try { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Exception $e) { - return true; // Test OK - } - } - - /** - * test for standard locale - * expected integer - */ - public function testTimeNoLocale() - { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Time value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testTimeValuePositive() - { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Time value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testTimeValueNegative() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Time value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testTimeValueDecimal() - { - $value = new Zend_Measure_Time('-100,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Time value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testTimeValueDecimalSeperated() - { - $value = new Zend_Measure_Time('-100.100,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Time Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testTimeValueString() - { - $value = new Zend_Measure_Time('string -100.100,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Time Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testTimeEquality() - { - $value = new Zend_Measure_Time('string -100.100,200',Zend_Measure_Time::STANDARD,'de'); - $newvalue = new Zend_Measure_Time('otherstring -100.100,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Time Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testTimeNoEquality() - { - $value = new Zend_Measure_Time('string -100.100,200',Zend_Measure_Time::STANDARD,'de'); - $newvalue = new Zend_Measure_Time('otherstring -100,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Time Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testTimeSetPositive() - { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Time value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testTimeSetNegative() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Time value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testTimeSetDecimal() - { - $value = new Zend_Measure_Time('-100,200',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Time value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testTimeSetDecimalSeperated() - { - $value = new Zend_Measure_Time('-100.100,200',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Time Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testTimeSetString() - { - $value = new Zend_Measure_Time('string -100.100,200',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Time Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testTimeSetUnknownType() - { - try { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Time::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testTimeSetUnknownValue() - { - try { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Time::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Exception $e) { - return; // Test OK - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testTimeSetUnknownLocale() - { - try { - $value = new Zend_Measure_Time('100',Zend_Measure_Time::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Time::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Exception $e) { - return true; // Test OK - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testTimeSetWithNoLocale() - { - $value = new Zend_Measure_Time('100', Zend_Measure_Time::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Time::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Time value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testTimeSetType() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $value->setType(Zend_Measure_Time::MINUTE); - $this->assertEquals(Zend_Measure_Time::MINUTE, $value->getType(), 'Zend_Measure_Time type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testTimeSetComputedType1() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $value->setType(Zend_Measure_Time::YEAR); - $this->assertEquals(Zend_Measure_Time::YEAR, $value->getType(), 'Zend_Measure_Time type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testTimeSetComputedType2() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::YEAR,'de'); - $value->setType(Zend_Measure_Time::LEAPYEAR); - $this->assertEquals(Zend_Measure_Time::LEAPYEAR, $value->getType(), 'Zend_Measure_Time type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testTimeSetTypeFailed() - { - try { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $value->setType('Time::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testTimeToString() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals('-100 s', $value->toString(), 'Value -100 s expected'); - } - - - /** - * test __toString - * expected string - */ - public function testTime_ToString() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $this->assertEquals('-100 s', $value->__toString(), 'Value -100 s expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testTimeConversionList() - { - $value = new Zend_Measure_Time('-100',Zend_Measure_Time::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/TorqueTest.php b/tests/Zend/Measure/TorqueTest.php deleted file mode 100644 index 157df4f0163d30d5da9c1a2286e60839b0a3d270..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/TorqueTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TorqueTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Torque - */ -require_once 'Zend/Measure/Torque.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_TorqueTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Torque initialisation - * expected instance - */ - public function testTorqueInit() - { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Torque,'Zend_Measure_Torque Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testTorqueUnknownType() - { - try { - $value = new Zend_Measure_Torque('100','Torque::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testTorqueUnknownValue() - { - try { - $value = new Zend_Measure_Torque('novalue',Zend_Measure_Torque::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testTorqueUnknownLocale() - { - try { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testTorqueNoLocale() - { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Torque value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testTorqueValuePositive() - { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Torque value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testTorqueValueNegative() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Torque value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testTorqueValueDecimal() - { - $value = new Zend_Measure_Torque('-100,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Torque value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testTorqueValueDecimalSeperated() - { - $value = new Zend_Measure_Torque('-100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Torque Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testTorqueValueString() - { - $value = new Zend_Measure_Torque('string -100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Torque Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testTorqueEquality() - { - $value = new Zend_Measure_Torque('string -100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $newvalue = new Zend_Measure_Torque('otherstring -100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Torque Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testTorqueNoEquality() - { - $value = new Zend_Measure_Torque('string -100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $newvalue = new Zend_Measure_Torque('otherstring -100,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Torque Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testTorqueSetPositive() - { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Torque value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testTorqueSetNegative() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Torque value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testTorqueSetDecimal() - { - $value = new Zend_Measure_Torque('-100,200',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Torque value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testTorqueSetDecimalSeperated() - { - $value = new Zend_Measure_Torque('-100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Torque Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testTorqueSetString() - { - $value = new Zend_Measure_Torque('string -100.100,200',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Torque Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testTorqueSetUnknownType() - { - try { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Torque::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testTorqueSetUnknownValue() - { - try { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Torque::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testTorqueSetUnknownLocale() - { - try { - $value = new Zend_Measure_Torque('100',Zend_Measure_Torque::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Torque::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testTorqueSetWithNoLocale() - { - $value = new Zend_Measure_Torque('100', Zend_Measure_Torque::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Torque::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Torque value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testTorqueSetType() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $value->setType(Zend_Measure_Torque::NEWTON_CENTIMETER); - $this->assertEquals(Zend_Measure_Torque::NEWTON_CENTIMETER, $value->getType(), 'Zend_Measure_Torque type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testTorqueSetComputedType1() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $value->setType(Zend_Measure_Torque::POUND_INCH); - $this->assertEquals(Zend_Measure_Torque::POUND_INCH, $value->getType(), 'Zend_Measure_Torque type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testTorqueSetComputedType2() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::POUND_INCH,'de'); - $value->setType(Zend_Measure_Torque::STANDARD); - $this->assertEquals(Zend_Measure_Torque::STANDARD, $value->getType(), 'Zend_Measure_Torque type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testTorqueSetTypeFailed() - { - try { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $value->setType('Torque::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testTorqueToString() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals('-100 Nm', $value->toString(), 'Value -100 Nm expected'); - } - - - /** - * test __toString - * expected string - */ - public function testTorque_ToString() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $this->assertEquals('-100 Nm', $value->__toString(), 'Value -100 Nm expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testTorqueConversionList() - { - $value = new Zend_Measure_Torque('-100',Zend_Measure_Torque::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Viscosity/DynamicTest.php b/tests/Zend/Measure/Viscosity/DynamicTest.php deleted file mode 100644 index a717bdfa65eee56f0f1471a862a9dd78d4d95130..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Viscosity/DynamicTest.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Viscosity_Dynamic - */ -require_once 'Zend/Measure/Viscosity/Dynamic.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Viscosity_DynamicTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Mass initialisation - * expected instance - */ - public function testMassInit() - { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Viscosity_Dynamic,'Zend_Measure_Viscosity_Dynamic Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testViscosity_DynamicUnknownType() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('100','Viscosity_Dynamic::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testViscosity_DynamicUnknownValue() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('novalue',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testViscosity_DynamicUnknownLocale() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testViscosity_DynamicNoLocale() - { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Viscosity_Dynamic value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testViscosity_DynamicValuePositive() - { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testViscosity_DynamicValueNegative() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testViscosity_DynamicValueDecimal() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testViscosity_DynamicValueDecimalSeperated() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Viscosity_Dynamic Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testViscosity_DynamicValueString() - { - $value = new Zend_Measure_Viscosity_Dynamic('string -100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Viscosity_Dynamic Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testViscosity_DynamicEquality() - { - $value = new Zend_Measure_Viscosity_Dynamic('string -100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $newvalue = new Zend_Measure_Viscosity_Dynamic('otherstring -100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Viscosity_Dynamic Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testViscosity_DynamicNoEquality() - { - $value = new Zend_Measure_Viscosity_Dynamic('string -100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $newvalue = new Zend_Measure_Viscosity_Dynamic('otherstring -100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Viscosity_Dynamic Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testViscosity_DynamicSetPositive() - { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testViscosity_DynamicSetNegative() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testViscosity_DynamicSetDecimal() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testViscosity_DynamicSetDecimalSeperated() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Viscosity_Dynamic Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testViscosity_DynamicSetString() - { - $value = new Zend_Measure_Viscosity_Dynamic('string -100.100,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Viscosity_Dynamic Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testViscosity_DynamicSetUnknownType() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Viscosity_Dynamic::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testViscosity_DynamicSetUnknownValue() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testViscosity_DynamicSetUnknownLocale() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Viscosity_Dynamic::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testViscosity_DynamicSetWithNoLocale() - { - $value = new Zend_Measure_Viscosity_Dynamic('100', Zend_Measure_Viscosity_Dynamic::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Viscosity_Dynamic::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Viscosity_Dynamic value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testViscosity_DynamicSetType() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setType(Zend_Measure_Viscosity_Dynamic::POISE); - $this->assertEquals(Zend_Measure_Viscosity_Dynamic::POISE, $value->getType(), 'Zend_Measure_Viscosity_Dynamic type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testViscosity_DynamicSetComputedType1() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setType(Zend_Measure_Viscosity_Dynamic::KILOGRAM_PER_METER_HOUR); - $this->assertEquals(Zend_Measure_Viscosity_Dynamic::KILOGRAM_PER_METER_HOUR, $value->getType(), 'Zend_Measure_Viscosity_Dynamic type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testViscosity_DynamicSetComputedType2() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::KILOGRAM_PER_METER_HOUR,'de'); - $value->setType(Zend_Measure_Viscosity_Dynamic::STANDARD); - $this->assertEquals(Zend_Measure_Viscosity_Dynamic::STANDARD, $value->getType(), 'Zend_Measure_Viscosity_Dynamic type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testViscosity_DynamicSetTypeFailed() - { - try { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $value->setType('Viscosity_Dynamic::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testViscosity_DynamicToString() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals('-100 kg/ms', $value->toString(), 'Value -100 kg/ms expected'); - } - - - /** - * test __toString - * expected string - */ - public function testViscosity_Dynamic_ToString() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $this->assertEquals('-100 kg/ms', $value->__toString(), 'Value -100 kg/ms expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testViscosity_DynamicConversionList() - { - $value = new Zend_Measure_Viscosity_Dynamic('-100',Zend_Measure_Viscosity_Dynamic::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/Viscosity/KinematicTest.php b/tests/Zend/Measure/Viscosity/KinematicTest.php deleted file mode 100644 index ad075adda34bd34bf5b522b760382ef59bb5061e..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/Viscosity/KinematicTest.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * @package Zend_Measure - * @subpackage UnitTests - */ - - -/** - * Zend_Measure_Viscosity_Kinematic - */ -require_once 'Zend/Measure/Viscosity/Kinematic.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_Viscosity_KinematicTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Mass initialisation - * expected instance - */ - public function testMassInit() - { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Viscosity_Kinematic,'Zend_Measure_Viscosity_Kinematic Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testViscosity_KinematicUnknownType() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('100','Viscosity_Kinematic::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testViscosity_KinematicUnknownValue() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('novalue',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testViscosity_KinematicUnknownLocale() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testViscosity_KinematicNoLocale() - { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Viscosity_Kinematic value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testViscosity_KinematicValuePositive() - { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testViscosity_KinematicValueNegative() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testViscosity_KinematicValueDecimal() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testViscosity_KinematicValueDecimalSeperated() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Viscosity_Kinematic Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testViscosity_KinematicValueString() - { - $value = new Zend_Measure_Viscosity_Kinematic('string -100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Viscosity_Kinematic Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testViscosity_KinematicEquality() - { - $value = new Zend_Measure_Viscosity_Kinematic('string -100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $newvalue = new Zend_Measure_Viscosity_Kinematic('otherstring -100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Viscosity_Kinematic Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testViscosity_KinematicNoEquality() - { - $value = new Zend_Measure_Viscosity_Kinematic('string -100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $newvalue = new Zend_Measure_Viscosity_Kinematic('otherstring -100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Viscosity_Kinematic Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testViscosity_KinematicSetPositive() - { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testViscosity_KinematicSetNegative() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testViscosity_KinematicSetDecimal() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testViscosity_KinematicSetDecimalSeperated() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Viscosity_Kinematic Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testViscosity_KinematicSetString() - { - $value = new Zend_Measure_Viscosity_Kinematic('string -100.100,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Viscosity_Kinematic Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testViscosity_KinematicSetUnknownType() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Viscosity_Kinematic::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testViscosity_KinematicSetUnknownValue() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testViscosity_KinematicSetUnknownLocale() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Viscosity_Kinematic::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testViscosity_KinematicSetWithNoLocale() - { - $value = new Zend_Measure_Viscosity_Kinematic('100', Zend_Measure_Viscosity_Kinematic::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Viscosity_Kinematic::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Viscosity_Kinematic value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testViscosity_KinematicSetType() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setType(Zend_Measure_Viscosity_Kinematic::LENTOR); - $this->assertEquals(Zend_Measure_Viscosity_Kinematic::LENTOR, $value->getType(), 'Zend_Measure_Viscosity_Kinematic type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testViscosity_KinematicSetComputedType1() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setType(Zend_Measure_Viscosity_Kinematic::LITER_PER_CENTIMETER_DAY); - $this->assertEquals(Zend_Measure_Viscosity_Kinematic::LITER_PER_CENTIMETER_DAY, $value->getType(), 'Zend_Measure_Viscosity_Kinematic type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testViscosity_KinematicSetComputedType2() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::LITER_PER_CENTIMETER_DAY,'de'); - $value->setType(Zend_Measure_Viscosity_Kinematic::STANDARD); - $this->assertEquals(Zend_Measure_Viscosity_Kinematic::STANDARD, $value->getType(), 'Zend_Measure_Viscosity_Kinematic type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testViscosity_KinematicSetTypeFailed() - { - try { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $value->setType('Viscosity_Kinematic::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testViscosity_KinematicToString() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals('-100 m²/s', $value->toString(), 'Value -100 m²/s expected'); - } - - - /** - * test __toString - * expected string - */ - public function testViscosity_Kinematic_ToString() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $this->assertEquals('-100 m²/s', $value->__toString(), 'Value -100 m²/s expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testViscosity_KinematicConversionList() - { - $value = new Zend_Measure_Viscosity_Kinematic('-100',Zend_Measure_Viscosity_Kinematic::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/VolumeTest.php b/tests/Zend/Measure/VolumeTest.php deleted file mode 100644 index 61319d8bdc38cec60ca9c518f66597d277fce65a..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/VolumeTest.php +++ /dev/null @@ -1,398 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: VolumeTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Volume - */ -require_once 'Zend/Measure/Volume.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_VolumeTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - } - - - /** - * test for Volume initialisation - * expected instance - */ - public function testVolumeInit() - { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Volume,'Zend_Measure_Volume Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testVolumeUnknownType() - { - try { - $value = new Zend_Measure_Volume('100','Volume::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testVolumeUnknownValue() - { - try { - $value = new Zend_Measure_Volume('novalue',Zend_Measure_Volume::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testVolumeUnknownLocale() - { - try { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testVolumeNoLocale() - { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Volume value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testVolumeValuePositive() - { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Volume value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testVolumeValueNegative() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Volume value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testVolumeValueDecimal() - { - $value = new Zend_Measure_Volume('-100,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Volume value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testVolumeValueDecimalSeperated() - { - $value = new Zend_Measure_Volume('-100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Volume Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testVolumeValueString() - { - $value = new Zend_Measure_Volume('string -100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Volume Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testVolumeEquality() - { - $value = new Zend_Measure_Volume('string -100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $newvalue = new Zend_Measure_Volume('otherstring -100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Volume Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testVolumeNoEquality() - { - $value = new Zend_Measure_Volume('string -100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $newvalue = new Zend_Measure_Volume('otherstring -100,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Volume Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testVolumeSetPositive() - { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Volume value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testVolumeSetNegative() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Volume value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testVolumeSetDecimal() - { - $value = new Zend_Measure_Volume('-100,200',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Volume value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testVolumeSetDecimalSeperated() - { - $value = new Zend_Measure_Volume('-100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Volume Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testVolumeSetString() - { - $value = new Zend_Measure_Volume('string -100.100,200',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Volume Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testVolumeSetUnknownType() - { - try { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Volume::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testVolumeSetUnknownValue() - { - try { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Volume::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testVolumeSetUnknownLocale() - { - try { - $value = new Zend_Measure_Volume('100',Zend_Measure_Volume::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Volume::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testVolumeSetWithNoLocale() - { - $value = new Zend_Measure_Volume('100', Zend_Measure_Volume::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Volume::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Volume value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testVolumeSetType() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $value->setType(Zend_Measure_Volume::CORD); - $this->assertEquals(Zend_Measure_Volume::CORD, $value->getType(), 'Zend_Measure_Volume type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testVolumeSetComputedType1() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $value->setType(Zend_Measure_Volume::CUBIC_YARD); - $this->assertEquals(Zend_Measure_Volume::CUBIC_YARD, $value->getType(), 'Zend_Measure_Volume type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testVolumeSetComputedType2() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::CUBIC_YARD,'de'); - $value->setType(Zend_Measure_Volume::STANDARD); - $this->assertEquals(Zend_Measure_Volume::STANDARD, $value->getType(), 'Zend_Measure_Volume type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testVolumeSetTypeFailed() - { - try { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $value->setType('Volume::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testVolumeToString() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals('-100 m³', $value->toString(), 'Value -100 m³ expected'); - } - - - /** - * test __toString - * expected string - */ - public function testVolume_ToString() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $this->assertEquals('-100 m³', $value->__toString(), 'Value -100 m³ expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testVolumeConversionList() - { - $value = new Zend_Measure_Volume('-100',Zend_Measure_Volume::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Measure/WeightTest.php b/tests/Zend/Measure/WeightTest.php deleted file mode 100644 index fda3085b6d518da5471eae2d41a8942bf2540cfb..0000000000000000000000000000000000000000 --- a/tests/Zend/Measure/WeightTest.php +++ /dev/null @@ -1,392 +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_Measure - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: WeightTest.php 6799 2007-11-09 22:44:42Z thomas $ - */ - - -/** - * Zend_Measure_Weight - */ -require_once 'Zend/Measure/Weight.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Measure - * @subpackage UnitTests - */ -class Zend_Measure_WeightTest extends PHPUnit_Framework_TestCase -{ - /** - * test for Weight initialisation - * expected instance - */ - public function testWeightInit() - { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'de'); - $this->assertTrue($value instanceof Zend_Measure_Weight,'Zend_Measure_Weight Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testWeightUnknownType() - { - try { - $value = new Zend_Measure_Weight('100','Weight::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testWeightUnknownValue() - { - try { - $value = new Zend_Measure_Weight('novalue',Zend_Measure_Weight::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected root value - */ - public function testWeightUnknownLocale() - { - try { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for standard locale - * expected integer - */ - public function testWeightNoLocale() - { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD); - $this->assertEquals(100, $value->getValue(),'Zend_Measure_Weight value expected'); - } - - - /** - * test for positive value - * expected integer - */ - public function testWeightValuePositive() - { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(100, $value->getValue(), 'Zend_Measure_Weight value expected to be a positive integer'); - } - - - /** - * test for negative value - * expected integer - */ - public function testWeightValueNegative() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-100, $value->getValue(), 'Zend_Measure_Weight value expected to be a negative integer'); - } - - - /** - * test for decimal value - * expected float - */ - public function testWeightValueDecimal() - { - $value = new Zend_Measure_Weight('-100,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-100.200, $value->getValue(), 'Zend_Measure_Weight value expected to be a decimal value'); - } - - - /** - * test for decimal seperated value - * expected float - */ - public function testWeightValueDecimalSeperated() - { - $value = new Zend_Measure_Weight('-100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Weight Object not returned'); - } - - - /** - * test for string with integrated value - * expected float - */ - public function testWeightValueString() - { - $value = new Zend_Measure_Weight('string -100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-100100.200, $value->getValue(),'Zend_Measure_Weight Object not returned'); - } - - - /** - * test for equality - * expected true - */ - public function testWeightEquality() - { - $value = new Zend_Measure_Weight('string -100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $newvalue = new Zend_Measure_Weight('otherstring -100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertTrue($value->equals($newvalue),'Zend_Measure_Weight Object should be equal'); - } - - - /** - * test for no equality - * expected false - */ - public function testWeightNoEquality() - { - $value = new Zend_Measure_Weight('string -100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $newvalue = new Zend_Measure_Weight('otherstring -100,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertFalse($value->equals($newvalue),'Zend_Measure_Weight Object should be not equal'); - } - - - /** - * test for set positive value - * expected integer - */ - public function testWeightSetPositive() - { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Weight value expected to be a positive integer'); - } - - - /** - * test for set negative value - * expected integer - */ - public function testWeightSetNegative() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('-200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-200, $value->getValue(), 'Zend_Measure_Weight value expected to be a negative integer'); - } - - - /** - * test for set decimal value - * expected float - */ - public function testWeightSetDecimal() - { - $value = new Zend_Measure_Weight('-100,200',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('-200,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-200.200, $value->getValue(), 'Zend_Measure_Weight value expected to be a decimal value'); - } - - - /** - * test for set decimal seperated value - * expected float - */ - public function testWeightSetDecimalSeperated() - { - $value = new Zend_Measure_Weight('-100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('-200.200,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Weight Object not returned'); - } - - - /** - * test for set string with integrated value - * expected float - */ - public function testWeightSetString() - { - $value = new Zend_Measure_Weight('string -100.100,200',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('otherstring -200.200,200',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals(-200200.200, $value->getValue(),'Zend_Measure_Weight Object not returned'); - } - - - /** - * test for exception unknown type - * expected exception - */ - public function testWeightSetUnknownType() - { - try { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('otherstring -200.200,200','Weight::UNKNOWN','de'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown value - * expected exception - */ - public function testWeightSetUnknownValue() - { - try { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('novalue',Zend_Measure_Weight::STANDARD,'de'); - $this->fail('Exception expected because of empty value'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testWeightSetUnknownLocale() - { - try { - $value = new Zend_Measure_Weight('100',Zend_Measure_Weight::STANDARD,'de'); - $value->setValue('200',Zend_Measure_Weight::STANDARD,'nolocale'); - $this->fail('Exception expected because of unknown locale'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test for exception unknown locale - * expected exception - */ - public function testMeasureSetWithNoLocale() - { - $value = new Zend_Measure_Weight('100', Zend_Measure_Weight::STANDARD, 'de'); - $value->setValue('200', Zend_Measure_Weight::STANDARD); - $this->assertEquals(200, $value->getValue(), 'Zend_Measure_Weight value expected to be a positive integer'); - } - - - /** - * test setting type - * expected new type - */ - public function testWeightSetType() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $value->setType(Zend_Measure_Weight::GRAM); - $this->assertEquals(Zend_Measure_Weight::GRAM, $value->getType(), 'Zend_Measure_Weight type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testWeightSetComputedType1() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::DRAM,'de'); - $value->setType(Zend_Measure_Weight::OUNCE); - $this->assertEquals(Zend_Measure_Weight::OUNCE, $value->getType(), 'Zend_Measure_Weight type expected'); - } - - - /** - * test setting computed type - * expected new type - */ - public function testWeightSetComputedType2() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::OUNCE,'de'); - $value->setType(Zend_Measure_Weight::DRAM); - $this->assertEquals(Zend_Measure_Weight::DRAM, $value->getType(), 'Zend_Measure_Weight type expected'); - } - - - /** - * test setting unknown type - * expected new type - */ - public function testWeightSetTypeFailed() - { - try { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $value->setType('Weight::UNKNOWN'); - $this->fail('Exception expected because of unknown type'); - } catch (Zend_Measure_Exception $e) { - // success - } - } - - - /** - * test toString - * expected string - */ - public function testWeightToString() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals('-100 kg', $value->toString(), 'Value -100 kg expected'); - } - - - /** - * test __toString - * expected string - */ - public function testWeight_ToString() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $this->assertEquals('-100 kg', $value->__toString(), 'Value -100 kg expected'); - } - - - /** - * test getConversionList - * expected array - */ - public function testWeightConversionList() - { - $value = new Zend_Measure_Weight('-100',Zend_Measure_Weight::STANDARD,'de'); - $unit = $value->getConversionList(); - $this->assertTrue(is_array($unit), 'Array expected'); - } -} diff --git a/tests/Zend/Memory/AccessControllerTest.php b/tests/Zend/Memory/AccessControllerTest.php deleted file mode 100644 index c668accb8e4b3539155b7bba124171a340efdb6d..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/AccessControllerTest.php +++ /dev/null @@ -1,123 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AccessControllerTest.php 8468 2008-02-29 17:56:34Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Memory */ -require_once 'Zend/Memory.php'; - -/** - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_Container_AccessControllerTest extends PHPUnit_Framework_TestCase -{ - /** - * Memory manager, used for tests - * - * @var Zend_Memory_Manager - */ - private $_memoryManager = null; - - /** - * Retrieve memory manager - * - */ - private function _getMemoryManager() - { - if ($this->_memoryManager === null) { - $backendOptions = array('cache_dir' => dirname(__FILE__) . '/_files/'); // Directory where to put the cache files - $this->_memoryManager = Zend_Memory::factory('File', $backendOptions); - } - - return $this->_memoryManager; - } - - - - /** - * tests the Movable memory container object creation - */ - public function testCreation() - { - $memoryManager = $this->_getMemoryManager(); - $memObject = $memoryManager->create('012345678'); - - $this->assertTrue($memObject instanceof Zend_Memory_AccessController); - } - - - /** - * tests the value access methods - */ - public function testValueAccess() - { - $memoryManager = $this->_getMemoryManager(); - $memObject = $memoryManager->create('0123456789'); - - // getRef() method - $this->assertEquals($memObject->getRef(), '0123456789'); - - $valueRef = &$memObject->getRef(); - $valueRef[3] = '_'; - $this->assertEquals($memObject->getRef(), '012_456789'); - - if (version_compare(PHP_VERSION, '5.2') < 0) { - // Skip next tests for PHP versions before 5.2 - return; - } - - // value property - $this->assertEquals((string)$memObject->value, '012_456789'); - - $memObject->value[7] = '_'; - $this->assertEquals((string)$memObject->value, '012_456_89'); - - $memObject->value = 'another value'; - $this->assertTrue($memObject->value instanceof Zend_Memory_Value); - $this->assertEquals((string)$memObject->value, 'another value'); - } - - - /** - * tests lock()/unlock()/isLocked() functions - */ - public function testLock() - { - $memoryManager = $this->_getMemoryManager(); - $memObject = $memoryManager->create('012345678'); - - $this->assertFalse((boolean)$memObject->isLocked()); - - $memObject->lock(); - $this->assertTrue((boolean)$memObject->isLocked()); - - $memObject->unlock(); - $this->assertFalse((boolean)$memObject->isLocked()); - } -} diff --git a/tests/Zend/Memory/AllTests.php b/tests/Zend/Memory/AllTests.php deleted file mode 100644 index 52293d9a39408be3c9945aa4ea1d2ad1d56c999e..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/AllTests.php +++ /dev/null @@ -1,71 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8468 2008-02-29 17:56:34Z darby $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Memory_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/Memory/MemoryTest.php'; -require_once 'Zend/Memory/ValueTest.php'; -require_once 'Zend/Memory/MovableTest.php'; -require_once 'Zend/Memory/LockedTest.php'; -require_once 'Zend/Memory/AccessControllerTest.php'; -require_once 'Zend/Memory/MemoryManagerTest.php'; - -/** - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Memory'); - - $suite->addTestSuite('Zend_Memory_MemoryTest'); - $suite->addTestSuite('Zend_Memory_ValueTest'); - $suite->addTestSuite('Zend_Memory_Container_MovableTest'); - $suite->addTestSuite('Zend_Memory_Container_LockedTest'); - $suite->addTestSuite('Zend_Memory_Container_AccessControllerTest'); - $suite->addTestSuite('Zend_Memory_MemoryManagerTest'); - - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Memory_AllTests::main') { - Zend_Memory_AllTests::main(); -} diff --git a/tests/Zend/Memory/LockedTest.php b/tests/Zend/Memory/LockedTest.php deleted file mode 100644 index eaa79f14597e66f598e07925dd6957562b3960cb..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/LockedTest.php +++ /dev/null @@ -1,105 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LockedTest.php 8468 2008-02-29 17:56:34Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Memory */ -require_once 'Zend/Memory.php'; - -/** - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_Container_LockedTest extends PHPUnit_Framework_TestCase -{ - /** - * tests the Movable memory container object creation - */ - public function testCreation() - { - $memObject = new Zend_Memory_Container_Locked('0123456789'); - - $this->assertTrue($memObject instanceof Zend_Memory_Container_Locked); - } - - - /** - * tests the value access methods - */ - public function testValueAccess() - { - $memObject = new Zend_Memory_Container_Locked('0123456789'); - - // getRef() method - $this->assertEquals($memObject->getRef(), '0123456789'); - - $valueRef = &$memObject->getRef(); - $valueRef[3] = '_'; - $this->assertEquals($memObject->getRef(), '012_456789'); - - // value property - $this->assertEquals((string)$memObject->value, '012_456789'); - - $memObject->value[7] = '_'; - $this->assertEquals((string)$memObject->value, '012_456_89'); - - $memObject->value = 'another value'; - $this->assertEquals((string)$memObject->value, 'another value'); - } - - - /** - * tests lock()/unlock()/isLocked() functions - */ - public function testLock() - { - $memObject = new Zend_Memory_Container_Locked('0123456789'); - - // It's always locked - $this->assertTrue((boolean)$memObject->isLocked()); - - $memObject->lock(); - $this->assertTrue((boolean)$memObject->isLocked()); - - $memObject->unlock(); - // It's always locked - $this->assertTrue((boolean)$memObject->isLocked()); - } - - /** - * tests the touch() method - */ - public function testTouch() - { - $memObject = new Zend_Memory_Container_Locked('0123456789'); - - $memObject->touch(); - - // Nothing to check - } -} diff --git a/tests/Zend/Memory/MemoryManagerTest.php b/tests/Zend/Memory/MemoryManagerTest.php deleted file mode 100644 index 60e19c2966d4a553e1f6aaa7d1375ff0ea3443a4..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/MemoryManagerTest.php +++ /dev/null @@ -1,146 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MemoryManagerTest.php 8468 2008-02-29 17:56:34Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Memory */ -require_once 'Zend/Memory.php'; - -/** - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_MemoryManagerTest extends PHPUnit_Framework_TestCase -{ - - /** - * tests the Memory Manager creation - * - */ - public function testCreation() - { - /** 'File' backend */ - $backendOptions = array('cache_dir' => dirname(__FILE__) . '/_files/'); // Directory where to put the cache files - $memoryManager = Zend_Memory::factory('File', $backendOptions); - $this->assertTrue($memoryManager instanceof Zend_Memory_Manager); - } - - - /** - * tests the Memory Manager settings - */ - public function testSettings() - { - /** 'File' backend */ - $backendOptions = array('cache_dir' => dirname(__FILE__) . '/_files/'); // Directory where to put the cache files - $memoryManager = Zend_Memory::factory('File', $backendOptions); - - // MemoryLimit - $memoryManager->setMemoryLimit(2*1024*1024 /* 2Mb */); - $this->assertEquals($memoryManager->getMemoryLimit(), 2*1024*1024); - - // MinSize - $this->assertEquals($memoryManager->getMinSize(), 16*1024); // check for default value (16K) - $memoryManager->setMinSize(4*1024 /* 4Kb */); - $this->assertEquals($memoryManager->getMinSize(), 4*1024); - } - - - /** - * tests the memory Objects creation - */ - public function testCreate() - { - /** 'File' backend */ - $backendOptions = array('cache_dir' => dirname(__FILE__) . '/_files/'); // Directory where to put the cache files - $memoryManager = Zend_Memory::factory('File', $backendOptions); - - $memObject1 = $memoryManager->create('Value of object 1'); - $this->assertTrue($memObject1 instanceof Zend_Memory_AccessController); - $this->assertEquals($memObject1->getRef(), 'Value of object 1'); - - $memObject2 = $memoryManager->create(); - $this->assertTrue($memObject2 instanceof Zend_Memory_AccessController); - $this->assertEquals($memObject2->getRef(), ''); - - $memObject3 = $memoryManager->createLocked('Value of object 3'); - $this->assertTrue($memObject3 instanceof Zend_Memory_Container_Locked); - $this->assertEquals($memObject3->getRef(), 'Value of object 3'); - - $memObject4 = $memoryManager->createLocked(); - $this->assertTrue($memObject4 instanceof Zend_Memory_Container_Locked); - $this->assertEquals($memObject4->getRef(), ''); - } - - - /** - * tests the processing of data - */ - public function testProcessing() - { - /** 'File' backend */ - $backendOptions = array('cache_dir' => dirname(__FILE__) . '/_files/'); // Directory where to put the cache files - $memoryManager = Zend_Memory::factory('File', $backendOptions); - - $memoryManager->setMinSize(256); - $memoryManager->setMemoryLimit(1024*32); - - $memObjects = array(); - for ($count = 0; $count < 64; $count++) { - $memObject = $memoryManager->create(str_repeat((string)($count % 10), 1024) /* 1K */); - $memObjects[] = $memObject; - } - - for ($count = 0; $count < 64; $count += 2) { - if (version_compare(PHP_VERSION, '5.2') < 0) { - $value = $memObjects[$count]->getRef(); - $this->assertEquals($value[16], (string)($count % 10)); - } else { - $this->assertEquals($memObjects[$count]->value[16], (string)($count % 10)); - } - } - - for ($count = 63; $count > 0; $count -= 2) { - if (version_compare(PHP_VERSION, '5.2') < 0) { - $value = &$memObjects[$count]->getRef(); - $value[16] = '_'; - } else { - $memObjects[$count]->value[16] = '_'; - } - } - - for ($count = 1; $count < 64; $count += 2) { - if (version_compare(PHP_VERSION, '5.2') < 0) { - $value = $memObjects[$count]->getRef(); - $this->assertEquals($value[16], '_'); - } else { - $this->assertEquals($memObjects[$count]->value[16], '_'); - } - } - } -} diff --git a/tests/Zend/Memory/MemoryTest.php b/tests/Zend/Memory/MemoryTest.php deleted file mode 100644 index b1dd7d0614e3afe3633c40e5cc6b713a293d7bf1..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/MemoryTest.php +++ /dev/null @@ -1,59 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MemoryTest.php 8468 2008-02-29 17:56:34Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Memory */ -require_once 'Zend/Memory.php'; - -/** - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_MemoryTest extends PHPUnit_Framework_TestCase -{ - - /** - * tests the Memory Manager creation - * - */ - public function testCreation() - { - /** 'None' backend */ - $memoryManager = Zend_Memory::factory('None'); - $this->assertTrue($memoryManager instanceof Zend_Memory_Manager); - unset($memoryManager); - - /** 'File' backend */ - $backendOptions = array('cache_dir' => dirname(__FILE__) . '/_files/'); // Directory where to put the cache files - $memoryManager = Zend_Memory::factory('File', $backendOptions); - $this->assertTrue($memoryManager instanceof Zend_Memory_Manager); - unset($memoryManager); - } -} - diff --git a/tests/Zend/Memory/MovableTest.php b/tests/Zend/Memory/MovableTest.php deleted file mode 100644 index 29f56b460839368a3648a23dd0654c28e8659e52..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/MovableTest.php +++ /dev/null @@ -1,182 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MovableTest.php 8468 2008-02-29 17:56:34Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Memory */ -require_once 'Zend/Memory.php'; - -/** - * Memory value container - * - * (Should be presented for value object) - * - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_Manager_Dummy extends Zend_Memory_Manager -{ - /** @var boolean */ - public $processUpdatePassed = false; - - /** @var integer */ - public $processedId; - - /** @var Zend_Memory_Container_Movable */ - public $processedObject; - - /** - * Dummy object constructor - */ - public function __construct() - { - // Do nothing - } - - /** - * Dummy value update callback method - */ - public function processUpdate(Zend_Memory_Container_Movable $container, $id) - { - $this->processUpdatePassed = true; - $this->processedId = $id; - $this->processedObject = $container; - } -} - - -/** - * @package Zend_Memory - * @subpackage UnitTests - */ -class Zend_Memory_Container_MovableTest extends PHPUnit_Framework_TestCase -{ - /** - * tests the Movable memory container object creation - */ - public function testCreation() - { - $memoryManager = new Zend_Memory_Manager_Dummy(); - $memObject = new Zend_Memory_Container_Movable($memoryManager, 10, '0123456789'); - - $this->assertTrue($memObject instanceof Zend_Memory_Container_Movable); - } - - - /** - * tests the value access methods - */ - public function testValueAccess() - { - $memoryManager = new Zend_Memory_Manager_Dummy(); - $memObject = new Zend_Memory_Container_Movable($memoryManager, 10, '0123456789'); - - // getRef() method - $this->assertEquals($memObject->getRef(), '0123456789'); - - $valueRef = &$memObject->getRef(); - $valueRef[3] = '_'; - $this->assertEquals($memObject->getRef(), '012_456789'); - - if (version_compare(PHP_VERSION, '5.2') < 0) { - // Skip next tests for PHP versions before 5.2 - return; - } - - // value property - $this->assertEquals((string)$memObject->value, '012_456789'); - - $memObject->value[7] = '_'; - $this->assertEquals((string)$memObject->value, '012_456_89'); - - $memObject->value = 'another value'; - $this->assertTrue($memObject->value instanceof Zend_Memory_Value); - $this->assertEquals((string)$memObject->value, 'another value'); - } - - - /** - * tests lock()/unlock()/isLocked() functions - */ - public function testLock() - { - $memoryManager = new Zend_Memory_Manager_Dummy(); - $memObject = new Zend_Memory_Container_Movable($memoryManager, 10, '0123456789'); - - $this->assertFalse((boolean)$memObject->isLocked()); - - $memObject->lock(); - $this->assertTrue((boolean)$memObject->isLocked()); - - $memObject->unlock(); - $this->assertFalse((boolean)$memObject->isLocked()); - } - - /** - * tests the touch() method - */ - public function testTouch() - { - $memoryManager = new Zend_Memory_Manager_Dummy(); - $memObject = new Zend_Memory_Container_Movable($memoryManager, 10, '0123456789'); - - $this->assertFalse($memoryManager->processUpdatePassed); - - $memObject->touch(); - - $this->assertTrue($memoryManager->processUpdatePassed); - $this->assertTrue($memoryManager->processedObject === $memObject); - $this->assertEquals($memoryManager->processedId, 10); - } - - /** - * tests the value update tracing - */ - public function testValueUpdateTracing() - { - if (version_compare(PHP_VERSION, '5.2') < 0) { - // Skip next tests for PHP versions before 5.2 - return; - } - - $memoryManager = new Zend_Memory_Manager_Dummy(); - $memObject = new Zend_Memory_Container_Movable($memoryManager, 10, '0123456789'); - - // startTrace() method is usually invoked by memory manager, when it need to be notified - // about value update - $memObject->startTrace(); - - $this->assertFalse($memoryManager->processUpdatePassed); - - $memObject->value[6] = '_'; - - $this->assertTrue($memoryManager->processUpdatePassed); - $this->assertTrue($memoryManager->processedObject === $memObject); - $this->assertEquals($memoryManager->processedId, 10); - } -} diff --git a/tests/Zend/Memory/ValueTest.php b/tests/Zend/Memory/ValueTest.php deleted file mode 100644 index a19e65922ce3f511e6f4374e1e9f9803f34344cc..0000000000000000000000000000000000000000 --- a/tests/Zend/Memory/ValueTest.php +++ /dev/null @@ -1,124 +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_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ValueTest.php 8468 2008-02-29 17:56:34Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Memory */ -require_once 'Zend/Memory.php'; - -/** - * @category Zend - * @package Zend_Memory - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Memory_Container_Movable_Dummy extends Zend_Memory_Container_Movable -{ - /** - * Dummy object constructor - */ - public function __construct() - { - // Do nothing - } - - /** - * Dummy value update callback method - */ - public function processUpdate() - { - // Do nothing - } -} - - -/** - * @package Zend_Memory - * @subpackage UnitTests - */ -class Zend_Memory_ValueTest extends PHPUnit_Framework_TestCase -{ - /** - * tests the Value object creation - */ - public function testCreation() - { - $valueObject = new Zend_Memory_Value('data data data ...', new Zend_Memory_Container_Movable_Dummy()); - $this->assertTrue($valueObject instanceof Zend_Memory_Value); - $this->assertEquals($valueObject->getRef(), 'data data data ...'); - } - - - /** - * tests the value reference retrieval - */ - public function testGetRef() - { - $valueObject = new Zend_Memory_Value('0123456789', new Zend_Memory_Container_Movable_Dummy()); - $valueRef = &$valueObject->getRef(); - $valueRef[3] = '_'; - - $this->assertEquals($valueObject->getRef(), '012_456789'); - } - - - /** - * tests the __toString() functionality - */ - public function testToString() - { - $valueObject = new Zend_Memory_Value('0123456789', new Zend_Memory_Container_Movable_Dummy()); - $this->assertEquals($valueObject->__toString(), '0123456789'); - - if (version_compare(PHP_VERSION, '5.2') < 0) { - // Skip following tests for PHP versions before 5.2 - return; - } - - $this->assertEquals(strlen($valueObject), 10); - $this->assertEquals((string)$valueObject, '0123456789'); - } - - /** - * tests the access through ArrayAccess methods - */ - public function testArrayAccess() - { - if (version_compare(PHP_VERSION, '5.2') < 0) { - // Skip following tests for PHP versions before 5.2 - return; - } - - $valueObject = new Zend_Memory_Value('0123456789', new Zend_Memory_Container_Movable_Dummy()); - $this->assertEquals($valueObject[8], '8'); - - $valueObject[2] = '_'; - $this->assertEquals((string)$valueObject, '01_3456789'); - - $valueObject[10] = '_'; - $this->assertEquals((string)$valueObject, '01_3456789_'); - } -} diff --git a/tests/Zend/Mime/AllTests.php b/tests/Zend/Mime/AllTests.php deleted file mode 100644 index dc697cc61685485e2a2e15b2e1b61ff20faca4ac..0000000000000000000000000000000000000000 --- a/tests/Zend/Mime/AllTests.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Mime_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Mime/PartTest.php'; -require_once 'Zend/Mime/MessageTest.php'; - -class Zend_Mime_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Mime'); - - $suite->addTestSuite('Zend_Mime_PartTest'); - $suite->addTestSuite('Zend_Mime_MessageTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Mime_AllTests::main') { - Zend_Mime_AllTests::main(); -} diff --git a/tests/Zend/Mime/MessageTest.php b/tests/Zend/Mime/MessageTest.php deleted file mode 100644 index 5efd22cbdd420965d415094243914a14090e1343..0000000000000000000000000000000000000000 --- a/tests/Zend/Mime/MessageTest.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** - * @package Zend_Mime - * @subpackage UnitTests - */ - - -/** - * Zend_Mime_Message - */ -require_once 'Zend/Mime/Message.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Mime - * @subpackage UnitTests - */ -class Zend_Mime_MessageTest extends PHPUnit_Framework_TestCase -{ - - public function testMultiPart() - { - $msg = new Zend_Mime_Message(); // No Parts - $this->assertFalse($msg->isMultiPart()); - } - - public function testSetGetParts() - { - $msg = new Zend_Mime_Message(); // No Parts - $p = $msg->getParts(); - $this->assertTrue(is_array($p)); - $this->assertTrue(count($p) == 0); - - $p2 = array(); - $p2[] = new Zend_Mime_Part('This is a test'); - $p2[] = new Zend_Mime_Part('This is another test'); - $msg->setParts($p2); - $p = $msg->getParts(); - $this->assertTrue(is_array($p)); - $this->assertTrue(count($p) == 2); - } - - public function testGetMime() - { - $msg = new Zend_Mime_Message(); // No Parts - $m = $msg->getMime(); - $this->assertType('Zend_Mime', $m); - - $msg = new Zend_Mime_Message(); // No Parts - $mime = new Zend_Mime('1234'); - $msg->setMime($mime); - $m2 = $msg->getMime(); - $this->assertType('Zend_Mime', $m2); - $this->assertEquals('1234', $m2->boundary()); - } - - public function testGenerate() - { - $msg = new Zend_Mime_Message(); // No Parts - $p1 = new Zend_Mime_Part('This is a test'); - $p2 = new Zend_Mime_Part('This is another test'); - $msg->addPart($p1); - $msg->addPart($p2); - $res = $msg->generateMessage(); - $mime = $msg->getMime(); - $boundary = $mime->boundary(); - $p1 = strpos($res, $boundary); - // $boundary must appear once for every mime part - $this->assertTrue($p1 !== false); - if ($p1) { - $p2 = strpos($res, $boundary, $p1 + strlen($boundary)); - $this->assertTrue($p2 !== false); - } - // check if the two test messages appear: - $this->assertTrue(strpos($res, 'This is a test') !== false); - $this->assertTrue(strpos($res, 'This is another test') !== false); - // ... more in ZMailTest - } - - /** - * check if decoding a string into a Zend_Mime_Message object works - * - */ - public function testDecodeMimeMessage() - { - $text = <<<EOD -This is a message in Mime Format. If you see this, your mail reader does not support this format. - ---=_af4357ef34b786aae1491b0a2d14399f -Content-Type: application/octet-stream -Content-Transfer-Encoding: 8bit - -This is a test ---=_af4357ef34b786aae1491b0a2d14399f -Content-Type: image/gif -Content-Transfer-Encoding: base64 -Content-ID: <12> - -This is another test ---=_af4357ef34b786aae1491b0a2d14399f-- -EOD; - $res = Zend_Mime_Message::createFromMessage($text, '=_af4357ef34b786aae1491b0a2d14399f'); - - $parts = $res->getParts(); - $this->assertEquals(2, count($parts)); - - $part1 = $parts[0]; - $this->assertEquals('application/octet-stream', $part1->type); - $this->assertEquals('8bit', $part1->encoding); - - $part2 = $parts[1]; - $this->assertEquals('image/gif', $part2->type); - $this->assertEquals('base64', $part2->encoding); - $this->assertEquals('12', $part2->id); - } -} diff --git a/tests/Zend/Mime/PartTest.php b/tests/Zend/Mime/PartTest.php deleted file mode 100644 index e9b6889022401015100141e9f296614badf362aa..0000000000000000000000000000000000000000 --- a/tests/Zend/Mime/PartTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/** - * @package Zend_Mime - * @subpackage UnitTests - */ - - -/** - * Zend_Mime_Part - */ -require_once 'Zend/Mime/Part.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @package Zend_Mime - * @subpackage UnitTests - */ -class Zend_Mime_PartTest extends PHPUnit_Framework_TestCase -{ - /** - * MIME part test object - * - * @var Zend_Mime_Part - */ - protected $_part = null; - protected $_testText; - - protected function setUp() - { - $this->_testText = 'safdsafsaölg öögdöö sdöjgösdjgöldögksdögjösdfgödsjögjsdögjödfsjgödsfjödjsög kjhdkj ' - . 'fgaskjfdh gksjhgjkdh gjhfsdghdhgksdjhg'; - $this->part = new Zend_Mime_Part($this->_testText); - $this->part->encoding = Zend_Mime::ENCODING_BASE64; - $this->part->type = "text/plain"; - $this->part->filename = 'test.txt'; - $this->part->disposition = 'attachment'; - $this->part->charset = 'iso8859-1'; - $this->part->id = '4711'; - } - - public function testHeaders() - { - $expectedHeaders = array('Content-Type: text/plain', - 'Content-Transfer-Encoding: ' . Zend_Mime::ENCODING_BASE64, - 'Content-Disposition: attachment', - 'filename="test.txt"', - 'charset="iso8859-1"', - 'Content-ID: <4711>'); - - $actual = $this->part->getHeaders(); - - foreach ($expectedHeaders as $expected) { - $this->assertContains($expected, $actual); - } - } - - public function testContentEncoding() - { - // Test with base64 encoding - $content = $this->part->getContent(); - $this->assertEquals($this->_testText, base64_decode($content)); - // Test with quotedPrintable Encoding: - $this->part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; - $content = $this->part->getContent(); - $this->assertEquals($this->_testText, quoted_printable_decode($content)); - // Test with 8Bit encoding - $this->part->encoding = Zend_Mime::ENCODING_8BIT; - $content = $this->part->getContent(); - $this->assertEquals($this->_testText, $content); - } - - public function testStreamEncoding() - { - $testfile = realpath(__FILE__); - $original = file_get_contents($testfile); - - // Test Base64 - $fp = fopen($testfile,'rb'); - $this->assertTrue(is_resource($fp)); - $part = new Zend_Mime_Part($fp); - $part->encoding = Zend_Mime::ENCODING_BASE64; - $fp2 = $part->getEncodedStream(); - $this->assertTrue(is_resource($fp2)); - $encoded = stream_get_contents($fp2); - fclose($fp); - $this->assertEquals(base64_decode($encoded),$original); - - // test QuotedPrintable - $fp = fopen($testfile,'rb'); - $this->assertTrue(is_resource($fp)); - $part = new Zend_Mime_Part($fp); - $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; - $fp2 = $part->getEncodedStream(); - $this->assertTrue(is_resource($fp2)); - $encoded = stream_get_contents($fp2); - fclose($fp); - $this->assertEquals(quoted_printable_decode($encoded),$original); - } -} diff --git a/tests/Zend/MimeTest.php b/tests/Zend/MimeTest.php deleted file mode 100644 index 049c3827d20aec90418add1f001bb17dbdafdedc..0000000000000000000000000000000000000000 --- a/tests/Zend/MimeTest.php +++ /dev/null @@ -1,106 +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_Mime - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** Zend_Mail */ -require_once 'Zend/Mail.php'; - -/** Zend_Mime */ -require_once 'Zend/Mime.php'; - -/** PHPUnit test case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_MailTest */ -require_once dirname(__FILE__) . '/MailTest.php'; - -/** - * @category Zend - * @package Zend_Mime - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_MimeTest extends PHPUnit_Framework_TestCase -{ - public function testBoundary() - { - // check boundary for uniqueness - $m1 = new Zend_Mime(); - $m2 = new Zend_Mime(); - $this->assertNotEquals($m1->boundary(), $m2->boundary()); - - // check instantiating with arbitrary boundary string - $myBoundary = 'mySpecificBoundary'; - $m3 = new Zend_Mime($myBoundary); - $this->assertEquals($m3->boundary(), $myBoundary); - - } - - public function testIsPrintable_notPrintable() - { - $this->assertFalse(Zend_Mime::isPrintable('Test with special chars: �����')); - } - - public function testIsPrintable_isPrintable() - { - $this->assertTrue(Zend_Mime::isPrintable('Test without special chars')); - } - - public function testQP() - { - $text = "This is a cool Test Text with special chars: ����\n" - . "and with multiple lines���� some of the Lines are long, long" - . ", long, long, long, long, long, long, long, long, long, long" - . ", long, long, long, long, long, long, long, long, long, long" - . ", long, long, long, long, long, long, long, long, long, long" - . ", long, long, long, long and with ����"; - - $qp = Zend_Mime::encodeQuotedPrintable($text); - $this->assertEquals(quoted_printable_decode($qp), $text); - } - - public function testBase64() - { - $content = str_repeat("\x88\xAA\xAF\xBF\x29\x88\xAA\xAF\xBF\x29\x88\xAA\xAF", 4); - $encoded = Zend_Mime::encodeBase64($content); - $this->assertEquals($content, base64_decode($encoded)); - } - - public function testZf1058WhitespaceAtEndOfBodyCausesInfiniteLoop() - { - $mail = new Zend_Mail(); - $mail->setSubject('my subject'); - $mail->setBodyText("my body\r\n\r\n...after two newlines\r\n "); - $mail->setFrom('test@email.com'); - $mail->addTo('test@email.com'); - - // test with generic transport - $mock = new Zend_Mail_Transport_Sendmail_Mock(); - $mail->send($mock); - $body = quoted_printable_decode($mock->body); - $this->assertContains("my body\r\n\r\n...after two newlines", $body, $body); - } -} diff --git a/tests/Zend/OpenId/AllTests.php b/tests/Zend/OpenId/AllTests.php deleted file mode 100644 index 1e36b1d9b2b704ed080e4cc67d81db97165be57f..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/AllTests.php +++ /dev/null @@ -1,64 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_OpenId_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/OpenId/ConsumerTest.php'; -require_once 'Zend/OpenId/Consumer/Storage/FileTest.php'; -require_once 'Zend/OpenId/ProviderTest.php'; -require_once 'Zend/OpenId/Provider/Storage/FileTest.php'; -require_once 'Zend/OpenId/Provider/User/SessionTest.php'; -require_once 'Zend/OpenId/ExtensionTest.php'; -require_once 'Zend/OpenId/Extension/SregTest.php'; - -class Zend_OpenId_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_OpenId'); - - $suite->addTestSuite('Zend_OpenId_ConsumerTest'); - $suite->addTestSuite('Zend_OpenId_Consumer_Storage_FileTest'); - $suite->addTestSuite('Zend_OpenId_ProviderTest'); - $suite->addTestSuite('Zend_OpenId_Provider_Storage_FileTest'); - $suite->addTestSuite('Zend_OpenId_Provider_User_SessionTest'); - $suite->addTestSuite('Zend_OpenId_ExtensionTest'); - $suite->addTestSuite('Zend_OpenId_Extension_SregTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_OpenId_AllTests::main') { - Zend_OpenId_AllTests::main(); -} diff --git a/tests/Zend/OpenId/Consumer/Storage/FileTest.php b/tests/Zend/OpenId/Consumer/Storage/FileTest.php deleted file mode 100644 index 9c87045a7762050af52a8224aebec75a5a2f0a39..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/Consumer/Storage/FileTest.php +++ /dev/null @@ -1,247 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FileTest.php 9248 2008-04-18 20:40:44Z darby $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** - * @see Zend_OpenId_Consumer_Storage_File - */ -require_once 'Zend/OpenId/Consumer/Storage/File.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_Consumer_Storage_FileTest extends PHPUnit_Framework_TestCase -{ - const URL = "http://www.myopenid.com/"; - const HANDLE = "d41d8cd98f00b204e9800998ecf8427e"; - const MAC_FUNC = "sha256"; - const SECRET = "4fa03202081808bd19f92b667a291873"; - - const ID = "http://id.myopenid.com/"; - const REAL_ID = "http://real_id.myopenid.com/"; - const SERVER = "http://www.myopenid.com/"; - const SERVER2 = "http://www.myopenid2.com/"; - const VERSION = 1.0; - - /** - * testing __construct - * - */ - public function testConstruct() - { - $tmp = dirname(__FILE__)."/_files"; - $dir = $tmp . '/openid_consumer'; - @rmdir($dir); - $storage = new Zend_OpenId_Consumer_Storage_File($dir); - $this->assertTrue( is_dir($dir) ); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return; - } - - chmod($dir, 0); - $dir2 = $dir . '/test'; - try { - $storage = new Zend_OpenId_Consumer_Storage_File($dir2); - $ex = null; - } catch (Exception $e) { - $ex = $e; - } - $this->assertTrue( $ex instanceof Zend_OpenId_Exception ); - $this->assertSame( Zend_OpenId_Exception::ERROR_STORAGE, $ex->getCode() ); - $this->assertContains( 'Cannot access storage directory', $ex->getMessage() ); - chmod($dir, 0777); - $this->assertFalse( is_dir($dir2) ); - @rmdir($dir); - } - - /** - * testing getAssociation - * - */ - public function testGetAssociation() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delAssociation(self::URL); - $this->assertTrue( $storage->addAssociation(self::URL, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - $this->assertTrue( $storage->getAssociation(self::URL, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( self::HANDLE, $handle ); - $this->assertSame( self::MAC_FUNC, $macFunc ); - $this->assertSame( self::SECRET, $secret ); - $this->assertSame( $expiresIn, $expires ); - $this->assertTrue( $storage->delAssociation(self::URL) ); - $this->assertFalse( $storage->getAssociation(self::URL, $handle, $macFunc, $secret, $expires) ); - - $tmp = dirname(__FILE__)."/_files"; - $dir = $tmp . '/openid_consumer'; - @rmdir($dir); - $storage = new Zend_OpenId_Consumer_Storage_File($dir); - $this->assertTrue( is_dir($dir) ); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return; - } - - chmod($dir, 0); - $this->assertFalse( $storage->addAssociation(self::URL, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - chmod($dir, 0777); - @rmdir($dir); - } - - /** - * testing getAssociationByHandle - * - */ - public function testGetAssociationByHandle() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delAssociation(self::URL); - $this->assertTrue( $storage->addAssociation(self::URL, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - $this->assertTrue( $storage->getAssociationByHandle(self::HANDLE, $url, $macFunc, $secret, $expires) ); - $this->assertSame( self::URL, $url ); - $this->assertSame( self::MAC_FUNC, $macFunc ); - $this->assertSame( self::SECRET, $secret ); - $this->assertSame( $expiresIn, $expires ); - $this->assertTrue( $storage->delAssociation(self::URL) ); - $this->assertFalse( $storage->getAssociationByHandle(self::HANDLE, $url, $macFunc, $secret, $expires) ); - } - - /** - * testing getAssociation - * - */ - public function testGetAssociationExpiratin() - { - $expiresIn = time() + 1; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delAssociation(self::URL); - $this->assertTrue( $storage->addAssociation(self::URL, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - sleep(2); - $this->assertFalse( $storage->getAssociation(self::URL, $handle, $macFunc, $secret, $expires) ); - } - - /** - * testing getAssociationByHandle - * - */ - public function testGetAssociationByHandleExpiration() - { - $expiresIn = time() + 1; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delAssociation(self::URL); - $this->assertTrue( $storage->addAssociation(self::URL, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - sleep(2); - $this->assertFalse( $storage->getAssociationByHandle(self::HANDLE, $url, $macFunc, $secret, $expires) ); - } - - /** - * testing getDiscoveryInfo - * - */ - public function testGetDiscoveryInfo() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, self::VERSION, $expiresIn) ); - $this->assertTrue( $storage->getDiscoveryInfo(self::ID, $realId, $server, $version, $expires) ); - $this->assertSame( self::REAL_ID, $realId ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( self::VERSION, $version ); - $this->assertSame( $expiresIn, $expires ); - $this->assertTrue( $storage->delDiscoveryInfo(self::ID) ); - $this->assertFalse( $storage->getDiscoveryInfo(self::ID, $realId, $server, $version, $expires) ); - - $tmp = dirname(__FILE__)."/_files"; - $dir = $tmp . '/openid_consumer'; - @rmdir($dir); - $storage = new Zend_OpenId_Consumer_Storage_File($dir); - $this->assertTrue( is_dir($dir) ); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return; - } - - chmod($dir, 0); - $this->assertFalse( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, self::VERSION, $expiresIn) ); - chmod($dir, 0777); - @rmdir($dir); - } - - /** - * testing getDiscoveryInfo - * - */ - public function testGetDiscoveryInfoExpiration() - { - $expiresIn = time() + 1; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->delDiscoveryInfo(self::ID); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, self::VERSION, $expiresIn) ); - sleep(2); - $this->assertFalse( $storage->getDiscoveryInfo(self::ID, $realId, $server, $version, $expires) ); - } - - /** - * testing isUniqueNonce - * - */ - public function testIsUniqueNonce() - { - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files"); - $storage->purgeNonces(); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '1') ); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '2') ); - $this->assertFalse( $storage->isUniqueNonce(self::SERVER, '1') ); - $this->assertFalse( $storage->isUniqueNonce(self::SERVER, '2') ); - $storage->purgeNonces(); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '1') ); - sleep(2); - $date = @date("r", time()); - sleep(2); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '2') ); - $storage->purgeNonces($date); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '1') ); - $this->assertFalse( $storage->isUniqueNonce(self::SERVER, '2') ); - $storage->purgeNonces(); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '1') ); - sleep(2); - $date = time(); - sleep(2); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '2') ); - $storage->purgeNonces($date); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '1') ); - $this->assertFalse( $storage->isUniqueNonce(self::SERVER, '2') ); - $storage->purgeNonces(); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER, '1') ); - $this->assertTrue( $storage->isUniqueNonce(self::SERVER2, '1') ); - $storage->purgeNonces(); - } -} diff --git a/tests/Zend/OpenId/ConsumerTest.php b/tests/Zend/OpenId/ConsumerTest.php deleted file mode 100644 index 8dfc0a34ff4a2591f2df265e07d14105054c4dea..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/ConsumerTest.php +++ /dev/null @@ -1,1037 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ConsumerTest.php 11879 2008-10-11 19:46:33Z alexander $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId/Consumer.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * Zend_OpenId_ResponseHelper - */ -require_once 'Zend/OpenId/ResponseHelper.php'; - -/** - * Zend_OpenId_Consumer_Storage_File - */ -require_once 'Zend/OpenId/Consumer/Storage/File.php'; - -/** - * Zend_OpenId_Extensions_Sreg - */ -require_once 'Zend/OpenId/Extension/Sreg.php'; - -/** - * Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_ConsumerTest extends PHPUnit_Framework_TestCase -{ - const ID = "http://id.myopenid.com/"; - const REAL_ID = "http://real_id.myopenid.com/"; - const SERVER = "http://www.myopenid.com/"; - - const HANDLE = "d41d8cd98f00b204e9800998ecf8427e"; - const MAC_FUNC = "sha256"; - const SECRET = "4fa03202081808bd19f92b667a291873"; - - /** - * testing login - * - */ - public function testLogin() - { - $expiresIn = time() + 600; - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $storage->delDiscoveryInfo(self::ID); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn) ); - $storage->delAssociation(self::SERVER); - $this->assertTrue( $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - - $response = new Zend_OpenId_ResponseHelper(true); - $consumer = new Zend_OpenId_Consumer($storage); - $this->assertTrue( $consumer->login(self::ID, null, null, null, $response) ); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - - // Test user defined return_to and trust_root - $response = new Zend_OpenId_ResponseHelper(true); - $consumer = new Zend_OpenId_Consumer($storage); - $this->assertTrue( $consumer->login(self::ID, "http://www.zf-test.com/return.php", "http://www.zf-test.com/trust.php", null, $response) ); - $headers = $response->getHeaders(); - $url = $headers[0]['value']; - $url = parse_url($url); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Freturn.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftrust.php', $query['openid.trust_root'] ); - - $storage->delDiscoveryInfo(self::ID); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 2.0, $expiresIn) ); - - // Test login with OpenID 2.0 - $response = new Zend_OpenId_ResponseHelper(true); - $consumer = new Zend_OpenId_Consumer($storage); - $this->assertTrue( $consumer->login(self::ID, "http://www.zf-test.com/return.php", "http://www.zf-test.com/trust.php", null, $response) ); - $headers = $response->getHeaders(); - $url = $headers[0]['value']; - $url = parse_url($url); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 7, count($query) ); - $this->assertSame( 'http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0', $query['openid.ns'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Freturn.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftrust.php', $query['openid.realm'] ); - - // Test login with SREG extension - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>false)); - $response = new Zend_OpenId_ResponseHelper(true); - $consumer = new Zend_OpenId_Consumer($storage); - $this->assertTrue( $consumer->login(self::ID, "http://www.zf-test.com/return.php", "http://www.zf-test.com/trust.php", $ext, $response) ); - $headers = $response->getHeaders(); - $url = $headers[0]['value']; - $url = parse_url($url); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 9, count($query) ); - $this->assertSame( 'http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0', $query['openid.ns'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Freturn.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftrust.php', $query['openid.realm'] ); - $this->assertSame( 'nickname', $query['openid.sreg.required'] ); - $this->assertSame( 'email', $query['openid.sreg.optional'] ); - - // Test login in dumb mode - $storage->delAssociation(self::SERVER); - $response = new Zend_OpenId_ResponseHelper(true); - $consumer = new Zend_OpenId_Consumer($storage, true); - $this->assertTrue( $consumer->login(self::ID, "http://www.zf-test.com/return.php", "http://www.zf-test.com/trust.php", null, $response) ); - $headers = $response->getHeaders(); - $url = $headers[0]['value']; - $url = parse_url($url); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0', $query['openid.ns'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Freturn.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftrust.php', $query['openid.realm'] ); - - $storage->delDiscoveryInfo(self::ID); - } - - /** - * testing check - * - */ - public function testCheck() - { - $expiresIn = time() + 600; - - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $storage->delDiscoveryInfo(self::ID); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn) ); - $storage->delAssociation(self::SERVER); - $this->assertTrue( $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - - $response = new Zend_OpenId_ResponseHelper(true); - $consumer = new Zend_OpenId_Consumer($storage); - $this->assertTrue( $consumer->check(self::ID, null, null, null, $response) ); - $headers = $response->getHeaders(); - $this->assertSame( '', $response->getBody() ); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $url = $headers[0]['value']; - $url = parse_url($url); - $this->assertSame( "http", $url['scheme'] ); - $this->assertSame( "www.myopenid.com", $url['host'] ); - $this->assertSame( "/", $url['path'] ); - $q = explode("&", $url['query']); - $query = array(); - foreach($q as $var) { - if (list($key, $val) = explode("=", $var, 2)) { - $query[$key] = $val; - } - } - $this->assertTrue( is_array($query) ); - $this->assertSame( 6, count($query) ); - $this->assertSame( 'checkid_immediate', $query['openid.mode'] ); - $this->assertSame( 'http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity'] ); - $this->assertSame( 'http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to'] ); - $this->assertSame( 'http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root'] ); - - $storage->delDiscoveryInfo(self::ID); - $storage->delAssociation(self::SERVER); - } - - /** - * testing _getAssociation - * - */ - public function testGetAssociation() - { - $expiresIn = time() + 600; - - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $storage->delAssociation(self::SERVER); - $consumer = new Zend_OpenId_ConsumerHelper($storage); - $this->assertFalse( $consumer->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertTrue( $storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - $this->assertTrue( $consumer->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( self::HANDLE, $handle ); - $this->assertSame( self::MAC_FUNC, $macFunc ); - $this->assertSame( self::SECRET, $secret ); - $this->assertSame( $expiresIn, $expires ); - $storage->delAssociation(self::SERVER); - $this->assertTrue( $consumer->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( self::HANDLE, $handle ); - $this->assertSame( self::MAC_FUNC, $macFunc ); - $this->assertSame( self::SECRET, $secret ); - $this->assertSame( $expiresIn, $expires ); - } - - /** - * testing _httpRequest - * - */ - public function testHttpRequest() - { - $consumer = new Zend_OpenId_ConsumerHelper(new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer")); - $http = new Zend_Http_Client(null, - array( - 'maxredirects' => 4, - 'timeout' => 15, - 'useragent' => 'Zend_OpenId' - )); - $test = new Zend_Http_Client_Adapter_Test(); - $http->setAdapter($test); - $consumer->SetHttpClient($http); - $this->assertSame( $http, $consumer->GetHttpClient() ); - $this->assertFalse( $consumer->httpRequest(self::SERVER) ); - - $test->setResponse("HTTP/1.1 200 OK\r\n\r\nok\n"); - - // Test GET request without parameters - $this->assertSame( "ok\n", $consumer->httpRequest(self::SERVER) ); - $this->assertSame( "GET / HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n\r\n", - $http->getLastRequest() ); - - // Test POST request without parameters - $this->assertSame( "ok\n", $consumer->httpRequest(self::SERVER, 'POST') ); - $this->assertSame( "POST / HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Length: 0\r\n\r\n", - $http->getLastRequest() ); - - // Test GET request with parameters - $this->assertSame( "ok\n", $consumer->httpRequest(self::SERVER . 'test.php', 'GET', array('a'=>'b','c'=>'d')) ); - $this->assertSame( "GET /test.php?a=b&c=d HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n\r\n", - $http->getLastRequest() ); - - // Test POST request with parameters - $this->assertSame( "ok\n", $consumer->httpRequest(self::SERVER . 'test.php', 'POST', array('a'=>'b','c'=>'d')) ); - $this->assertSame( "POST /test.php HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "Content-Length: 7\r\n\r\n" . - "a=b&c=d", - $http->getLastRequest() ); - - // Test GET parameters combination - $this->assertSame( "ok\n", $consumer->httpRequest(self::SERVER . 'test.php?a=b', 'GET', array('c'=>'x y')) ); - $this->assertSame( "GET /test.php?a=b&c=x+y HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n\r\n", - $http->getLastRequest() ); - - // Test GET and POST parameters combination - $this->assertSame( "ok\n", $consumer->httpRequest(self::SERVER . 'test.php?a=b', 'POST', array('c'=>'x y')) ); - $this->assertSame( "POST /test.php?a=b HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "Content-Length: 5\r\n\r\n" . - "c=x+y", - $http->getLastRequest() ); - } - - /** - * testing _associate - * - */ - public function testAssociate() - { - try { - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $storage->delAssociation(self::SERVER); - $consumer = new Zend_OpenId_ConsumerHelper($storage); - $http = new Zend_Http_Client(null, - array( - 'maxredirects' => 4, - 'timeout' => 15, - 'useragent' => 'Zend_OpenId' - )); - $test = new Zend_Http_Client_Adapter_Test(); - $http->setAdapter($test); - $consumer->SetHttpClient($http); - - // Test OpenID 1.1 association request with DH-SHA1 - $consumer->clearAssociation(); - $this->assertFalse( $consumer->associate(self::SERVER, 1.1, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertSame( "POST / HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "Content-Length: 510\r\n\r\n" . - "openid.mode=associate&" . - "openid.assoc_type=HMAC-SHA1&" . - "openid.session_type=DH-SHA1&". - "openid.dh_modulus=ANz5OguIOXLsDhmYmsWizjEOHTdxfo2Vcbt2I3MYZuYe91ouJ4mLBX%2BYkcLiemOcPym2CBRYHNOyyjmG0mg3BVd9RcLn5S3IHHoXGHblzqdLFEi%2F368Ygo79JRnxTkXjgmY0rxlJ5bU1zIKaSDuKdiI%2BXUkKJX8Fvf8W8vsixYOr&" . - "openid.dh_gen=Ag%3D%3D&" . - "openid.dh_consumer_public=GaLlROlBGgSopPzo1ewYISnnT4BUFBfIKlgDPoS9U41t5eQb8QYqgcw7%2BW3dSF1VlWcvJGR0UbZIEhJ3UrCs6p69q6sgl%2FOZ7P%2B17rme7OynqszA3pqD6MJoQVZ5Ht%2FR%2BjmMjK08ajcgYEZU1GG4U5k8eYbcFnje00%2FTGfjKY0I%3D", - $http->getLastRequest() ); - - // Test OpenID 2.0 association request with DH-SHA256 - $consumer->clearAssociation(); - $this->assertFalse( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertSame( "POST / HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "Content-Length: 567\r\n\r\n" . - "openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&" . - "openid.mode=associate&" . - "openid.assoc_type=HMAC-SHA256&" . - "openid.session_type=DH-SHA256&". - "openid.dh_modulus=ANz5OguIOXLsDhmYmsWizjEOHTdxfo2Vcbt2I3MYZuYe91ouJ4mLBX%2BYkcLiemOcPym2CBRYHNOyyjmG0mg3BVd9RcLn5S3IHHoXGHblzqdLFEi%2F368Ygo79JRnxTkXjgmY0rxlJ5bU1zIKaSDuKdiI%2BXUkKJX8Fvf8W8vsixYOr&" . - "openid.dh_gen=Ag%3D%3D&" . - "openid.dh_consumer_public=GaLlROlBGgSopPzo1ewYISnnT4BUFBfIKlgDPoS9U41t5eQb8QYqgcw7%2BW3dSF1VlWcvJGR0UbZIEhJ3UrCs6p69q6sgl%2FOZ7P%2B17rme7OynqszA3pqD6MJoQVZ5Ht%2FR%2BjmMjK08ajcgYEZU1GG4U5k8eYbcFnje00%2FTGfjKY0I%3D", - $http->getLastRequest() ); - - // Test OpenID 1.1 association response with DH-SHA1 - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "assoc_type:HMAC-SHA1\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:DH-SHA1\n". - "dh_server_public:AIoP3d+ZTkd5vZj6G82XVIQ6KRAfSKmLz2Q3qVMzZ5tt7Z7St714GccipYXzCs5Tzgkc+Nt/uDE5xQ/f0Zn0uDS65CZHx3MOPqAANw/9YC/CafF1CD1MxW5TiN50GsjT/wGkcJFcpPXYVigQDOjIkHjKCysk53ktFvCoT60nFKGc\n". - "enc_mac_key:ON+M6/X8uUcOfxw1HF4sw/0XYyw=\n"); - $this->assertTrue( $consumer->associate(self::SERVER, 1.1, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertTrue( $storage->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( "0123456789absdef0123456789absdef", $handle ); - $this->assertSame( "sha1", $macFunc ); - $this->assertSame( "e36624c686748f6b646648f12748ffd157e4d4dd", bin2hex($secret) ); - $this->assertTrue( $storage->delAssociation(self::SERVER) ); - - // Wrong OpenID 2.0 association response (wrong ns) - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/1.0\n" . - "assoc_type:HMAC-SHA256\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:DH-SHA256\n". - "dh_server_public:AIlflxF8rvxx1Xi4Oj/KdP+7fvczeIRvx8WScMQS9I27R6YKd3Nx++5tAAF0rHelKDSG2ZeFM/zLEu9ZmUFzF02OaehWqykCfmtLASwMZO0u2GwYiIu5BoeJb9HlXJes58u/M4ViPXWhn27w2ZTlZJuuK8sDiTSTj9TmFxOriH4X\n". - "enc_mac_key:lvvCoTyvKy8oV6wnNHeroU0uLgBHiGV4BNkrXJe04JE=\n"); - $this->assertFalse( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - - // Wrong OpenID 2.0 association response (wrong assoc_type) - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/2.0\n" . - "assoc_type:HMAC-SHA1\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:DH-SHA256\n". - "dh_server_public:AIlflxF8rvxx1Xi4Oj/KdP+7fvczeIRvx8WScMQS9I27R6YKd3Nx++5tAAF0rHelKDSG2ZeFM/zLEu9ZmUFzF02OaehWqykCfmtLASwMZO0u2GwYiIu5BoeJb9HlXJes58u/M4ViPXWhn27w2ZTlZJuuK8sDiTSTj9TmFxOriH4X\n". - "enc_mac_key:lvvCoTyvKy8oV6wnNHeroU0uLgBHiGV4BNkrXJe04JE=\n"); - $this->assertFalse( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - - // Wrong OpenID 2.0 association response (wrong session_type) - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/2.0\n" . - "assoc_type:HMAC-SHA256\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:DH-SHA257\n". - "dh_server_public:AIlflxF8rvxx1Xi4Oj/KdP+7fvczeIRvx8WScMQS9I27R6YKd3Nx++5tAAF0rHelKDSG2ZeFM/zLEu9ZmUFzF02OaehWqykCfmtLASwMZO0u2GwYiIu5BoeJb9HlXJes58u/M4ViPXWhn27w2ZTlZJuuK8sDiTSTj9TmFxOriH4X\n". - "enc_mac_key:lvvCoTyvKy8oV6wnNHeroU0uLgBHiGV4BNkrXJe04JE=\n"); - $this->assertFalse( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - - // Test OpenID 2.0 association response with DH-SHA256 - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/2.0\n" . - "assoc_type:HMAC-SHA256\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:DH-SHA256\n". - "dh_server_public:AIlflxF8rvxx1Xi4Oj/KdP+7fvczeIRvx8WScMQS9I27R6YKd3Nx++5tAAF0rHelKDSG2ZeFM/zLEu9ZmUFzF02OaehWqykCfmtLASwMZO0u2GwYiIu5BoeJb9HlXJes58u/M4ViPXWhn27w2ZTlZJuuK8sDiTSTj9TmFxOriH4X\n". - "enc_mac_key:lvvCoTyvKy8oV6wnNHeroU0uLgBHiGV4BNkrXJe04JE=\n"); - $this->assertTrue( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertTrue( $storage->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( "0123456789absdef0123456789absdef", $handle ); - $this->assertSame( "sha256", $macFunc ); - $this->assertSame( "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8", bin2hex($secret) ); - $this->assertTrue( $storage->delAssociation(self::SERVER) ); - - // Test OpenID 2.0 association response without encryption (missing session_type) - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/2.0\n" . - "assoc_type:HMAC-SHA256\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "mac_key:7ZAbxWHCn9e7QoYuXwn6N+eUSn7nIUIyLzSiG/4ThLg=\n"); - $this->assertTrue( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertTrue( $storage->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( "0123456789absdef0123456789absdef", $handle ); - $this->assertSame( "sha256", $macFunc ); - $this->assertSame( "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8", bin2hex($secret) ); - $this->assertTrue( $storage->delAssociation(self::SERVER) ); - - // Test OpenID 2.0 association response without encryption (blank session_type) - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/2.0\n" . - "assoc_type:HMAC-SHA256\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:\n". - "mac_key:7ZAbxWHCn9e7QoYuXwn6N+eUSn7nIUIyLzSiG/4ThLg=\n"); - $this->assertTrue( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertTrue( $storage->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( "0123456789absdef0123456789absdef", $handle ); - $this->assertSame( "sha256", $macFunc ); - $this->assertSame( "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8", bin2hex($secret) ); - $this->assertTrue( $storage->delAssociation(self::SERVER) ); - - // Test OpenID 2.0 association response without encryption (blank session_type) - $consumer->clearAssociation(); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "ns:http://specs.openid.net/auth/2.0\n" . - "assoc_type:HMAC-SHA256\n" . - "assoc_handle:0123456789absdef0123456789absdef\n" . - "expires_in:3600\n" . - "session_type:no-encryption\n". - "mac_key:7ZAbxWHCn9e7QoYuXwn6N+eUSn7nIUIyLzSiG/4ThLg=\n"); - $this->assertTrue( $consumer->associate(self::SERVER, 2.0, pack("H*", "60017f7ebf0ef29ace27f0dfee2aaa6528d170e147b1260cc3987d7851cb67d49fbfdbb42c56494e61b1e1e39fa42315db0bf4f879787fcf1e807d0629d47cf05d3ac50602b1e7f6e73cd370320ddcdcf7f7aa86f35a3273d187de9c9efa959a02ce3a9c80f47dfcc83cfaad60b673e1806a764227344deae158ceec9ca4d60e")) ); - $this->assertTrue( $storage->getAssociation(self::SERVER, $handle, $macFunc, $secret, $expires) ); - $this->assertSame( "0123456789absdef0123456789absdef", $handle ); - $this->assertSame( "sha256", $macFunc ); - $this->assertSame( "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8", bin2hex($secret) ); - $this->assertTrue( $storage->delAssociation(self::SERVER) ); - } catch (Zend_OpenId_Exception $e) { - $this->markTestSkipped($e->getMessage()); - } - } - - /** - * testing discovery - * - */ - public function testDiscovery() - { - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $consumer = new Zend_OpenId_ConsumerHelper($storage); - $http = new Zend_Http_Client(null, - array( - 'maxredirects' => 4, - 'timeout' => 15, - 'useragent' => 'Zend_OpenId' - )); - $test = new Zend_Http_Client_Adapter_Test(); - $http->setAdapter($test); - $consumer->SetHttpClient($http); - - // Bad response - $storage->delDiscoveryInfo(self::ID); - $id = self::ID; - $this->assertFalse( $consumer->discovery($id, $server, $version) ); - - // Test HTML based discovery (OpenID 1.1) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel=\"openid.server\" href=\"" . self::SERVER . "\">\n" . - "<link rel=\"openid.delegate\" href=\"" . self::REAL_ID . "\">\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 1.1, $version ); - - // Test HTML based discovery (OpenID 1.1) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link href=\"" . self::SERVER . "\" rel=\"openid.server\">\n" . - "<link href=\"" . self::REAL_ID . "\" rel=\"openid.delegate\">\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 1.1, $version ); - - // Test HTML based discovery (OpenID 2.0) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel=\"openid2.provider\" href=\"" . self::SERVER . "\">\n" . - "<link rel=\"openid2.local_id\" href=\"" . self::REAL_ID . "\">\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 2.0, $version ); - - // Test HTML based discovery (OpenID 2.0) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link href=\"" . self::SERVER . "\" rel=\"openid2.provider\">\n" . - "<link href=\"" . self::REAL_ID . "\" rel=\"openid2.local_id\">\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 2.0, $version ); - - // Test HTML based discovery (OpenID 1.1 and 2.0) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel=\"openid2.provider\" href=\"" . self::SERVER . "\">\n" . - "<link rel=\"openid2.local_id\" href=\"" . self::REAL_ID . "\">\n" . - "<link rel=\"openid.server\" href=\"" . self::SERVER . "\">\n" . - "<link rel=\"openid.delegate\" href=\"" . self::REAL_ID . "\">\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 2.0, $version ); - - // Test HTML based discovery (OpenID 1.1) (single quotes) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel='openid.server' href='" . self::SERVER . "'>\n" . - "<link rel='openid.delegate' href='" . self::REAL_ID . "'>\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 1.1, $version ); - - // Test HTML based discovery (OpenID 1.1) (single quotes) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link href='" . self::SERVER . "' rel='openid.server'>\n" . - "<link href='" . self::REAL_ID . "' rel='openid.delegate'>\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 1.1, $version ); - - // Test HTML based discovery (OpenID 2.0) (single quotes) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel='openid2.provider' href='" . self::SERVER . "'>\n" . - "<link rel='openid2.local_id' href='" . self::REAL_ID . "'>\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 2.0, $version ); - - // Test HTML based discovery (OpenID 2.0) (single quotes) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link href='" . self::SERVER . "' rel='openid2.provider'>\n" . - "<link href='" . self::REAL_ID . "' rel='openid2.local_id'>\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 2.0, $version ); - - // Test HTML based discovery (OpenID 1.1 and 2.0) (single quotes) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel='openid2.provider' href='" . self::SERVER . "'>\n" . - "<link rel='openid2.local_id' href='" . self::REAL_ID . "'>\n" . - "<link rel='openid.server' href='" . self::SERVER . "'>\n" . - "<link rel='openid.delegate' href='" . self::REAL_ID . "'>\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 2.0, $version ); - - // Wrong HTML - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertFalse( $consumer->discovery($id, $server, $version) ); - - // Test HTML based discovery with multivalue rel (OpenID 1.1) - $storage->delDiscoveryInfo(self::ID); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\n" . - "<html><head>\n" . - "<link rel=\" aaa openid.server bbb \" href=\"" . self::SERVER . "\">\n" . - "<link rel=\"aaa openid.delegate\" href=\"" . self::REAL_ID . "\">\n" . - "</head><body</body></html>\n"); - $id = self::ID; - $this->assertTrue( $consumer->discovery($id, $server, $version) ); - $this->assertSame( self::REAL_ID, $id ); - $this->assertSame( self::SERVER, $server ); - $this->assertSame( 1.1, $version ); - } - - /** - * testing verify - * - */ - public function testVerify() - { - $expiresIn = time() + 600; - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $consumer = new Zend_OpenId_ConsumerHelper($storage); - - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - - // Wrong arguments - $this->assertFalse( $consumer->verify(array()) ); - - // HMAC-SHA1 - $consumer->clearAssociation(); - $params = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, "sha1", pack("H*", "8382aea922560ece833ba55fa53b7a975f597370"), $expiresIn); - $storage->purgeNonces(); - $this->assertTrue( $consumer->verify($params) ); - - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 2.0, $expiresIn); - - // HMAC-SHA256 - $consumer->clearAssociation(); - $params = array( - "openid_ns" => Zend_OpenId::NS_2_0, - "openid_op_endpoint" => self::SERVER, - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "rMiVhEmHVcIHoY2uzPNb7udWqa4lruvjnwZfujct0TE=" - ); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, "sha256", pack("H*", "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8"), $expiresIn); - $storage->purgeNonces(); - $this->assertTrue( $consumer->verify($params) ); - - // HMAC-SHA256 (duplicate response_nonce) - $consumer->clearAssociation(); - $params = array( - "openid_ns" => Zend_OpenId::NS_2_0, - "openid_op_endpoint" => self::SERVER, - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "rMiVhEmHVcIHoY2uzPNb7udWqa4lruvjnwZfujct0TE=" - ); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, "sha256", pack("H*", "ed901bc561c29fd7bb42862e5f09fa37e7944a7ee72142322f34a21bfe1384b8"), $expiresIn); - $this->assertFalse( $consumer->verify($params) ); - - $storage->delDiscoveryInfo(self::ID); - $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn); - - // wrong signature - $consumer->clearAssociation(); - $params = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124fff", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, "sha1", pack("H*", "8382aea922560ece833ba55fa53b7a975f597370"), $expiresIn); - $storage->purgeNonces(); - $this->assertFalse( $consumer->verify($params) ); - $this->assertFalse( $storage->getAssociation(self::SERVER, $handle, $func, $secret, $expires) ); - - // openid_invalidate_handle - $consumer->clearAssociation(); - $params = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_invalidate_handle" => self::HANDLE."1", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->delAssociation(self::SERVER); - $storage->addAssociation(self::SERVER, self::HANDLE, "sha1", pack("H*", "8382aea922560ece833ba55fa53b7a975f597370"), $expiresIn); - $storage->delAssociation(self::SERVER."1"); - $storage->addAssociation(self::SERVER."1", self::HANDLE."1", "sha1", pack("H*", "8382aea922560ece833ba55fa53b7a975f597370"), $expiresIn); - $storage->purgeNonces(); - $this->assertTrue( $consumer->verify($params) ); - $this->assertFalse( $storage->getAssociation(self::SERVER."1", $handle, $func, $secret, $expires) ); - - $storage->delDiscoveryInfo(self::ID); - } - - /** - * testing verify - * - */ - public function testVerifyDumb() - { - $expiresIn = time() + 600; - $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php"; - $storage = new Zend_OpenId_Consumer_Storage_File(dirname(__FILE__)."/_files/consumer"); - $consumer = new Zend_OpenId_ConsumerHelper($storage); - $http = new Zend_Http_Client(null, - array( - 'maxredirects' => 4, - 'timeout' => 15, - 'useragent' => 'Zend_OpenId' - )); - $test = new Zend_Http_Client_Adapter_Test(); - $http->setAdapter($test); - $consumer->SetHttpClient($http); - $storage->delDiscoveryInfo(self::ID); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn) ); - $this->assertTrue( $storage->addDiscoveryInfo(self::REAL_ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn) ); - - // Wrong arguments (no identity) - $test->setResponse("HTTP/1.1 200 OK\r\n\r\nis_valid:true"); - $consumer->clearAssociation(); - $storage->delAssociation(self::SERVER); - $params = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->purgeNonces(); - $this->assertFalse( $consumer->verify($params) ); - - $test->setResponse("HTTP/1.1 200 OK\r\n\r\nis_valid:false"); - $consumer->clearAssociation(); - $storage->delAssociation(self::SERVER); - $params = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->purgeNonces(); - $this->assertFalse( $consumer->verify($params) ); - $this->assertSame( "POST / HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "Content-Length: 445\r\n\r\n" . - "openid.return_to=http%3A%2F%2Fwww.zf-test.com%2Ftest.php&" . - "openid.assoc_handle=d41d8cd98f00b204e9800998ecf8427e&" . - "openid.claimed_id=http%3A%2F%2Fid.myopenid.com%2F&" . - "openid.identity=http%3A%2F%2Freal_id.myopenid.com%2F&" . - "openid.response_nonce=2007-08-14T12%3A52%3A33Z46c1a59124ffe&" . - "openid.mode=check_authentication&" . - "openid.signed=assoc_handle%2Creturn_to%2Cclaimed_id%2Cidentity%2Cresponse_nonce%2Cmode%2Csigned&" . - "openid.sig=h%2F5AFD25NpzSok5tzHEGCVUkQSw%3D", - $http->getLastRequest() ); - - $test->setResponse("HTTP/1.1 200 OK\r\n\r\nis_valid:true"); - $consumer->clearAssociation(); - $storage->delAssociation(self::SERVER); - $params = array( - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->purgeNonces(); - $this->assertTrue( $consumer->verify($params) ); - - // SREG - $this->assertTrue( $storage->delDiscoveryInfo(self::ID) ); - $this->assertTrue( $storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 2.0, $expiresIn) ); - $test->setResponse("HTTP/1.1 200 OK\r\n\r\nis_valid:true"); - $consumer->clearAssociation(); - $storage->delAssociation(self::SERVER); - $params = array( - "openid_ns" => Zend_OpenId::NS_2_0, - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_op_endpoint" => self::SERVER, - "openid_mode" => "id_res", - "openid_ns_sreg" => "http://openid.net/extensions/sreg/1.1", - "openid_sreg_nickname" => "test", - "openid_signed" => "ns,assoc_handle,return_to,claimed_id,identity,response_nonce,mode,ns.sreg,sreg.nickname,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->purgeNonces(); - $this->assertTrue( $consumer->verify($params) ); - $this->assertSame( "POST / HTTP/1.1\r\n" . - "Host: www.myopenid.com\r\n" . - "Connection: close\r\n" . - "Accept-encoding: gzip, deflate\r\n" . - "User-Agent: Zend_OpenId\r\n" . - "Content-Type: application/x-www-form-urlencoded\r\n" . - "Content-Length: 672\r\n\r\n" . - "openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&" . - "openid.return_to=http%3A%2F%2Fwww.zf-test.com%2Ftest.php&" . - "openid.assoc_handle=d41d8cd98f00b204e9800998ecf8427e&" . - "openid.claimed_id=http%3A%2F%2Fid.myopenid.com%2F&" . - "openid.identity=http%3A%2F%2Freal_id.myopenid.com%2F&" . - "openid.response_nonce=2007-08-14T12%3A52%3A33Z46c1a59124ffe&" . - "openid.op_endpoint=http%3A%2F%2Fwww.myopenid.com%2F&" . - "openid.mode=check_authentication&" . - "openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&" . - "openid.sreg.nickname=test&" . - "openid.signed=ns%2Cassoc_handle%2Creturn_to%2Cclaimed_id%2Cidentity%2Cresponse_nonce%2Cmode%2Cns.sreg%2Csreg.nickname%2Csigned&" . - "openid.sig=h%2F5AFD25NpzSok5tzHEGCVUkQSw%3D", - $http->getLastRequest() ); - - // invalidate_handle - $test->setResponse("HTTP/1.1 200 OK\r\n\r\nis_valid:false\ninvalidate_handle:".self::HANDLE."1"."\n"); - $consumer->clearAssociation(); - $params = array( - "openid_ns" => Zend_OpenId::NS_2_0, - "openid_return_to" => "http://www.zf-test.com/test.php", - "openid_assoc_handle" => self::HANDLE, - "openid_claimed_id" => self::ID, - "openid_identity" => self::REAL_ID, - "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", - "openid_op_endpoint" => self::SERVER, - "openid_mode" => "id_res", - "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed", - "openid_sig" => "h/5AFD25NpzSok5tzHEGCVUkQSw=" - ); - $storage->delAssociation(self::SERVER."1"); - $storage->addAssociation(self::SERVER."1", self::HANDLE."1", "sha1", pack("H*", "8382aea922560ece833ba55fa53b7a975f597370"), $expiresIn); - $storage->purgeNonces(); - $this->assertFalse( $consumer->verify($params) ); - $this->assertFalse( $storage->getAssociation(self::SERVER."1", $handle, $func, $secret, $expires) ); - } -} - -class Zend_OpenId_ConsumerHelper extends Zend_OpenId_Consumer { - - public function addAssociation($url, $handle, $macFunc, $secret, $expires) - { - return $this->_addAssociation($url, $handle, $macFunc, $secret, $expires); - } - - public function getAssociation($url, &$handle, &$macFunc, &$secret, &$expires) - { - return $this->_getAssociation($url, $handle, $macFunc, $secret, $expires); - } - - public function clearAssociation() - { - $this->_cache = array(); - } - - public function httpRequest($url, $method = 'GET', array $params = array()) - { - return $this->_httpRequest($url, $method, $params); - } - - public function associate($url, $version, $priv_key = null) - { - return $this->_associate($url, $version, $priv_key); - } - - public function discovery(&$id, &$server, &$version) - { - return $this->_discovery($id, $server, $version); - } - -} diff --git a/tests/Zend/OpenId/Extension/SregTest.php b/tests/Zend/OpenId/Extension/SregTest.php deleted file mode 100644 index e9a1de9c6c534178868824acb81b1176ed018e5e..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/Extension/SregTest.php +++ /dev/null @@ -1,259 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SregTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId/Extension/Sreg.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_Extension_SregTest extends PHPUnit_Framework_TestCase -{ - const USER = "test_user"; - const EMAIL = "user@test.com"; - const POLICY = "http://www.somewhere.com/policy.html"; - - /** - * testing getProperties - * - */ - public function testGetProperties() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $this->assertSame( array(), $ext->getProperties() ); - $ext = new Zend_OpenId_Extension_Sreg(array('nickname'=>true,'email'=>false)); - $this->assertSame( array('nickname'=>true,'email'=>false), $ext->getProperties() ); - } - - /** - * testing getPolicyUrl - * - */ - public function testGetPolicyUrl() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $this->assertSame( null, $ext->getPolicyUrl() ); - $ext = new Zend_OpenId_Extension_Sreg(null, self::POLICY); - $this->assertSame( self::POLICY, $ext->getPolicyUrl() ); - } - - /** - * testing getVersion - * - */ - public function testGetVersion() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $this->assertSame( 1.0, $ext->getVersion() ); - $ext = new Zend_OpenId_Extension_Sreg(null, null, 1.1); - $this->assertSame( 1.1, $ext->getVersion() ); - } - - /** - * testing getSregProperties - * - */ - public function testGetSregProperties() - { - $this->assertSame( - array( - "nickname", - "email", - "fullname", - "dob", - "gender", - "postcode", - "country", - "language", - "timezone" - ), - Zend_OpenId_Extension_Sreg::getSregProperties() ); - } - - /** - * testing prepareRequest - * - */ - public function testPrepareRequest() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $params = array(); - $this->assertTrue( $ext->prepareRequest($params) ); - $this->assertSame( array(), $params ); - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>false)); - $params = array(); - $this->assertTrue( $ext->prepareRequest($params) ); - $this->assertSame( array('openid.sreg.required'=>"nickname", 'openid.sreg.optional'=>"email"), $params ); - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>true), self::POLICY); - $params = array(); - $this->assertTrue( $ext->prepareRequest($params) ); - $this->assertSame( array('openid.sreg.required'=>"nickname,email", 'openid.sreg.policy_url' => self::POLICY), $params ); - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>false,"email"=>false), self::POLICY, 1.1); - $params = array(); - $this->assertTrue( $ext->prepareRequest($params) ); - $this->assertSame( array('openid.ns.sreg'=>"http://openid.net/extensions/sreg/1.1",'openid.sreg.optional'=>"nickname,email", 'openid.sreg.policy_url' => self::POLICY), $params ); - } - - /** - * testing parseRequest - * - */ - public function testParseRequest() - { - $ext = new Zend_OpenId_Extension_Sreg(); - - $this->assertTrue( $ext->parseRequest(array()) ); - $this->assertSame( array(), $ext->getProperties() ); - $this->assertSame( null, $ext->getPolicyUrl() ); - $this->assertSame( 1.0, $ext->getVersion() ); - - $this->assertTrue( $ext->parseRequest(array('openid_sreg_required'=>"nickname", 'openid_sreg_optional'=>"email")) ); - $this->assertSame( array('nickname'=>true,'email'=>false), $ext->getProperties() ); - $this->assertSame( null, $ext->getPolicyUrl() ); - $this->assertSame( 1.0, $ext->getVersion() ); - - $this->assertTrue( $ext->parseRequest(array('openid_sreg_required'=>"nickname,email", 'openid_sreg_policy_url' => self::POLICY)) ); - $this->assertSame( array('nickname'=>true,'email'=>true), $ext->getProperties() ); - $this->assertSame( self::POLICY, $ext->getPolicyUrl() ); - $this->assertSame( 1.0, $ext->getVersion() ); - - $this->assertTrue( $ext->parseRequest(array('openid_ns_sreg'=>"http://openid.net/extensions/sreg/1.1", 'openid_sreg_optional'=>"nickname,email", 'openid_sreg_policy_url' => self::POLICY)) ); - $this->assertSame( array('nickname'=>false,'email'=>false), $ext->getProperties() ); - $this->assertSame( self::POLICY, $ext->getPolicyUrl() ); - $this->assertSame( 1.1, $ext->getVersion() ); - } - - /** - * testing getTrustData - * - */ - public function testGetTrustData() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $data = array(); - $this->assertTrue( $ext->getTrustData($data) ); - $this->assertSame( 1, count($data) ); - $this->assertSame( array(), $data["Zend_OpenId_Extension_Sreg"] ); - $ext = new Zend_OpenId_Extension_Sreg(array('nickname'=>true,'email'=>false)); - $data = array(); - $this->assertTrue( $ext->getTrustData($data) ); - $this->assertSame( 1, count($data) ); - $this->assertSame( array('nickname'=>true,'email'=>false), $data["Zend_OpenId_Extension_Sreg"] ); - } - - /** - * testing checkTrustData - * - */ - public function testCheckTrustData() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $this->assertTrue( $ext->checkTrustData(array()) ); - $this->assertSame( array(), $ext->getProperties() ); - - $ext = new Zend_OpenId_Extension_Sreg(); - $this->assertTrue( $ext->checkTrustData(array("Zend_OpenId_Extension_Sreg"=>array())) ); - $this->assertSame( array(), $ext->getProperties() ); - - $ext = new Zend_OpenId_Extension_Sreg(array()); - $this->assertTrue( $ext->checkTrustData(array("Zend_OpenId_Extension_Sreg"=>array("nickname"=>self::USER, "email"=>self::EMAIL))) ); - $this->assertSame( array(), $ext->getProperties() ); - - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>true)); - $this->assertTrue( $ext->checkTrustData(array("Zend_OpenId_Extension_Sreg"=>array("nickname"=>self::USER, "email"=>self::EMAIL))) ); - $this->assertSame( array('nickname'=>self::USER, "email"=>self::EMAIL), $ext->getProperties() ); - - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>true)); - $this->assertFalse( $ext->checkTrustData(array("Zend_OpenId_Extension_Sreg"=>array("nickname"=>self::USER))) ); - - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>true,"email"=>false)); - $this->assertTrue( $ext->checkTrustData(array("Zend_OpenId_Extension_Sreg"=>array("nickname"=>self::USER))) ); - $this->assertSame( array('nickname'=>self::USER), $ext->getProperties() ); - - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>false,"email"=>true)); - $this->assertTrue( $ext->checkTrustData(array("Zend_OpenId_Extension_Sreg"=>array("nickname"=>self::USER, "email"=>self::EMAIL))) ); - $this->assertSame( array('nickname'=>self::USER, "email"=>self::EMAIL), $ext->getProperties() ); - - $ext = new Zend_OpenId_Extension_Sreg(array("nickname"=>false,"email"=>true)); - $this->assertFalse( $ext->checkTrustData(array("Zend_OpenId_Extension_SregX"=>array("nickname"=>self::USER, "email"=>self::EMAIL))) ); - } - - /** - * testing prepareResponse - * - */ - public function testPrepareResponse() - { - $ext = new Zend_OpenId_Extension_Sreg(); - $params = array(); - $this->assertTrue( $ext->prepareResponse($params) ); - $this->assertSame( array(), $params ); - - $ext = new Zend_OpenId_Extension_Sreg(array('nickname'=>self::USER, "email"=>self::EMAIL), self::POLICY); - $params = array(); - $this->assertTrue( $ext->prepareResponse($params) ); - $this->assertSame( array('openid.sreg.nickname'=>self::USER, 'openid.sreg.email'=>self::EMAIL), $params ); - - $ext = new Zend_OpenId_Extension_Sreg(array('nickname'=>self::USER, "email"=>self::EMAIL), self::POLICY, 1.1); - $params = array(); - $this->assertTrue( $ext->prepareResponse($params) ); - $this->assertSame( array('openid.ns.sreg'=>"http://openid.net/extensions/sreg/1.1", 'openid.sreg.nickname'=>self::USER, 'openid.sreg.email'=>self::EMAIL), $params ); - } - - /** - * testing parseResponse - * - */ - public function testParseResponse() - { - $ext = new Zend_OpenId_Extension_Sreg(); - - $this->assertTrue( $ext->parseResponse(array()) ); - $this->assertSame( array(), $ext->getProperties() ); - $this->assertSame( null, $ext->getPolicyUrl() ); - $this->assertSame( 1.0, $ext->getVersion() ); - - $this->assertTrue( $ext->parseResponse(array('openid_sreg_nickname'=>self::USER, 'openid_sreg_email'=>self::EMAIL)) ); - $this->assertSame( array('nickname'=>self::USER,'email'=>self::EMAIL), $ext->getProperties() ); - $this->assertSame( null, $ext->getPolicyUrl() ); - $this->assertSame( 1.0, $ext->getVersion() ); - - $this->assertTrue( $ext->parseResponse(array('openid_sreg_nickname'=>self::USER, 'openid_sreg_email'=>self::EMAIL, 'openid_sreg_policy_url' => self::POLICY)) ); - $this->assertSame( array('nickname'=>self::USER,'email'=>self::EMAIL), $ext->getProperties() ); - $this->assertSame( null, $ext->getPolicyUrl() ); - $this->assertSame( 1.0, $ext->getVersion() ); - - $this->assertTrue( $ext->parseResponse(array('openid_ns_sreg'=>"http://openid.net/extensions/sreg/1.1",'openid_sreg_nickname'=>self::USER, 'openid_sreg_email'=>self::EMAIL)) ); - $this->assertSame( array('nickname'=>self::USER,'email'=>self::EMAIL), $ext->getProperties() ); - $this->assertSame( null, $ext->getPolicyUrl() ); - $this->assertSame( 1.1, $ext->getVersion() ); - } -} diff --git a/tests/Zend/OpenId/ExtensionTest.php b/tests/Zend/OpenId/ExtensionTest.php deleted file mode 100644 index 26ba2c8971c1ef0da010d67d6d971dc64e4a9a5e..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/ExtensionTest.php +++ /dev/null @@ -1,110 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExtensionTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId/Extension.php'; -require_once 'Zend/OpenId/Extension/Sreg.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_ExtensionTest extends PHPUnit_Framework_TestCase -{ - /** - * testing forAll - * - */ - public function testForAll() - { - $params = array(); - $this->assertTrue( Zend_OpenId_Extension::forAll(null, 'getTrustData', $params) ); - $this->assertSame( array(), $params ); - - $params = array(); - $this->assertTrue( Zend_OpenId_Extension::forAll(array(), 'getTrustData', $params) ); - $this->assertSame( array(), $params ); - - $params = array(); - $this->assertFalse( Zend_OpenId_Extension::forAll(array(1), 'getTrustData', $params) ); - - $params = array(); - $this->assertFalse( Zend_OpenId_Extension::forAll(new stdClass(), 'getTrustData', $params) ); - - $ext = new Zend_OpenId_Extension_Sreg(); - $params = array(); - $this->assertTrue( Zend_OpenId_Extension::forAll($ext, 'getTrustData', $params) ); - $this->assertSame( array('Zend_OpenId_Extension_Sreg'=>array()), $params ); - - $ext = new Zend_OpenId_Extension_Sreg(); - $params = array(); - $this->assertTrue( Zend_OpenId_Extension::forAll(array($ext), 'getTrustData', $params) ); - $this->assertSame( array('Zend_OpenId_Extension_Sreg'=>array()), $params ); - - $ext = new Zend_OpenId_Extension_Helper(); - $params = array(); - $this->assertTrue( Zend_OpenId_Extension::forAll(array($ext), 'getTrustData', $params) ); - $this->assertSame( array(), $params ); - $this->assertFalse( Zend_OpenId_Extension::forAll(array($ext), 'wrong', $params) ); - $this->assertSame( array(), $params ); - } - - /** - * testing extension callbacks - * - */ - public function testCallbacks() - { - $ext = new Zend_OpenId_Extension_Helper(); - $a = array(); - $this->assertTrue( $ext->prepareRequest($a) ); - $this->assertSame( array(), $a ); - $this->assertTrue( $ext->parseRequest($a) ); - $this->assertSame( array(), $a ); - $this->assertTrue( $ext->prepareResponse($a) ); - $this->assertSame( array(), $a ); - $this->assertTrue( $ext->parseResponse($a) ); - $this->assertSame( array(), $a ); - $this->assertTrue( $ext->getTrustData($a) ); - $this->assertSame( array(), $a ); - $this->assertTrue( $ext->checkTrustData($a) ); - $this->assertSame( array(), $a ); - $this->assertFalse( $ext->wrong($a) ); - $this->assertSame( array(), $a ); - } -} - -class Zend_OpenId_Extension_Helper extends Zend_OpenId_Extension -{ - function wrong($data) - { - return false; - } -} diff --git a/tests/Zend/OpenId/Provider/Storage/FileTest.php b/tests/Zend/OpenId/Provider/Storage/FileTest.php deleted file mode 100644 index 4ed0512a0f86458b674fd4c44029143110d13e93..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/Provider/Storage/FileTest.php +++ /dev/null @@ -1,214 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FileTest.php 9248 2008-04-18 20:40:44Z darby $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** - * @see Zend_OpenId_Provider_Storage_File - */ -require_once 'Zend/OpenId/Provider/Storage/File.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_Provider_Storage_FileTest extends PHPUnit_Framework_TestCase -{ - const HANDLE = "d41d8cd98f00b204e9800998ecf8427e"; - const MAC_FUNC = "sha256"; - const SECRET = "4fa03202081808bd19f92b667a291873"; - const USER = "test_user"; - const PASSWORD = "01234567890abcdef"; - const SITE1 = "http://www.php.net/"; - const SITE2 = "http://www.yahoo.com/"; - - /** - * testing __construct - * - */ - public function testConstruct() - { - $tmp = dirname(__FILE__)."/_files"; - $dir = $tmp . '/openid_provider'; - @rmdir($dir); - $storage = new Zend_OpenId_Provider_Storage_File($dir); - $this->assertTrue( is_dir($dir) ); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return; - } - - chmod($dir, 0); - $dir2 = $dir . '/test'; - try { - $storage = new Zend_OpenId_Provider_Storage_File($dir2); - $ex = null; - } catch (Exception $e) { - $ex = $e; - } - $this->assertTrue( $ex instanceof Zend_OpenId_Exception ); - $this->assertSame( Zend_OpenId_Exception::ERROR_STORAGE, $ex->getCode() ); - $this->assertContains( 'Cannot access storage directory', $ex->getMessage() ); - chmod($dir, 0777); - $this->assertFalse( is_dir($dir2) ); - @rmdir($dir); - } - - /** - * testing getAssociation - * - */ - public function testGetAssociation() - { - $expiresIn = time() + 600; - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files"); - $storage->delAssociation(self::HANDLE); - $this->assertTrue( $storage->addAssociation(self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - $this->assertTrue( $storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires) ); - $this->assertSame( self::MAC_FUNC, $macFunc ); - $this->assertSame( self::SECRET, $secret ); - $this->assertSame( $expiresIn, $expires ); - $this->assertTrue( $storage->delAssociation(self::HANDLE) ); - $this->assertFalse( $storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires) ); - - $tmp = dirname(__FILE__)."/_files"; - $dir = $tmp . '/openid_consumer'; - @rmdir($dir); - $storage = new Zend_OpenId_Provider_Storage_File($dir); - $this->assertTrue( is_dir($dir) ); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return; - } - - chmod($dir, 0); - $this->assertFalse( $storage->addAssociation(self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - chmod($dir, 0777); - @rmdir($dir); - } - - /** - * testing getAssociation - * - */ - public function testGetAssociationExpiratin() - { - $expiresIn = time() + 1; - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files"); - $storage->delAssociation(self::HANDLE); - $this->assertTrue( $storage->addAssociation(self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn) ); - sleep(2); - $this->assertFalse( $storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires) ); - } - - /** - * testing addUser - * - */ - public function testAddUser() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files"); - $storage->delUser(self::USER); - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertFalse( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertTrue( $storage->delUser(self::USER) ); - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertTrue( $storage->delUser(self::USER) ); - } - - /** - * testing hasUser - * - */ - public function testHasUser() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files"); - $storage->delUser(self::USER); - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertTrue( $storage->hasUser(self::USER) ); - $this->assertTrue( $storage->delUser(self::USER) ); - $this->assertFalse( $storage->hasUser(self::USER) ); - } - - /** - * testing checkUser - * - */ - public function testCheckUser() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files"); - $storage->delUser(self::USER); - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertTrue( $storage->checkUser(self::USER, self::PASSWORD) ); - $this->assertFalse( $storage->checkUser(self::USER, self::USER) ); - $this->assertTrue( $storage->delUser(self::USER) ); - $this->assertFalse( $storage->checkUser(self::USER, self::PASSWORD) ); - } - - /** - * testing addSite - * - */ - public function testAddSite() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files"); - $storage->delUser(self::USER); - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertTrue( $storage->addSite(self::USER, self::SITE1, true) ); - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 1, count($trusted) ); - reset($trusted); - $this->assertSame( self::SITE1, key($trusted) ); - $this->assertSame( true, current($trusted) ); - $this->assertTrue( $storage->delUser(self::USER) ); - $this->assertFalse( $storage->addSite(self::USER, self::SITE1, true) ); - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 0, count($trusted) ); - $this->assertTrue( $storage->addSite(self::USER, self::SITE1, self::SITE1) ); - $this->assertTrue( $storage->addSite(self::USER, self::SITE2, self::SITE2) ); - $this->assertTrue( $storage->addSite(self::USER, self::SITE1, self::USER) ); - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 2, count($trusted) ); - $this->assertSame( self::USER, $trusted[self::SITE1] ); - $this->assertSame( self::SITE2, $trusted[self::SITE2] ); - $this->assertTrue( $storage->addSite(self::USER, self::SITE2, null) ); - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 1, count($trusted) ); - $this->assertSame( self::USER, $trusted[self::SITE1] ); - $this->assertTrue( $storage->addSite(self::USER, self::SITE1, null) ); - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 0, count($trusted) ); - $this->assertTrue( $storage->delUser(self::USER) ); - $storage->delUser(self::USER); - $this->assertFalse( $storage->getTrustedSites(self::USER) ); - } -} diff --git a/tests/Zend/OpenId/Provider/User/SessionTest.php b/tests/Zend/OpenId/Provider/User/SessionTest.php deleted file mode 100644 index 55604e14833df159f85626f6c38d9ea527cab653..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/Provider/User/SessionTest.php +++ /dev/null @@ -1,75 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SessionTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId/Provider/User/Session.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_Provider_User_SessionTest extends PHPUnit_Framework_TestCase -{ - const USER1 = "test_user1"; - const USER2 = "test_user2"; - - private $_user; - - public function __construct() - { - $this->_user1 = new Zend_OpenId_Provider_User_Session(); - $this->_user2 = new Zend_OpenId_Provider_User_Session(new Zend_Session_Namespace("openid2")); - } - - /** - * testing getLoggedInUser - * - */ - public function testGetLoggedInUser() - { - $user = $this->_user1; - $user->delLoggedInUser(); - $this->assertTrue( $user->setLoggedInUser(self::USER1) ); - $this->assertSame( self::USER1, $user->getLoggedInUser() ); - $this->assertTrue( $user->setLoggedInUser(self::USER2) ); - $this->assertSame( self::USER2, $user->getLoggedInUser() ); - $this->assertTrue( $user->delLoggedInUser() ); - $this->assertFalse( $user->getLoggedInUser()); - - $user = $this->_user2; - $user->delLoggedInUser(); - $this->assertTrue( $user->setLoggedInUser(self::USER1) ); - $this->assertSame( self::USER1, $user->getLoggedInUser() ); - $this->assertTrue( $user->setLoggedInUser(self::USER2) ); - $this->assertSame( self::USER2, $user->getLoggedInUser() ); - $this->assertTrue( $user->delLoggedInUser() ); - $this->assertFalse( $user->getLoggedInUser()); - } -} diff --git a/tests/Zend/OpenId/ProviderTest.php b/tests/Zend/OpenId/ProviderTest.php deleted file mode 100644 index 924cba1f0d55884263ca17f2794d2b7003623dd3..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/ProviderTest.php +++ /dev/null @@ -1,1600 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ProviderTest.php 8724 2008-03-10 11:04:53Z dmitry $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId/Provider.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * Zend_OpenId_ResponseHelper - */ -require_once 'Zend/OpenId/ResponseHelper.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_ProviderTest extends PHPUnit_Framework_TestCase -{ - const USER = "http://test_user.myopenid.com/"; - const PASSWORD = "01234567890abcdef"; - - const HANDLE = "01234567890abcdef"; - - private $_user; - - public function __construct() - { - $this->_user = new Zend_OpenId_Provider_User_Session(); - } - - /** - * testing register - * - */ - public function testRegister() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - $this->assertFalse( $storage->checkUser(self::USER, self::PASSWORD) ); - - // wrong ID - $this->assertFalse( $provider->register("", self::PASSWORD) ); - // registration of new user - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - // registration of existent user - $this->assertFalse( $provider->register(self::USER, self::PASSWORD) ); - - $this->assertTrue( $storage->checkUser(self::USER, md5(self::USER . self::PASSWORD)) ); - $storage->delUser(self::USER); - } - - /** - * testing hasUser - * - */ - public function testHasUser() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - - // wrong ID - $this->assertFalse( $provider->hasUser("") ); - $this->assertFalse( $provider->hasUser("http://:80/test") ); - - // check for non existent - $this->assertFalse( $provider->hasUser(self::USER) ); - - // check for existent user - $this->assertTrue( $storage->addUser(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->hasUser(self::USER) ); - - $storage->delUser(self::USER); - } - - /** - * testing login - * - */ - public function testLogin() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - - // wrong ID - $this->assertFalse( $provider->login("", self::PASSWORD) ); - $this->assertFalse( $this->_user->getLoggedInUser() ); - $this->assertFalse( $provider->login("http://:80/test", self::PASSWORD) ); - $this->assertFalse( $this->_user->getLoggedInUser() ); - - // login as non existent user - $this->assertFalse( $provider->login(self::USER, self::PASSWORD) ); - $this->assertFalse( $this->_user->getLoggedInUser() ); - // login as existent user with wrong password - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertFalse( $provider->login(self::USER, self::PASSWORD . "x") ); - $this->assertFalse( $this->_user->getLoggedInUser() ); - // login as existent user with proper password - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertSame( self::USER, $this->_user->getLoggedInUser() ); - - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - } - - /** - * testing logout - * - */ - public function testLogout() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - - $this->assertFalse( $this->_user->getLoggedInUser() ); - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertFalse( $this->_user->getLoggedInUser() ); - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertSame( self::USER, $this->_user->getLoggedInUser() ); - $this->assertTrue( $provider->logout() ); - $this->assertFalse( $this->_user->getLoggedInUser() ); - - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - } - - /** - * testing logout - * - */ - public function testLoggedInUser() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - - $this->assertFalse( $provider->getLoggedInUser() ); - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertFalse( $provider->getLoggedInUser() ); - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertSame( self::USER, $this->_user->getLoggedInUser() ); - $this->assertTrue( $provider->logout() ); - $this->assertFalse( $provider->getLoggedInUser() ); - - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - } - - /** - * testing getSiteRoot - * - */ - public function testGetSiteRoot() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - - $params = array( - 'openid_realm' => "http://wrong/", - 'openid_trust_root' => "http://root/", - 'openid_return_to' => "http://wrong/", - ); - $this->assertSame( "http://root/", $provider->getSiteRoot($params) ); - - $params = array( - 'openid_realm' => "http://wrong/", - 'openid_return_to' => "http://root/", - ); - $this->assertSame( "http://root/", $provider->getSiteRoot($params) ); - - $params = array( - 'openid_realm' => "http://wrong/", - ); - $this->assertFalse( $provider->getSiteRoot($params) ); - - $params = array( - 'openid_ns' => Zend_OpenId::NS_2_0, - 'openid_realm' => "http://root/", - 'openid_trust_root' => "http://wrong/", - 'openid_return_to' => "http://wrong/", - ); - $this->assertSame( "http://root/", $provider->getSiteRoot($params) ); - - $params = array( - 'openid_ns' => Zend_OpenId::NS_2_0, - 'openid_trust_root' => "http://wrong/", - 'openid_return_to' => "http://root/", - ); - $this->assertSame( "http://root/", $provider->getSiteRoot($params) ); - - $params = array( - 'openid_ns' => Zend_OpenId::NS_2_0, - 'openid_return_to' => "http://root/", - ); - $this->assertSame( "http://root/", $provider->getSiteRoot($params) ); - - $params = array( - 'openid_ns' => Zend_OpenId::NS_2_0, - ); - $this->assertFalse( $provider->getSiteRoot($params) ); - - $params = array( - 'openid_trust_root' => "", - ); - $this->assertFalse( $provider->getSiteRoot($params) ); - } - - /** - * testing allowSite - * - */ - public function testAllowSite() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - - // not logged in - $this->assertFalse( $provider->allowSite("http://www.test.com/") ); - // logged in - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->allowSite("http://www.test.com/") ); - - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 1, count($trusted) ); - reset($trusted); - $this->assertSame( "http://www.test.com/", key($trusted) ); - $this->assertSame( true, current($trusted) ); - - // duplicate - $this->assertTrue( $provider->allowSite("http://www.test.com/") ); - - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 1, count($trusted) ); - reset($trusted); - $this->assertSame( "http://www.test.com/", key($trusted) ); - $this->assertSame( true, current($trusted) ); - - // extensions - $sreg = new Zend_OpenId_Extension_Sreg(array("nickname"=>"test_id")); - $this->assertTrue( $provider->allowSite("http://www.test.com/", $sreg) ); - - $trusted = $storage->getTrustedSites(self::USER); - $this->assertTrue( is_array($trusted) ); - $this->assertSame( 1, count($trusted) ); - reset($trusted); - $this->assertSame( "http://www.test.com/", key($trusted) ); - $this->assertSame( array('Zend_OpenId_Extension_Sreg'=>array('nickname'=>'test_id')), current($trusted) ); - - $this->_user->delLoggedInUser(); - $storage->delUser(self::USER); - } - - /** - * testing denySite - * - */ - public function testDenySite() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - $sreg = new Zend_OpenId_Extension_Sreg(array("nickname"=>"test_id")); - - // not logged in - $this->assertFalse( $provider->denySite("http://www.test.com/") ); - - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->allowSite("http://www.test1.com/") ); - $this->assertTrue( $provider->allowSite("http://www.test2.com/", $sreg) ); - $this->AssertSame( array( - 'http://www.test1.com/' => true, - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ) - ), - $storage->getTrustedSites(self::USER) ); - - $this->assertTrue( $provider->denySite("http://www.test3.com/") ); - $this->AssertSame( array( - 'http://www.test1.com/' => true, - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ), - 'http://www.test3.com/' => false - ), - $storage->getTrustedSites(self::USER) ); - - $this->assertTrue( $provider->denySite("http://www.test1.com/") ); - $this->AssertSame( array( - 'http://www.test1.com/' => false, - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ), - 'http://www.test3.com/' => false - ), - $storage->getTrustedSites(self::USER) ); - - $this->assertTrue( $provider->denySite("http://www.test2.com/") ); - $this->AssertSame( array( - 'http://www.test1.com/' => false, - 'http://www.test2.com/' => false, - 'http://www.test3.com/' => false - ), - $storage->getTrustedSites(self::USER) ); - - $this->_user->delLoggedInUser(); - $storage->delUser(self::USER); - } - - /** - * testing delSite - * - */ - public function testDelSite() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - $sreg = new Zend_OpenId_Extension_Sreg(array("nickname"=>"test_id")); - - // not logged in - $this->assertFalse( $provider->delSite("http://www.test.com/") ); - - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->allowSite("http://www.test1.com/") ); - $this->assertTrue( $provider->allowSite("http://www.test2.com/", $sreg) ); - $this->AssertSame( array( - 'http://www.test1.com/' => true, - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ) - ), - $storage->getTrustedSites(self::USER) ); - - $this->assertTrue( $provider->delSite("http://www.test3.com/") ); - $this->AssertSame( array( - 'http://www.test1.com/' => true, - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ) - ), - $storage->getTrustedSites(self::USER) ); - - $this->assertTrue( $provider->delSite("http://www.test1.com/") ); - $this->AssertSame( array( - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ) - ), - $storage->getTrustedSites(self::USER) ); - - $this->assertTrue( $provider->delSite("http://www.test2.com/") ); - $this->AssertSame( array( - ), - $storage->getTrustedSites(self::USER) ); - - $this->_user->delLoggedInUser(); - $storage->delUser(self::USER); - } - - /** - * testing getTrustedSites - * - */ - public function testGetTrustedSites() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $storage->delUser(self::USER); - $this->_user->delLoggedInUser(); - $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage); - $sreg = new Zend_OpenId_Extension_Sreg(array("nickname"=>"test_id")); - - $this->assertTrue( $provider->register(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->allowSite("http://www.test1.com/") ); - $this->assertTrue( $provider->allowSite("http://www.test2.com/", $sreg) ); - $this->AssertSame( array( - 'http://www.test1.com/' => true, - 'http://www.test2.com/' => array( - 'Zend_OpenId_Extension_Sreg' => array( - 'nickname' => 'test_id' - ) - ) - ), - $provider->getTrustedSites() ); - - $this->_user->delLoggedInUser(); - $this->AssertFalse( $provider->getTrustedSites() ); - - $storage->delUser(self::USER); - } - - /** - * testing genSecret - * - */ - public function testGenSecret() - { - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider")); - - // SHA1 - $x = $provider->genSecret("sha1"); - $this->assertTrue( is_string($x) ); - $this->assertSame( 20, strlen($x) ); - - // SHA256 - $x = $provider->genSecret("sha256"); - $this->assertTrue( is_string($x) ); - $this->assertSame( 32, strlen($x) ); - - // invalid function - $this->assertFalse( $provider->genSecret("md5") ); - } - - /** - * testing _associate - * - */ - public function testAssociate() - { - try { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, $storage); - - // Wrong assoc_type - $ret = $provider->handle(array('openid_mode'=>'associate')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'unsupported-type', $res['error-code'] ); - - // Wrong assoc_type (OpenID 2.0) - $ret = $provider->handle(array('openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_mode'=>'associate')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( Zend_OpenId::NS_2_0, $res['ns'] ); - $this->assertSame( 'unsupported-type', $res['error-code'] ); - - // Wrong session_type - $ret = $provider->handle(array('openid_mode'=>'associate', - 'openid_assoc_type'=>'HMAC-SHA1', - 'openid_session_type'=>'DH-SHA257')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'unsupported-type', $res['error-code'] ); - - // Associaation without encryption - $ret = $provider->handle(array('openid_assoc_type'=>'HMAC-SHA1', - 'openid_mode'=>'associate')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'HMAC-SHA1', $res['assoc_type'] ); - $this->assertTrue( isset($res['mac_key']) ); - $this->assertSame( 20, strlen(base64_decode($res['mac_key'])) ); - $this->assertTrue( isset($res['assoc_handle']) ); - $this->assertSame( '3600', $res['expires_in'] ); - $this->assertFalse( isset($res['session_type']) ); - $this->assertTrue( $storage->getAssociation($res['assoc_handle'], $macFunc, $secret, $expires) ); - $this->assertSame( 'sha1', $macFunc ); - $this->assertSame( bin2hex(base64_decode($res['mac_key'])), bin2hex($secret) ); - - // Associaation without encryption (OpenID 2.0) - $ret = $provider->handle(array('openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_type'=>'HMAC-SHA256', - 'openid_mode'=>'associate')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( Zend_OpenId::NS_2_0, $res['ns'] ); - $this->assertSame( 'HMAC-SHA256', $res['assoc_type'] ); - $this->assertTrue( isset($res['mac_key']) ); - $this->assertSame( 32, strlen(base64_decode($res['mac_key'])) ); - $this->assertTrue( isset($res['assoc_handle']) ); - $this->assertSame( '3600', $res['expires_in'] ); - $this->assertFalse( isset($res['session_type']) ); - $this->assertTrue( $storage->getAssociation($res['assoc_handle'], $macFunc, $secret, $expires) ); - $this->assertSame( 'sha256', $macFunc ); - $this->assertSame( bin2hex(base64_decode($res['mac_key'])), bin2hex($secret) ); - - // Associaation without encryption (OpenID 2.0) - $ret = $provider->handle(array('openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_type'=>'HMAC-SHA256', - 'openid_mode'=>'associate', - 'openid_session_type'=>'no-encryption')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( Zend_OpenId::NS_2_0, $res['ns'] ); - $this->assertSame( 'HMAC-SHA256', $res['assoc_type'] ); - $this->assertTrue( isset($res['mac_key']) ); - $this->assertSame( 32, strlen(base64_decode($res['mac_key'])) ); - $this->assertTrue( isset($res['assoc_handle']) ); - $this->assertSame( '3600', $res['expires_in'] ); - $this->assertSame( 'no-encryption', $res['session_type'] ); - $this->assertTrue( $storage->getAssociation($res['assoc_handle'], $macFunc, $secret, $expires) ); - $this->assertSame( 'sha256', $macFunc ); - $this->assertSame( bin2hex(base64_decode($res['mac_key'])), bin2hex($secret) ); - - // Associaation with DH-SHA1 encryption - $ret = $provider->handle(array('openid_assoc_type'=>'HMAC-SHA1', - 'openid_mode'=>'associate', - 'openid_session_type'=>'DH-SHA1', - 'openid_dh_modulus'=>'ANz5OguIOXLsDhmYmsWizjEOHTdxfo2Vcbt2I3MYZuYe91ouJ4mLBX+YkcLiemOcPym2CBRYHNOyyjmG0mg3BVd9RcLn5S3IHHoXGHblzqdLFEi/368Ygo79JRnxTkXjgmY0rxlJ5bU1zIKaSDuKdiI+XUkKJX8Fvf8W8vsixYOr', - 'openid_dh_gen'=>'Ag==', - 'openid_dh_consumer_public'=>'RqexRm+Zn5s3sXxFBjI9WfCOBwBDDQBKPzX4fjMGl3YEJh5tx8SVo7awgwuqsliR+nvjmRh5kSFIGv8YSCsy88v1CcAfWUGfjehO9euxQcXOYJnNGbl6GQrE2FYe2RCvML4Yi8eYCYtCQi0wlDE7BJXGSVPXFzj/ru0lR/voPpk=', - )); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'HMAC-SHA1', $res['assoc_type'] ); - $this->assertSame( 'DH-SHA1', $res['session_type'] ); - $this->assertTrue( isset($res['dh_server_public']) ); - $this->assertTrue( isset($res['enc_mac_key']) ); - $this->assertSame( 20, strlen(base64_decode($res['enc_mac_key'])) ); - $this->assertTrue( isset($res['assoc_handle']) ); - $this->assertSame( '3600', $res['expires_in'] ); - $this->assertTrue( $storage->getAssociation($res['assoc_handle'], $macFunc, $secret, $expires) ); - $this->assertSame( 'sha1', $macFunc ); - - // Associaation with DH-SHA256 encryption (OpenID 2.0) - $ret = $provider->handle(array('openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_type'=>'HMAC-SHA256', - 'openid_mode'=>'associate', - 'openid_session_type'=>'DH-SHA256', - 'openid_dh_modulus'=>'ANz5OguIOXLsDhmYmsWizjEOHTdxfo2Vcbt2I3MYZuYe91ouJ4mLBX+YkcLiemOcPym2CBRYHNOyyjmG0mg3BVd9RcLn5S3IHHoXGHblzqdLFEi/368Ygo79JRnxTkXjgmY0rxlJ5bU1zIKaSDuKdiI+XUkKJX8Fvf8W8vsixYOr', - 'openid_dh_gen'=>'Ag==', - 'openid_dh_consumer_public'=>'RqexRm+Zn5s3sXxFBjI9WfCOBwBDDQBKPzX4fjMGl3YEJh5tx8SVo7awgwuqsliR+nvjmRh5kSFIGv8YSCsy88v1CcAfWUGfjehO9euxQcXOYJnNGbl6GQrE2FYe2RCvML4Yi8eYCYtCQi0wlDE7BJXGSVPXFzj/ru0lR/voPpk=', - )); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'HMAC-SHA256', $res['assoc_type'] ); - $this->assertSame( 'DH-SHA256', $res['session_type'] ); - $this->assertTrue( isset($res['dh_server_public']) ); - $this->assertTrue( isset($res['enc_mac_key']) ); - $this->assertSame( 32, strlen(base64_decode($res['enc_mac_key'])) ); - $this->assertTrue( isset($res['assoc_handle']) ); - $this->assertSame( '3600', $res['expires_in'] ); - $this->assertTrue( $storage->getAssociation($res['assoc_handle'], $macFunc, $secret, $expires) ); - $this->assertSame( 'sha256', $macFunc ); - } catch (Zend_OpenId_Exception $e) { - $this->markTestSkipped($e->getMessage()); - } - } - - /** - * testing _checkAuthentication - * - */ - public function testCheckAuthentication() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, $storage); - - // Wrong arguments - $ret = $provider->handle(array('openid_mode'=>'check_authentication')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'id_res', $res['openid.mode'] ); - $this->assertSame( 'false', $res['is_valid'] ); - - // Wrong arguments (OpenID 2.0) - $ret = $provider->handle(array('openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_mode'=>'check_authentication')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( Zend_OpenId::NS_2_0, $res['ns'] ); - $this->assertSame( 'id_res', $res['openid.mode'] ); - $this->assertSame( 'false', $res['is_valid'] ); - - // Wrong session id - $storage->delAssociation(self::HANDLE); - $ret = $provider->handle(array('openid_mode'=>'check_authentication', - 'openid_assoc_handle'=>self::HANDLE)); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'id_res', $res['openid.mode'] ); - $this->assertSame( 'false', $res['is_valid'] ); - - // Proper session signed with HAMC-SHA256 - $storage->addAssociation(self::HANDLE, "sha1", pack("H*", '0102030405060708091011121314151617181920'), time() + 3660); - $ret = $provider->handle(array('openid_mode'=>'check_authentication', - 'openid_assoc_handle'=>self::HANDLE, - 'openid_signed'=>'mode,assoc_handle,signed', - 'openid_sig'=>'IgLZCOXmEPowYl6yyFZjYL4ZTtQ=')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'id_res', $res['openid.mode'] ); - $this->assertSame( 'true', $res['is_valid'] ); - - // Proper session signed with HAMC-SHA256 - $storage->delAssociation(self::HANDLE); - $storage->addAssociation(self::HANDLE, "sha256", pack("H*", '0102030405060708091011121314151617181920212223242526272829303132'), time() + 3660); - $ret = $provider->handle(array('openid_mode'=>'check_authentication', - 'openid_assoc_handle'=>self::HANDLE, - 'openid_signed'=>'mode,assoc_handle,signed', - 'openid_sig'=>'xoJcXj30L1N7QRir7I2ovop1SaijXnAI97X/yH+kvck=')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'id_res', $res['openid.mode'] ); - $this->assertSame( 'true', $res['is_valid'] ); - - // Wrong signature - $storage->delAssociation(self::HANDLE); - $storage->addAssociation(self::HANDLE, "sha256", pack("H*", '0102030405060708091011121314151617181920212223242526272829303132'), time() + 3660); - $ret = $provider->handle(array('openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_mode'=>'check_authentication', - 'openid_assoc_handle'=>self::HANDLE, - 'openid_signed'=>'ns,mode,assoc_handle,signed', - 'openid_sig'=>'xoJcXj30L1N7QRir7I2ovop1SaijXnAI97X/yH+kvck=')); - $res = array(); - foreach (explode("\n", $ret) as $line) { - if (!empty($line)) { - list($key, $val) = explode(":", $line, 2); - $res[$key] = $val; - } - } - $this->assertSame( 'id_res', $res['openid.mode'] ); - $this->assertSame( 'false', $res['is_valid'] ); - - $storage->delAssociation(self::HANDLE); - } - - /** - * testing respondToConsumer - * - */ - public function testRespondToConsumer() - { - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, $storage); - - // dumb mode - $response = new Zend_OpenId_ResponseHelper(true); - $storage->delAssociation(self::HANDLE); - $this->assertTrue( $provider->respondToConsumer(array( - 'openid_assoc_handle' => self::HANDLE, - 'openid_return_to' => 'http://www.test.com/test.php' - ), null, $response) ); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $ret = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $ret[$key] = urldecode($val); - } - $this->assertSame( 'id_res', $ret['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $ret['openid.return_to'] ); - $this->assertTrue( isset($ret['openid.assoc_handle']) ); - $this->assertTrue( isset($ret['openid.response_nonce']) ); - $this->assertTrue( isset($ret['openid.signed']) ); - $this->assertTrue( isset($ret['openid.sig']) ); - $this->assertTrue( $storage->getAssociation($ret['openid.assoc_handle'], $macFunc, $secret, $expires) ); - $this->assertSame( 'sha1', $macFunc ); - - // OpenID 2.0 with SHA256 - $_SERVER['SCRIPT_URI'] = "http://www.test.com/endpoint.php"; - $response = new Zend_OpenId_ResponseHelper(true); - $storage->addAssociation(self::HANDLE, "sha256", pack("H*", '0102030405060708091011121314151617181920212223242526272829303132'), time() + 3660); - $this->assertTrue( $provider->respondToConsumer(array( - 'openid_ns' => Zend_OpenId::NS_2_0, - 'openid_assoc_handle' => self::HANDLE, - 'openid_return_to' => 'http://www.test.com/test.php' - ), null, $response) ); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $ret = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $ret[$key] = urldecode($val); - } - $this->assertSame( 'id_res', $ret['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $ret['openid.return_to'] ); - $this->assertSame( self::HANDLE, $ret['openid.assoc_handle'] ); - $this->assertTrue( isset($ret['openid.response_nonce']) ); - $this->assertTrue( isset($ret['openid.signed']) ); - $this->assertTrue( isset($ret['openid.sig']) ); - $this->assertSame( Zend_OpenId::NS_2_0, $ret['openid.ns'] ); - $this->assertSame( "http://www.test.com/endpoint.php", $ret['openid.op_endpoint'] ); - $this->assertTrue( $storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires) ); - $this->assertSame( 'sha256', $macFunc ); - $storage->delAssociation(self::HANDLE); - - // OpenID 1.1 with SHA1 - $storage->addAssociation(self::HANDLE, "sha1", pack("H*", '0102030405060708091011121314151617181920'), time() + 3660); - $response = new Zend_OpenId_ResponseHelper(true); - $ret = $provider->respondToConsumer(array( - 'openid_assoc_handle' => self::HANDLE, - 'openid_return_to' => 'http://www.test.com/test.php', - 'openid_claimed_id' => 'http://claimed_id/', - 'openid_identity' => 'http://identity/', - 'openid_unknown' => 'http://www.test.com/test.php', - ), null, $response); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $ret = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $ret[$key] = urldecode($val); - } - $this->assertSame( 'id_res', $ret['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $ret['openid.return_to'] ); - $this->assertSame( self::HANDLE, $ret['openid.assoc_handle'] ); - $this->assertTrue( isset($ret['openid.response_nonce']) ); - $this->assertTrue( isset($ret['openid.signed']) ); - $this->assertTrue( isset($ret['openid.sig']) ); - $this->assertFalse( isset($ret['openid.ns']) ); - $this->assertFalse( isset($ret['openid.op_endpoint']) ); - $this->assertSame( 'http://claimed_id/', $ret['openid.claimed_id'] ); - $this->assertSame( 'http://identity/', $ret['openid.identity'] ); - $this->assertFalse( isset($ret['openid.unknown']) ); - $this->assertTrue( $storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires) ); - $this->assertSame( 'sha1', $macFunc ); - $storage->delAssociation(self::HANDLE); - - // extensions - $sreg = new Zend_OpenId_Extension_Sreg(array("nickname"=>"test_id")); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue( $provider->respondToConsumer(array( - 'openid_return_to' => 'http://www.test.com/test.php', - ), $sreg, $response) ); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $ret = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $ret[$key] = urldecode($val); - } - $this->assertSame( 'test_id', $ret['openid.sreg.nickname'] ); - } - - /** - * testing _checkId - * - */ - public function testCheckIdImmediate() - { - $_SERVER['SCRIPT_URI'] = "http://www.test.com/server.php"; - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, $storage); - $provider->logout(); - - // Wrong arguments (no openid.return_to and openid.trust_root) - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertFalse( $provider->handle(array( - 'openid_mode'=>'checkid_immediate'), - null, $response) ); - - // Unexistent user - $storage->delUser(self::USER); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( 'http://www.test.com/test.php?openid.mode=cancel', $headers[0]['value'] ); - - // No openid_identity - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'login', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - - // Non logged in user - $provider->register(self::USER, self::PASSWORD); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'login', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - $this->assertSame( self::USER, $query2['openid.identity'] ); - - // Non logged in user with SREG - $provider->register(self::USER, self::PASSWORD); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php', - 'openid_ns_sreg'=>Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, - 'openid_sreg_required'=>'nickname'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'login', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - $this->assertSame( self::USER, $query2['openid.identity'] ); - $this->assertSame( Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, $query2['openid.ns.sreg'] ); - $this->assertSame( "nickname", $query2['openid.sreg.required'] ); - - // Logged in user (unknown site) - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'trust', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - $this->assertSame( self::USER, $query2['openid.identity'] ); - - // Logged in user (unknown site 2) - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $this->assertTrue( $provider->allowSite('http://www.test.com/test1.php') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'trust', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - $this->assertSame( self::USER, $query2['openid.identity'] ); - - // Logged in user (unknown site + SREG) - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue( $provider->delSite('http://www.test.com/test1.php') ); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php', - 'openid_ns_sreg'=>Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, - 'openid_sreg_required'=>'nickname'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'trust', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - $this->assertSame( self::USER, $query2['openid.identity'] ); - $this->assertSame( Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, $query2['openid.ns.sreg'] ); - $this->assertSame( "nickname", $query2['openid.sreg.required'] ); - - // Logged in user (untrusted site) - $this->assertTrue( $provider->denySite('http://www.test.com') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( 'http://www.test.com/test.php?openid.mode=cancel', $headers[0]['value'] ); - - // Logged in user (untrusted site with wildcard) - $this->assertTrue( $provider->delSite('http://www.test.com') ); - $this->assertTrue( $provider->denySite('http://*.test.com') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( 'http://www.test.com/test.php?openid.mode=cancel', $headers[0]['value'] ); - - // Logged in user (trusted site) - $this->assertTrue( $provider->delSite('http://*.test.com') ); - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertTrue( isset($query['openid.assoc_handle']) ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 20, strlen(base64_decode($query['openid.sig'])) ); - - // Logged in user (trusted site without openid.return_to) - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_trust_root'=>'http://www.test.com/test.php'), - null, $response)); - $this->assertSame( array(), $response->getHeaders() ); - $this->assertSame( '', $response->getBody() ); - - // Logged in user (trusted site) & OpenID 2.0 & established session - $storage->delAssociation(self::HANDLE); - $storage->addAssociation(self::HANDLE, "sha1", pack("H*", '0102030405060708091011121314151617181920'), time() + 3660); - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_handle'=>self::HANDLE, - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( Zend_OpenId::NS_2_0, $query['openid.ns'] ); - $this->assertSame( "http://www.test.com/server.php", $query['openid.op_endpoint'] ); - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 20, strlen(base64_decode($query['openid.sig'])) ); - - // Logged in user (trusted site) & invalid association handle - $storage->delAssociation(self::HANDLE); - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_handle'=>self::HANDLE, - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( Zend_OpenId::NS_2_0, $query['openid.ns'] ); - $this->assertSame( "http://www.test.com/server.php", $query['openid.op_endpoint'] ); - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertSame( self::HANDLE, $query['openid.invalidate_handle'] ); - $this->assertTrue( isset($query['openid.assoc_handle']) ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 32, strlen(base64_decode($query['openid.sig'])) ); - - // SREG success - $sreg = new Zend_OpenId_Extension_Sreg(array('nickname'=>'test','email'=>'test@test.com')); - $this->assertTrue( $provider->allowSite('http://www.test.com/', $sreg) ); - $sreg = new Zend_OpenId_Extension_Sreg(); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php', - 'openid_ns_sreg'=>Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, - 'openid_sreg_required'=>'nickname', - 'openid_sreg_optional'=>'email', - ), - $sreg, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( Zend_OpenId::NS_2_0, $query['openid.ns'] ); - $this->assertSame( "http://www.test.com/server.php", $query['openid.op_endpoint'] ); - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertTrue( isset($query['openid.assoc_handle']) ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 32, strlen(base64_decode($query['openid.sig'])) ); - $this->assertSame( Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, $query['openid.ns.sreg'] ); - $this->assertSame( 'test', $query['openid.sreg.nickname'] ); - $this->assertSame( 'test@test.com', $query['openid.sreg.email'] ); - - // SREG failed - $sreg = new Zend_OpenId_Extension_Sreg(array('nickname'=>'test')); - $this->assertTrue( $provider->allowSite('http://www.test.com/', $sreg) ); - $sreg = new Zend_OpenId_Extension_Sreg(); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_immediate', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php', - 'openid_sreg_required'=>'nickname,email', - ), - $sreg, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'cancel', $query['openid.mode'] ); - $url2 = parse_url($query['openid.user_setup_url']); - $this->assertSame( 'www.test.com', $url2['host'] ); - $this->assertSame( '/server.php', $url2['path'] ); - $query2 = array(); - foreach (explode('&', $url2['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query2[$key] = urldecode($val); - } - $this->assertSame( 'trust', $query2['openid.action'] ); - $this->assertSame( 'checkid_setup', $query2['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query2['openid.return_to'] ); - $this->assertSame( self::USER, $query2['openid.identity'] ); - $this->assertSame( "nickname,email", $query2['openid.sreg.required'] ); - - $provider->logout(); - $storage->delUser(self::USER); - } - - /** - * testing handle - * - */ - public function testCheckIdSetup() - { - $_SERVER['SCRIPT_URI'] = "http://www.test.com/server.php"; - $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider"); - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, $storage); - $provider->logout(); - - // Wrong arguments (no openid.return_to and openid.trust_root) - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertFalse( $provider->handle(array( - 'openid_mode'=>'checkid_setup'), - null, $response) ); - - // Unexistent user - $storage->delUser(self::USER); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( 'http://www.test.com/test.php?openid.mode=cancel', $headers[0]['value'] ); - - // No openid_identity - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/server.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'login', $query['openid.action'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - - // Non logged in user - $provider->register(self::USER, self::PASSWORD); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/server.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'login', $query['openid.action'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - - // Logged in user (unknown site) - $this->assertTrue( $provider->login(self::USER, self::PASSWORD) ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/server.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'trust', $query['openid.action'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - - // Logged in user (untrusted site) - $this->assertTrue( $provider->denySite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( 'http://www.test.com/test.php?openid.mode=cancel', $headers[0]['value'] ); - - // Logged in user (trusted site) - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertTrue( isset($query['openid.assoc_handle']) ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 20, strlen(base64_decode($query['openid.sig'])) ); - - // Logged in user (trusted site without openid.return_to) - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_trust_root'=>'http://www.test.com/test.php'), - null, $response)); - $this->assertSame( array(), $response->getHeaders() ); - $this->assertSame( '', $response->getBody() ); - - // Logged in user (trusted site) & OpenID 2.0 & established session - $storage->delAssociation(self::HANDLE); - $storage->addAssociation(self::HANDLE, "sha1", pack("H*", '0102030405060708091011121314151617181920'), time() + 3660); - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_handle'=>self::HANDLE, - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( Zend_OpenId::NS_2_0, $query['openid.ns'] ); - $this->assertSame( "http://www.test.com/server.php", $query['openid.op_endpoint'] ); - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertSame( self::HANDLE, $query['openid.assoc_handle'] ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 20, strlen(base64_decode($query['openid.sig'])) ); - - // Logged in user (trusted site) & invalid association handle - $storage->delAssociation(self::HANDLE); - $this->assertTrue( $provider->allowSite('http://www.test.com/') ); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_assoc_handle'=>self::HANDLE, - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php'), - null, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( Zend_OpenId::NS_2_0, $query['openid.ns'] ); - $this->assertSame( "http://www.test.com/server.php", $query['openid.op_endpoint'] ); - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertSame( self::HANDLE, $query['openid.invalidate_handle'] ); - $this->assertTrue( isset($query['openid.assoc_handle']) ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 32, strlen(base64_decode($query['openid.sig'])) ); - - // SREG success - $sreg = new Zend_OpenId_Extension_Sreg(array('nickname'=>'test','email'=>'test@test.com')); - $this->assertTrue( $provider->allowSite('http://www.test.com/', $sreg) ); - $sreg = new Zend_OpenId_Extension_Sreg(); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_ns'=>Zend_OpenId::NS_2_0, - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php', - 'openid_ns_sreg'=>Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, - 'openid_sreg_required'=>'nickname', - 'openid_sreg_optional'=>'email', - ), - $sreg, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/test.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( Zend_OpenId::NS_2_0, $query['openid.ns'] ); - $this->assertSame( "http://www.test.com/server.php", $query['openid.op_endpoint'] ); - $this->assertSame( 'id_res', $query['openid.mode'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertTrue( isset($query['openid.assoc_handle']) ); - $this->assertTrue( isset($query['openid.response_nonce']) ); - $this->assertTrue( isset($query['openid.signed']) ); - $this->assertTrue( isset($query['openid.sig']) ); - $this->assertSame( 32, strlen(base64_decode($query['openid.sig'])) ); - $this->assertSame( Zend_OpenId_Extension_Sreg::NAMESPACE_1_1, $query['openid.ns.sreg'] ); - $this->assertSame( 'test', $query['openid.sreg.nickname'] ); - $this->assertSame( 'test@test.com', $query['openid.sreg.email'] ); - - // SREG failed - $sreg = new Zend_OpenId_Extension_Sreg(array('nickname'=>'test')); - $this->assertTrue( $provider->allowSite('http://www.test.com/', $sreg) ); - $sreg = new Zend_OpenId_Extension_Sreg(); - $response = new Zend_OpenId_ResponseHelper(true); - $this->assertTrue($provider->handle(array( - 'openid_mode'=>'checkid_setup', - 'openid_identity'=>self::USER, - 'openid_return_to'=>'http://www.test.com/test.php', - 'openid_sreg_required'=>'nickname,email', - ), - $sreg, $response)); - $headers = $response->getHeaders(); - $this->assertSame( 'Location', $headers[0]['name'] ); - $url = parse_url($headers[0]['value']); - $this->assertSame( 'www.test.com', $url['host'] ); - $this->assertSame( '/server.php', $url['path'] ); - $query = array(); - foreach (explode('&', $url['query']) as $line) { - list($key,$val) = explode('=', $line, 2); - $query[$key] = urldecode($val); - } - $this->assertSame( 'trust', $query['openid.action'] ); - $this->assertSame( 'checkid_setup', $query['openid.mode'] ); - $this->assertSame( self::USER, $query['openid.identity'] ); - $this->assertSame( 'http://www.test.com/test.php', $query['openid.return_to'] ); - $this->assertSame( 'nickname,email', $query['openid.sreg.required'] ); - - $provider->logout(); - $storage->delUser(self::USER); - } - - /** - * testing handle - * - */ - public function testHandle() - { - $provider = new Zend_OpenId_ProviderHelper(null, null, $this->_user, new Zend_OpenId_Provider_Storage_File(dirname(__FILE__)."/_files/provider")); - - // no openid_mode - $this->assertFalse( $provider->handle(array()) ); - - // wrong openid_mode - $this->assertFalse( $provider->handle(array('openid_mode'=>'wrong')) ); - } -} - -class Zend_OpenId_ProviderHelper extends Zend_OpenId_Provider -{ - public function genSecret($func) - { - return $this->_genSecret($func); - } -} diff --git a/tests/Zend/OpenId/ResponseHelper.php b/tests/Zend/OpenId/ResponseHelper.php deleted file mode 100644 index 36066543213f7341e37a61655123b7f17521107b..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenId/ResponseHelper.php +++ /dev/null @@ -1,50 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ResponseHelper.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId.php'; - -Zend_OpenId::$exitOnRedirect = false; - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenId_ResponseHelper extends Zend_Controller_Response_Abstract -{ - private $_canSendHeaders; - - public function __construct($canSendHeaders) - { - $this->_canSendHeaders = $canSendHeaders; - } - - public function canSendHeaders($throw = false) - { - return $this->_canSendHeaders; - } - - public function sendResponse() - { - } -} diff --git a/tests/Zend/OpenIdTest.php b/tests/Zend/OpenIdTest.php deleted file mode 100644 index 707159819d2d3a381c6928cfe2a760e9f2a94f26..0000000000000000000000000000000000000000 --- a/tests/Zend/OpenIdTest.php +++ /dev/null @@ -1,678 +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_OpenId - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OpenIdTest.php 10262 2008-07-21 16:31:27Z matthew $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * Zend_OpenId - */ -require_once 'Zend/OpenId.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework.php'; - - -/** - * Zend_OpenId_ResponseHelper - */ -require_once 'Zend/OpenId/ResponseHelper.php'; - - -/** - * @package Zend_OpenId - * @subpackage UnitTests - */ -class Zend_OpenIdTest extends PHPUnit_Framework_TestCase -{ - private $_serverVariables; - - public function setUp() - { - $this->_serverVariables = $_SERVER; - } - - public function tearDown() - { - $_SERVER = $this->_serverVariables; - } - - - /** - * testing testSelfUrl - * - */ - public function testSelfUrl() - { - unset($_SERVER['SCRIPT_URI']); - unset($_SERVER['HTTPS']); - unset($_SERVER['HTTP_HOST']); - unset($_SERVER['SERVER_NAME']); - unset($_SERVER['SERVER_PORT']); - unset($_SERVER['SCRIPT_URL']); - unset($_SERVER['REDIRECT_URL']); - unset($_SERVER['PHP_SELF']); - unset($_SERVER['SCRIPT_NAME']); - unset($_SERVER['PATH_INFO']); - $this->assertSame( 'http://', Zend_OpenId::selfUrl() ); - - $_SERVER['SCRIPT_URI'] = "http://www.test.com/"; - $this->assertSame( 'http://www.test.com/', Zend_OpenId::selfUrl() ); - - unset($_SERVER['SCRIPT_URI']); - $_SERVER['HTTP_HOST'] = "www.test.com"; - $_SERVER['SERVER_NAME'] = "www.wrong.com"; - $this->assertSame( 'http://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['HTTP_HOST'] = "www.test.com:80"; - $this->assertSame( 'http://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['HTTP_HOST'] = "www.test.com:8080"; - $this->assertSame( 'http://www.test.com:8080', Zend_OpenId::selfUrl() ); - - $_SERVER['HTTP_HOST'] = "www.test.com"; - $_SERVER['SERVER_PORT'] = "80"; - $this->assertSame( 'http://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['SERVER_PORT'] = "8080"; - $this->assertSame( 'http://www.test.com:8080', Zend_OpenId::selfUrl() ); - - unset($_SERVER['HTTP_HOST']); - unset($_SERVER['SERVER_PORT']); - $_SERVER['SERVER_NAME'] = "www.test.com"; - $this->assertSame( 'http://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['SERVER_PORT'] = "80"; - $this->assertSame( 'http://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['SERVER_PORT'] = "8080"; - $this->assertSame( 'http://www.test.com:8080', Zend_OpenId::selfUrl() ); - - unset($_SERVER['SERVER_PORT']); - $_SERVER['HTTPS'] = "on"; - $this->assertSame( 'https://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['SERVER_PORT'] = "443"; - $this->assertSame( 'https://www.test.com', Zend_OpenId::selfUrl() ); - - $_SERVER['SERVER_PORT'] = "8080"; - $this->assertSame( 'https://www.test.com:8080', Zend_OpenId::selfUrl() ); - - unset($_SERVER['SERVER_PORT']); - unset($_SERVER['HTTPS']); - - $_SERVER['SCRIPT_URL'] = '/test.php'; - $_SERVER['PHP_SELF'] = '/bug.php'; - $_SERVER['SCRIPT_NAME'] = '/bug.php'; - $_SERVER['PATH_INFO'] = '/bug'; - $this->assertSame( 'http://www.test.com/test.php', Zend_OpenId::selfUrl() ); - - unset($_SERVER['SCRIPT_URL']); - $_SERVER['REDIRECT_URL'] = '/ok'; - $_SERVER['PHP_SELF'] = '/bug.php'; - $_SERVER['SCRIPT_NAME'] = '/bug.php'; - $_SERVER['PATH_INFO'] = '/bug'; - $this->assertSame( 'http://www.test.com/ok', Zend_OpenId::selfUrl() ); - - unset($_SERVER['REDIRECT_URL']); - $_SERVER['PHP_SELF'] = '/test.php'; - $this->assertSame( 'http://www.test.com/test.php', Zend_OpenId::selfUrl() ); - - unset($_SERVER['PHP_SELF']); - $_SERVER['SCRIPT_NAME'] = '/test.php'; - $_SERVER['PATH_INFO'] = '/ok'; - $this->assertSame( 'http://www.test.com/test.php/ok', Zend_OpenId::selfUrl() ); - - unset($_SERVER['PATH_INFO']); - $this->assertSame( 'http://www.test.com/test.php', Zend_OpenId::selfUrl() ); - } - - /** - * testing testAbsolutefUrl - * - */ - public function testAbsoluteUrl() - { - unset($_SERVER['SCRIPT_URI']); - unset($_SERVER['HTTPS']); - unset($_SERVER['HTTP_HOST']); - unset($_SERVER['SERVER_NAME']); - unset($_SERVER['SERVER_PORT']); - unset($_SERVER['SCRIPT_URL']); - unset($_SERVER['REDIRECT_URL']); - unset($_SERVER['PHP_SELF']); - unset($_SERVER['SCRIPT_NAME']); - unset($_SERVER['PATH_INFO']); - - $_SERVER['HTTP_HOST'] = "www.test.com"; - $_SERVER['SCRIPT_NAME'] = '/a/b/c/test.php'; - - $this->assertSame( 'http://www.test.com/a/b/c/test.php', Zend_OpenId::absoluteUrl("") ); - - $this->assertSame( 'http://www.test.com/a/b/c/ok.php', Zend_OpenId::absoluteUrl("ok.php") ); - - $this->assertSame( 'http://www.test.com/a/ok.php', Zend_OpenId::absoluteUrl("/a/ok.php") ); - - $this->assertSame( 'http://www.php.net/ok.php', Zend_OpenId::absoluteUrl("http://www.php.net/ok.php") ); - - $this->assertSame( 'https://www.php.net/ok.php', Zend_OpenId::absoluteUrl("https://www.php.net/ok.php") ); - - $_SERVER['SCRIPT_NAME'] = '/test.php'; - $this->assertSame( 'http://www.test.com/a/b.php', Zend_OpenId::absoluteUrl("/a/b.php") ); - - $this->assertSame( 'http://www.test.com/a/b.php', Zend_OpenId::absoluteUrl("a/b.php") ); - } - - /** - * testing testParamsToQuery - * - */ - public function testParamsToQuery() - { - $this->assertSame( '', Zend_OpenId::paramsToQuery(array()) ); - $this->assertSame( 'a=1', Zend_OpenId::paramsToQuery(array('a'=>1)) ); - $this->assertSame( 'a=1&b=2', Zend_OpenId::paramsToQuery(array('a'=>1,'b'=>2)) ); - $this->assertSame( 'a=x+y', Zend_OpenId::paramsToQuery(array('a'=>'x y')) ); - } - - /** - * testing testNormalizeUrl - * - */ - public function testNormalizeUrl() - { - $url = 'example://a/b/c/%7Bfoo%7D'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://a/b/c/%7Bfoo%7D', $url ); - - $url = 'eXAMPLE://A/./b/../b/%63/%7bfoo%7d'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://a/b/c/%7Bfoo%7D', $url ); - - $url = 'eXAMPLE://A/./b/../b/%63/%bbfoo%Bd'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://a/b/c/%BBfoo%BD', $url ); - - $url = 'example://a/b/c/%1'; - $this->assertFalse( Zend_OpenId::normalizeUrl($url) ); - - $url = 'example://a/b/c/%x1'; - $this->assertFalse( Zend_OpenId::normalizeUrl($url) ); - - $url = 'example://a/b/c/%1x'; - $this->assertFalse( Zend_OpenId::normalizeUrl($url) ); - - $url = 'eXAMPLE://A/b/c/x%20y'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://a/b/c/x%20y', $url ); - - $url = 'example://host/.a/b/c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/.a/b/c', $url ); - - $url = 'a/b/c'; - $this->assertFalse( Zend_OpenId::normalizeUrl($url) ); - - $url = 'example://:80/a/b/c'; - $this->assertFalse( Zend_OpenId::normalizeUrl($url) ); - - $url = 'example://host/a/.b/c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/.b/c', $url ); - - $url = 'example://host/a/b/.c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b/.c', $url ); - - $url = 'example://host/..a/b/c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/..a/b/c', $url ); - - $url = 'example://host/a/..b/c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/..b/c', $url ); - - $url = 'example://host/a/b/..c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b/..c', $url ); - - $url = 'example://host/./b/c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/b/c', $url ); - - $url = 'example://host/a/./c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/c', $url ); - - $url = 'example://host/a/b/.'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b', $url ); - - $url = 'example://host/a/b/./'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b/', $url ); - - $url = 'example://host/../b/c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/b/c', $url ); - - $url = 'example://host/a/../c'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/c', $url ); - - $url = 'example://host/a/b/..'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a', $url ); - - $url = 'example://host/a/b/../'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/', $url ); - - $url = 'example://host/a/b/c/..'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b', $url ); - - $url = 'example://host/a/b/c/../..'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a', $url ); - - $url = 'example://host/a/b/c/../../..'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/', $url ); - - $url = 'example://host///a///b///c///..///../d'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/d', $url ); - - $url = 'example://host///a///b///c///.///./d'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b/c/d', $url ); - - $url = 'example://host///a///b///c///..///./d'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b/d', $url ); - - $url = 'example://host///a///b///c///.///../d'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'example://host/a/b/d', $url ); - - $url = 'http://example.com'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/', $url ); - - $url = 'http://example.com/'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/', $url ); - - $url = 'http://example.com:'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/', $url ); - - $url = 'http://example.com:80/'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/', $url ); - - $url = 'https://example.com:443/'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'https://example.com/', $url ); - - $url = 'http://example.com?'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/?', $url ); - - $url = 'http://example.com/?'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/?', $url ); - - $url = 'http://example.com/test.php?Foo=Bar#Baz'; - $this->assertTrue( Zend_OpenId::normalizeUrl($url) ); - $this->assertSame( 'http://example.com/test.php?Foo=Bar', $url ); - } - - /** - * testing testNormalize - * - */ - public function testNormalize() - { - $url = ''; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( '', $url ); - - $url = ' localhost '; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'http://localhost/', $url ); - - $url = 'xri://$ip*127.0.0.1'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'http://127.0.0.1/', $url ); - - $url = 'xri://$dns*localhost'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'http://localhost/', $url ); - - $url = 'xri://localhost'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'http://localhost/', $url ); - - $url = '=name'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( '=name', $url ); - - $url = '@name'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( '@name', $url ); - - $url = '+name'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( '+name', $url ); - - $url = '$name'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( '$name', $url ); - - $url = '!name'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( '!name', $url ); - - $url = 'localhost'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'http://localhost/', $url ); - - $url = 'http://localhost'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'http://localhost/', $url ); - - $url = 'https://localhost'; - $this->assertTrue( Zend_OpenId::normalize($url) ); - $this->assertSame( 'https://localhost/', $url ); - } - - /** - * testing testRedirect - * - */ - public function testRedirect() - { - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/", null, $response, 'GET'); - $this->assertSame( 302, $response->getHttpResponseCode() ); - $this->assertSame( array(), $response->getRawHeaders() ); - $headers = $response->getHeaders(); - $this->assertTrue( is_array($headers) ); - $this->assertSame( 1, count($headers) ); - $this->assertTrue( is_array($headers[0]) ); - $this->assertSame( 3, count($headers[0]) ); - $this->assertSame( 'Location', $headers[0]['name'] ); - $this->assertSame( 'http://www.test.com/', $headers[0]['value'] ); - $this->assertSame( true, $headers[0]['replace'] ); - $this->assertSame( '', $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php?a=b", null, $response, 'GET'); - $headers = $response->getHeaders(); - $this->assertSame( 'http://www.test.com/test.php?a=b', $headers[0]['value'] ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php", array('a'=>'b'), $response, 'GET'); - $headers = $response->getHeaders(); - $this->assertSame( 'http://www.test.com/test.php?a=b', $headers[0]['value'] ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php", array('a'=>'b', 'c'=>'d'), $response, 'GET'); - $headers = $response->getHeaders(); - $this->assertSame( 'http://www.test.com/test.php?a=b&c=d', $headers[0]['value'] ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php?a=b", array('c'=>'d'), $response, 'GET'); - $headers = $response->getHeaders(); - $this->assertSame( 'http://www.test.com/test.php?a=b&c=d', $headers[0]['value'] ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php", array('a'=>'x y'), $response, 'GET'); - $headers = $response->getHeaders(); - $this->assertSame( 'http://www.test.com/test.php?a=x+y', $headers[0]['value'] ); - - $response = new Zend_OpenId_ResponseHelper(false); - Zend_OpenId::redirect("http://www.test.com/", null, $response, 'GET'); - $this->assertSame( 200, $response->getHttpResponseCode() ); - $this->assertSame( array(), $response->getRawHeaders() ); - $this->assertSame( array(), $response->getHeaders() ); - $this->assertSame( - "<script language=\"JavaScript\" type=\"text/javascript\">window.location='http://www.test.com/';</script>", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(false); - Zend_OpenId::redirect("http://www.test.com/test.php?a=b", null, $response, 'GET'); - $this->assertSame( - "<script language=\"JavaScript\" type=\"text/javascript\">window.location='http://www.test.com/test.php?a=b';</script>", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(false); - Zend_OpenId::redirect("http://www.test.com/test.php", array('a'=>'b'), $response, 'GET'); - $this->assertSame( - "<script language=\"JavaScript\" type=\"text/javascript\">window.location='http://www.test.com/test.php?a=b';</script>", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(false); - Zend_OpenId::redirect("http://www.test.com/test.php", array('a'=>'b','c'=>'d'), $response, 'GET'); - $this->assertSame( - "<script language=\"JavaScript\" type=\"text/javascript\">window.location='http://www.test.com/test.php?a=b&c=d';</script>", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(false); - Zend_OpenId::redirect("http://www.test.com/test.php?a=b", array('c'=>'d'), $response, 'GET'); - $this->assertSame( - "<script language=\"JavaScript\" type=\"text/javascript\">window.location='http://www.test.com/test.php?a=b&c=d';</script>", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(false); - Zend_OpenId::redirect("http://www.test.com/test.php", array('a'=>'x y'), $response, 'GET'); - $this->assertSame( - "<script language=\"JavaScript\" type=\"text/javascript\">window.location='http://www.test.com/test.php?a=x+y';</script>", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/", null, $response, 'POST'); - $this->assertSame( 200, $response->getHttpResponseCode() ); - $this->assertSame( array(), $response->getRawHeaders() ); - $this->assertSame( array(), $response->getHeaders() ); - $this->assertSame( - "<html><body onLoad=\"document.forms[0].submit();\">\n" . - "<form method=\"POST\" action=\"http://www.test.com/\">\n" . - "<input type=\"submit\" value=\"Continue OpenID transaction\">\n" . - "</form></body></html>\n", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php?a=b", array('a'=>'b'), $response, 'POST'); - $this->assertSame( - "<html><body onLoad=\"document.forms[0].submit();\">\n" . - "<form method=\"POST\" action=\"http://www.test.com/test.php?a=b\">\n" . - "<input type=\"hidden\" name=\"a\" value=\"b\">\n" . - "<input type=\"submit\" value=\"Continue OpenID transaction\">\n" . - "</form></body></html>\n", - $response->getBody() ); - - $response = new Zend_OpenId_ResponseHelper(true); - Zend_OpenId::redirect("http://www.test.com/test.php?a=b", array('a'=>'b','c'=>'d'), $response, 'POST'); - $this->assertSame( - "<html><body onLoad=\"document.forms[0].submit();\">\n" . - "<form method=\"POST\" action=\"http://www.test.com/test.php?a=b\">\n" . - "<input type=\"hidden\" name=\"a\" value=\"b\">\n" . - "<input type=\"hidden\" name=\"c\" value=\"d\">\n" . - "<input type=\"submit\" value=\"Continue OpenID transaction\">\n" . - "</form></body></html>\n", - $response->getBody() ); - } - - /** - * testing testRedirect - * - */ - public function testRandomBytes() - { - $this->assertSame( '', Zend_OpenId::randomBytes(0) ); - $x = Zend_OpenId::randomBytes(1); - $this->assertTrue( is_string($x) ); - $this->assertSame( 1, strlen($x) ); - $x = Zend_OpenId::randomBytes(1024); - $this->assertTrue( is_string($x) ); - $this->assertSame( 1024, strlen($x) ); - } - - /** - * testing testDigest - * - */ - public function testDigest() - { - $this->assertSame( - 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d', - bin2hex(Zend_OpenId::digest('sha1', 'hello')) ); - $this->assertSame( - '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824', - bin2hex(Zend_OpenId::digest('sha256', 'hello')) ); - } - - /** - * testing testHashHmac - * - */ - public function testHashHmac() - { - $key = 'password'; - $this->assertSame( - '1f48abc79459fa853af681ddb3c73ff7f35c48fb', - bin2hex(Zend_OpenId::hashHmac('sha1', 'hello', $key)) ); - $this->assertSame( - '7ae615e698567e5e1512dd8140e740bd4d65dfa4db195d80ca327de6302b4a63', - bin2hex(Zend_OpenId::hashHmac('sha256', 'hello', $key)) ); - $key = str_repeat('x',128); - $this->assertSame( - '59c6c30dc9fb96b2cb2d7c41dbc6f96d1fbf67ac', - bin2hex(Zend_OpenId::hashHmac('sha1', 'hello', $key)) ); - $this->assertSame( - 'f5e0c31f7cdd272710052ac3ebcc40d7e82be2427b7e5e1e8373ef1e327515f4', - bin2hex(Zend_OpenId::hashHmac('sha256', 'hello', $key)) ); - } - - /** - * testing testCreateDhKey - * - */ - public function testCreateDhKey() - { - try { - $dh = Zend_OpenId::createDhKey( - pack('H*', '0233'), - pack('H*', '05'), - pack('H*', '09')); - $dh_details = Zend_OpenId::getDhKeyDetails($dh); - $this->assertTrue( is_array($dh_details) ); - $this->assertSame( 4, count($dh_details)); - $this->assertSame( '0233', bin2hex($dh_details['p']) ); - $this->assertSame( '05', bin2hex($dh_details['g']) ); - $this->assertSame( '09', bin2hex($dh_details['priv_key']) ); - $this->assertSame( '4e', bin2hex($dh_details['pub_key']) ); - - $dh = Zend_OpenId::createDhKey( - pack('H*', '0233'), - pack('H*', '02'), - pack('H*', '09')); - $dh_details = Zend_OpenId::getDhKeyDetails($dh); - $this->assertTrue( is_array($dh_details) ); - $this->assertSame( 4, count($dh_details) ); - $this->assertSame( '0233', bin2hex($dh_details['p']) ); - $this->assertSame( '02', bin2hex($dh_details['g']) ); - $this->assertSame( '09', bin2hex($dh_details['priv_key']) ); - $this->assertSame( '0200', bin2hex($dh_details['pub_key']) ); - - $dh = Zend_OpenId::createDhKey( - pack('H*', '0233'), - pack('H*', '02')); - $dh_details = Zend_OpenId::getDhKeyDetails($dh); - $this->assertTrue( is_array($dh_details) ); - $this->assertSame( 4, count($dh_details) ); - $this->assertSame( '0233', bin2hex($dh_details['p']) ); - $this->assertSame( '02', bin2hex($dh_details['g']) ); - $this->assertTrue( is_string($dh_details['priv_key']) ); - $this->assertTrue( strlen($dh_details['priv_key']) > 0 ); - $this->assertTrue( is_string($dh_details['pub_key']) ); - $this->assertTrue( strlen($dh_details['pub_key']) > 0 ); - } catch (Zend_OpenId_Exception $e) { - $this->markTestSkipped($e->getMessage()); - } - } - - /** - * testing testComputeDhSecret - * - */ - public function testComputeDhSecret() - { - try { - $alice = Zend_OpenId::createDhKey( - pack('H*', '0233'), - pack('H*', '05'), - pack('H*', '09')); - $alice_details = Zend_OpenId::getDhKeyDetails($alice); - $this->assertSame( '4e', bin2hex($alice_details['pub_key']) ); - - $bob = Zend_OpenId::createDhKey( - pack('H*', '0233'), - pack('H*', '05'), - pack('H*', '0e')); - $bob_details = Zend_OpenId::getDhKeyDetails($bob); - $this->assertSame( '0216', bin2hex($bob_details['pub_key']) ); - - $this->assertSame( '75', - bin2hex(Zend_OpenId::computeDhSecret($alice_details['pub_key'], $bob)) ); - $this->assertSame( '75', - bin2hex(Zend_OpenId::computeDhSecret($bob_details['pub_key'], $alice)) ); - } catch (Zend_OpenId_Exception $e) { - $this->markTestSkipped($e->getMessage()); - } - } - - /** - * testing testBtwoc - * - */ - public function testBtwoc() - { - $this->assertSame( '00', bin2hex(Zend_OpenId::btwoc(pack('H*', '00'))) ); - $this->assertSame( '01', bin2hex(Zend_OpenId::btwoc(pack('H*', '01'))) ); - $this->assertSame( '7e', bin2hex(Zend_OpenId::btwoc(pack('H*', '7e'))) ); - $this->assertSame( '78', bin2hex(Zend_OpenId::btwoc(pack('H*', '78'))) ); - $this->assertSame( '0080', bin2hex(Zend_OpenId::btwoc(pack('H*', '80'))) ); - $this->assertSame( '0081', bin2hex(Zend_OpenId::btwoc(pack('H*', '81'))) ); - $this->assertSame( '00fe', bin2hex(Zend_OpenId::btwoc(pack('H*', 'fe'))) ); - $this->assertSame( '00ff', bin2hex(Zend_OpenId::btwoc(pack('H*', 'ff'))) ); - } -} diff --git a/tests/Zend/Paginator/Adapter/ArrayTest.php b/tests/Zend/Paginator/Adapter/ArrayTest.php deleted file mode 100644 index 545bda0a5861fe5d1a6fca76bff642c676354668..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/Adapter/ArrayTest.php +++ /dev/null @@ -1,82 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ArrayTest.php 11219 2008-09-04 02:09:23Z mratzloff $ - */ - -/** - * @see Zend_Paginator_Adapter_Array - */ -require_once 'Zend/Paginator/Adapter/Array.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_Adapter_ArrayTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_Adapter_Array - */ - private $_adapter; - - /** - * Prepares the environment before running a test. - */ - protected function setUp () - { - parent::setUp(); - $this->_adapter = new Zend_Paginator_Adapter_Array(range(1, 101)); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown () - { - $this->_adapter = null; - parent::tearDown(); - } - - public function testGetsItemsAtOffsetZero() - { - $expected = range(1, 10); - $actual = $this->_adapter->getItems(0, 10); - $this->assertEquals($expected, $actual); - } - - public function testGetsItemsAtOffsetTen() - { - $expected = range(11, 20); - $actual = $this->_adapter->getItems(10, 10); - $this->assertEquals($expected, $actual); - } - - public function testReturnsCorrectCount() - { - $this->assertEquals(101, $this->_adapter->count()); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/Adapter/DbSelectTest.php b/tests/Zend/Paginator/Adapter/DbSelectTest.php deleted file mode 100644 index b2f9b8fb2232b957073fb29273aae31f4c4dd145..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/Adapter/DbSelectTest.php +++ /dev/null @@ -1,268 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbSelectTest.php 11763 2008-10-09 01:39:04Z mratzloff $ - */ - -/** - * @see Zend_Paginator_Adapter_DbSelect - */ -require_once 'Zend/Paginator/Adapter/DbSelect.php'; - -/** - * @see Zend_Db_Adapter_Pdo_Sqlite - */ -require_once 'Zend/Db/Adapter/Pdo/Sqlite.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -require_once dirname(__FILE__) . '/../_files/TestTable.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_Adapter_DbSelectTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_Adapter_DbSelect - */ - private $_adapter; - - /** - * @var Zend_Db_Adapter_Pdo_Sqlite - */ - private $_db; - - /** - * @var Zend_Db_Select - */ - private $_query; - - /** - * @var Zend_Db_Table_Abstract - */ - protected $_table; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->_db = new Zend_Db_Adapter_Pdo_Sqlite(array( - 'dbname' => dirname(__FILE__) . '/../_files/test.sqlite' - )); - - $this->_table = new TestTable($this->_db); - - $this->_query = $this->_db->select()->from('test') - ->order('number ASC') // ZF-3740 - ->limit(1000, 0); // ZF-3727 - - $this->_adapter = new Zend_Paginator_Adapter_DbSelect($this->_query); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->_adapter = null; - parent::tearDown(); - } - - public function testGetsItemsAtOffsetZero() - { - $actual = $this->_adapter->getItems(0, 10); - - $i = 1; - foreach ($actual as $item) { - $this->assertEquals($i, $item['number']); - $i++; - } - } - - public function testGetsItemsAtOffsetTen() - { - $actual = $this->_adapter->getItems(10, 10); - - $i = 11; - foreach ($actual as $item) { - $this->assertEquals($i, $item['number']); - $i++; - } - } - - public function testAcceptsIntegerValueForRowCount() - { - $this->_adapter->setRowCount(101); - $this->assertEquals(101, $this->_adapter->count()); - } - - public function testThrowsExceptionIfInvalidQuerySuppliedForRowCount() - { - try { - $this->_adapter->setRowCount($this->_db->select()->from('test')); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertContains('Row count column not found', $e->getMessage()); - } - - try { - $expr = new Zend_Db_Expr('COUNT(*) AS wrongcolumn'); - $query = $this->_db->select($expr)->from('test'); - - $this->_adapter->setRowCount($query); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertEquals('Row count column not found', $e->getMessage()); - } - } - - public function testAcceptsQueryForRowCount() - { - $expression = new Zend_Db_Expr('COUNT(*) AS ' . Zend_Paginator_Adapter_DbSelect::ROW_COUNT_COLUMN); - - $rowCount = clone $this->_query; - $rowCount->reset(Zend_Db_Select::COLUMNS) - ->reset(Zend_Db_Select::ORDER) // ZF-3740 - ->reset(Zend_Db_Select::LIMIT_OFFSET) // ZF-3727 - ->reset(Zend_Db_Select::GROUP) // ZF-4001 - ->columns($expression); - - $this->_adapter->setRowCount($rowCount); - - $this->assertEquals(500, $this->_adapter->count()); - } - - public function testThrowsExceptionIfInvalidRowCountValueSupplied() - { - try { - $this->_adapter->setRowCount('invalid'); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertEquals('Invalid row count', $e->getMessage()); - } - } - - public function testReturnsCorrectCountWithAutogeneratedQuery() - { - $expected = 500; - $actual = $this->_adapter->count(); - - $this->assertEquals($expected, $actual); - } - - public function testDbTableSelectDoesNotThrowException() - { - $adapter = new Zend_Paginator_Adapter_DbSelect($this->_table->select()); - $count = $adapter->count(); - $this->assertEquals(500, $count); - } - - /** - * @group ZF-4001 - */ - public function testGroupByQueryReturnsOneRow() - { - $query = $this->_db->select()->from('test') - ->order('number ASC') - ->limit(1000, 0) - ->group('number'); - $adapter = new Zend_Paginator_Adapter_DbSelect($query); - - $this->assertEquals(500, $adapter->count()); - } - - /** - * @group ZF-4001 - */ - public function testGroupByQueryOnEmptyTableReturnsRowCountZero() - { - $db = new Zend_Db_Adapter_Pdo_Sqlite(array( - 'dbname' => dirname(__FILE__) . '/../_files/testempty.sqlite' - )); - - $query = $db->select()->from('test') - ->order('number ASC') - ->limit(1000, 0); - $adapter = new Zend_Paginator_Adapter_DbSelect($query); - - $this->assertEquals(0, $adapter->count()); - } - - /** - * @group ZF-4001 - */ - public function testGroupByQueryReturnsCorrectResult() - { - $query = $this->_db->select()->from('test') - ->order('number ASC') - ->limit(1000, 0) - ->group('testgroup'); - $adapter = new Zend_Paginator_Adapter_DbSelect($query); - - $this->assertEquals(2, $adapter->count()); - } - - /** - * @group ZF-4032 - */ - public function testDistinctColumnQueryReturnsCorrectResult() - { - $query = $this->_db->select()->from('test', 'testgroup') - ->order('number ASC') - ->limit(1000, 0) - ->distinct(); - $adapter = new Zend_Paginator_Adapter_DbSelect($query); - - $this->assertEquals(2, $adapter->count()); - } - - /** - * @group ZF-4094 - */ - public function testSelectSpecificColumns() - { - $query = $this->_db->select()->from('test', array('testgroup', 'number')) - ->where('number >= ?', '1'); - $adapter = new Zend_Paginator_Adapter_DbSelect($query); - - $this->assertEquals(500, $adapter->count()); - } - - /** - * @group ZF-4177 - */ - public function testSelectDistinctAllUsesRegularCountAll() - { - $query = $this->_db->select()->from('test') - ->distinct(); - $adapter = new Zend_Paginator_Adapter_DbSelect($query); - - $this->assertEquals(500, $adapter->count()); - } -} diff --git a/tests/Zend/Paginator/Adapter/DbTableSelectTest.php b/tests/Zend/Paginator/Adapter/DbTableSelectTest.php deleted file mode 100644 index 4beff95e6c783458caaeb24e715cde7f4a92e35c..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/Adapter/DbTableSelectTest.php +++ /dev/null @@ -1,50 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbTableSelectTest.php 11763 2008-10-09 01:39:04Z mratzloff $ - */ - -/** - * @see Zend_Paginator_Adapter_DbTableSelect - */ -require_once 'Zend/Paginator/Adapter/DbTableSelect.php'; - -require_once dirname(__FILE__) . '/DbSelectTest.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_Adapter_DbTableSelectTest extends Zend_Paginator_Adapter_DbSelectTest -{ - /** - * @group ZF-3775 - */ - public function testSelectDoesReturnZendDbTableRowset() - { - $query = $this->_table->select(); - $adapter = new Zend_Paginator_Adapter_DbTableSelect($query); - $items = $adapter->getItems(0, 10); - - $this->assertType('Zend_Db_Table_Rowset', $items); - } -} diff --git a/tests/Zend/Paginator/Adapter/IteratorTest.php b/tests/Zend/Paginator/Adapter/IteratorTest.php deleted file mode 100644 index 8bdfa819adc723651e8b0a9233af44d934d31d0c..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/Adapter/IteratorTest.php +++ /dev/null @@ -1,119 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IteratorTest.php 11763 2008-10-09 01:39:04Z mratzloff $ - */ - -/** - * @see Zend_Paginator_Adapter_Iterator - */ -require_once 'Zend/Paginator/Adapter/Iterator.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_Adapter_IteratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_Adapter_Iterator - */ - private $_adapter; - - /** - * Prepares the environment before running a test. - */ - protected function setUp () - { - parent::setUp(); - $iterator = new ArrayIterator(range(1, 101)); - $this->_adapter = new Zend_Paginator_Adapter_Iterator($iterator); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown () - { - $this->_adapter = null; - parent::tearDown(); - } - - public function testGetsItemsAtOffsetZero() - { - $actual = $this->_adapter->getItems(0, 10); - $this->assertType('LimitIterator', $actual); - - $i = 1; - foreach ($actual as $item) { - $this->assertEquals($i, $item); - $i++; - } - } - - public function testGetsItemsAtOffsetTen() - { - $actual = $this->_adapter->getItems(10, 10); - $this->assertType('LimitIterator', $actual); - - $i = 11; - foreach ($actual as $item) { - $this->assertEquals($i, $item); - $i++; - } - } - - public function testReturnsCorrectCount() - { - $this->assertEquals(101, $this->_adapter->count()); - } - - public function testThrowsExceptionIfNotCountable() - { - $iterator = new LimitIterator(new ArrayIterator(range(1, 101))); - - try { - new Zend_Paginator_Adapter_Iterator($iterator); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertEquals('Iterator must implement Countable', $e->getMessage()); - } - } - - /** - * @group ZF-4151 - */ - public function testDoesNotThrowOutOfBoundsExceptionIfIteratorIsEmpty() - { - $this->_paginator = Zend_Paginator::factory(new ArrayIterator(array())); - $items = $this->_paginator->getCurrentItems(); - try { - foreach ($items as $item); - } catch (OutOfBoundsException $e) { - $this->fail('Empty iterator caused in an OutOfBoundsException'); - } - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/Adapter/NullTest.php b/tests/Zend/Paginator/Adapter/NullTest.php deleted file mode 100644 index ae1520141e185fc67b378fdc97e0b37161b12561..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/Adapter/NullTest.php +++ /dev/null @@ -1,74 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NullTest.php 11219 2008-09-04 02:09:23Z mratzloff $ - */ - -/** - * @see Zend_Paginator_Adapter_Null - */ -require_once 'Zend/Paginator/Adapter/Null.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_Adapter_NullTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_Adapter_Array - */ - private $_adapter; - - /** - * Prepares the environment before running a test. - */ - protected function setUp () - { - parent::setUp(); - $this->_adapter = new Zend_Paginator_Adapter_Null(101); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->_adapter = null; - parent::tearDown(); - } - - public function testGetsItems() - { - $actual = $this->_adapter->getItems(0, 10); - $this->assertEquals(array_fill(0, 10, null), $actual); - } - - public function testReturnsCorrectCount() - { - $this->assertEquals(101, $this->_adapter->count()); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/AllTests.php b/tests/Zend/Paginator/AllTests.php deleted file mode 100644 index 37eda16f96557c59ce0836254b3c26d0bce59d67..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/AllTests.php +++ /dev/null @@ -1,85 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 11736 2008-10-08 14:02:18Z norm2782 $ - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Paginator_AllTests::main'); -} - -require_once 'Zend/PaginatorTest.php'; - -require_once 'Zend/Paginator/Adapter/ArrayTest.php'; -require_once 'Zend/Paginator/Adapter/DbSelectTest.php'; -require_once 'Zend/Paginator/Adapter/DbTableSelectTest.php'; -require_once 'Zend/Paginator/Adapter/IteratorTest.php'; -require_once 'Zend/Paginator/Adapter/NullTest.php'; - -require_once 'Zend/Paginator/ScrollingStyle/AllTest.php'; -require_once 'Zend/Paginator/ScrollingStyle/ElasticTest.php'; -require_once 'Zend/Paginator/ScrollingStyle/JumpingTest.php'; -require_once 'Zend/Paginator/ScrollingStyle/SlidingTest.php'; - -require_once 'Zend/View/Helper/PaginationControlTest.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Paginator'); - $suite->addTestSuite('Zend_PaginatorTest'); - - $suite->addTestSuite('Zend_Paginator_Adapter_ArrayTest'); - $suite->addTestSuite('Zend_Paginator_Adapter_DbSelectTest'); - $suite->addTestSuite('Zend_Paginator_Adapter_DbTableSelectTest'); - $suite->addTestSuite('Zend_Paginator_Adapter_IteratorTest'); - $suite->addTestSuite('Zend_Paginator_Adapter_NullTest'); - - $suite->addTestSuite('Zend_Paginator_ScrollingStyle_AllTest'); - $suite->addTestSuite('Zend_Paginator_ScrollingStyle_ElasticTest'); - $suite->addTestSuite('Zend_Paginator_ScrollingStyle_JumpingTest'); - $suite->addTestSuite('Zend_Paginator_ScrollingStyle_SlidingTest'); - - $suite->addTestSuite('Zend_View_Helper_PaginationControlTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Paginator_AllTests::main') { - Zend_Paginator_AllTests::main(); -} \ No newline at end of file diff --git a/tests/Zend/Paginator/ScrollingStyle/AllTest.php b/tests/Zend/Paginator/ScrollingStyle/AllTest.php deleted file mode 100644 index 3cea94d585643d47c3ca9551a3e271e11c6c1b77..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/ScrollingStyle/AllTest.php +++ /dev/null @@ -1,121 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTest.php 11219 2008-09-04 02:09:23Z mratzloff $ - */ - -/** - * @see Zend_Paginator - */ -require_once 'Zend/Paginator.php'; - -/** - * @see Zend_Paginator_ScrollingStyle_All - */ -require_once 'Zend/Paginator/ScrollingStyle/All.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_ScrollingStyle_AllTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_ScrollingStyle_All - */ - private $_scrollingStyle = null; - private $_paginator = null; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_All(); - $this->_paginator = Zend_Paginator::factory(range(1, 101)); - $this->_paginator->setItemCountPerPage(10); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown () - { - $this->_scrollingStyle = null; - $this->_paginator = null; - parent::tearDown(); - } - - /** - * Tests Zend_Paginator_ScrollingStyle_All->getPages() - */ - public function testGetsPages() - { - $expected = array_combine(range(1, 11), range(1, 11)); - $pages = $this->_scrollingStyle->getPages($this->_paginator); - $this->assertEquals($expected, $pages); - } - - public function testGetsNextAndPreviousPageForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $pages = $this->_paginator->getPages('All'); - - $this->assertEquals(2, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $pages = $this->_paginator->getPages('All'); - $this->assertEquals(1, $pages->previous); - $this->assertEquals(3, $pages->next); - } - - public function testGetsNextAndPreviousPageForMiddlePage() - { - $this->_paginator->setCurrentPageNumber(6); - $pages = $this->_paginator->getPages('All'); - $this->assertEquals(5, $pages->previous); - $this->assertEquals(7, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondLastPage() - { - $this->_paginator->setCurrentPageNumber(10); - $pages = $this->_paginator->getPages('All'); - $this->assertEquals(9, $pages->previous); - $this->assertEquals(11, $pages->next); - } - - public function testGetsNextAndPreviousPageForLastPage() - { - $this->_paginator->setCurrentPageNumber(11); - $pages = $this->_paginator->getPages('All'); - $this->assertEquals(10, $pages->previous); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/ScrollingStyle/ElasticTest.php b/tests/Zend/Paginator/ScrollingStyle/ElasticTest.php deleted file mode 100644 index c1c6a37bf2a622d79af26180a1cf5895384c0d1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/ScrollingStyle/ElasticTest.php +++ /dev/null @@ -1,147 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ElasticTest.php 11219 2008-09-04 02:09:23Z mratzloff $ - */ - -/** - * @see Zend_Paginator_ScrollingStyle_Elastic - */ -require_once 'Zend/Paginator/ScrollingStyle/Elastic.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @see Zend_Paginator - */ -require_once 'Zend/Paginator.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_ScrollingStyle_ElasticTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_ScrollingStyle_Elastic - */ - private $_scrollingStyle; - /** - * @var Zend_Paginator - */ - private $_paginator; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Elastic(); - $this->_paginator = Zend_Paginator::factory(range(1, 101)); - $this->_paginator->setItemCountPerPage(5); - $this->_paginator->setPageRange(5); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->_scrollingStyle = null; - $this->_paginator = null; - parent::tearDown(); - } - - public function testGetsPagesInRangeForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(1, 5), range(1, 5)); - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesInRangeForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(1, 6), range(1, 6)); - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesInRangeForTenthPage() - { - $this->_paginator->setCurrentPageNumber(10); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(6, 14), range(6, 14)); - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesInRangeForLastPage() - { - $this->_paginator->setCurrentPageNumber(21); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(13, 21), range(13, 21)); - $this->assertEquals($expected, $actual); - } - - public function testGetsNextAndPreviousPageForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $pages = $this->_paginator->getPages('Elastic'); - - $this->assertEquals(2, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $pages = $this->_paginator->getPages('Elastic'); - $this->assertEquals(1, $pages->previous); - $this->assertEquals(3, $pages->next); - } - - public function testGetsNextAndPreviousPageForMiddlePage() - { - $this->_paginator->setCurrentPageNumber(10); - $pages = $this->_paginator->getPages('Elastic'); - $this->assertEquals(9, $pages->previous); - $this->assertEquals(11, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondLastPage() - { - $this->_paginator->setCurrentPageNumber(20); - $pages = $this->_paginator->getPages('Elastic'); - $this->assertEquals(19, $pages->previous); - $this->assertEquals(21, $pages->next); - } - - public function testGetsNextAndPreviousPageForLastPage() - { - $this->_paginator->setCurrentPageNumber(21); - $pages = $this->_paginator->getPages('Elastic'); - $this->assertEquals(20, $pages->previous); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/ScrollingStyle/JumpingTest.php b/tests/Zend/Paginator/ScrollingStyle/JumpingTest.php deleted file mode 100644 index 5291a40a4a9526984c4d64d383fa62eefce13fd4..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/ScrollingStyle/JumpingTest.php +++ /dev/null @@ -1,147 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: JumpingTest.php 11219 2008-09-04 02:09:23Z mratzloff $ - */ - -/** - * @see Zend_Paginator - */ -require_once 'Zend/Paginator.php'; - -/** - * @see Zend_Paginator_ScrollingStyle_Jumping - */ -require_once 'Zend/Paginator/ScrollingStyle/Jumping.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_ScrollingStyle_JumpingTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_ScrollingStyle_Jumping - */ - private $_scrollingStyle; - /** - * @var Zend_Paginator - */ - private $_paginator; - - private $_expectedRange; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Jumping(); - $this->_paginator = Zend_Paginator::factory(range(1, 101)); - $this->_paginator->setItemCountPerPage(10); - $this->_paginator->setPageRange(10); - $this->_expectedRange = array_combine(range(1, 10), range(1, 10)); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->_scrollingStyle = null; - $this->_paginator = null; - parent::tearDown(); - } - - public function testGetsPagesInRangeForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $this->assertEquals($this->_expectedRange, $actual); - } - - public function testGetsPagesInRangeForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $this->assertEquals($this->_expectedRange, $actual); - } - - public function testGetsPagesInRangeForSecondLastPage() - { - $this->_paginator->setCurrentPageNumber(10); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $this->assertEquals($this->_expectedRange, $actual); - } - - public function testGetsPagesInRangeForLastPage() - { - $this->_paginator->setCurrentPageNumber(11); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array(11 => 11); - $this->assertEquals($expected, $actual); - } - - public function testGetsNextAndPreviousPageForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $pages = $this->_paginator->getPages('Jumping'); - - $this->assertEquals(2, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $pages = $this->_paginator->getPages('Jumping'); - $this->assertEquals(1, $pages->previous); - $this->assertEquals(3, $pages->next); - } - - public function testGetsNextAndPreviousPageForMiddlePage() - { - $this->_paginator->setCurrentPageNumber(6); - $pages = $this->_paginator->getPages('Jumping'); - $this->assertEquals(5, $pages->previous); - $this->assertEquals(7, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondLastPage() - { - $this->_paginator->setCurrentPageNumber(10); - $pages = $this->_paginator->getPages('Jumping'); - $this->assertEquals(9, $pages->previous); - $this->assertEquals(11, $pages->next); - } - - public function testGetsNextAndPreviousPageForLastPage() - { - $this->_paginator->setCurrentPageNumber(11); - $pages = $this->_paginator->getPages('Jumping'); - $this->assertEquals(10, $pages->previous); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/ScrollingStyle/SlidingTest.php b/tests/Zend/Paginator/ScrollingStyle/SlidingTest.php deleted file mode 100644 index 58505dc2550bebe69506a21b11a4db19b0cac1a4..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/ScrollingStyle/SlidingTest.php +++ /dev/null @@ -1,154 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SlidingTest.php 11219 2008-09-04 02:09:23Z mratzloff $ - */ - -/** - * @see Zend_Paginator_ScrollingStyle_Sliding - */ -require_once 'Zend/Paginator/ScrollingStyle/Sliding.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @see Zend_Paginator - */ -require_once 'Zend/Paginator.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Paginator_ScrollingStyle_SlidingTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_Paginator_ScrollingStyle_Sliding - */ - private $_scrollingStyle; - /** - * @var Zend_Paginator - */ - private $_paginator; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Sliding(); - $this->_paginator = Zend_Paginator::factory(range(1, 101)); - $this->_paginator->setItemCountPerPage(10); - $this->_paginator->setPageRange(5); - } - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->_scrollingStyle = null; - $this->_paginator = null; - parent::tearDown(); - } - - public function testGetsPagesInRangeForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(1, 5), range(1, 5)); - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesInRangeForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(1, 5), range(1, 5)); - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesInRangeForFifthPage() - { - $this->_paginator->setCurrentPageNumber(5); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(3, 7), range(3, 7)); - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesInRangeForLastPage() - { - $this->_paginator->setCurrentPageNumber(11); - $actual = $this->_scrollingStyle->getPages($this->_paginator); - $expected = array_combine(range(7, 11), range(7, 11)); - $this->assertEquals($expected, $actual); - } - - public function testGetsNextAndPreviousPageForFirstPage() - { - $this->_paginator->setCurrentPageNumber(1); - $pages = $this->_paginator->getPages('Sliding'); - - $this->assertEquals(2, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondPage() - { - $this->_paginator->setCurrentPageNumber(2); - $pages = $this->_paginator->getPages('Sliding'); - $this->assertEquals(1, $pages->previous); - $this->assertEquals(3, $pages->next); - } - - public function testGetsNextAndPreviousPageForMiddlePage() - { - $this->_paginator->setCurrentPageNumber(6); - $pages = $this->_paginator->getPages('Sliding'); - $this->assertEquals(5, $pages->previous); - $this->assertEquals(7, $pages->next); - } - - public function testGetsNextAndPreviousPageForSecondLastPage() - { - $this->_paginator->setCurrentPageNumber(10); - $pages = $this->_paginator->getPages('Sliding'); - $this->assertEquals(9, $pages->previous); - $this->assertEquals(11, $pages->next); - } - - public function testGetsNextAndPreviousPageForLastPage() - { - $this->_paginator->setCurrentPageNumber(11); - $pages = $this->_paginator->getPages('Sliding'); - $this->assertEquals(10, $pages->previous); - } - - public function testAcceptsPageRangeLargerThanPageCount() - { - $this->_paginator->setPageRange(100); - $pages = $this->_paginator->getPages(); - $this->assertEquals(11, $pages->last); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/_files/TestTable.php b/tests/Zend/Paginator/_files/TestTable.php deleted file mode 100644 index 8875f9ee2a5a145bc7389f80a4f183de5bfc079f..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/_files/TestTable.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -require_once 'Zend/Db/Table/Abstract.php'; - -class TestTable extends Zend_Db_Table_Abstract -{ - protected $_primary = 'number'; - protected $_name = 'test'; -} \ No newline at end of file diff --git a/tests/Zend/Paginator/_files/Zf4207.php b/tests/Zend/Paginator/_files/Zf4207.php deleted file mode 100644 index 3606d273213953fd83a5753f16cafa3d73f9ffb1..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/_files/Zf4207.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -require_once 'Zend/Paginator/Adapter/Interface.php'; - -class Zf4207 extends ArrayObject implements Zend_Paginator_Adapter_Interface -{ - public function count() - { - return 10; - } - - public function getItems($pageNumber, $itemCountPerPage) - { - return new ArrayObject(range(1, 10)); - } -} \ No newline at end of file diff --git a/tests/Zend/Paginator/_files/config.xml b/tests/Zend/Paginator/_files/config.xml deleted file mode 100644 index 98e0947faa61d849deb871bed562c18d5f79c34f..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/_files/config.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<paginator> - <default> - <itemcountperpage>10</itemcountperpage> - <pagerange>10</pagerange> - </default> - <testing> - <scrollingstyle>Scrolling</scrollingstyle> - <prefixpaths> - <prefixpath> - <prefix>prefix6</prefix> - <path>path6</path> - </prefixpath> - <prefixpath> - <prefix>prefix7</prefix> - <path>path7</path> - </prefixpath> - <prefixpath> - <prefix>prefix8</prefix> - <path>path8</path> - </prefixpath> - </prefixpaths> - <adapterpaths> - <adapterpath> - <prefix>prefix6</prefix> - <path>path6</path> - </adapterpath> - <adapterpath> - <prefix>prefix7</prefix> - <path>path7</path> - </adapterpath> - <adapterpath> - <prefix>prefix8</prefix> - <path>path8</path> - </adapterpath> - </adapterpaths> - <itemcountperpage>3</itemcountperpage> - <pagerange>7</pagerange> - </testing> -</paginator> \ No newline at end of file diff --git a/tests/Zend/Paginator/_files/scripts/partial.phtml b/tests/Zend/Paginator/_files/scripts/partial.phtml deleted file mode 100644 index f53e81c02c04da0f290400382b7c3c974c2099ed..0000000000000000000000000000000000000000 --- a/tests/Zend/Paginator/_files/scripts/partial.phtml +++ /dev/null @@ -1 +0,0 @@ -partial rendered successfully \ No newline at end of file diff --git a/tests/Zend/Paginator/_files/test.sqlite b/tests/Zend/Paginator/_files/test.sqlite deleted file mode 100644 index ba6d4fee36820fccdd86a73ecd860f975f3db444..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Paginator/_files/test.sqlite and /dev/null differ diff --git a/tests/Zend/Paginator/_files/testempty.sqlite b/tests/Zend/Paginator/_files/testempty.sqlite deleted file mode 100644 index 1804d26916bef825bba3b6a2e1788fc9402cdf8f..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Paginator/_files/testempty.sqlite and /dev/null differ diff --git a/tests/Zend/PaginatorTest.php b/tests/Zend/PaginatorTest.php deleted file mode 100644 index 8609ee197493b46aa52c1b68354a4da0db96619c..0000000000000000000000000000000000000000 --- a/tests/Zend/PaginatorTest.php +++ /dev/null @@ -1,651 +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_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PaginatorTest.php 11777 2008-10-09 16:07:48Z norm2782 $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * @see Zend_Paginator - */ -require_once 'Zend/Paginator.php'; - -/** - * @see PHPUnit_Framework_TestCase - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * @see Zend_Config_Xml - */ -require_once 'Zend/Config/Xml.php'; - -/** - * @see Zend_Db_Adapter_Pdo_Sqlite - */ -require_once 'Zend/Db/Adapter/Pdo/Sqlite.php'; - -/** - * @see Zend_View - */ -require_once 'Zend/View.php'; - -/** - * @see Zend_Controller_Action_HelperBroker - */ -require_once 'Zend/Controller/Action/HelperBroker.php'; - -/** - * @see Zend_View_Helper_PaginationControl - */ -require_once 'Zend/View/Helper/PaginationControl.php'; - -/** - * @see Zf4207 - */ -require_once 'Zend/Paginator/_files/Zf4207.php'; - -/** - * @category Zend - * @package Zend_Paginator - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_PaginatorTest extends PHPUnit_Framework_TestCase -{ - /** - * Paginator instance - * - * @var Zend_Paginator - */ - protected $_paginator = null; - - protected $_testCollection = null; - - protected $_query = null; - - protected $_config = null; - - protected function setUp() - { - $db = new Zend_Db_Adapter_Pdo_Sqlite(array( - 'dbname' => dirname(__FILE__) . '/Paginator/_files/test.sqlite' - )); - - $this->_query = $db->select()->from('test'); - - $this->_testCollection = range(1, 101); - $this->_paginator = Zend_Paginator::factory($this->_testCollection); - - $this->_config = new Zend_Config_Xml(dirname(__FILE__) . '/Paginator/_files/config.xml'); - // get a fresh new copy of ViewRenderer in each tests - Zend_Controller_Action_HelperBroker::resetHelpers(); - - $this->_restorePaginatorDefaults(); - } - - protected function tearDown() - { - $this->_dbConn = null; - $this->_testCollection = null; - $this->_paginator = null; - } - - protected function _restorePaginatorDefaults() - { - $this->_paginator->setItemCountPerPage(10); - $this->_paginator->setCurrentPageNumber(1); - $this->_paginator->setPageRange(10); - $this->_paginator->setView(); - - Zend_Paginator::setDefaultScrollingStyle(); - Zend_View_Helper_PaginationControl::setDefaultViewPartial(null); - - Zend_Paginator::setConfig($this->_config->default); - - $loader = Zend_Paginator::getScrollingStyleLoader(); - $loader->clearPaths(); - $loader->addPrefixPath('Zend_Paginator_ScrollingStyle', 'Zend/Paginator/ScrollingStyle'); - } - - public function testFactoryReturnsArrayAdapter() - { - $paginator = Zend_Paginator::factory($this->_testCollection); - $this->assertType('Zend_Paginator_Adapter_Array', $paginator->getAdapter()); - } - - public function testFactoryReturnsDbSelectAdapter() - { - $paginator = Zend_Paginator::factory($this->_query); - - $this->assertType('Zend_Paginator_Adapter_DbSelect', $paginator->getAdapter()); - } - - public function testFactoryReturnsIteratorAdapter() - { - $paginator = Zend_Paginator::factory(new ArrayIterator($this->_testCollection)); - $this->assertType('Zend_Paginator_Adapter_Iterator', $paginator->getAdapter()); - } - - public function testFactoryReturnsNullAdapter() - { - $paginator = Zend_Paginator::factory(101); - $this->assertType('Zend_Paginator_Adapter_Null', $paginator->getAdapter()); - } - - public function testFactoryThrowsInvalidClassExceptionAdapter() - { - try { - $paginator = Zend_Paginator::factory(new stdClass()); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertContains('stdClass', $e->getMessage()); - } - } - - public function testFactoryThrowsInvalidTypeExceptionAdapter() - { - try { - $paginator = Zend_Paginator::factory('invalid argument'); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertContains('string', $e->getMessage()); - } - } - - public function testAddsSingleScrollingStylePrefixPath() - { - Zend_Paginator::addScrollingStylePrefixPath('prefix1', 'path1'); - $loader = Zend_Paginator::getScrollingStyleLoader(); - $paths = $loader->getPaths(); - - $this->assertArrayHasKey('prefix1_', $paths); - $this->assertEquals($paths['prefix1_'], array('path1/')); - - $loader->clearPaths('prefix1'); - } - - public function testAddsSingleScrollingStylePrefixPathWithArray() - { - Zend_Paginator::addScrollingStylePrefixPaths(array('prefix' => 'prefix2', - 'path' => 'path2')); - $loader = Zend_Paginator::getScrollingStyleLoader(); - $paths = $loader->getPaths(); - - $this->assertArrayHasKey('prefix2_', $paths); - $this->assertEquals($paths['prefix2_'], array('path2/')); - - $loader->clearPaths('prefix2'); - } - - public function testAddsMultipleScrollingStylePrefixPaths() - { - $paths = array('prefix3' => 'path3', - 'prefix4' => 'path4', - 'prefix5' => 'path5'); - - Zend_Paginator::addScrollingStylePrefixPaths($paths); - $loader = Zend_Paginator::getScrollingStyleLoader(); - $paths = $loader->getPaths(); - - for ($i = 3; $i <= 5; $i++) { - $prefix = 'prefix' . $i . '_'; - $this->assertArrayHasKey($prefix, $paths); - $this->assertEquals($paths[$prefix], array('path' . $i . '/')); - } - - $loader->clearPaths('prefix3'); - $loader->clearPaths('prefix4'); - $loader->clearPaths('prefix5'); - } - - public function testAddsSingleAdapterPrefixPath() - { - Zend_Paginator::addAdapterPrefixPath('prefix1', 'path1'); - $loader = Zend_Paginator::getAdapterLoader(); - $paths = $loader->getPaths(); - - $this->assertArrayHasKey('prefix1_', $paths); - $this->assertEquals($paths['prefix1_'], array('path1/')); - - $loader->clearPaths('prefix1'); - } - - public function testAddsSingleAdapterPrefixPathWithArray() - { - Zend_Paginator::addAdapterPrefixPaths(array('prefix' => 'prefix2', - 'path' => 'path2')); - $loader = Zend_Paginator::getAdapterLoader(); - $paths = $loader->getPaths(); - - $this->assertArrayHasKey('prefix2_', $paths); - $this->assertEquals($paths['prefix2_'], array('path2/')); - - $loader->clearPaths('prefix2'); - } - - public function testAddsMultipleAdapterPrefixPaths() - { - $paths = array('prefix3' => 'path3', - 'prefix4' => 'path4', - 'prefix5' => 'path5'); - - Zend_Paginator::addAdapterPrefixPaths($paths); - $loader = Zend_Paginator::getAdapterLoader(); - $paths = $loader->getPaths(); - - for ($i = 3; $i <= 5; $i++) { - $prefix = 'prefix' . $i . '_'; - $this->assertArrayHasKey($prefix, $paths); - $this->assertEquals($paths[$prefix], array('path' . $i . '/')); - } - - $loader->clearPaths('prefix3'); - $loader->clearPaths('prefix4'); - $loader->clearPaths('prefix5'); - } - - public function testGetsAndSetsDefaultScrollingStyle() - { - $this->assertEquals(Zend_Paginator::getDefaultScrollingStyle(), 'Sliding'); - Zend_Paginator::setDefaultScrollingStyle('Scrolling'); - $this->assertEquals(Zend_Paginator::getDefaultScrollingStyle(), 'Scrolling'); - Zend_Paginator::setDefaultScrollingStyle('Sliding'); - } - - public function testHasCorrectCountAfterInit() - { - $paginator = Zend_Paginator::factory(range(1, 101)); - $this->assertEquals(11, $paginator->count()); - } - - public function testAddCustomAdapterPathsInConstructor() - { - $paginator = Zend_Paginator::factory(range(1, 101), Zend_Paginator::INTERNAL_ADAPTER, array('My_Paginator_Adapter' => 'My/Paginator/Adapter')); - - $loader = Zend_Paginator::getAdapterLoader(); - $paths = $loader->getPaths(); - - $this->assertEquals(2, count($paths)); - $this->assertEquals(array('Zend_Paginator_Adapter_' => array('Zend/Paginator/Adapter/'), - 'My_Paginator_Adapter_' => array('My/Paginator/Adapter/')), $paths); - - $loader->clearPaths('My_Paginator_Adapter'); - } - - public function testLoadsFromConfig() - { - Zend_Paginator::setConfig($this->_config->testing); - $this->assertEquals('Scrolling', Zend_Paginator::getDefaultScrollingStyle()); - - $paths = array( - 'prefix6' => 'path6', - 'prefix7' => 'path7', - 'prefix8' => 'path8' - ); - - $loader = Zend_Paginator::getScrollingStyleLoader(); - $paths = $loader->getPaths(); - - for ($i = 6; $i <= 8; $i++) { - $prefix = 'prefix' . $i . '_'; - $this->assertArrayHasKey($prefix, $paths); - $this->assertEquals($paths[$prefix], array('path' . $i . '/')); - } - - $loader->clearPaths('prefix6'); - $loader->clearPaths('prefix7'); - $loader->clearPaths('prefix8'); - - $loader = Zend_Paginator::getAdapterLoader(); - $paths = $loader->getPaths(); - - for ($i = 6; $i <= 8; $i++) { - $prefix = 'prefix' . $i . '_'; - $this->assertArrayHasKey($prefix, $paths); - $this->assertEquals($paths[$prefix], array('path' . $i . '/')); - } - - $loader->clearPaths('prefix6'); - $loader->clearPaths('prefix7'); - $loader->clearPaths('prefix8'); - - $paginator = Zend_Paginator::factory(range(1, 101)); - $this->assertEquals(3, $paginator->getItemCountPerPage()); - $this->assertEquals(7, $paginator->getPageRange()); - } - - public function testGetsPagesForPageOne() - { - $expected = new stdClass(); - $expected->pageCount = 11; - $expected->itemCountPerPage = 10; - $expected->first = 1; - $expected->current = 1; - $expected->last = 11; - $expected->next = 2; - $expected->pagesInRange = array_combine(range(1, 10), range(1, 10)); - $expected->firstPageInRange = 1; - $expected->lastPageInRange = 10; - $expected->currentItemCount = 10; - $expected->totalItemCount = 101; - $expected->firstItemNumber = 1; - $expected->lastItemNumber = 10; - - $actual = $this->_paginator->getPages(); - - $this->assertEquals($expected, $actual); - } - - public function testGetsPagesForPageTwo() - { - $expected = new stdClass(); - $expected->pageCount = 11; - $expected->itemCountPerPage = 10; - $expected->first = 1; - $expected->current = 2; - $expected->last = 11; - $expected->previous = 1; - $expected->next = 3; - $expected->pagesInRange = array_combine(range(1, 10), range(1, 10)); - $expected->firstPageInRange = 1; - $expected->lastPageInRange = 10; - $expected->currentItemCount = 10; - $expected->totalItemCount = 101; - $expected->firstItemNumber = 11; - $expected->lastItemNumber = 20; - - $this->_paginator->setCurrentPageNumber(2); - $actual = $this->_paginator->getPages(); - - $this->assertEquals($expected, $actual); - } - - public function testRendersWithoutPartial() - { - $this->_paginator->setView(new Zend_View()); - $string = @$this->_paginator->__toString(); - $this->assertEquals('', $string); - } - - public function testRendersWithPartial() - { - $view = new Zend_View(); - $view->addBasePath(dirname(__FILE__) . '/Paginator/_files'); - $view->addHelperPath(dirname(__FILE__) . '/../../../trunk/library/Zend/View/Helper', 'Zend_View_Helper'); - - Zend_View_Helper_PaginationControl::setDefaultViewPartial('partial.phtml'); - - $this->_paginator->setView($view); - - $string = $this->_paginator->__toString(); - $this->assertEquals('partial rendered successfully', $string); - } - - public function testGetsPageCount() - { - $this->assertEquals(11, $this->_paginator->count()); - } - - public function testGetsAndSetsItemCountPerPage() - { - $this->assertEquals(10, $this->_paginator->getItemCountPerPage()); - $this->_paginator->setItemCountPerPage(15); - $this->assertEquals(15, $this->_paginator->getItemCountPerPage()); - $this->_paginator->setItemCountPerPage(10); - } - - public function testGetsCurrentItemCount() - { - $this->_paginator->setItemCountPerPage(10); - $this->_paginator->setPageRange(10); - - $this->assertEquals(10, $this->_paginator->getCurrentItemCount()); - - $this->_paginator->setCurrentPageNumber(11); - - $this->assertEquals(1, $this->_paginator->getCurrentItemCount()); - - $this->_paginator->setCurrentPageNumber(1); - } - - public function testGetsCurrentItems() - { - $items = $this->_paginator->getCurrentItems(); - $this->assertType('ArrayIterator', $items); - - $count = 0; - - foreach ($items as $item) { - $count++; - } - - $this->assertEquals(10, $count); - } - - public function testGetsIterator() - { - $items = $this->_paginator->getIterator(); - $this->assertType('ArrayIterator', $items); - - $count = 0; - - foreach ($items as $item) { - $count++; - } - - $this->assertEquals(10, $count); - } - - public function testGetsAndSetsCurrentPageNumber() - { - $this->assertEquals(1, $this->_paginator->getCurrentPageNumber()); - $this->_paginator->setCurrentPageNumber(-1); - $this->assertEquals(1, $this->_paginator->getCurrentPageNumber()); - $this->_paginator->setCurrentPageNumber(11); - $this->assertEquals(11, $this->_paginator->getCurrentPageNumber()); - $this->_paginator->setCurrentPageNumber(111); - $this->assertEquals(11, $this->_paginator->getCurrentPageNumber()); - $this->_paginator->setCurrentPageNumber(1); - $this->assertEquals(1, $this->_paginator->getCurrentPageNumber()); - } - - public function testGetsAbsoluteItemNumber() - { - $this->assertEquals(1, $this->_paginator->getAbsoluteItemNumber(1)); - $this->assertEquals(11, $this->_paginator->getAbsoluteItemNumber(1, 2)); - $this->assertEquals(24, $this->_paginator->getAbsoluteItemNumber(4, 3)); - } - - public function testGetsItem() - { - $this->assertEquals(1, $this->_paginator->getItem(1)); - $this->assertEquals(11, $this->_paginator->getItem(1, 2)); - $this->assertEquals(24, $this->_paginator->getItem(4, 3)); - } - - public function testThrowsExceptionWhenCollectionIsEmpty() - { - $paginator = Zend_Paginator::factory(array()); - - try { - $paginator->getItem(1); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertContains('Page 1 does not exist', $e->getMessage()); - } - } - - public function testThrowsExceptionWhenRetrievingNonexistentItemFromLastPage() - { - try { - $this->_paginator->getItem(10, 11); - } catch (Exception $e) { - $this->assertType('Zend_Paginator_Exception', $e); - $this->assertContains('Page 11 does not contain item number 10', $e->getMessage()); - } - } - - public function testNormalizesPageNumber() - { - $this->assertEquals(1, $this->_paginator->normalizePageNumber(0)); - $this->assertEquals(1, $this->_paginator->normalizePageNumber(1)); - $this->assertEquals(2, $this->_paginator->normalizePageNumber(2)); - $this->assertEquals(5, $this->_paginator->normalizePageNumber(5)); - $this->assertEquals(10, $this->_paginator->normalizePageNumber(10)); - $this->assertEquals(11, $this->_paginator->normalizePageNumber(11)); - $this->assertEquals(11, $this->_paginator->normalizePageNumber(12)); - } - - public function testNormalizesItemNumber() - { - $this->assertEquals(1, $this->_paginator->normalizeItemNumber(0)); - $this->assertEquals(1, $this->_paginator->normalizeItemNumber(1)); - $this->assertEquals(2, $this->_paginator->normalizeItemNumber(2)); - $this->assertEquals(5, $this->_paginator->normalizeItemNumber(5)); - $this->assertEquals(9, $this->_paginator->normalizeItemNumber(9)); - $this->assertEquals(10, $this->_paginator->normalizeItemNumber(10)); - $this->assertEquals(10, $this->_paginator->normalizeItemNumber(11)); - } - - public function testGetsPagesInSubsetRange() - { - $actual = $this->_paginator->getPagesInRange(3, 8); - $this->assertEquals(array_combine(range(3, 8), range(3, 8)), $actual); - } - - public function testGetsPagesInOutOfBoundsRange() - { - $actual = $this->_paginator->getPagesInRange(-1, 12); - $this->assertEquals(array_combine(range(1, 11), range(1, 11)), $actual); - } - - public function testGetsItemsByPage() - { - $expected = new ArrayIterator(range(1, 10)); - - $page1 = $this->_paginator->getItemsByPage(1); - - $this->assertEquals($page1, $expected); - $this->assertEquals($page1, $this->_paginator->getItemsByPage(1)); - } - - public function testGetsItemCount() - { - $this->assertEquals(101, $this->_paginator->getItemCount(range(1, 101))); - - $limitIterator = new LimitIterator(new ArrayIterator(range(1, 101))); - $this->assertEquals(101, $this->_paginator->getItemCount($limitIterator)); - } - - public function testGetsViewFromViewRenderer() - { - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $viewRenderer->setView(new Zend_View()); - - $this->assertType('Zend_View_Interface', $this->_paginator->getView()); - } - - public function testGeneratesViewIfNonexistent() - { - $this->assertType('Zend_View_Interface', $this->_paginator->getView()); - } - - public function testGetsAndSetsView() - { - $this->_paginator->setView(new Zend_View()); - $this->assertType('Zend_View_Interface', $this->_paginator->getView()); - } - - public function testRenders() - { - try { - $this->_paginator->render(new Zend_View()); - } catch (Exception $e) { - $this->assertType('Zend_View_Exception', $e); - $this->assertEquals('No view partial provided and no default set', $e->getMessage()); - } - } - - public function testGetsAndSetsPageRange() - { - $this->assertEquals(10, $this->_paginator->getPageRange()); - $this->_paginator->setPageRange(15); - $this->assertEquals(15, $this->_paginator->getPageRange()); - } - - /** - * @group ZF-3720 - */ - public function testGivesCorrectItemCount() - { - $paginator = Zend_Paginator::factory(range(1, 101)); - $paginator->setCurrentPageNumber(5) - ->setItemCountPerPage(5); - $expected = new ArrayIterator(range(21, 25)); - - $this->assertEquals($expected, $paginator->getCurrentItems()); - } - - /** - * @group ZF-3737 - */ - public function testKeepsCurrentPageNumberAfterItemCountPerPageSet() - { - $paginator = Zend_Paginator::factory(array('item1', 'item2')); - $paginator->setCurrentPageNumber(2) - ->setItemCountPerPage(1); - - $items = $paginator->getCurrentItems(); - - $this->assertEquals('item2', $items[0]); - } - - /** - * @group ZF-4193 - */ - public function testCastsIntegerValuesToInteger() - { - // Current page number - $this->_paginator->setCurrentPageNumber(3.3); - $this->assertTrue($this->_paginator->getCurrentPageNumber() == 3); - - // Item count per page - $this->_paginator->setItemCountPerPage(3.3); - $this->assertTrue($this->_paginator->getItemCountPerPage() == 3); - - // Page range - $this->_paginator->setPageRange(3.3); - $this->assertTrue($this->_paginator->getPageRange() == 3); - } - - /** - * @group ZF-4207 - */ - public function testAcceptsTraversableInstanceFromAdapter() - { - $paginator = new Zend_Paginator(new Zf4207()); - $this->assertType('ArrayObject', $paginator->getCurrentItems()); - } -} \ No newline at end of file diff --git a/tests/Zend/Pdf/AllTests.php b/tests/Zend/Pdf/AllTests.php deleted file mode 100644 index daa2a60989e1650d65acf28daa5a152ffa8cd383..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/AllTests.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Pdf_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Pdf/ProcessingTest.php'; -require_once 'Zend/Pdf/DrawingTest.php'; - -require_once 'Zend/Pdf/Element/AllTests.php'; - -class Zend_Pdf_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Pdf'); - - $suite->addTestSuite('Zend_Pdf_ProcessingTest'); - $suite->addTestSuite('Zend_Pdf_DrawingTest'); - - $suite->addTest(Zend_Pdf_Element_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Pdf_AllTests::main') { - Zend_Pdf_AllTests::main(); -} diff --git a/tests/Zend/Pdf/DrawingTest.php b/tests/Zend/Pdf/DrawingTest.php deleted file mode 100644 index a6a16a98a0b27b8a7a03c383bef6690985249760..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/DrawingTest.php +++ /dev/null @@ -1,480 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** Zend_Pdf */ -require_once 'Zend/Pdf.php'; - -/** PHPUnit Test Case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_DrawingTest extends PHPUnit_Framework_TestCase -{ - public function testDrawing() - { - $pdf = new Zend_Pdf(); - - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page1 = $pdf->newPage('A4')); - - // Add new page generated by Zend_Pdf_Page object (page is not attached to the document) - $pdf->pages[] = ($page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE)); - - // Create new font - $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); - - // Apply font and draw text - $page1->setFont($font, 36); - $page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc')); - $page1->drawText('Helvetica 36 text string', 60, 500); - - // Use font object for another page - $page2->setFont($font, 24); - $page2->drawText('Helvetica 24 text string', 60, 500); - - // Use another font - $page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32); - $page2->drawText('Times-Roman 32 text string', 60, 450); - - // Draw rectangle - $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)); - $page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)); - $page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6); - $page2->drawRectangle(60, 400, 400, 350); - - // Draw circle - $page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0)); - $page2->drawCircle(85, 375, 25); - - // Draw sectors - $page2->drawCircle(200, 375, 25, 2*M_PI/3, -M_PI/6); - $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0)); - $page2->drawCircle(200, 375, 25, M_PI/6, 2*M_PI/3); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0)); - $page2->drawCircle(200, 375, 25, -M_PI/6, M_PI/6); - - // Draw ellipse - $page2->setFillColor(new Zend_Pdf_Color_Html('Red')); - $page2->drawEllipse(250, 400, 400, 350); - $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0)); - $page2->drawEllipse(250, 400, 400, 350, M_PI/6, 2*M_PI/3); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0)); - $page2->drawEllipse(250, 400, 400, 350, -M_PI/6, M_PI/6); - - // Draw and fill polygon - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1)); - $x = array(); - $y = array(); - for ($count = 0; $count < 8; $count++) { - $x[] = 140 + 25*cos(3*M_PI_4*$count); - $y[] = 375 + 25*sin(3*M_PI_4*$count); - } - $page2->drawPolygon($x, $y, - Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, - Zend_Pdf_Page::FILL_METHOD_EVEN_ODD); - - // Draw line - $page2->setLineWidth(0.5); - $page2->drawLine(60, 375, 400, 375); - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - $this->assertTrue($pdf1 instanceof Zend_Pdf); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } - - public function testImageDrawing() - { - $pdf = new Zend_Pdf(); - - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page = $pdf->newPage('A4')); - - - $stampImagePNG = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.png'); - $this->assertTrue($stampImagePNG instanceof Zend_Pdf_Resource_Image); - - $page->saveGS(); - $page->clipCircle(250, 500, 50); - $page->drawImage($stampImagePNG, 200, 450, 300, 550); - $page->restoreGS(); - - - $stampImageTIFF = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.tif'); - $this->assertTrue($stampImageTIFF instanceof Zend_Pdf_Resource_Image); - - $page->saveGS(); - $page->clipCircle(325, 500, 50); - $page->drawImage($stampImagePNG, 275, 450, 375, 550); - $page->restoreGS(); - - if (function_exists('gd_info')) { - $info = gd_info(); - $jpegSupported = $info['JPG Support']; - } else { - $jpegSupported = false; - } - if ($jpegSupported) { - $stampImageJPG = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.jpg'); - - $this->assertTrue($stampImageJPG instanceof Zend_Pdf_Resource_Image); - - $page->saveGS(); - $page->clipCircle(287.5, 440, 50); - $page->drawImage($stampImageJPG, 237.5, 390, 337.5, 490); - $page->restoreGS(); - - $page->saveGS(); - $page->clipCircle(250, 500, 50); - $page->clipCircle(287.5, 440, 50); - $page->drawImage($stampImagePNG, 200, 450, 300, 550); - $page->restoreGS(); - } - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - $this->assertTrue($pdf1 instanceof Zend_Pdf); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } - - public function testFontDrawing() - { - $pdf = new Zend_Pdf(); - - $fontsList = array(Zend_Pdf_Font::FONT_COURIER, - Zend_Pdf_Font::FONT_COURIER_BOLD, - Zend_Pdf_Font::FONT_COURIER_BOLD_ITALIC, - Zend_Pdf_Font::FONT_COURIER_BOLD_OBLIQUE, - Zend_Pdf_Font::FONT_COURIER_ITALIC, - Zend_Pdf_Font::FONT_COURIER_OBLIQUE, - Zend_Pdf_Font::FONT_HELVETICA, - Zend_Pdf_Font::FONT_HELVETICA_BOLD, - Zend_Pdf_Font::FONT_HELVETICA_BOLD_ITALIC, - Zend_Pdf_Font::FONT_HELVETICA_BOLD_OBLIQUE, - Zend_Pdf_Font::FONT_HELVETICA_ITALIC, - Zend_Pdf_Font::FONT_HELVETICA_OBLIQUE, - Zend_Pdf_Font::FONT_TIMES, - Zend_Pdf_Font::FONT_TIMES_BOLD, - Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC, - Zend_Pdf_Font::FONT_TIMES_ITALIC, - Zend_Pdf_Font::FONT_TIMES_ROMAN); - - $titleFont = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER_BOLD_OBLIQUE); - - foreach ($fontsList as $fontName) { - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE)); - - $font = Zend_Pdf_Font::fontWithName($fontName); - $this->assertTrue($font instanceof Zend_Pdf_Resource_Font); - - $page->setFont($titleFont, 10); - $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400); - - $page->setFont($font, 20); - $page->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360); - - $ascent = $font->getAscent(); - $this->assertTrue( abs(1 - $font->getCoveredPercentage('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxwz')) < 0.00001 ); - $descent = $font->getDescent(); - - $font->getFontName(Zend_Pdf_Font::NAME_FULL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_FAMILY, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_FAMILY, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_STYLE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_STYLE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESCRIPTION, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_SAMPLE_TEXT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_ID, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_VERSION, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_CID_NAME, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER_URL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_MANUFACTURER, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_VENDOR_URL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_COPYRIGHT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_TRADEMARK, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_LICENSE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_LICENSE_URL, 'en'); - - $type = $font->getFontType(); - $lineGap = $font->getLineGap(); - $lineHeight = $font->getLineHeight(); - $this->assertTrue($font->getResource() instanceof Zend_Pdf_Element_Object); - $font->getStrikePosition(); - $font->getStrikeThickness(); - $font->getUnderlinePosition(); - $font->getUnitsPerEm(); - $font->widthForGlyph(10); - } - - $nonAlphabeticalPhonts = - array(Zend_Pdf_Font::FONT_SYMBOL => - "\x00\x20\x00\x21\x22\x00\x00\x23\x22\x03\x00\x25\x00\x26\x22\x0b\x00\x28\x00\x29\x22\x17\x00\x2b\x00\x2c\x22\x12\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x22\x45\x03\x91\x03\x92\x03\xa7\x22\x06\x03\x95\x03\xa6", - Zend_Pdf_Font::FONT_ZAPFDINGBATS => - "\x00\x20\x27\x01\x27\x02\x27\x03\x27\x04\x26\x0e\x27\x06\x27\x07\x27\x08\x27\x09\x26\x1b\x26\x1e\x27\x0c\x27\x0d\x27\x0e\x27\x0f\x27\x10\x27\x11\x27\x12\x27\x13\x27\x14\x27\x15\x27\x16\x27\x17\x27\x18\x27\x19\x27\x1a"); - foreach ($nonAlphabeticalPhonts as $fontName => $example) { - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE)); - - $font = Zend_Pdf_Font::fontWithName($fontName); - $this->assertTrue($font instanceof Zend_Pdf_Resource_Font); - - $page->setFont($titleFont, 10); - $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400); - - $page->setFont($font, 20); - $page->drawText($example, 100, 360, 'UTF-16BE'); - - $ascent = $font->getAscent(); - $this->assertTrue( abs(1 - $font->getCoveredPercentage($example, 'UTF-16BE')) < 0.00001 ); - $descent = $font->getDescent(); - - $font->getFontName(Zend_Pdf_Font::NAME_FULL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_FAMILY, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_FAMILY, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_STYLE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_STYLE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESCRIPTION, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_SAMPLE_TEXT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_ID, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_VERSION, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_CID_NAME, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER_URL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_MANUFACTURER, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_VENDOR_URL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_COPYRIGHT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_TRADEMARK, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_LICENSE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_LICENSE_URL, 'en'); - - $type = $font->getFontType(); - $lineGap = $font->getLineGap(); - $lineHeight = $font->getLineHeight(); - $this->assertTrue($font->getResource() instanceof Zend_Pdf_Element_Object); - $font->getStrikePosition(); - $font->getStrikeThickness(); - $font->getUnderlinePosition(); - $font->getUnitsPerEm(); - $font->widthForGlyph(10); - } - - $TTFFontsList = array('VeraBd.ttf', - 'VeraBI.ttf', - 'VeraIt.ttf', - 'VeraMoBd.ttf', - 'VeraMoBI.ttf', - 'VeraMoIt.ttf', - 'VeraMono.ttf', - 'VeraSeBd.ttf', - 'VeraSe.ttf', - 'Vera.ttf'); - - foreach ($TTFFontsList as $fontName) { - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE)); - - $font = Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/_fonts/' . $fontName); - $this->assertTrue($font instanceof Zend_Pdf_Resource_Font); - - $page->setFont($titleFont, 10); - $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400); - - $page->setFont($font, 20); - $page->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360); - - $ascent = $font->getAscent(); - $this->assertTrue( abs(1 - $font->getCoveredPercentage('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxwz')) < 0.00001 ); - $descent = $font->getDescent(); - - $font->getFontName(Zend_Pdf_Font::NAME_FULL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_FAMILY, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_FAMILY, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_STYLE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_STYLE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESCRIPTION, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_SAMPLE_TEXT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_ID, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_VERSION, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_CID_NAME, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER_URL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_MANUFACTURER, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_VENDOR_URL, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_COPYRIGHT, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_TRADEMARK, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_LICENSE, 'en'); - $font->getFontName(Zend_Pdf_Font::NAME_LICENSE_URL, 'en'); - - $type = $font->getFontType(); - $lineGap = $font->getLineGap(); - $lineHeight = $font->getLineHeight(); - $this->assertTrue($font->getResource() instanceof Zend_Pdf_Element_Object); - $font->getStrikePosition(); - $font->getStrikeThickness(); - $font->getUnderlinePosition(); - $font->getUnitsPerEm(); - $font->widthForGlyph(10); - } - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - $this->assertTrue($pdf1 instanceof Zend_Pdf); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } - - public function testFontExtracting() - { - $pdf = new Zend_Pdf(); - - $fontsList = array(Zend_Pdf_Font::FONT_COURIER, - Zend_Pdf_Font::FONT_HELVETICA_BOLD, - Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC); - - foreach ($fontsList as $fontName) { - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE)); - - $font = Zend_Pdf_Font::fontWithName($fontName); - $page->setFont($font, 10); - $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400); - $page->setFont($font, 20); - $page->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360); - - $type = $font->getFontType(); - } - - $TTFFontsList = array('VeraBd.ttf', - 'VeraBI.ttf', - 'VeraIt.ttf', - 'VeraMoBd.ttf', - 'VeraMoBI.ttf', - 'VeraMoIt.ttf', - 'VeraMono.ttf', - 'VeraSeBd.ttf', - 'VeraSe.ttf', - 'Vera.ttf'); - - foreach ($TTFFontsList as $fontName) { - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE)); - - $font = Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/_fonts/' . $fontName); - $page->setFont($font, 10); - $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'CP1252') . ':', 100, 400); - - $page->setFont($font, 20); - $page->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360); - $type = $font->getFontType(); - } - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - - $newPages = array(); - - $fontList = array(); - $fontNames = array(); - foreach ($pdf1->pages as $page) { - $pageFonts = $page->extractFonts(); - foreach ($pageFonts as $font) { - $fontList[] = $font; - $fontNames[] = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8'); - } - } - - $this->assertEquals(array(Zend_Pdf_Font::FONT_COURIER, - Zend_Pdf_Font::FONT_HELVETICA_BOLD, - Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC, - 'BitstreamVeraSans-Bold', - 'BitstreamVeraSans-BoldOblique', - 'BitstreamVeraSans-Oblique', - 'BitstreamVeraSansMono-Bold', - 'BitstreamVeraSansMono-BoldOb', - 'BitstreamVeraSansMono-Oblique', - 'BitstreamVeraSansMono-Roman', - 'BitstreamVeraSerif-Bold', - 'BitstreamVeraSerif-Roman', - 'BitstreamVeraSans-Roman'), - $fontNames); - - $pdf1->pages[] = ($page = $pdf1->newPage(Zend_Pdf_Page::SIZE_A4)); - $yPosition = 700; - foreach ($fontList as $font) { - $page->setFont($font, 15); - $page->drawText("The quick brown fox jumps over the lazy dog", 100, $yPosition); - $yPosition -= 30; - } - - $fontNames1 = array(); - foreach ($pdf1->extractFonts() as $font) { - $fontNames1[] = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8'); - } - $this->assertEquals(array(Zend_Pdf_Font::FONT_COURIER, - Zend_Pdf_Font::FONT_HELVETICA_BOLD, - Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC, - 'BitstreamVeraSans-Bold', - 'BitstreamVeraSans-BoldOblique', - 'BitstreamVeraSans-Oblique', - 'BitstreamVeraSansMono-Bold', - 'BitstreamVeraSansMono-BoldOb', - 'BitstreamVeraSansMono-Oblique', - 'BitstreamVeraSansMono-Roman', - 'BitstreamVeraSerif-Bold', - 'BitstreamVeraSerif-Roman', - 'BitstreamVeraSans-Roman'), - $fontNames1); - - $page = reset($pdf1->pages); - $font = $page->extractFont(Zend_Pdf_Font::FONT_COURIER); - $this->assertTrue($font instanceof Zend_Pdf_Resource_Font_Extracted); - - $font = $page->extractFont(Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC); - $this->assertNull($font); - - - $font = $pdf1->extractFont(Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC); - $this->assertTrue($font instanceof Zend_Pdf_Resource_Font_Extracted); - - $font = $pdf1->extractFont(Zend_Pdf_Font::FONT_TIMES_ROMAN); - $this->assertNull($font); - - $pdf1->save(dirname(__FILE__) . '/_files/output1.pdf'); - unset($pdf1); - - - $pdf2 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output1.pdf'); - $this->assertTrue($pdf2 instanceof Zend_Pdf); - unset($pdf2); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - unlink(dirname(__FILE__) . '/_files/output1.pdf'); - } -} diff --git a/tests/Zend/Pdf/Element/AllTests.php b/tests/Zend/Pdf/Element/AllTests.php deleted file mode 100644 index e5478b9afa1c154d1b3ac0fc4045277f7a8d7da8..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/AllTests.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Pdf_Element_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Pdf/Element/ArrayTest.php'; -require_once 'Zend/Pdf/Element/BooleanTest.php'; -require_once 'Zend/Pdf/Element/DictionaryTest.php'; -require_once 'Zend/Pdf/Element/NameTest.php'; -require_once 'Zend/Pdf/Element/NullTest.php'; -require_once 'Zend/Pdf/Element/NumericTest.php'; -require_once 'Zend/Pdf/Element/ObjectTest.php'; -require_once 'Zend/Pdf/Element/Object/AllTests.php'; -require_once 'Zend/Pdf/Element/StreamTest.php'; -require_once 'Zend/Pdf/Element/StringTest.php'; -require_once 'Zend/Pdf/Element/String/AllTests.php'; - -class Zend_Pdf_Element_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Pdf_Element'); - - $suite->addTestSuite('Zend_Pdf_Element_ArrayTest'); - $suite->addTestSuite('Zend_Pdf_Element_BooleanTest'); - $suite->addTestSuite('Zend_Pdf_Element_DictionaryTest'); - $suite->addTestSuite('Zend_Pdf_Element_NameTest'); - $suite->addTestSuite('Zend_Pdf_Element_NullTest'); - $suite->addTestSuite('Zend_Pdf_Element_NumericTest'); - $suite->addTestSuite('Zend_Pdf_Element_ObjectTest'); - $suite->addTest(Zend_Pdf_Element_Object_AllTests::suite()); - $suite->addTestSuite('Zend_Pdf_Element_StreamTest'); - $suite->addTestSuite('Zend_Pdf_Element_StringTest'); - $suite->addTest(Zend_Pdf_Element_String_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Pdf_Element_AllTests::main') { - Zend_Pdf_Element_AllTests::main(); -} diff --git a/tests/Zend/Pdf/Element/ArrayTest.php b/tests/Zend/Pdf/Element/ArrayTest.php deleted file mode 100644 index 9e9241eeec5e2d16a6e2eaad6992ecd3b679782c..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/ArrayTest.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Array - */ -require_once 'Zend/Pdf/Element/Array.php'; - -/** - * Zend_Pdf_Element_Boolean - */ -require_once 'Zend/Pdf/Element/Boolean.php'; - -/** - * Zend_Pdf_Element_Numeric - */ -require_once 'Zend/Pdf/Element/Numeric.php'; - -/** - * Zend_Pdf_Element_Name - */ -require_once 'Zend/Pdf/Element/Name.php'; - -/** - * Zend_Pdf_Element_String - */ -require_once 'Zend/Pdf/Element/String.php'; - -/** - * Zend_Pdf_Element_String_Binary - */ -require_once 'Zend/Pdf/Element/String/Binary.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_ArrayTest extends PHPUnit_Framework_TestCase -{ - public function testPDFArray1() - { - $arrayObj = new Zend_Pdf_Element_Array(); - $this->assertTrue($arrayObj instanceof Zend_Pdf_Element_Array); - } - - public function testPDFArray2() - { - $srcArray = array(); - $srcArray[] = new Zend_Pdf_Element_Boolean(false); - $srcArray[] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray[] = new Zend_Pdf_Element_Name('MyName'); - $srcArray[] = new Zend_Pdf_Element_String('some text'); - $srcArray[] = new Zend_Pdf_Element_String_Binary('some text'); - - $arrayObj = new Zend_Pdf_Element_Array($srcArray); - $this->assertTrue($arrayObj instanceof Zend_Pdf_Element_Array); - } - - public function testPDFArrayBadInput1() - { - try { - $arrayObj = new Zend_Pdf_Element_Array(346); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be an array/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFArrayBadInput2() - { - try { - $srcArray = array(); - $srcArray[] = new Zend_Pdf_Element_Boolean(false); - $srcArray[] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray[] = new Zend_Pdf_Element_Name('MyName'); - $srcArray[] = new Zend_Pdf_Element_String('some text'); - $srcArray[] = new Zend_Pdf_Element_String_Binary('some text'); - $srcArray[] = 24; - $arrayObj = new Zend_Pdf_Element_Array($srcArray); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be Zend_Pdf_Element/i', $e->getMessage()); - return; - } - $this->fail('No exception thrown.'); - } - - public function testGetType() - { - $arrayObj = new Zend_Pdf_Element_Array(); - $this->assertEquals($arrayObj->getType(), Zend_Pdf_Element::TYPE_ARRAY); - } - - public function testToString() - { - $srcArray = array(); - $srcArray[] = new Zend_Pdf_Element_Boolean(false); - $srcArray[] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray[] = new Zend_Pdf_Element_Name('MyName'); - $srcArray[] = new Zend_Pdf_Element_String('some text'); - $arrayObj = new Zend_Pdf_Element_Array($srcArray); - $this->assertEquals($arrayObj->toString(), '[false 100.426 /MyName (some text) ]'); - } - - /** - * @todo Zend_Pdf_Element_Array::add() does not exist - */ - /* - public function testAdd() - { - $arrayObj = new Zend_Pdf_Element_Array($srcArray); - $arrayObj->add(new Zend_Pdf_Element_Boolean(false)); - $arrayObj->add(new Zend_Pdf_Element_Numeric(100.426)); - $arrayObj->add(new Zend_Pdf_Element_Name('MyName')); - $arrayObj->add(new Zend_Pdf_Element_String('some text')); - $this->assertEquals($arrayObj->toString(), '[false 100.426 /MyName (some text) ]' ); - } - //*/ - - /** - * @todo Zend_Pdf_Element_Array::add() does not exist - */ - /* - public function testAddBadArgument() - { - try { - $arrayObj = new ZPdfPDFArray(); - $arrayObj->add(100.426); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be Zend_Pdf_Element/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - //*/ -} diff --git a/tests/Zend/Pdf/Element/BooleanTest.php b/tests/Zend/Pdf/Element/BooleanTest.php deleted file mode 100644 index 98d59168c51c32d398db314e4ea4141b3c05a068..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/BooleanTest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Boolean - */ -require_once 'Zend/Pdf/Element/Boolean.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_BooleanTest extends PHPUnit_Framework_TestCase -{ - public function testPDFBoolean() - { - $boolObj = new Zend_Pdf_Element_Boolean(false); - $this->assertTrue($boolObj instanceof Zend_Pdf_Element_Boolean); - } - - public function testPDFBooleanBadArgument() - { - try { - $boolObj = new Zend_Pdf_Element_Boolean('some input'); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be boolean/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testGetType() - { - $boolObj = new Zend_Pdf_Element_Boolean((boolean) 100); - $this->assertEquals($boolObj->getType(), Zend_Pdf_Element::TYPE_BOOL); - } - - public function testToString() - { - $boolObj = new Zend_Pdf_Element_Boolean(true); - $this->assertEquals($boolObj->toString(), 'true'); - } -} diff --git a/tests/Zend/Pdf/Element/DictionaryTest.php b/tests/Zend/Pdf/Element/DictionaryTest.php deleted file mode 100644 index f0be8d4dc8e49137c1d36707f28b059208ad7b07..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/DictionaryTest.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Dictionary - */ -require_once 'Zend/Pdf/Element/Dictionary.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_DictionaryTest extends PHPUnit_Framework_TestCase -{ - public function testPDFDictionary1() - { - $dictionaryObj = new Zend_Pdf_Element_Dictionary(); - $this->assertTrue($dictionaryObj instanceof Zend_Pdf_Element_Dictionary); - } - - public function testPDFDictionary2() - { - $srcArray = array(); - $srcArray['Bool'] = new Zend_Pdf_Element_Boolean(false); - $srcArray['Number'] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray['Name'] = new Zend_Pdf_Element_Name('MyName'); - $srcArray['Text'] = new Zend_Pdf_Element_String('some text'); - $srcArray['BinaryText'] = new Zend_Pdf_Element_String_Binary('some text'); - - $dictionaryObj = new Zend_Pdf_Element_Dictionary($srcArray); - $this->assertTrue($dictionaryObj instanceof Zend_Pdf_Element_Dictionary); - } - - public function testPDFDictionaryBadInput1() - { - try { - $arrayObj = new Zend_Pdf_Element_Dictionary(346); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be an array/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFDictionaryBadInput2() - { - try { - $srcArray = array(); - $srcArray['Bool'] = new Zend_Pdf_Element_Boolean(false); - $srcArray['Number'] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray['Name'] = new Zend_Pdf_Element_Name('MyName'); - $srcArray['Text'] = new Zend_Pdf_Element_String('some text'); - $srcArray['BinaryText'] = new Zend_Pdf_Element_String_Binary('some text'); - $srcArray['bad value'] = 24; - $dictionaryObj = new Zend_Pdf_Element_Dictionary($srcArray); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be Zend_Pdf_Element/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFDictionaryBadInput3() - { - try { - $srcArray = array(); - $srcArray['Bool'] = new Zend_Pdf_Element_Boolean(false); - $srcArray['Number'] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray['Name'] = new Zend_Pdf_Element_Name('MyName'); - $srcArray['Text'] = new Zend_Pdf_Element_String('some text'); - $srcArray['BinaryText'] = new Zend_Pdf_Element_String_Binary('some text'); - $srcArray[5] = new Zend_Pdf_Element_String('bad name'); - $dictionaryObj = new Zend_Pdf_Element_Dictionary($srcArray); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/keys must be strings/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testGetType() - { - $dictionaryObj = new Zend_Pdf_Element_Dictionary(); - $this->assertEquals($dictionaryObj->getType(), Zend_Pdf_Element::TYPE_DICTIONARY); - } - - public function testToString() - { - $srcArray = array(); - $srcArray['Bool'] = new Zend_Pdf_Element_Boolean(false); - $srcArray['Number'] = new Zend_Pdf_Element_Numeric(100.426); - $srcArray['Name'] = new Zend_Pdf_Element_Name('MyName'); - $srcArray['Text'] = new Zend_Pdf_Element_String('some text'); - $srcArray['BinaryText'] = new Zend_Pdf_Element_String_Binary("\x01\x02\x00\xff"); - $dictionaryObj = new Zend_Pdf_Element_Dictionary($srcArray); - $this->assertEquals($dictionaryObj->toString(), - '<</Bool false /Number 100.426 /Name /MyName /Text (some text) /BinaryText <010200FF> >>'); - } - - public function testAdd() - { - $dictionaryObj = new Zend_Pdf_Element_Dictionary(); - $dictionaryObj->add(new Zend_Pdf_Element_Name('Var1'), new Zend_Pdf_Element_Boolean(false)); - $dictionaryObj->add(new Zend_Pdf_Element_Name('Var2'), new Zend_Pdf_Element_Numeric(100.426)); - $dictionaryObj->add(new Zend_Pdf_Element_Name('Var3'), new Zend_Pdf_Element_Name('MyName')); - $dictionaryObj->add(new Zend_Pdf_Element_Name('Var4'), new Zend_Pdf_Element_String('some text')); - $this->assertEquals($dictionaryObj->toString(), - '<</Var1 false /Var2 100.426 /Var3 /MyName /Var4 (some text) >>'); - } - -} diff --git a/tests/Zend/Pdf/Element/NameTest.php b/tests/Zend/Pdf/Element/NameTest.php deleted file mode 100644 index 7a5f2f659d9ff00f4823b1b58baafef929c732f4..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/NameTest.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Name - */ -require_once 'Zend/Pdf/Element/Name.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_NameTest extends PHPUnit_Framework_TestCase -{ - public function testPDFName() - { - $nameObj = new Zend_Pdf_Element_Name('MyName'); - $this->assertTrue($nameObj instanceof Zend_Pdf_Element_Name); - } - - public function testPDFNameBadString() - { - try { - $nameObj = new Zend_Pdf_Element_Name("MyName\x00"); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/Null character is not allowed/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testGetType() - { - $nameObj = new Zend_Pdf_Element_Name('MyName'); - $this->assertEquals($nameObj->getType(), Zend_Pdf_Element::TYPE_NAME); - } - - public function testToString() - { - $nameObj = new Zend_Pdf_Element_Name('MyName'); - $this->assertEquals($nameObj->toString(), '/MyName'); - } - - public function testEscape() - { - $this->assertEquals(Zend_Pdf_Element_Name::escape('My Cool Name()'), 'My#20Cool#20Name#28#29'); - } - - public function testUnescape() - { - $this->assertEquals(Zend_Pdf_Element_Name::unescape('My#20Cool#20Name#28#29'), 'My Cool Name()'); - } -} diff --git a/tests/Zend/Pdf/Element/NullTest.php b/tests/Zend/Pdf/Element/NullTest.php deleted file mode 100644 index f7dcc40ecb4f276ad61cc9d97be8e9aa47d47dca..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/NullTest.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Null - */ -require_once 'Zend/Pdf/Element/Null.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_NullTest extends PHPUnit_Framework_TestCase -{ - public function testPDFNull() - { - $nullObj = new Zend_Pdf_Element_Null(); - $this->assertTrue($nullObj instanceof Zend_Pdf_Element_Null); - } - - public function testGetType() - { - $nullObj = new Zend_Pdf_Element_Null(); - $this->assertEquals($nullObj->getType(), Zend_Pdf_Element::TYPE_NULL); - } - - public function testToString() - { - $nullObj = new Zend_Pdf_Element_Null(); - $this->assertEquals($nullObj->toString(), 'null'); - } -} diff --git a/tests/Zend/Pdf/Element/NumericTest.php b/tests/Zend/Pdf/Element/NumericTest.php deleted file mode 100644 index 9a75835378890dd0ef55c2f3befc7868a31b0345..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/NumericTest.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Numeric - */ -require_once 'Zend/Pdf/Element/Numeric.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_NumericTest extends PHPUnit_Framework_TestCase -{ - public function testPDFNumeric() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $this->assertTrue($intObj instanceof Zend_Pdf_Element_Numeric); - } - - public function testPDFNumericBadArgument() - { - try { - $intObj = new Zend_Pdf_Element_Numeric('some input'); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must be numeric/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testGetType() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $this->assertEquals($intObj->getType(), Zend_Pdf_Element::TYPE_NUMERIC); - } - - public function testToString() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $this->assertEquals($intObj->toString(), '100'); - } - - public function testToStringFloat1() - { - $intObj = new Zend_Pdf_Element_Numeric(100.426); - $this->assertEquals($intObj->toString(), '100.426'); - } - - public function testToStringFloat2() - { - $intObj = new Zend_Pdf_Element_Numeric(100.42633); - $this->assertEquals($intObj->toString(), '100.42633'); - } - - public function testToStringFloat3() - { - $intObj = new Zend_Pdf_Element_Numeric(-100.426); - $this->assertEquals($intObj->toString(), '-100.426'); - } -} diff --git a/tests/Zend/Pdf/Element/Object/AllTests.php b/tests/Zend/Pdf/Element/Object/AllTests.php deleted file mode 100644 index 3b2c40c4bc1a9ca9b5887e4e0033b81d610317f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/Object/AllTests.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Pdf_Element_Object_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Pdf/Element/Object/StreamTest.php'; - -class Zend_Pdf_Element_Object_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Pdf_Element_Object'); - - $suite->addTestSuite('Zend_Pdf_Element_Object_StreamTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Pdf_Element_Object_AllTests::main') { - Zend_Pdf_Element_Object_AllTests::main(); -} diff --git a/tests/Zend/Pdf/Element/Object/StreamTest.php b/tests/Zend/Pdf/Element/Object/StreamTest.php deleted file mode 100644 index 13afdf72fe304168e369e6d31cb29e18e8052fa9..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/Object/StreamTest.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Object_Stream - */ -require_once 'Zend/Pdf/Element/Object/Stream.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_Object_StreamTest extends PHPUnit_Framework_TestCase -{ - public function testPDFStreamObject() - { - $obj = new Zend_Pdf_Element_Object_Stream('some data', 1, 0, new Zend_Pdf_ElementFactory(1)); - $this->assertTrue($obj instanceof Zend_Pdf_Element_Object_Stream); - } - - public function testGetType() - { - $obj = new Zend_Pdf_Element_Object_Stream('some data', 1, 0, new Zend_Pdf_ElementFactory(1)); - $this->assertEquals($obj->getType(), Zend_Pdf_Element::TYPE_STREAM); - } - - public function testDump() - { - $factory = new Zend_Pdf_ElementFactory(1); - - $obj = new Zend_Pdf_Element_Object_Stream('some data', 55, 3, $factory); - $this->assertEquals($obj->dump($factory), "55 3 obj \n<</Length 9 >>\nstream\nsome data\nendstream\nendobj\n"); - } -} diff --git a/tests/Zend/Pdf/Element/ObjectTest.php b/tests/Zend/Pdf/Element/ObjectTest.php deleted file mode 100644 index 8c91931d2c662d8c5e92a980e7ab81d005f2ade1..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/ObjectTest.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** Zend_Pdf_Element_Object */ -require_once 'Zend/Pdf/Element/Object.php'; - -/** Zend_Pdf_Element_Numeric */ -require_once 'Zend/Pdf/Element/Numeric.php'; - -/** PHPUnit Test Case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_ObjectTest extends PHPUnit_Framework_TestCase -{ - public function testPDFObject() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 1, 0, new Zend_Pdf_ElementFactory(1)); - - $this->assertTrue($obj instanceof Zend_Pdf_Element_Object); - } - - public function testPDFObjectBadObjectType1() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj1 = new Zend_Pdf_Element_Object($intObj, 1, 0, new Zend_Pdf_ElementFactory(1)); - - try { - $obj2 = new Zend_Pdf_Element_Object($obj1, 1, 0, new Zend_Pdf_ElementFactory(1)); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/must not be instance of Zend_Pdf_Element_Object/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFObjectBadGenNumber1() - { - try { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 1, -1, new Zend_Pdf_ElementFactory(1)); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/non-negative integer/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFObjectBadGenNumber2() - { - try { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 1, 1.2, new Zend_Pdf_ElementFactory(1)); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/non-negative integer/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFObjectBadObjectNumber1() - { - try { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 0, 0, new Zend_Pdf_ElementFactory(1)); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/positive integer/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFObjectBadObjectNumber2() - { - try { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, -1, 0, new Zend_Pdf_ElementFactory(1)); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/positive integer/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testPDFObjectBadObjectNumber3() - { - try { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 1.2, 0, new Zend_Pdf_ElementFactory(1)); - } catch (Zend_Pdf_Exception $e) { - $this->assertRegExp('/positive integer/i', $e->getMessage()); - return; - } - $this->fail('Expected Zend_Pdf_Exception to be thrown'); - } - - public function testGetType() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 1, 0, new Zend_Pdf_ElementFactory(1)); - - $this->assertEquals($obj->getType(), $intObj->getType()); - } - - public function testToString() - { - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 55, 3, new Zend_Pdf_ElementFactory(1)); - - $this->assertEquals($obj->toString(), '55 3 R'); - } - - public function testDump() - { - $factory = new Zend_Pdf_ElementFactory(1); - - $intObj = new Zend_Pdf_Element_Numeric(100); - $obj = new Zend_Pdf_Element_Object($intObj, 55, 3, $factory); - - $this->assertEquals($obj->dump($factory), "55 3 obj \n100\nendobj\n"); - } -} diff --git a/tests/Zend/Pdf/Element/StreamTest.php b/tests/Zend/Pdf/Element/StreamTest.php deleted file mode 100644 index a99a846ce970de2f6299314dbbd173f0c3a6f4d4..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/StreamTest.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_Stream - */ -require_once 'Zend/Pdf/Element/Stream.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_StreamTest extends PHPUnit_Framework_TestCase -{ - public function testPDFStream() - { - $streamObj = new Zend_Pdf_Element_Stream('some text'); - $this->assertTrue($streamObj instanceof Zend_Pdf_Element_Stream); - } - - public function testGetType() - { - $streamObj = new Zend_Pdf_Element_Stream('some text'); - $this->assertEquals($streamObj->getType(), Zend_Pdf_Element::TYPE_STREAM); - } - - public function testValueAccess() - { - $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n"); - $this->assertEquals($streamObj->value->getRef(), "some text (\x00\x01\x02)\n"); - - $valueRef = &$streamObj->value->getRef(); - $valueRef = "another text (\x02\x03\x04)\n"; - $streamObj->value->touch(); - - $this->assertEquals($streamObj->value->getRef(), "another text (\x02\x03\x04)\n"); - } - - public function testToString() - { - $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n"); - $this->assertEquals($streamObj->toString(), "stream\nsome text (\x00\x01\x02)\n\nendstream"); - } - - public function testLength() - { - $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n"); - $this->assertEquals($streamObj->length(), 16); - } - - public function testClear() - { - $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n"); - $streamObj->clear(); - $this->assertEquals($streamObj->length(), 0); - $this->assertEquals($streamObj->toString(), "stream\n\nendstream"); - } - - public function testAppend() - { - $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n"); - $streamObj->append("something\xAF"); - $this->assertEquals($streamObj->length(), 16 + 10); - $this->assertEquals($streamObj->toString(), "stream\nsome text (\x00\x01\x02)\nsomething\xAF\nendstream"); - } -} diff --git a/tests/Zend/Pdf/Element/String/AllTests.php b/tests/Zend/Pdf/Element/String/AllTests.php deleted file mode 100644 index 413e2707751c68a5e8bf8955514230fb31108712..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/String/AllTests.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Pdf_Element_String_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Pdf/Element/String/BinaryTest.php'; - -class Zend_Pdf_Element_String_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Pdf_Element_String'); - - $suite->addTestSuite('Zend_Pdf_Element_String_BinaryTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Pdf_Element_String_AllTests::main') { - Zend_Pdf_Element_String_AllTests::main(); -} diff --git a/tests/Zend/Pdf/Element/String/BinaryTest.php b/tests/Zend/Pdf/Element/String/BinaryTest.php deleted file mode 100644 index 25538df53f7b950c657f0eddccf1926b5e0058ef..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/String/BinaryTest.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_String_Binary - */ -require_once 'Zend/Pdf/Element/String/Binary.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_String_BinaryTest extends PHPUnit_Framework_TestCase -{ - public function testPDFBinaryString() - { - $stringObj = new Zend_Pdf_Element_String_Binary('some text'); - $this->assertTrue($stringObj instanceof Zend_Pdf_Element_String_Binary); - } - - public function testGetType() - { - $stringObj = new Zend_Pdf_Element_String_Binary('some text'); - $this->assertEquals($stringObj->getType(), Zend_Pdf_Element::TYPE_STRING); - } - - public function testToString() - { - $stringObj = new Zend_Pdf_Element_String_Binary("\x00\x01\x02\x03\x04\x05\x06\x07\x22\xFF\xF3"); - $this->assertEquals($stringObj->toString(), '<000102030405060722FFF3>'); - } - - public function testEscape() - { - $this->assertEquals(Zend_Pdf_Element_String_Binary::escape("\n\r\t\x08\x0C()\\"), '0A0D09080C28295C'); - } - - public function testUnescape1() - { - $this->assertEquals(Zend_Pdf_Element_String_Binary::unescape('01020304FF20'), "\x01\x02\x03\x04\xFF "); - } - - public function testUnescape2() - { - $this->assertEquals(Zend_Pdf_Element_String_Binary::unescape('01020304FF2'), "\x01\x02\x03\x04\xFF "); - } -} diff --git a/tests/Zend/Pdf/Element/StringTest.php b/tests/Zend/Pdf/Element/StringTest.php deleted file mode 100644 index a6b3783dd84eb268a1df8579eb7e3ee5b1405382..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/Element/StringTest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** - * Zend_Pdf_Element_String - */ -require_once 'Zend/Pdf/Element/String.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_Element_StringTest extends PHPUnit_Framework_TestCase -{ - public function testPDFString() - { - $stringObj = new Zend_Pdf_Element_String('some text'); - $this->assertTrue($stringObj instanceof Zend_Pdf_Element_String); - } - - public function testGetType() - { - $stringObj = new Zend_Pdf_Element_String('some text'); - $this->assertEquals($stringObj->getType(), Zend_Pdf_Element::TYPE_STRING); - } - - public function testToString() - { - $stringObj = new Zend_Pdf_Element_String('some text ()'); - $this->assertEquals($stringObj->toString(), '(some text \\(\\))' ); - } - - public function testEscape() - { - $this->assertEquals(Zend_Pdf_Element_String::escape("\n\r\t\x08\x0C()\\"), "\\n\\r\\t\\b\\f\\(\\)\\\\"); - } - - public function testUnescape() - { - $this->assertEquals(Zend_Pdf_Element_String::unescape("\\n\\r\\t\\b\\f\\(\\)\\\\ \nsome \\\ntext"), - "\n\r\t\x08\x0C()\\ \nsome text"); - } -} diff --git a/tests/Zend/Pdf/ProcessingTest.php b/tests/Zend/Pdf/ProcessingTest.php deleted file mode 100644 index f402386d19ad52b834a6cf629e22bf63c29372cc..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/ProcessingTest.php +++ /dev/null @@ -1,306 +0,0 @@ -<?php -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ - - -/** Zend_Pdf */ -require_once 'Zend/Pdf.php'; - -/** PHPUnit Test Case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_Pdf - * @subpackage UnitTests - */ -class Zend_Pdf_ProcessingTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $pdf = new Zend_Pdf(); - - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page1 = $pdf->newPage('A4')); - - // Add new page generated by Zend_Pdf_Page object (page is not attached to the document) - $pdf->pages[] = ($page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE)); - - // Create new font - $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); - - // Apply font and draw text - $page1->setFont($font, 36); - $page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc')); - $page1->drawText('Helvetica 36 text string', 60, 500); - - // Use font object for another page - $page2->setFont($font, 24); - $page2->drawText('Helvetica 24 text string', 60, 500); - - // Use another font - $page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32); - $page2->drawText('Times-Roman 32 text string', 60, 450); - - // Draw rectangle - $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)); - $page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)); - $page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6); - $page2->drawRectangle(60, 400, 400, 350); - - // Draw circle - $page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0)); - $page2->drawCircle(85, 375, 25); - - // Draw sectors - $page2->drawCircle(200, 375, 25, 2*M_PI/3, -M_PI/6); - $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0)); - $page2->drawCircle(200, 375, 25, M_PI/6, 2*M_PI/3); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0)); - $page2->drawCircle(200, 375, 25, -M_PI/6, M_PI/6); - - // Draw ellipse - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0)); - $page2->drawEllipse(250, 400, 400, 350); - $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0)); - $page2->drawEllipse(250, 400, 400, 350, M_PI/6, 2*M_PI/3); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0)); - $page2->drawEllipse(250, 400, 400, 350, -M_PI/6, M_PI/6); - - // Draw and fill polygon - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1)); - $x = array(); - $y = array(); - for ($count = 0; $count < 8; $count++) { - $x[] = 140 + 25*cos(3*M_PI_4*$count); - $y[] = 375 + 25*sin(3*M_PI_4*$count); - } - $page2->drawPolygon($x, $y, - Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, - Zend_Pdf_Page::FILL_METHOD_EVEN_ODD); - - // Draw line - $page2->setLineWidth(0.5); - $page2->drawLine(60, 375, 400, 375); - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - - $this->assertTrue($pdf1 instanceof Zend_Pdf); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } - - public function testModify() - { - $pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf'); - - // Reverse page order - $pdf->pages = array_reverse($pdf->pages); - - // Mark page as modified - foreach ($pdf->pages as $page){ - $page->saveGS(); - - // Create new Style - $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9)); - $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)); - $page->setLineWidth(3); - $page->setLineDashingPattern(array(3, 2, 3, 4), 1.6); - $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32); - - - $page->rotate(0, 0, M_PI_2/3); - $page->drawText('Modified by Zend Framework!', 150, 0); - $page->restoreGS(); - } - - - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages[] = ($page1 = $pdf->newPage('A4')); - - // Add new page generated by Zend_Pdf_Page object (page is not attached to the document) - $pdf->pages[] = ($page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE)); - - // Create new font - $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); - - // Apply font and draw text - $page1->setFont($font, 36); - $page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc')); - $page1->drawText('Helvetica 36 text string', 60, 500); - - // Use font object for another page - $page2->setFont($font, 24); - $page2->drawText('Helvetica 24 text string', 60, 500); - - // Use another font - $page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32); - $page2->drawText('Times-Roman 32 text string', 60, 450); - - // Draw rectangle - $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)); - $page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)); - $page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6); - $page2->drawRectangle(60, 400, 400, 350); - - // Draw circle - $page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0)); - $page2->drawCircle(85, 375, 25); - - // Draw sectors - $page2->drawCircle(200, 375, 25, 2*M_PI/3, -M_PI/6); - $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0)); - $page2->drawCircle(200, 375, 25, M_PI/6, 2*M_PI/3); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0)); - $page2->drawCircle(200, 375, 25, -M_PI/6, M_PI/6); - - // Draw ellipse - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0)); - $page2->drawEllipse(250, 400, 400, 350); - $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0)); - $page2->drawEllipse(250, 400, 400, 350, M_PI/6, 2*M_PI/3); - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0)); - $page2->drawEllipse(250, 400, 400, 350, -M_PI/6, M_PI/6); - - // Draw and fill polygon - $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1)); - $x = array(); - $y = array(); - for ($count = 0; $count < 8; $count++) { - $x[] = 140 + 25*cos(3*M_PI_4*$count); - $y[] = 375 + 25*sin(3*M_PI_4*$count); - } - $page2->drawPolygon($x, $y, - Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, - Zend_Pdf_Page::FILL_METHOD_EVEN_ODD); - - // Draw line - $page2->setLineWidth(0.5); - $page2->drawLine(60, 375, 400, 375); - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - - $this->assertTrue($pdf1 instanceof Zend_Pdf); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } - - public function testInfoProcessing() - { - $pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf'); - - $this->assertEquals($pdf->properties['Title'], 'PDF as a Standard for Archiving'); - $this->assertEquals($pdf->properties['Author'], 'Adobe Systems Incorporated'); - - $metadata = $pdf->getMetadata(); - - $metadataDOM = new DOMDocument(); - $metadataDOM->loadXML($metadata); - - $xpath = new DOMXPath($metadataDOM); - $pdfPreffixNamespaceURI = $xpath->query('/rdf:RDF/rdf:Description')->item(0)->lookupNamespaceURI('pdf'); - $xpath->registerNamespace('pdf', $pdfPreffixNamespaceURI); - - $titleNodeset = $xpath->query('/rdf:RDF/rdf:Description/pdf:Title'); - $titleNode = $titleNodeset->item(0); - $this->assertEquals($titleNode->nodeValue, 'PDF as a Standard for Archiving'); - - - $pdf->properties['Title'] .= ' (modified)'; - $pdf->properties['New_Property'] = 'New property'; - - $titleNode->nodeValue .= ' (modified using RDF data)'; - $pdf->setMetadata($metadataDOM->saveXML()); - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - unset($pdf); - - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - $this->assertEquals($pdf1->properties['Title'], 'PDF as a Standard for Archiving (modified)'); - $this->assertEquals($pdf1->properties['Author'], 'Adobe Systems Incorporated'); - $this->assertEquals($pdf1->properties['New_Property'], 'New property'); - - $metadataDOM1 = new DOMDocument(); - $metadataDOM1->loadXML($metadata); - - $xpath1 = new DOMXPath($metadataDOM); - $pdfPreffixNamespaceURI1 = $xpath1->query('/rdf:RDF/rdf:Description')->item(0)->lookupNamespaceURI('pdf'); - $xpath1->registerNamespace('pdf', $pdfPreffixNamespaceURI1); - - $titleNodeset1 = $xpath->query('/rdf:RDF/rdf:Description/pdf:Title'); - $titleNode1 = $titleNodeset->item(0); - $this->assertEquals($titleNode1->nodeValue, 'PDF as a Standard for Archiving (modified using RDF data)'); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } - - public function testPageCloning() - { - $pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf'); - - $srcPageCount = count($pdf->pages); - - try { - $newPage = clone reset($pdf->pages); - } catch (Zend_Pdf_Exception $e) { - if (strpos($e->getMessage(), 'Cloning Zend_Pdf_Page object using \'clone\' keyword is not supported.') !== 0) { - throw $e; - } - - // Exception is thrown - } - - $outputPageSet = array(); - foreach ($pdf->pages as $srcPage){ - $page = new Zend_Pdf_Page($srcPage); - - $outputPageSet[] = $srcPage; - $outputPageSet[] = $page; - - $page->saveGS(); - - // Create new Style - $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9)); - $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)); - $page->setLineWidth(3); - $page->setLineDashingPattern(array(3, 2, 3, 4), 1.6); - $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32); - - - $page->rotate(0, 0, M_PI_2/3); - $page->drawText('Modified by Zend Framework!', 150, 0); - $page->restoreGS(); - } - - - // Add new page generated by Zend_Pdf object (page is attached to the specified the document) - $pdf->pages = $outputPageSet; - - $pdf->save(dirname(__FILE__) . '/_files/output.pdf'); - - unset($pdf); - - $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf'); - - $this->assertTrue($pdf1 instanceof Zend_Pdf); - $this->assertEquals($srcPageCount*2, count($pdf1->pages)); - unset($pdf1); - - unlink(dirname(__FILE__) . '/_files/output.pdf'); - } -} diff --git a/tests/Zend/Pdf/_files/pdfarchiving.pdf b/tests/Zend/Pdf/_files/pdfarchiving.pdf deleted file mode 100644 index f1d89b010ef0179a8483e7331dca260674210796..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_files/pdfarchiving.pdf and /dev/null differ diff --git a/tests/Zend/Pdf/_files/stamp.jpg b/tests/Zend/Pdf/_files/stamp.jpg deleted file mode 100644 index 1c3f56ae8a42dd9948ce87caff0c4483ae366dee..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_files/stamp.jpg and /dev/null differ diff --git a/tests/Zend/Pdf/_files/stamp.png b/tests/Zend/Pdf/_files/stamp.png deleted file mode 100644 index f091e4859759cf5a09a3f51487e0f6ec3fb7c083..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_files/stamp.png and /dev/null differ diff --git a/tests/Zend/Pdf/_files/stamp.tif b/tests/Zend/Pdf/_files/stamp.tif deleted file mode 100644 index 5c6fc59f8a883c47af0f82de1a2b8fdb817ccb9c..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_files/stamp.tif and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/COPYRIGHT.TXT b/tests/Zend/Pdf/_fonts/COPYRIGHT.TXT deleted file mode 100644 index e651be1c4fe958e06fd7d7a2e79b3e7c2cb70a8e..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/_fonts/COPYRIGHT.TXT +++ /dev/null @@ -1,124 +0,0 @@ -Bitstream Vera Fonts Copyright - -The fonts have a generous copyright, allowing derivative works (as -long as "Bitstream" or "Vera" are not in the names), and full -redistribution (so long as they are not *sold* by themselves). They -can be be bundled, redistributed and sold with any software. - -The fonts are distributed under the following copyright: - -Copyright -========= - -Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream -Vera is a trademark of Bitstream, Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of the fonts accompanying this license ("Fonts") and associated -documentation files (the "Font Software"), to reproduce and distribute -the Font Software, including without limitation the rights to use, -copy, merge, publish, distribute, and/or sell copies of the Font -Software, and to permit persons to whom the Font Software is furnished -to do so, subject to the following conditions: - -The above copyright and trademark notices and this permission notice -shall be included in all copies of one or more of the Font Software -typefaces. - -The Font Software may be modified, altered, or added to, and in -particular the designs of glyphs or characters in the Fonts may be -modified and additional glyphs or characters may be added to the -Fonts, only if the fonts are renamed to names not containing either -the words "Bitstream" or the word "Vera". - -This License becomes null and void to the extent applicable to Fonts -or Font Software that has been modified and is distributed under the -"Bitstream Vera" names. - -The Font Software may be sold as part of a larger software package but -no copy of one or more of the Font Software typefaces may be sold by -itself. - -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL -BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, -OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT -SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. - -Except as contained in this notice, the names of Gnome, the Gnome -Foundation, and Bitstream Inc., shall not be used in advertising or -otherwise to promote the sale, use or other dealings in this Font -Software without prior written authorization from the Gnome Foundation -or Bitstream Inc., respectively. For further information, contact: -fonts at gnome dot org. - -Copyright FAQ -============= - - 1. I don't understand the resale restriction... What gives? - - Bitstream is giving away these fonts, but wishes to ensure its - competitors can't just drop the fonts as is into a font sale system - and sell them as is. It seems fair that if Bitstream can't make money - from the Bitstream Vera fonts, their competitors should not be able to - do so either. You can sell the fonts as part of any software package, - however. - - 2. I want to package these fonts separately for distribution and - sale as part of a larger software package or system. Can I do so? - - Yes. A RPM or Debian package is a "larger software package" to begin - with, and you aren't selling them independently by themselves. - See 1. above. - - 3. Are derivative works allowed? - Yes! - - 4. Can I change or add to the font(s)? - Yes, but you must change the name(s) of the font(s). - - 5. Under what terms are derivative works allowed? - - You must change the name(s) of the fonts. This is to ensure the - quality of the fonts, both to protect Bitstream and Gnome. We want to - ensure that if an application has opened a font specifically of these - names, it gets what it expects (though of course, using fontconfig, - substitutions could still could have occurred during font - opening). You must include the Bitstream copyright. Additional - copyrights can be added, as per copyright law. Happy Font Hacking! - - 6. If I have improvements for Bitstream Vera, is it possible they might get - adopted in future versions? - - Yes. The contract between the Gnome Foundation and Bitstream has - provisions for working with Bitstream to ensure quality additions to - the Bitstream Vera font family. Please contact us if you have such - additions. Note, that in general, we will want such additions for the - entire family, not just a single font, and that you'll have to keep - both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add - glyphs to the font, they must be stylistically in keeping with Vera's - design. Vera cannot become a "ransom note" font. Jim Lyles will be - providing a document describing the design elements used in Vera, as a - guide and aid for people interested in contributing to Vera. - - 7. I want to sell a software package that uses these fonts: Can I do so? - - Sure. Bundle the fonts with your software and sell your software - with the fonts. That is the intent of the copyright. - - 8. If applications have built the names "Bitstream Vera" into them, - can I override this somehow to use fonts of my choosing? - - This depends on exact details of the software. Most open source - systems and software (e.g., Gnome, KDE, etc.) are now converting to - use fontconfig (see www.fontconfig.org) to handle font configuration, - selection and substitution; it has provisions for overriding font - names and subsituting alternatives. An example is provided by the - supplied local.conf file, which chooses the family Bitstream Vera for - "sans", "serif" and "monospace". Other software (e.g., the XFree86 - core server) has other mechanisms for font substitution. - diff --git a/tests/Zend/Pdf/_fonts/README.TXT b/tests/Zend/Pdf/_fonts/README.TXT deleted file mode 100644 index 0f71795a7cbe78e7561b9b2ba8879b02bb962088..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/_fonts/README.TXT +++ /dev/null @@ -1,11 +0,0 @@ -Contained herin is the Bitstream Vera font family. - -The Copyright information is found in the COPYRIGHT.TXT file (along -with being incoporated into the fonts themselves). - -The releases notes are found in the file "RELEASENOTES.TXT". - -We hope you enjoy Vera! - - Bitstream, Inc. - The Gnome Project diff --git a/tests/Zend/Pdf/_fonts/RELEASENOTES.TXT b/tests/Zend/Pdf/_fonts/RELEASENOTES.TXT deleted file mode 100644 index 270bc0d409af68e6953349725b3198f6a42cb6c4..0000000000000000000000000000000000000000 --- a/tests/Zend/Pdf/_fonts/RELEASENOTES.TXT +++ /dev/null @@ -1,162 +0,0 @@ -Bitstream Vera Fonts - April 16, 2003 -===================================== - -The version number of these fonts is 1.10 to distinguish them from the -beta test fonts. - -Note that the Vera copyright is incorporated in the fonts themselves. -The License field in the fonts contains the copyright license as it -appears below. The TrueType copyright field is not large enough to -contain the full license, so the license is incorporated (as you might -think if you thought about it) into the license field, which -unfortunately can be obscure to find. (In pfaedit, see: Element->Font -Info->TTFNames->License). - -Our apologies for it taking longer to complete the fonts than planned. -Beta testers requested a tighter line spacing (less leading) and Jim -Lyles redesigned Vera's accents to bring its line spacing to more -typical of other fonts. This took additional time and effort. Our -thanks to Jim for this effort above and beyond the call of duty. - -There are four monospace and sans faces (normal, oblique, bold, bold -oblique) and two serif faces (normal and bold). Fontconfig/Xft2 (see -www.fontconfig.org) can artificially oblique the serif faces for you: -this loses hinting and distorts the faces slightly, but is visibly -different than normal and bold, and reasonably pleasing. - -On systems with fontconfig 2.0 or 2.1 installed, making your sans, -serif and monospace fonts default to these fonts is very easy. Just -drop the file local.conf into your /etc/fonts directory. This will -make the Bitstream fonts your default fonts for all applications using -fontconfig (if sans, serif, or monospace names are used, as they often -are as default values in many desktops). The XML in local.conf may -need modification to enable subpixel decimation, if appropriate, -however, the commented out phrase does so for XFree86 4.3, in the case -that the server does not have sufficient information to identify the -use of a flat panel. Fontconfig 2.2 adds Vera to the list of font -families and will, by default use it as the default sans, serif and -monospace fonts. - -During the testing of the final Vera fonts, we learned that screen -fonts in general are only typically hinted to work correctly at -integer pixel sizes. Vera is coded internally for integer sizes only. -We need to investigate further to see if there are commonly used fonts -that are hinted to be rounded but are not rounded to integer sizes due -to oversights in their coding. - -Most fonts work best at 8 pixels and below if anti-aliased only, as -the amount of work required to hint well at smaller and smaller sizes -becomes astronomical. GASP tables are typically used to control -whether hinting is used or not, but Freetype/Xft does not currently -support GASP tables (which are present in Vera). - -To mitigate this problem, both for Vera and other fonts, there will be -(very shortly) a new fontconfig 2.2 release that will, by default not -apply hints if the size is below 8 pixels. if you should have a font -that in fact has been hinted more agressively, you can use fontconfig -to note this exception. We believe this should improve many hinted -fonts in addition to Vera, though implemeting GASP support is likely -the right long term solution. - -Font rendering in Gnome or KDE is the combination of algorithms in -Xft2 and Freetype, along with hinting in the fonts themselves. It is -vital to have sufficient information to disentangle problems that you -may observe. - -Note that having your font rendering system set up correctly is vital -to proper judgement of problems of the fonts: - - * Freetype may or may not be configured to in ways that may - implement execution of possibly patented (in some parts of the world) - TrueType hinting algorithms, particularly at small sizes. Best - results are obtained while using these algorithms. - - * The freetype autohinter (used when the possibly patented - algorithms are not used) continues to improve with each release. If - you are using the autohinter, please ensure you are using an up to - date version of freetype before reporting problems. - - * Please identify what version of freetype you are using in any - bug reports, and how your freetype is configured. - - * Make sure you are not using the freetype version included in - XFree86 4.3, as it has bugs that significantly degrade most fonts, - including Vera. if you build XFree86 4.3 from source yourself, you may - have installed this broken version without intending it (as I - did). Vera was verified with the recently released Freetype 2.1.4. On - many systems, 'ldd" can be used to see which freetype shared library - is actually being used. - - * Xft/X Render does not (yet) implement gamma correction. This - causes significant problems rendering white text on a black background - (causing partial pixels to be insufficiently shaded) if the gamma of - your monitor has not been compensated for, and minor problems with - black text on a while background. The program "xgamma" can be used to - set a gamma correction value in the X server's color pallette. Most - monitors have a gamma near 2. - - * Note that the Vera family uses minimal delta hinting. Your - results on other systems when not used anti-aliased may not be - entirely satisfying. We are primarily interested in reports of - problems on open source systems implementing Xft2/fontconfig/freetype - (which implements antialiasing and hinting adjustements, and - sophisticated subpixel decimation on flatpanels). Also, the - algorithms used by Xft2 adjust the hints to integer widths and the - results are crisper on open source systems than on Windows or - MacIntosh. - - * Your fontconfig may (probably does) predate the release of - fontconfig 2.2, and you may see artifacts not present when the font is - used at very small sizes with hinting enabled. "vc-list -V" can be - used to see what version you have installed. - -We believe and hope that these fonts will resolve the problems -reported during beta test. The largest change is the reduction of -leading (interline spacing), which had annoyed a number of people, and -reduced Vera's utility for some applcations. The Vera monospace font -should also now make '0' and 'O' and '1' and 'l' more clearly -distinguishable. - -The version of these fonts is version 1.10. Fontconfig should be -choosing the new version of the fonts if both the released fonts and -beta test fonts are installed (though please discard them: they have -names of form tt20[1-12]gn.ttf). Note that older versions of -fontconfig sometimes did not rebuild their cache correctly when new -fonts are installed: please upgrade to fontconfig 2.2. "fc-cache -f" -can be used to force rebuilding fontconfig's cache files. - -If you note problems, please send them to fonts at gnome dot org, with -exactly which face and size and unicode point you observe the problem -at. The xfd utility from XFree86 CVS may be useful for this (e.g. "xfd --fa sans"). A possibly more useful program to examine fonts at a -variety of sizes is the "waterfall" program found in Keith Packard's -CVS. - - $ cvs -d :pserver:anoncvs@keithp.com:/local/src/CVS login - Logging in to :pserver:anoncvs@keithp.com:2401/local/src/CVS - CVS password: <hit return> - $ cvs -d :pserver:anoncvs@keithp.com:/local/src/CVS co waterfall - $ cd waterfall - $ xmkmf -a - $ make - # make install - # make install.man - -Again, please make sure you are running an up-to-date freetype, and -that you are only examining integer sizes. - -Reporting Problems -================== - -Please send problem reports to fonts at gnome org, with the following -information: - - 1. Version of Freetype, Xft2 and fontconfig - 2. Whether TT hinting is being used, or the autohinter - 3. Application being used - 4. Character/Unicode code point that has problems (if applicable) - 5. Version of which operating system - 6. Please include a screenshot, when possible. - -Please check the fonts list archives before reporting problems to cut -down on duplication. diff --git a/tests/Zend/Pdf/_fonts/Vera.ttf b/tests/Zend/Pdf/_fonts/Vera.ttf deleted file mode 100644 index 58cd6b5e61eff273e920942e28041f8ddcf1e1b5..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/Vera.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraBI.ttf b/tests/Zend/Pdf/_fonts/VeraBI.ttf deleted file mode 100644 index b55eee397ee4c3a502f33a0e6ff708101f59fe9c..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraBI.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraBd.ttf b/tests/Zend/Pdf/_fonts/VeraBd.ttf deleted file mode 100644 index 51d6111d722981a86766cc99c53f1956e5c0a229..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraBd.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraIt.ttf b/tests/Zend/Pdf/_fonts/VeraIt.ttf deleted file mode 100644 index cc23c9efd20503a0d8d9c93a4650a68d50006281..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraIt.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraMoBI.ttf b/tests/Zend/Pdf/_fonts/VeraMoBI.ttf deleted file mode 100644 index 8624542ed208db88b2d1e99bcce1e1acc7e6c28b..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraMoBI.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraMoBd.ttf b/tests/Zend/Pdf/_fonts/VeraMoBd.ttf deleted file mode 100644 index 9be6547ed61cbea68f354fc49651bc3645c822fa..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraMoBd.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraMoIt.ttf b/tests/Zend/Pdf/_fonts/VeraMoIt.ttf deleted file mode 100644 index 24049248569555995b6a4e45d1ec62d87d53bac0..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraMoIt.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraMono.ttf b/tests/Zend/Pdf/_fonts/VeraMono.ttf deleted file mode 100644 index 139f0b4311ad2e0369a347b3be6c46e6c2b730d5..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraMono.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraSe.ttf b/tests/Zend/Pdf/_fonts/VeraSe.ttf deleted file mode 100644 index 4b4ecc66671e45e9dac162aa85dab558cebc191c..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraSe.ttf and /dev/null differ diff --git a/tests/Zend/Pdf/_fonts/VeraSeBd.ttf b/tests/Zend/Pdf/_fonts/VeraSeBd.ttf deleted file mode 100644 index 672bf761fe9ebf408371373f84d7203358766854..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Pdf/_fonts/VeraSeBd.ttf and /dev/null differ diff --git a/tests/Zend/RegistryTest.php b/tests/Zend/RegistryTest.php deleted file mode 100644 index 24684c2d956984becbb0de25667f2a62a3689a45..0000000000000000000000000000000000000000 --- a/tests/Zend/RegistryTest.php +++ /dev/null @@ -1,208 +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_Registry - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RegistryTest.php 9007 2008-03-22 23:19:56Z alexander $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * @see Zend_Registry - */ -require_once 'Zend/Registry.php'; - -/** - * @category Zend - * @package Zend_Registry - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_RegistryTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - Zend_Registry::_unsetInstance(); - } - - public function tearDown() - { - Zend_Registry::_unsetInstance(); - } - - public function testRegistryUninitIsRegistered() - { - // checking entry is set returns false, - // but does not initialize instance - $this->assertFalse(Zend_Registry::isRegistered('objectname')); - } - - public function testRegistryUninitGetInstance() - { - // getting instance initializes instance - $registry = Zend_Registry::getInstance(); - $this->assertType('Zend_Registry', $registry); - } - - public function testRegistryUninitSet() - { - // setting value initializes instance - Zend_Registry::set('foo', 'bar'); - $registry = Zend_Registry::getInstance(); - $this->assertType('Zend_Registry', $registry); - } - - public function testRegistryUninitGet() - { - // getting value initializes instance - // but throws different exception because - // entry is not registered - try { - Zend_Registry::get('foo'); - $this->fail('Expected exception when trying to fetch a non-existent key.'); - } catch (Zend_Exception $e) { - $this->assertContains('No entry is registered for key', $e->getMessage()); - } - $registry = Zend_Registry::getInstance(); - $this->assertType('Zend_Registry', $registry); - } - - public function testRegistrySingletonSameness() - { - $registry1 = Zend_Registry::getInstance(); - $registry2 = Zend_Registry::getInstance(); - $this->assertType('Zend_Registry', $registry1); - $this->assertType('Zend_Registry', $registry2); - $this->assertEquals($registry1, $registry2); - $this->assertSame($registry1, $registry2); - } - - public function testRegistryEqualContents() - { - Zend_Registry::set('foo', 'bar'); - $registry1 = Zend_Registry::getInstance(); - $registry2 = new Zend_Registry(array('foo' => 'bar')); - $this->assertEquals($registry1, $registry2); - $this->assertNotSame($registry1, $registry2); - } - - public function testRegistryUnequalContents() - { - $registry1 = Zend_Registry::getInstance(); - $registry2 = new Zend_Registry(array('foo' => 'bar')); - $this->assertNotEquals($registry1, $registry2); - $this->assertNotSame($registry1, $registry2); - } - - public function testRegistrySetAndIsRegistered() - { - $this->assertFalse(Zend_Registry::isRegistered('foo')); - Zend_Registry::set('foo', 'bar'); - $this->assertTrue(Zend_Registry::isRegistered('foo')); - } - - public function testRegistryGet() - { - Zend_Registry::set('foo', 'bar'); - $bar = Zend_Registry::get('foo'); - $this->assertEquals('bar', $bar); - } - - public function testRegistryArrayObject() - { - $registry = Zend_Registry::getInstance(); - $registry['emptyArray'] = array(); - $registry['null'] = null; - - $this->assertTrue(isset($registry['emptyArray'])); - $this->assertTrue(isset($registry['null'])); - $this->assertFalse(isset($registry['noIndex'])); - - $this->assertTrue(Zend_Registry::isRegistered('emptyArray')); - $this->assertTrue(Zend_Registry::isRegistered('null')); - $this->assertFalse(Zend_Registry::isRegistered('noIndex')); - } - - public function testRegistryArrayAsProps() - { - $registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS); - $registry->foo = 'bar'; - $this->assertTrue(isset($registry->foo)); - $this->assertEquals('bar', $registry->foo); - } - - public function testRegistryExceptionInvalidClassname() - { - try { - $registry = Zend_Registry::setClassName(new StdClass()); - $this->fail('Expected exception, because setClassName() wants a string'); - } catch (Zend_Exception $e) { - $this->assertContains('Argument is not a class name', $e->getMessage()); - } - } - - /** - * NB: We cannot make a unit test for the class not Zend_Registry or - * a subclass, because that is enforced by type-hinting in the - * Zend_Registry::setInstance() method. Type-hinting violations throw - * an error, not an exception, so it cannot be caught in a unit test. - */ - - public function testRegistryExceptionNoEntry() - { - try { - $foo = Zend_Registry::get('foo'); - $this->fail('Expected exception when trying to fetch a non-existent key.'); - } catch (Zend_Exception $e) { - $this->assertContains('No entry is registered for key', $e->getMessage()); - } - } - - public function testRegistryExceptionAlreadyInitialized() - { - $registry = Zend_Registry::getInstance(); - - try { - Zend_Registry::setClassName('anyclass'); - $this->fail('Expected exception, because we cannot initialize the registry if it is already initialized.'); - } catch (Zend_Exception $e) { - $this->assertContains('Registry is already initialized', $e->getMessage()); - } - try { - Zend_Registry::setInstance(new Zend_Registry()); - $this->fail('Expected exception, because we cannot initialize the registry if it is already initialized.'); - } catch (Zend_Exception $e) { - $this->assertContains('Registry is already initialized', $e->getMessage()); - } - } - - public function testRegistryExceptionClassNotFound() - { - try { - $registry = @Zend_Registry::setClassName('classdoesnotexist'); - $this->fail('Expected exception, because we cannot initialize the registry using a non-existent class.'); - } catch (Zend_Exception $e) { - $this->assertRegExp('/file .* does not exist or .*/i', $e->getMessage()); - } - } - -} \ No newline at end of file diff --git a/tests/Zend/Rest/AllTests.php b/tests/Zend/Rest/AllTests.php deleted file mode 100644 index 09090dbb5e8a206e96606dce06f8365910f06269..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/AllTests.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Rest_AllTests::main'); - - set_include_path(dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR - . get_include_path()); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Rest/ServerTest.php'; -require_once 'Zend/Rest/ClientTest.php'; -require_once 'Zend/Rest/ResultTest.php'; - -class Zend_Rest_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Rest'); - - $suite->addTestSuite('Zend_Rest_ServerTest'); - $suite->addTestSuite('Zend_Rest_ClientTest'); - $suite->addTestSuite('Zend_Rest_ResultTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Rest_AllTests::main') { - Zend_Rest_AllTests::main(); -} diff --git a/tests/Zend/Rest/ClientTest.php b/tests/Zend/Rest/ClientTest.php deleted file mode 100644 index 321f23a07362ef42512762ed7657847df1a55cf5..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/ClientTest.php +++ /dev/null @@ -1,268 +0,0 @@ -<?php -/** - * @package Zend_Rest - * @subpackage UnitTests - */ - -/** Zend_Rest_Client */ -require_once 'Zend/Rest/Client.php'; - -/** Zend_Http_Client_Adapter_Test */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** PHPUnit Test Case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Test cases for Zend_Rest_Client - * - * @package Zend_Rest - * @subpackage UnitTests - */ -class Zend_Rest_ClientTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->path = dirname(__FILE__) . '/responses/'; - - $this->adapter = new Zend_Http_Client_Adapter_Test(); - $client = new Zend_Http_Client(null, array( - 'adapter' => $this->adapter - )); - Zend_Rest_Client::setHttpClient($client); - - $this->rest = new Zend_Rest_Client('http://framework.zend.com/'); - } - - public function testUri() - { - $client = new Zend_Rest_Client('http://framework.zend.com/rest/'); - $uri = $client->getUri(); - $this->assertTrue($uri instanceof Zend_Uri_Http); - $this->assertEquals('http://framework.zend.com/rest/', $uri->getUri()); - - $client->setUri(Zend_Uri::factory('http://framework.zend.com/soap/')); - $uri = $client->getUri(); - $this->assertTrue($uri instanceof Zend_Uri_Http); - $this->assertEquals('http://framework.zend.com/soap/', $uri->getUri()); - - $client->setUri('http://framework.zend.com/xmlrpc/'); - $uri = $client->getUri(); - $this->assertTrue($uri instanceof Zend_Uri_Http); - $this->assertEquals('http://framework.zend.com/xmlrpc/', $uri->getUri()); - } - - public function testRestGetThrowsExceptionWithNoUri() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $rest = new Zend_Rest_Client(); - - try { - $response = $rest->restGet('/rest/'); - $this->fail('Should throw exception if no URI in object'); - } catch (Exception $e) { - // success - } - } - - public function testRestFixesPathWithMissingSlashes() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $rest = new Zend_Rest_Client('http://framework.zend.com'); - - $response = $rest->restGet('rest'); - $this->assertTrue($response instanceof Zend_Http_Response); - $this->assertContains($expXml, $response->getBody()); - } - - public function testRestGet() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $response = $this->rest->restGet('/rest/'); - $this->assertTrue($response instanceof Zend_Http_Response); - $this->assertContains($expXml, $response->getBody()); - } - - public function testRestPost() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $reqXml = file_get_contents($this->path . 'returnInt.xml'); - $response = $this->rest->restPost('/rest/', $reqXml); - $this->assertTrue($response instanceof Zend_Http_Response); - $body = $response->getBody(); - $this->assertContains($expXml, $response->getBody()); - - $request = Zend_Rest_Client::getHttpClient()->getLastRequest(); - $this->assertContains($reqXml, $request, $request); - } - - public function testRestPostWithArrayData() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $response = $this->rest->restPost('/rest/', array('foo' => 'bar', 'baz' => 'bat')); - $this->assertTrue($response instanceof Zend_Http_Response); - $body = $response->getBody(); - $this->assertContains($expXml, $response->getBody()); - - $request = Zend_Rest_Client::getHttpClient()->getLastRequest(); - $this->assertContains('foo=bar&baz=bat', $request, $request); - } - - public function testRestPut() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $reqXml = file_get_contents($this->path . 'returnInt.xml'); - $response = $this->rest->restPut('/rest/', $reqXml); - $this->assertTrue($response instanceof Zend_Http_Response); - $body = $response->getBody(); - $this->assertContains($expXml, $response->getBody()); - - $request = Zend_Rest_Client::getHttpClient()->getLastRequest(); - $this->assertContains($reqXml, $request, $request); - } - - public function testRestDelete() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $reqXml = file_get_contents($this->path . 'returnInt.xml'); - $response = $this->rest->restDelete('/rest/'); - $this->assertTrue($response instanceof Zend_Http_Response); - $body = $response->getBody(); - $this->assertContains($expXml, $response->getBody()); - } - - public function testCallWithHttpMethod() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $response = $this->rest->get('/rest/'); - $this->assertTrue($response instanceof Zend_Rest_Client_Result); - $this->assertTrue($response->isSuccess()); - $this->assertEquals('string', $response->response()); - } - - public function testCallAsObjectMethodReturnsClient() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $response = $this->rest->doStuff('why', 'not'); - $this->assertTrue($response instanceof Zend_Rest_Client); - $this->assertSame($this->rest, $response); - } - - public function testCallAsObjectMethodChainPerformsRequest() - { - $expXml = file_get_contents($this->path . 'returnString.xml'); - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/5.2.0\r\n" - . "Content-type: text/xml\r\n" - . "Content-length: " . strlen($expXml) . "\r\n" - . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . $expXml; - $this->adapter->setResponse($response); - - $response = $this->rest->doStuff('why', 'not')->get(); - $this->assertTrue($response instanceof Zend_Rest_Client_Result); - $this->assertEquals('string', $response->response()); - } -} diff --git a/tests/Zend/Rest/ResultTest.php b/tests/Zend/Rest/ResultTest.php deleted file mode 100644 index 9ec59c2a475df455bfe765eb26b6e89c7a00f5a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/ResultTest.php +++ /dev/null @@ -1,165 +0,0 @@ -<?php -/** - * @package Zend_Rest - * @subpackage UnitTests - */ - -/** - * Zend_Rest_Server - */ -require_once 'Zend/Rest/Client/Result.php'; - -/** - * PHPUnit Test Case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Test cases for Zend_Rest_Server - * - * @package Zend_Rest - * @subpackage UnitTests - */ -class Zend_Rest_ResultTest extends PHPUnit_Framework_TestCase -{ - static $path; - - public function __construct() - { - self::$path = dirname(__FILE__).'/responses/'; - } - - public function testResponseSuccess() - { - $xml = file_get_contents(self::$path ."returnString.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertTrue($client->isSuccess()); - } - - public function testResponseIsError() - { - $xml = file_get_contents(self::$path ."returnError.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertTrue($client->isError()); - } - - public function testResponseString() - { - $xml = file_get_contents(self::$path ."returnString.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertEquals("string", $client->__toString()); - } - - public function testResponseInt() - { - $xml = file_get_contents(self::$path ."returnInt.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertEquals("123", $client->__toString()); - } - - public function testResponseArray() - { - $xml = file_get_contents(self::$path ."returnArray.xml"); - // <foo>bar</foo><baz>1</baz><key_1>0</key_1><bat>123</bat> - $client = new Zend_Rest_Client_Result($xml); - foreach ($client as $key => $value) { - $result_array[$key] = (string) $value; - } - $this->assertEquals(array("foo" => "bar", "baz" => "1", "key_1" => "0", "bat" => "123", "status" => "success"), $result_array); - } - - public function testResponseObject() - { - $xml = file_get_contents(self::$path ."returnObject.xml"); - // <foo>bar</foo><baz>1</baz><bat>123</bat><qux>0</qux><status>success</status> - $client = new Zend_Rest_Client_Result($xml); - $this->assertEquals("bar", $client->foo()); - $this->assertEquals(1, $client->baz()); - $this->assertEquals(123, $client->bat()); - $this->assertEquals(0, $client->qux()); - $this->assertEquals("success", $client->status()); - } - - public function testResponseTrue() - { - $xml = file_get_contents(self::$path ."returnTrue.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertTrue((bool)$client->response); - } - - public function testResponseFalse() - { - $xml = file_get_contents(self::$path ."returnFalse.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertFalse((bool) $client->response()); - } - - public function testResponseVoid() - { - $xml = file_get_contents(self::$path . "returnVoid.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertEquals(null, $client->response()); - } - - public function testResponseException() - { - $xml = file_get_contents(self::$path . "returnError.xml"); - $client = new Zend_Rest_Client_Result($xml); - $this->assertTrue($client->isError()); - } - - public function testGetXpathValue() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $key_1 = $result->key_1(); - $this->assertEquals(0, $key_1); - } - - public function testGetXpathValueMissing() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $lola = $result->lola; - $this->assertNull($lola); - } - - public function testGetXpathValueArray() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $baz = $result->baz; - $this->assertTrue(is_array($baz), var_export($baz, 1)); - $this->assertEquals('1', (string) $baz[0]); - $this->assertEquals('farama', (string) $baz[1]); - } - - public function testIsset() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $this->assertTrue(isset($result->bar)); - } - - public function testIssetXpathValue() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $this->assertTrue(isset($result->baz)); - } - - public function testIssetInvalidValue() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $this->assertFalse(isset($result->lola)); - } - - public function testCall() - { - $xml = file_get_contents(self::$path . DIRECTORY_SEPARATOR . 'returnNestedArray.xml'); - $result = new Zend_Rest_Client_Result($xml); - $returned = $result->key_1(); - $this->assertEquals(0, $returned); - } -} diff --git a/tests/Zend/Rest/ServerTest.php b/tests/Zend/Rest/ServerTest.php deleted file mode 100644 index 0824c514953ca3e88c03375c973ed45d43ffb2ce..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/ServerTest.php +++ /dev/null @@ -1,822 +0,0 @@ -<?php -/** - * @package Zend_Rest - * @subpackage UnitTests - */ - -// Call Zend_Rest_ServerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Rest_ServerTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Rest_Server - */ -require_once 'Zend/Rest/Server.php'; - -/** - * Test cases for Zend_Rest_Server - * - * @package Zend_Rest - * @subpackage UnitTests - */ -class Zend_Rest_ServerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Rest_ServerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - if (isset($this->request)) { - $_REQUEST = $this->request; - } else { - $this->request = $_REQUEST; - } - } - - public function testAddFunctionSimple() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc'); - $funcs = $server->getFunctions(); - $this->assertTrue(isset($funcs['Zend_Rest_Server_TestFunc']), "Function not registered."); - } - - public function testSetClass() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - $funcs = $server->getFunctions(); - $this->assertTrue(isset($funcs['testFunc']), "Class Not Registered. testFunc not found"); - $this->assertTrue(isset($funcs['testFunc2']), "Class Not Registered. testFunc2 not found"); - $this->assertTrue(isset($funcs['testFunc3']), "Class Not Registered. testFunc3 not found"); - } - - public function testHandleNamedArgFunction() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc', 'who' => 'Davey')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc generator="zend" version="1.0"><response>Hello Davey</response><status>success</status></Zend_Rest_Server_TestFunc>', $result, "Bad Result"); - } - - public function testHandleFunctionNoArgs() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc2'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc2')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc2 generator="zend" version="1.0"><response>Hello World</response><status>success</status></Zend_Rest_Server_TestFunc2>', $result, "Bad Result"); - } - - public function testHandleFunctionNoArgsRaisesFaultResponse() - { - $server = new Zend_Rest_Server(); - $server->returnResponse(true); - $server->addFunction('Zend_Rest_Server_TestFunc'); - $result = $server->handle(array('method' => 'Zend_Rest_Server_TestFunc')); - $this->assertContains('failed', $result); - } - - public function testHandleFunctionNoArgsUsingRequest() - { - $_REQUEST = array( - 'method' => 'Zend_Rest_Server_TestFunc2' - ); - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc2'); - ob_start(); - $server->handle(); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc2 generator="zend" version="1.0"><response>Hello World</response><status>success</status></Zend_Rest_Server_TestFunc2>', $result, "Bad Result"); - } - - public function testHandleAnonymousArgFunction() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc', 'arg1' => 'Davey')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc generator="zend" version="1.0"><response>Hello Davey</response><status>success</status></Zend_Rest_Server_TestFunc>', $result, "Bad Result"); - } - - public function testHandleMultipleFunction() - { - - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc2'); - $server->addFunction('Zend_Rest_Server_TestFunc'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc2')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc2 generator="zend" version="1.0"><response>Hello World</response><status>success</status></Zend_Rest_Server_TestFunc2>', $result, "Bad Result"); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc', 'arg1' => 'Davey')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc generator="zend" version="1.0"><response>Hello Davey</response><status>success</status></Zend_Rest_Server_TestFunc>', $result, "Bad Result"); - } - - public function testHandleMethodNoArgs() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc><response>Hello World</response><status>success</status></testFunc></Zend_Rest_Server_Test>', $result, 'Bad Result'); - } - - public function testHandleMethodOfClassWithConstructor() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2', '', array('testing args')); - ob_start(); - $server->handle(array('method' => 'test2Func1')); - $result = ob_get_clean(); - $this->assertContains("testing args", $result, "Bad Result"); - } - - public function testHandleAnonymousArgMethod() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc2', 'arg1' => "Davey")); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc2><response>Hello Davey</response><status>success</status></testFunc2></Zend_Rest_Server_Test>', $result, 'Bad Result'); - } - - public function testHandleNamedArgMethod() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc3', 'who' => "Davey", 'when' => 'today')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc3><response>Hello Davey, How are you today</response><status>success</status></testFunc3></Zend_Rest_Server_Test>', $result, 'Bad Result'); - } - - public function testHandleStaticNoArgs() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc4')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc4><response>Hello World</response><status>success</status></testFunc4></Zend_Rest_Server_Test>', $result, var_export($result, 1)); - } - - public function testHandleAnonymousArgStatic() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc5', 'arg1' => "Davey")); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc5><response>Hello Davey</response><status>success</status></testFunc5></Zend_Rest_Server_Test>', $result, 'Bad Result'); - } - - public function testHandleNamedArgStatic() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc6', 'who' => "Davey", 'when' => 'today')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc6><response>Hello Davey, How are you today</response><status>success</status></testFunc6></Zend_Rest_Server_Test>', $result, 'Bad Result'); - } - - public function testHandleMultipleAnonymousArgs() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc9'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc9', 'arg1' => "Hello", 'arg2' => "Davey")); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc9 generator="zend" version="1.0"><response>Hello Davey</response><status>success</status></Zend_Rest_Server_TestFunc9>', $result, "Bad Result"); - } - - public function testHandleReturnFalse() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc3'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc3')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc3 generator="zend" version="1.0"><response>0</response><status>success</status></Zend_Rest_Server_TestFunc3>', $result, 'Bas Response'); - } - - public function testHandleReturnTrue() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc4'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc4')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc4 generator="zend" version="1.0"><response>1</response><status>success</status></Zend_Rest_Server_TestFunc4>', $result, 'Bas Response'); - } - - - public function testHandleReturnInteger() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc5'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc5')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc5 generator="zend" version="1.0"><response>123</response><status>success</status></Zend_Rest_Server_TestFunc5>', $result, 'Bas Response'); - } - - public function testHandleReturnString() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc6'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc6')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc6 generator="zend" version="1.0"><response>string</response><status>success</status></Zend_Rest_Server_TestFunc6>', $result, 'Bas Response'); - } - - public function testHandleReturnArray() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc7'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc7')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc7 generator="zend" version="1.0"><foo>bar</foo><baz>1</baz><key_1>0</key_1><bat>123</bat><status>success</status></Zend_Rest_Server_TestFunc7>', $result, $result); - } - - public function testHandleReturnNestedArray() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc12'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc12')); - $result = ob_get_clean(); - $this->assertContains('Zend_Rest_Server_TestFunc12', $result, $result); - $this->assertContains('<foo><baz>1</baz>', $result, $result); - $this->assertContains('<bat>123</bat></foo><bar>baz</bar>', $result, $result); - $this->assertContains('</bar><status>success</status', $result, $result); - } - - public function testHandleMethodReturnObject() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $server->handle(array('method' => 'test2Struct')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test2', $result, $result); - $this->assertContains('<test2Struct', $result, $result); - $this->assertContains('<foo><baz>1</baz>', $result, $result); - $this->assertContains('<bat>123</bat></foo><bar>baz</bar>', $result, $result); - $this->assertContains('</bar><status>success</status', $result, $result); - } - - public function testHandleReturnObject() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc8'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc8')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc8 generator="zend" version="1.0"><foo>bar</foo><baz>1</baz><bat>123</bat><qux>0</qux><status>success</status></Zend_Rest_Server_TestFunc8>', $result, $result); - } - - public function testHandleReturnSimpleXml() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $server->handle(array('method' => 'test2Xml')); - $result = ob_get_clean(); - $this->assertContains("<foo>bar</foo>", $result, "Bad Result"); - } - - public function testHandleReturnDomDocument() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $server->handle(array('method' => 'test2DomDocument')); - $result = ob_get_clean(); - $this->assertContains("<foo>bar</foo>", $result, "Bad Result"); - } - - public function testHandleReturnDomElement() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $server->handle(array('method' => 'test2DomElement')); - $result = ob_get_clean(); - $this->assertContains("<foo>bar</foo>", $result, "Bad Result"); - } - - public function testHandleInvalidMethod() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - $server->returnResponse(true); - $response = $server->handle(array('method' => 'test3DomElement')); - $this->assertContains('<status>failed</status>', $response); - } - - public function testFault() - { - $e = new Exception('testing fault'); - $server = new Zend_Rest_Server(); - $fault = $server->fault($e); - $this->assertTrue($fault instanceof DOMDocument); - $sx = simplexml_import_dom($fault); - $this->assertTrue(isset($sx->response)); - $this->assertTrue(isset($sx->response->message)); - $this->assertContains('testing fault', (string) $sx->response->message); - } - - public function testFaultWithoutException() - { - $server = new Zend_Rest_Server(); - $fault = $server->fault('testing fault'); - $this->assertTrue($fault instanceof DOMDocument); - $sx = simplexml_import_dom($fault); - $this->assertTrue(isset($sx->response)); - $this->assertTrue(isset($sx->response->message)); - $this->assertContains('An unknown error occured. Please try again.', (string) $sx->response->message); - } - - public function testHandleException() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc11'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc11')); - $result = ob_get_clean(); - $this->assertContains("<Zend_Rest_Server_TestFunc11", $result); - $this->assertContains("<message>testing rest server faults</message>", $result); - } - - public function testHandleClassMethodException() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $server->handle(array('method' => 'test2ThrowException')); - $result = ob_get_clean(); - $this->assertContains("<Zend_Rest_Server_Test2", $result); - $this->assertContains("<test2ThrowException>", $result); - $this->assertContains("<message>testing class method exception</message>", $result); - } - - public function testHandleVoid() - { - $server = new Zend_Rest_Server(); - $server->addFunction('Zend_Rest_Server_TestFunc10'); - ob_start(); - $server->handle(array('method' => 'Zend_Rest_Server_TestFunc10')); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_TestFunc10 generator="zend" version="1.0"><response/><status>success</status></Zend_Rest_Server_TestFunc10>', $result, $result); - } - - public function testGetHeaders() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $server->handle(array('method' => 'test2ThrowException')); - $result = ob_get_clean(); - $headers = $server->getHeaders(); - $this->assertContains('HTTP/1.0 400 Bad Request', $headers); - } - - public function testReturnResponse() - { - $server = new Zend_Rest_Server(); - $this->assertFalse($server->returnResponse()); - $server->returnResponse(true); - $this->assertTrue($server->returnResponse()); - } - - public function testReturnResponseForcesHandleToReturnResponse() - { - $server = new Zend_Rest_Server(); - $server->returnResponse(true); - $server->setClass('Zend_Rest_Server_Test2'); - ob_start(); - $response = $server->handle(array('method' => 'test2Xml')); - $result = ob_get_clean(); - $this->assertTrue(empty($result)); - $this->assertContains('<foo>bar</foo>', $response); - } - - public function testGeneratedXmlEncodesScalarAmpersands() - { - $server = new Zend_Rest_Server(); - $server->returnResponse(true); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $response = $server->handle(array('method' => 'testScalarEncoding')); - $result = ob_get_clean(); - $this->assertTrue(empty($result)); - $this->assertContains('This string has chars & ampersands', $response); - } - - public function testGeneratedXmlEncodesStructAmpersands() - { - $server = new Zend_Rest_Server(); - $server->returnResponse(true); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $response = $server->handle(array('method' => 'testStructEncoding')); - $result = ob_get_clean(); - $this->assertTrue(empty($result)); - $this->assertContains('bar & baz', $response); - } - - public function testGeneratedXmlEncodesFaultAmpersands() - { - $server = new Zend_Rest_Server(); - $server->returnResponse(true); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $response = $server->handle(array('method' => 'testExceptionsEncoding')); - $result = ob_get_clean(); - $this->assertTrue(empty($result)); - $this->assertContains('testing class method exception & encoding', $response); - } - - /** - * @see ZF-1992 - */ - public function testDefaultEncodingShouldBeUtf8() - { - $server = new Zend_Rest_Server(); - $this->assertEquals('UTF-8', $server->getEncoding()); - } - - /** - * @see ZF-1992 - */ - public function testEncodingShouldBeMutableViaAccessors() - { - $server = new Zend_Rest_Server(); - $this->assertEquals('UTF-8', $server->getEncoding()); - $server->setEncoding('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $server->getEncoding()); - } - - /** - * @see ZF-2279 - */ - public function testNamesOfArgumentsShouldDetermineArgumentOrder() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc6', 'arg2' => 'today', 'arg1' => "Davey")); - $result = ob_get_clean(); - $this->assertContains('<Zend_Rest_Server_Test generator="zend" version="1.0"><testFunc6><response>Hello Davey, How are you today</response><status>success</status></testFunc6></Zend_Rest_Server_Test>', $result, var_export($result, 1)); - } - - /** - * @see ZF-1949 - */ - public function testMissingArgumentsShouldResultInFaultResponse() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc6', 'arg1' => "Davey")); - $result = ob_get_clean(); - $this->assertRegexp('#<message>Invalid Method Call to(.*?)(Requires).*?(given).*?(</message>)#', $result); - $this->assertContains('<status>failed</status>', $result); - } - - /** - * @see ZF-1949 - */ - public function testMissingArgumentsWithDefaultsShouldNotResultInFaultResponse() - { - $server = new Zend_Rest_Server(); - $server->setClass('Zend_Rest_Server_Test'); - ob_start(); - $server->handle(array('method' => 'testFunc7', 'arg1' => "Davey")); - $result = ob_get_clean(); - $this->assertContains('<status>success</status>', $result, var_export($result, 1)); - $this->assertContains('<response>Hello today, How are you Davey</response>', $result, var_export($result, 1)); - } -} - -/* Test Functions */ - -/** - * Test Function - * - * @param string $arg - * @return string - */ -function Zend_Rest_Server_TestFunc($who) -{ - return "Hello $who"; -} - -/** - * Test Function 2 - */ -function Zend_Rest_Server_TestFunc2() -{ - return "Hello World"; -} - -/** - * Return false - * - * @return bool - */ -function Zend_Rest_Server_TestFunc3() -{ - return false; -} - -/** - * Return true - * - * @return bool - */ -function Zend_Rest_Server_TestFunc4() -{ - return true; -} - -/** - * Return integer - * - * @return int - */ -function Zend_Rest_Server_TestFunc5() -{ - return 123; -} - -/** - * Return string - * - * @return string - */ -function Zend_Rest_Server_TestFunc6() -{ - return "string"; -} - -/** - * Return array - * - * @return array - */ -function Zend_Rest_Server_TestFunc7() -{ - return array('foo' => 'bar', 'baz' => true, 1 => false, 'bat' => 123); -} - -/** - * Return Object - * - * @return StdClass - */ -function Zend_Rest_Server_TestFunc8() -{ - $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false); - return $return; -} - -/** - * Multiple Args - * - * @param string $foo - * @param string $bar - * @return string - */ -function Zend_Rest_Server_TestFunc9($foo, $bar) -{ - return "$foo $bar"; -} - -/** - * Void arguments - * - * @return void - */ -function Zend_Rest_Server_TestFunc10() -{ - // returns nothing -} - -/** - * throws exception - * - * @return void - * @throws Exception - */ -function Zend_Rest_Server_TestFunc11() -{ - throw new Exception('testing rest server faults'); -} - -/** - * Return nested array - * - * @return struct - */ -function Zend_Rest_Server_TestFunc12() -{ - return array('foo' => array('baz' => true, 1 => false, 'bat' => 123), 'bar' => 'baz'); -} - - -/** - * Test Class - */ -class Zend_Rest_Server_Test -{ - /** - * Test Function - */ - public function testFunc() - { - return "Hello World"; - } - - /** - * Test Function 2 - * - * @param string $who Some Arg - */ - public function testFunc2($who) - { - return "Hello $who"; - } - - /** - * Test Function 3 - * - * @param string $who Some Arg - * @param int $when Some Arg2 - */ - public function testFunc3($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 4 - */ - public static function testFunc4() - { - return "Hello World"; - } - - /** - * Test Function 5 - * - * @param string $who Some Arg - */ - public static function testFunc5($who) - { - return "Hello $who"; - } - - /** - * Test Function 6 - * - * @param string $who Some Arg - * @param int $when Some Arg2 - */ - public static function testFunc6($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 7 - * - * @param string $who Some Arg - * @param int $when Some Arg2 - */ - public static function testFunc7($who, $when = 'today') - { - return "Hello $who, How are you $when"; - } - - /** - * Test scalar encoding - * - * @return string - */ - public function testScalarEncoding() - { - return 'This string has chars & ampersands'; - } - - /** - * Test structs encode correctly - * - * @return struct - */ - public function testStructEncoding() - { - return array( - 'foo' => 'bar & baz' - ); - } - - /** - * Test exceptions encode correctly - * - * @return void - */ - public function testExceptionsEncoding() - { - throw new Exception('testing class method exception & encoding'); - } -} - -class Zend_Rest_Server_Test2 -{ - public function __construct($arg1 = 'unset') - { - $this->arg1 = $arg1; - } - - public function test2Func1() - { - return $this->arg1; - } - - public function test2Xml() - { - $sx = new SimpleXMLElement('<root><foo>bar</foo></root>'); - return $sx; - } - - public function test2DomDocument() - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $root = $dom->createElement('root'); - $dom->appendChild($root); - - $foo = $dom->createElement('foo', 'bar'); - $root->appendChild($foo); - - return $dom; - } - - public function test2DomElement() - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $root = $dom->createElement('root'); - $dom->appendChild($root); - - $foo = $dom->createElement('foo', 'bar'); - $root->appendChild($foo); - - return $foo; - } - - public function test2ThrowException() - { - throw new Exception('testing class method exception'); - } - - public function test2Struct() - { - $o = new stdClass(); - $o->foo = array('baz' => true, 1 => false, 'bat' => 123); - $o->bar = 'baz'; - - return $o; - } -} - -class Zend_Rest_TestException extends Exception { } - -// Call Zend_Rest_ServerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Rest_ServerTest::main") { - Zend_Rest_ServerTest::main(); -} diff --git a/tests/Zend/Rest/responses/returnArray.xml b/tests/Zend/Rest/responses/returnArray.xml deleted file mode 100644 index 2d9e1a4663b4bd90f5c26830f53f4eb8f1e2839c..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnArray.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc7 generator='zend'><foo>bar</foo><baz>1</baz><key_1>0</key_1><bat>123</bat><status>success</status></Zend_Rest_Server_TestFunc7> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnError.xml b/tests/Zend/Rest/responses/returnError.xml deleted file mode 100644 index c95b71187ff6237d3005c4538ed908f5aa8330a2..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnError.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc10 generator='zend' version='1.0'><response><message>An error occurred.</message></response><status>failed</status></Zend_Rest_Server_TestFunc10> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnFalse.xml b/tests/Zend/Rest/responses/returnFalse.xml deleted file mode 100644 index bb66cd8c691e43e468743bd1143feed837c5dcd4..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnFalse.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc3 generator='zend' version='1.0'><response>0</response><status>success</status></Zend_Rest_Server_TestFunc3> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnInt.xml b/tests/Zend/Rest/responses/returnInt.xml deleted file mode 100644 index 62bfd93619ad4f603ce2be63fadf5325c7ecb8a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnInt.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc5 generator='zend' version='1.0'><response>123</response><status>success</status></Zend_Rest_Server_TestFunc5> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnNestedArray.xml b/tests/Zend/Rest/responses/returnNestedArray.xml deleted file mode 100644 index 39bee5d6f9fa2061a92f98e953c726d97365d5d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnNestedArray.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc7 generator='zend'><foo><baz>1</baz><key_1>0</key_1><bat><baz>farama</baz></bat></foo><bar>baz</bar><status>success</status></Zend_Rest_Server_TestFunc7> diff --git a/tests/Zend/Rest/responses/returnObject.xml b/tests/Zend/Rest/responses/returnObject.xml deleted file mode 100644 index 01d2acff3c23882c19129f574db24f5b48035903..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnObject.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc8 generator='zend'><foo>bar</foo><baz>1</baz><bat>123</bat><qux>0</qux><status>success</status></Zend_Rest_Server_TestFunc8> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnString.xml b/tests/Zend/Rest/responses/returnString.xml deleted file mode 100644 index fb7127b0d33a45138e872764ad3d6ad429788211..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnString.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc6 generator='zend' version='1.0'><response>string</response><status>success</status></Zend_Rest_Server_TestFunc6> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnTrue.xml b/tests/Zend/Rest/responses/returnTrue.xml deleted file mode 100644 index 43c5763b82660eced49addba9295210a02dd0614..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnTrue.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc4 generator='zend' version='1.0'><response>1</response><status>success</status></Zend_Rest_Server_TestFunc4> \ No newline at end of file diff --git a/tests/Zend/Rest/responses/returnVoid.xml b/tests/Zend/Rest/responses/returnVoid.xml deleted file mode 100644 index 37a8fca1dc7110f96fe597946d0ed9d59d6986bd..0000000000000000000000000000000000000000 --- a/tests/Zend/Rest/responses/returnVoid.xml +++ /dev/null @@ -1 +0,0 @@ -<Zend_Rest_Server_TestFunc10 generator='zend' version='1.0'><response /><status>success</status></Zend_Rest_Server_TestFunc10> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/AllTests.php b/tests/Zend/Search/Lucene/AllTests.php deleted file mode 100644 index ac3ce12c8aeb31216f9ab284339a18c31efd141b..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/AllTests.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Search_Lucene_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Search/Lucene/LuceneTest.php'; - -require_once 'Zend/Search/Lucene/DocumentTest.php'; -require_once 'Zend/Search/Lucene/FSMTest.php'; -require_once 'Zend/Search/Lucene/FieldTest.php'; -require_once 'Zend/Search/Lucene/PriorityQueueTest.php'; - -require_once 'Zend/Search/Lucene/AnalysisTest.php'; - -require_once 'Zend/Search/Lucene/Index/DictionaryLoaderTest.php'; -require_once 'Zend/Search/Lucene/Index/FieldInfoTest.php'; -require_once 'Zend/Search/Lucene/Index/SegmentInfoPriorityQueueTest.php'; -require_once 'Zend/Search/Lucene/Index/SegmentInfoTest.php'; -require_once 'Zend/Search/Lucene/Index/SegmentMergerTest.php'; -require_once 'Zend/Search/Lucene/Index/TermInfoTest.php'; -require_once 'Zend/Search/Lucene/Index/TermTest.php'; - -require_once 'Zend/Search/Lucene/Storage/DirectoryTest.php'; -require_once 'Zend/Search/Lucene/Storage/FileTest.php'; - -require_once 'Zend/Search/Lucene/SearchTest.php'; -require_once 'Zend/Search/Lucene/Search23Test.php'; - - -class Zend_Search_Lucene_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Search_Lucene'); - - $suite->addTestSuite('Zend_Search_Lucene_LuceneTest'); - - $suite->addTestSuite('Zend_Search_Lucene_DocumentTest'); - $suite->addTestSuite('Zend_Search_Lucene_FSMTest'); - $suite->addTestSuite('Zend_Search_Lucene_FieldTest'); - $suite->addTestSuite('Zend_Search_Lucene_PriorityQueueTest'); - - $suite->addTestSuite('Zend_Search_Lucene_AnalysisTest'); - - $suite->addTestSuite('Zend_Search_Lucene_Index_DictionaryLoaderTest'); - $suite->addTestSuite('Zend_Search_Lucene_Index_FieldInfoTest'); - $suite->addTestSuite('Zend_Search_Lucene_Index_SegmentInfoPriorityQueueTest'); - $suite->addTestSuite('Zend_Search_Lucene_Index_SegmentInfoTest'); - $suite->addTestSuite('Zend_Search_Lucene_Index_SegmentMergerTest'); - $suite->addTestSuite('Zend_Search_Lucene_Index_TermInfoTest'); - $suite->addTestSuite('Zend_Search_Lucene_Index_TermTest'); - /** - * SegmentWriter class, its subclasses and Writer class are completely tested within - * Lucene::addDocument and Lucene::optimize testing - */ - - $suite->addTestSuite('Zend_Search_Lucene_Storage_DirectoryTest'); - $suite->addTestSuite('Zend_Search_Lucene_Storage_FileTest'); - - $suite->addTestSuite('Zend_Search_Lucene_SearchTest'); - $suite->addTestSuite('Zend_Search_Lucene_Search23Test'); - - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Search_Lucene_AllTests::main') { - Zend_Search_Lucene_AllTests::main(); -} diff --git a/tests/Zend/Search/Lucene/AnalysisTest.php b/tests/Zend/Search/Lucene/AnalysisTest.php deleted file mode 100644 index cb7d2944433c9bb8cb821ddbd652c7abfb5b65f1..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/AnalysisTest.php +++ /dev/null @@ -1,327 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene - */ -require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_AnalysisTest extends PHPUnit_Framework_TestCase -{ - public function testAnalyzer() - { - $currentAnalyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault(); - $this->assertTrue($currentAnalyzer instanceof Zend_Search_Lucene_Analysis_Analyzer); - - $newAnalyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num(); - Zend_Search_Lucene_Analysis_Analyzer::setDefault($newAnalyzer); - $this->assertTrue(Zend_Search_Lucene_Analysis_Analyzer::getDefault() === $newAnalyzer); - - // Set analyzer to the default value (used in other tests) - Zend_Search_Lucene_Analysis_Analyzer::setDefault($currentAnalyzer); - } - - public function testText() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text(); - - $tokenList = $analyzer->tokenize('Word1 Word2 anotherWord'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Word'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 4); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Word'); - $this->assertEquals($tokenList[1]->getStartOffset(), 6); - $this->assertEquals($tokenList[1]->getEndOffset(), 10); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'anotherWord'); - $this->assertEquals($tokenList[2]->getStartOffset(), 12); - $this->assertEquals($tokenList[2]->getEndOffset(), 23); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testTextCaseInsensitive() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive(); - - $tokenList = $analyzer->tokenize('Word1 Word2 anotherWord'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'word'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 4); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'word'); - $this->assertEquals($tokenList[1]->getStartOffset(), 6); - $this->assertEquals($tokenList[1]->getEndOffset(), 10); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'anotherword'); - $this->assertEquals($tokenList[2]->getStartOffset(), 12); - $this->assertEquals($tokenList[2]->getEndOffset(), 23); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testTextNum() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum(); - - $tokenList = $analyzer->tokenize('Word1 Word2 anotherWord'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Word1'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 5); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Word2'); - $this->assertEquals($tokenList[1]->getStartOffset(), 6); - $this->assertEquals($tokenList[1]->getEndOffset(), 11); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'anotherWord'); - $this->assertEquals($tokenList[2]->getStartOffset(), 12); - $this->assertEquals($tokenList[2]->getEndOffset(), 23); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testTextNumCaseInsensitive() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive(); - - $tokenList = $analyzer->tokenize('Word1 Word2 anotherWord'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'word1'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 5); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'word2'); - $this->assertEquals($tokenList[1]->getStartOffset(), 6); - $this->assertEquals($tokenList[1]->getEndOffset(), 11); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'anotherword'); - $this->assertEquals($tokenList[2]->getStartOffset(), 12); - $this->assertEquals($tokenList[2]->getEndOffset(), 23); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testUtf8() - { - if (@preg_match('/\pL/u', 'a') != 1) { - // PCRE unicode support is turned off - return; - } - - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8(); - - // UTF-8 text with a cyrillic symbols - $tokenList = $analyzer->tokenize('Слово1 Слово2 ДругоеСлово', 'UTF-8'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Слово'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 5); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Слово'); - $this->assertEquals($tokenList[1]->getStartOffset(), 7); - $this->assertEquals($tokenList[1]->getEndOffset(), 12); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'ДругоеСлово'); - $this->assertEquals($tokenList[2]->getStartOffset(), 14); - $this->assertEquals($tokenList[2]->getEndOffset(), 25); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testUtf8Num() - { - if (@preg_match('/\pL/u', 'a') != 1) { - // PCRE unicode support is turned off - return; - } - - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num(); - - // UTF-8 text with a cyrillic symbols - $tokenList = $analyzer->tokenize('Слово1 Слово2 ДругоеСлово', 'UTF-8'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Слово1'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 6); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Слово2'); - $this->assertEquals($tokenList[1]->getStartOffset(), 7); - $this->assertEquals($tokenList[1]->getEndOffset(), 13); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'ДругоеСлово'); - $this->assertEquals($tokenList[2]->getStartOffset(), 14); - $this->assertEquals($tokenList[2]->getEndOffset(), 25); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testUtf8CaseInsensitive() - { - if (@preg_match('/\pL/u', 'a') != 1) { - // PCRE unicode support is turned off - return; - } - if (!function_exists('mb_strtolower')) { - // mbstring extension is disabled - return; - } - - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive(); - - // UTF-8 text with a cyrillic symbols - $tokenList = $analyzer->tokenize('Слово1 Слово2 ДругоеСлово', 'UTF-8'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Ñлово'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 5); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Ñлово'); - $this->assertEquals($tokenList[1]->getStartOffset(), 7); - $this->assertEquals($tokenList[1]->getEndOffset(), 12); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'другоеÑлово'); - $this->assertEquals($tokenList[2]->getStartOffset(), 14); - $this->assertEquals($tokenList[2]->getEndOffset(), 25); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testUtf8NumCaseInsensitive() - { - if (@preg_match('/\pL/u', 'a') != 1) { - // PCRE unicode support is turned off - return; - } - if (!function_exists('mb_strtolower')) { - // mbstring extension is disabled - return; - } - - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive(); - - // UTF-8 text with a cyrillic symbols - $tokenList = $analyzer->tokenize('Слово1 Слово2 ДругоеСлово', 'UTF-8'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Ñлово1'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 6); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Ñлово2'); - $this->assertEquals($tokenList[1]->getStartOffset(), 7); - $this->assertEquals($tokenList[1]->getEndOffset(), 13); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'другоеÑлово'); - $this->assertEquals($tokenList[2]->getStartOffset(), 14); - $this->assertEquals($tokenList[2]->getEndOffset(), 25); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testEncoding() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8(); - - // UTF-8 text with a cyrillic symbols - $tokenList = $analyzer->tokenize(iconv('UTF-8', 'Windows-1251', 'Слово1 Слово2 ДругоеСлово'), 'Windows-1251'); - - $this->assertEquals(count($tokenList), 3); - - $this->assertEquals($tokenList[0]->getTermText(), 'Слово'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 5); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'Слово'); - $this->assertEquals($tokenList[1]->getStartOffset(), 7); - $this->assertEquals($tokenList[1]->getEndOffset(), 12); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[2]->getTermText(), 'ДругоеСлово'); - $this->assertEquals($tokenList[2]->getStartOffset(), 14); - $this->assertEquals($tokenList[2]->getEndOffset(), 25); - $this->assertEquals($tokenList[2]->getPositionIncrement(), 1); - } - - public function testStopWords() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive(); - $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords(array('word', 'and', 'or')); - - $analyzer->addFilter($stopWordsFilter); - - $tokenList = $analyzer->tokenize('Word1 Word2 anotherWord'); - - $this->assertEquals(count($tokenList), 1); - - $this->assertEquals($tokenList[0]->getTermText(), 'anotherword'); - $this->assertEquals($tokenList[0]->getStartOffset(), 12); - $this->assertEquals($tokenList[0]->getEndOffset(), 23); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - } - - public function testShortWords() - { - $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive(); - $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(4 /* Minimal length */); - - $analyzer->addFilter($stopWordsFilter); - - $tokenList = $analyzer->tokenize('Word1 and anotherWord'); - - $this->assertEquals(count($tokenList), 2); - - $this->assertEquals($tokenList[0]->getTermText(), 'word'); - $this->assertEquals($tokenList[0]->getStartOffset(), 0); - $this->assertEquals($tokenList[0]->getEndOffset(), 4); - $this->assertEquals($tokenList[0]->getPositionIncrement(), 1); - - $this->assertEquals($tokenList[1]->getTermText(), 'anotherword'); - $this->assertEquals($tokenList[1]->getStartOffset(), 10); - $this->assertEquals($tokenList[1]->getEndOffset(), 21); - $this->assertEquals($tokenList[1]->getPositionIncrement(), 1); - } -} diff --git a/tests/Zend/Search/Lucene/DocumentTest.php b/tests/Zend/Search/Lucene/DocumentTest.php deleted file mode 100644 index 129bc76f1ceb772a28e64bb847b75df45ef85860..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/DocumentTest.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Document - */ -require_once 'Zend/Search/Lucene/Document.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_DocumentTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $document = new Zend_Search_Lucene_Document(); - - $this->assertEquals($document->boost, 1); - } - - public function testFields() - { - $document = new Zend_Search_Lucene_Document(); - - $document->addField(Zend_Search_Lucene_Field::Text('title', 'Title')); - $document->addField(Zend_Search_Lucene_Field::Text('annotation', 'Annotation')); - $document->addField(Zend_Search_Lucene_Field::Text('body', 'Document body, document body, document body...')); - - $fieldnamesDiffArray = array_diff($document->getFieldNames(), array('title', 'annotation', 'body')); - $this->assertTrue(is_array($fieldnamesDiffArray)); - $this->assertEquals(count($fieldnamesDiffArray), 0); - - $this->assertEquals($document->title, 'Title'); - $this->assertEquals($document->annotation, 'Annotation'); - $this->assertEquals($document->body, 'Document body, document body, document body...'); - - $this->assertEquals($document->getField('title')->value, 'Title'); - $this->assertEquals($document->getField('annotation')->value, 'Annotation'); - $this->assertEquals($document->getField('body')->value, 'Document body, document body, document body...'); - - $this->assertEquals($document->getFieldValue('title'), 'Title'); - $this->assertEquals($document->getFieldValue('annotation'), 'Annotation'); - $this->assertEquals($document->getFieldValue('body'), 'Document body, document body, document body...'); - - - $wordsWithUmlautsIso88591 = iconv('UTF-8', 'ISO-8859-1', 'Words with umlauts: åãü...'); - $document->addField(Zend_Search_Lucene_Field::Text('description', $wordsWithUmlautsIso88591, 'ISO-8859-1')); - $this->assertEquals($document->description, $wordsWithUmlautsIso88591); - $this->assertEquals($document->getFieldUtf8Value('description'), 'Words with umlauts: åãü...'); - } - - public function testAddFieldMethodChaining() - { - $document = new Zend_Search_Lucene_Document(); - $this->assertTrue($document->addField(Zend_Search_Lucene_Field::Text('title', 'Title')) instanceof Zend_Search_Lucene_Document); - - $document = new Zend_Search_Lucene_Document(); - $document->addField(Zend_Search_Lucene_Field::Text('title', 'Title')) - ->addField(Zend_Search_Lucene_Field::Text('annotation', 'Annotation')) - ->addField(Zend_Search_Lucene_Field::Text('body', 'Document body, document body, document body...')); - } - - public function testHtml() - { - $doc = Zend_Search_Lucene_Document_Html::loadHTML('<HTML><HEAD><TITLE>Page title</TITLE></HEAD><BODY>Document body.</BODY></HTML>'); - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document_Html); - - $doc->highlight('document', '#66ffff'); - $this->assertTrue(strpos($doc->getHTML(), "<b style=\"color:black;background-color:#66ffff\">Document</b> body.") !== false); - - $doc = Zend_Search_Lucene_Document_Html::loadHTMLFile(dirname(__FILE__) . '/_indexSource/_files/contributing.documentation.html', true); - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document_Html); - - $this->assertTrue(array_values($doc->getHeaderLinks()) == - array('index.html', 'contributing.html', 'contributing.bugs.html', 'contributing.wishlist.html')); - $this->assertTrue(array_values($doc->getLinks()) == - array('contributing.bugs.html', - 'contributing.wishlist.html', - 'developers.documentation.html', - 'faq.translators-revision-tracking.html', - 'index.html', - 'contributing.html')); - } - - public function testHtmlNoFollowLinks() - { - $html = '<HTML>' - . '<HEAD><TITLE>Page title</TITLE></HEAD>' - . '<BODY>' - . 'Document body.' - . '<a href="link1.html">Link 1</a>.' - . '<a href="link2.html" rel="nofollow">Link 1</a>.' - . '</BODY>' - . '</HTML>'; - - $oldNoFollowValue = Zend_Search_Lucene_Document_Html::getExcludeNoFollowLinks(); - - Zend_Search_Lucene_Document_Html::setExcludeNoFollowLinks(false); - $doc1 = Zend_Search_Lucene_Document_Html::loadHTML($html); - $this->assertTrue($doc1 instanceof Zend_Search_Lucene_Document_Html); - $this->assertTrue(array_values($doc1->getLinks()) == array('link1.html', 'link2.html')); - - Zend_Search_Lucene_Document_Html::setExcludeNoFollowLinks(true); - $doc2 = Zend_Search_Lucene_Document_Html::loadHTML($html); - $this->assertTrue($doc2 instanceof Zend_Search_Lucene_Document_Html); - $this->assertTrue(array_values($doc2->getLinks()) == array('link1.html')); - } -} - diff --git a/tests/Zend/Search/Lucene/FSMTest.php b/tests/Zend/Search/Lucene/FSMTest.php deleted file mode 100644 index 0632c120e9f626a55cf8999c2abc44a7ac782661..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/FSMTest.php +++ /dev/null @@ -1,182 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_FSM - */ -require_once 'Zend/Search/Lucene/FSM.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - - -class Zend_Search_Lucene_FSM_testClass -{ - public $action1Passed = false; - public $action2Passed = false; - public $action3Passed = false; - public $action4Passed = false; - public $action5Passed = false; - public $action6Passed = false; - public $action7Passed = false; - public $action8Passed = false; - - public function action1() { $this->action1Passed = true; } - public function action2() { $this->action2Passed = true; } - public function action3() { $this->action3Passed = true; } - public function action4() { $this->action4Passed = true; } - public function action5() { $this->action5Passed = true; } - public function action6() { $this->action6Passed = true; } - public function action7() { $this->action7Passed = true; } - public function action8() { $this->action8Passed = true; } -} - -class Zend_Search_Lucene_FSM_testFSMClass extends Zend_Search_Lucene_FSM -{ - const OPENED = 0; - const CLOSED = 1; - const CLOSED_AND_LOCKED = 2; - - const OPENED_AND_LOCKED = 3; // Wrong state, should not be used - - - const OPEN = 0; - const CLOSE = 1; - const LOCK = 3; - const UNLOCK = 4; - - /** - * Object to trace FSM actions - * - * @var Zend_Search_Lucene_FSM_testClass - */ - public $actionTracer; - - public function __construct() - { - $this->actionTracer = new Zend_Search_Lucene_FSM_testClass(); - - $this->addStates(array(self::OPENED, self::CLOSED, self::CLOSED_AND_LOCKED)); - $this->addInputSymbols(array(self::OPEN, self::CLOSE, self::LOCK, self::UNLOCK)); - - $unlockAction = new Zend_Search_Lucene_FSMAction($this->actionTracer, 'action4'); - $openAction = new Zend_Search_Lucene_FSMAction($this->actionTracer, 'action6'); - $closeEntryAction = new Zend_Search_Lucene_FSMAction($this->actionTracer, 'action2'); - $closeExitAction = new Zend_Search_Lucene_FSMAction($this->actionTracer, 'action8'); - - $this->addRules(array( array(self::OPENED, self::CLOSE, self::CLOSED), - array(self::CLOSED, self::OPEN, self::OPEN), - array(self::CLOSED, self::LOCK, self::CLOSED_AND_LOCKED), - array(self::CLOSED_AND_LOCKED, self::UNLOCK, self::CLOSED, $unlockAction), - )); - - $this->addInputAction(self::CLOSED_AND_LOCKED, self::UNLOCK, $unlockAction); - - $this->addTransitionAction(self::CLOSED, self::OPENED, $openAction); - - $this->addEntryAction(self::CLOSED, $closeEntryAction); - - $this->addExitAction(self::CLOSED, $closeExitAction); - } -} - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_FSMTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $doorFSM = new Zend_Search_Lucene_FSM_testFSMClass(); - - $this->assertTrue($doorFSM instanceof Zend_Search_Lucene_FSM); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::OPENED); - } - - public function testSetState() - { - $doorFSM = new Zend_Search_Lucene_FSM_testFSMClass(); - - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::OPENED); - - $doorFSM->setState(Zend_Search_Lucene_FSM_testFSMClass::CLOSED_AND_LOCKED); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::CLOSED_AND_LOCKED ); - - $wrongStateExceptionCatched = false; - try { - $doorFSM->setState(Zend_Search_Lucene_FSM_testFSMClass::OPENED_AND_LOCKED); - } catch(Zend_Search_Exception $e) { - $wrongStateExceptionCatched = true; - } - $this->assertTrue($wrongStateExceptionCatched); - } - - public function testReset() - { - $doorFSM = new Zend_Search_Lucene_FSM_testFSMClass(); - - $doorFSM->setState(Zend_Search_Lucene_FSM_testFSMClass::CLOSED_AND_LOCKED); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::CLOSED_AND_LOCKED); - - $doorFSM->reset(); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::OPENED); - } - - public function testProcess() - { - $doorFSM = new Zend_Search_Lucene_FSM_testFSMClass(); - - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::CLOSE); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::CLOSED); - - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::LOCK); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::CLOSED_AND_LOCKED); - - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::UNLOCK); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::CLOSED); - - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::OPEN); - $this->assertEquals($doorFSM->getState(), Zend_Search_Lucene_FSM_testFSMClass::OPENED); - - $wrongInputExceptionCatched = false; - try { - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::LOCK); - } catch(Zend_Search_Exception $e) { - $wrongInputExceptionCatched = true; - } - $this->assertTrue($wrongInputExceptionCatched); - } - - public function testActions() - { - $doorFSM = new Zend_Search_Lucene_FSM_testFSMClass(); - - $this->assertFalse($doorFSM->actionTracer->action2Passed /* 'closed' state entry action*/); - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::CLOSE); - $this->assertTrue($doorFSM->actionTracer->action2Passed); - - $this->assertFalse($doorFSM->actionTracer->action8Passed /* 'closed' state exit action*/); - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::LOCK); - $this->assertTrue($doorFSM->actionTracer->action8Passed); - - $this->assertFalse($doorFSM->actionTracer->action4Passed /* 'closed&locked' state +'unlock' input action */); - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::UNLOCK); - $this->assertTrue($doorFSM->actionTracer->action4Passed); - - $this->assertFalse($doorFSM->actionTracer->action6Passed /* 'locked' -> 'opened' transition action action */); - $doorFSM->process(Zend_Search_Lucene_FSM_testFSMClass::OPEN); - $this->assertTrue($doorFSM->actionTracer->action6Passed); - } -} - diff --git a/tests/Zend/Search/Lucene/FieldTest.php b/tests/Zend/Search/Lucene/FieldTest.php deleted file mode 100644 index 8954ee735073c3c6a4ba61823b872494c01ef71c..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/FieldTest.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Field - */ -require_once 'Zend/Search/Lucene/Field.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_FieldTest extends PHPUnit_Framework_TestCase -{ - public function testBinary() - { - $field = Zend_Search_Lucene_Field::Binary('field', 'value'); - - $this->assertEquals($field->boost, 1); - $this->assertEquals($field->encoding, ''); - $this->assertEquals($field->isBinary, true); - $this->assertEquals($field->isIndexed, false); - $this->assertEquals($field->isStored, true); - $this->assertEquals($field->isTokenized, false); - - $this->assertEquals($field->name, 'field'); - $this->assertEquals($field->value, 'value'); - } - - public function testKeyword() - { - $field = Zend_Search_Lucene_Field::Keyword('field', 'value'); - - $this->assertEquals($field->boost, 1); - $this->assertEquals($field->encoding, ''); - $this->assertEquals($field->isBinary, false); - $this->assertEquals($field->isIndexed, true); - $this->assertEquals($field->isStored, true); - $this->assertEquals($field->isTokenized, false); - - $this->assertEquals($field->name, 'field'); - $this->assertEquals($field->value, 'value'); - } - - public function testText() - { - $field = Zend_Search_Lucene_Field::Text('field', 'value'); - - $this->assertEquals($field->boost, 1); - $this->assertEquals($field->encoding, ''); - $this->assertEquals($field->isBinary, false); - $this->assertEquals($field->isIndexed, true); - $this->assertEquals($field->isStored, true); - $this->assertEquals($field->isTokenized, true); - - $this->assertEquals($field->name, 'field'); - $this->assertEquals($field->value, 'value'); - } - - public function testUnIndexed() - { - $field = Zend_Search_Lucene_Field::UnIndexed('field', 'value'); - - $this->assertEquals($field->boost, 1); - $this->assertEquals($field->encoding, ''); - $this->assertEquals($field->isBinary, false); - $this->assertEquals($field->isIndexed, false); - $this->assertEquals($field->isStored, true); - $this->assertEquals($field->isTokenized, false); - - $this->assertEquals($field->name, 'field'); - $this->assertEquals($field->value, 'value'); - } - - public function testUnStored() - { - $field = Zend_Search_Lucene_Field::UnStored('field', 'value'); - - $this->assertEquals($field->boost, 1); - $this->assertEquals($field->encoding, ''); - $this->assertEquals($field->isBinary, false); - $this->assertEquals($field->isIndexed, true); - $this->assertEquals($field->isStored, false); - $this->assertEquals($field->isTokenized, true); - - $this->assertEquals($field->name, 'field'); - $this->assertEquals($field->value, 'value'); - } - - public function testEncoding() - { - $field = Zend_Search_Lucene_Field::Text('field', 'Words with umlauts: åãü...', 'ISO-8859-1'); - - $this->assertEquals($field->encoding, 'ISO-8859-1'); - - $this->assertEquals($field->name, 'field'); - $this->assertEquals($field->value, 'Words with umlauts: åãü...'); - $this->assertEquals($field->getUtf8Value(), 'Words with umlauts: åãü...'); - } -} - diff --git a/tests/Zend/Search/Lucene/Index/DictionaryLoaderTest.php b/tests/Zend/Search/Lucene/Index/DictionaryLoaderTest.php deleted file mode 100644 index 8584a6b5a1dd104f7aa96e10a3cfbb33298fdafa..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/DictionaryLoaderTest.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Storage_Directory_Filesystem - */ -require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php'; - -/** - * Zend_Search_Lucene_Index_SegmentInfo - */ -require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - -/** - * Zend_Search_Lucene_Index_DictionaryLoader - */ -require_once 'Zend/Search/Lucene/Index/DictionaryLoader.php'; - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_DictionaryLoaderTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $stiFile = $directory->getFileObject('_1.sti'); - $stiFileData = $stiFile->readBytes($directory->fileLength('_1.sti')); - - // Load dictionary index data - list($termDictionary, $termDictionaryInfos) = unserialize($stiFileData); - - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - $tiiFile = $segmentInfo->openCompoundFile('.tii'); - $tiiFileData = $tiiFile->readBytes($segmentInfo->compoundFileLength('.tii')); - - // Load dictionary index data - list($loadedTermDictionary, $loadedTermDictionaryInfos) = - Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData); - - $this->assertTrue($termDictionary == $loadedTermDictionary); - $this->assertTrue($termDictionaryInfos == $loadedTermDictionaryInfos); - } -} - diff --git a/tests/Zend/Search/Lucene/Index/FieldInfoTest.php b/tests/Zend/Search/Lucene/Index/FieldInfoTest.php deleted file mode 100644 index b411a589fabcd2c4382b34a7ae911eaf901f9954..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/FieldInfoTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Index_FieldInfo - */ -require_once 'Zend/Search/Lucene/Index/FieldInfo.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_FieldInfoTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $fieldInfo = new Zend_Search_Lucene_Index_FieldInfo('field_name', true, 3, false); - $this->assertTrue($fieldInfo instanceof Zend_Search_Lucene_Index_FieldInfo); - - $this->assertEquals($fieldInfo->name, 'field_name'); - $this->assertEquals($fieldInfo->isIndexed, true); - $this->assertEquals($fieldInfo->number, 3); - $this->assertEquals($fieldInfo->storeTermVector, false); - } -} - diff --git a/tests/Zend/Search/Lucene/Index/SegmentInfoPriorityQueueTest.php b/tests/Zend/Search/Lucene/Index/SegmentInfoPriorityQueueTest.php deleted file mode 100644 index 071a2958582fe9381bc2d9a7d62e8deabf5d66d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/SegmentInfoPriorityQueueTest.php +++ /dev/null @@ -1,683 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Storage_Directory_Filesystem - */ -require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php'; - -/** - * Zend_Search_Lucene_Index_SegmentInfo - */ -require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - -/** - * Zend_Search_Lucene_Index_SegmentInfoPriorityQueue - */ -require_once 'Zend/Search/Lucene/Index/SegmentInfoPriorityQueue.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_SegmentInfoPriorityQueueTest extends PHPUnit_Framework_TestCase -{ - public function testQueue() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentsList = array('_0', '_1', '_2', '_3', '_4'); - - $segmentInfoQueue = new Zend_Search_Lucene_Index_SegmentInfoPriorityQueue(); - - foreach ($segmentsList as $segmentName) { - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, $segmentName, 2); - $segmentInfo->reset(); - - // Skip "empty" segments - if ($segmentInfo->currentTerm() !== null) { - $segmentInfoQueue->put($segmentInfo); - } - } - - $result = array(); - while (($segmentInfo = $segmentInfoQueue->pop()) !== null) { - if ($segmentInfoQueue->top() === null || - $segmentInfoQueue->top()->currentTerm()->key() != - $segmentInfo->currentTerm()->key()) { - // We got new term - $result[] = $segmentInfo->currentTerm(); - } - - $segmentInfo->nextTerm(); - // check, if segment dictionary is finished - if ($segmentInfo->currentTerm() !== null) { - // Put segment back into the priority queue - $segmentInfoQueue->put($segmentInfo); - } - } - - $this->assertTrue($result == - array(new Zend_Search_Lucene_Index_Term('a', 'contents'), - new Zend_Search_Lucene_Index_Term('about', 'contents'), - new Zend_Search_Lucene_Index_Term('above', 'contents'), - new Zend_Search_Lucene_Index_Term('absolutely', 'contents'), - new Zend_Search_Lucene_Index_Term('accept', 'contents'), - new Zend_Search_Lucene_Index_Term('accesskey', 'contents'), - new Zend_Search_Lucene_Index_Term('account', 'contents'), - new Zend_Search_Lucene_Index_Term('accounts', 'contents'), - new Zend_Search_Lucene_Index_Term('adding', 'contents'), - new Zend_Search_Lucene_Index_Term('additional', 'contents'), - new Zend_Search_Lucene_Index_Term('adresses', 'contents'), - new Zend_Search_Lucene_Index_Term('advised', 'contents'), - new Zend_Search_Lucene_Index_Term('after', 'contents'), - new Zend_Search_Lucene_Index_Term('alan', 'contents'), - new Zend_Search_Lucene_Index_Term('alberton', 'contents'), - new Zend_Search_Lucene_Index_Term('alexander', 'contents'), - new Zend_Search_Lucene_Index_Term('align', 'contents'), - new Zend_Search_Lucene_Index_Term('alink', 'contents'), - new Zend_Search_Lucene_Index_Term('all', 'contents'), - new Zend_Search_Lucene_Index_Term('alphabetic', 'contents'), - new Zend_Search_Lucene_Index_Term('already', 'contents'), - new Zend_Search_Lucene_Index_Term('also', 'contents'), - new Zend_Search_Lucene_Index_Term('always', 'contents'), - new Zend_Search_Lucene_Index_Term('amazon', 'contents'), - new Zend_Search_Lucene_Index_Term('an', 'contents'), - new Zend_Search_Lucene_Index_Term('and', 'contents'), - new Zend_Search_Lucene_Index_Term('annoying', 'contents'), - new Zend_Search_Lucene_Index_Term('another', 'contents'), - new Zend_Search_Lucene_Index_Term('any', 'contents'), - new Zend_Search_Lucene_Index_Term('apart', 'contents'), - new Zend_Search_Lucene_Index_Term('api', 'contents'), - new Zend_Search_Lucene_Index_Term('appreciate', 'contents'), - new Zend_Search_Lucene_Index_Term('are', 'contents'), - new Zend_Search_Lucene_Index_Term('arising', 'contents'), - new Zend_Search_Lucene_Index_Term('as', 'contents'), - new Zend_Search_Lucene_Index_Term('asked', 'contents'), - new Zend_Search_Lucene_Index_Term('at', 'contents'), - new Zend_Search_Lucene_Index_Term('attach', 'contents'), - new Zend_Search_Lucene_Index_Term('attachments', 'contents'), - new Zend_Search_Lucene_Index_Term('authors', 'contents'), - new Zend_Search_Lucene_Index_Term('available', 'contents'), - new Zend_Search_Lucene_Index_Term('b', 'contents'), - new Zend_Search_Lucene_Index_Term('back', 'contents'), - new Zend_Search_Lucene_Index_Term('backwards', 'contents'), - new Zend_Search_Lucene_Index_Term('bar', 'contents'), - new Zend_Search_Lucene_Index_Term('base', 'contents'), - new Zend_Search_Lucene_Index_Term('be', 'contents'), - new Zend_Search_Lucene_Index_Term('beaver', 'contents'), - new Zend_Search_Lucene_Index_Term('because', 'contents'), - new Zend_Search_Lucene_Index_Term('been', 'contents'), - new Zend_Search_Lucene_Index_Term('before', 'contents'), - new Zend_Search_Lucene_Index_Term('bgcolor', 'contents'), - new Zend_Search_Lucene_Index_Term('binary', 'contents'), - new Zend_Search_Lucene_Index_Term('blockquote', 'contents'), - new Zend_Search_Lucene_Index_Term('body', 'contents'), - new Zend_Search_Lucene_Index_Term('book', 'contents'), - new Zend_Search_Lucene_Index_Term('border', 'contents'), - new Zend_Search_Lucene_Index_Term('bottom', 'contents'), - new Zend_Search_Lucene_Index_Term('break', 'contents'), - new Zend_Search_Lucene_Index_Term('brought', 'contents'), - new Zend_Search_Lucene_Index_Term('browser', 'contents'), - new Zend_Search_Lucene_Index_Term('bug', 'contents'), - new Zend_Search_Lucene_Index_Term('bugs', 'contents'), - new Zend_Search_Lucene_Index_Term('business', 'contents'), - new Zend_Search_Lucene_Index_Term('but', 'contents'), - new Zend_Search_Lucene_Index_Term('buy', 'contents'), - new Zend_Search_Lucene_Index_Term('buying', 'contents'), - new Zend_Search_Lucene_Index_Term('by', 'contents'), - new Zend_Search_Lucene_Index_Term('c', 'contents'), - new Zend_Search_Lucene_Index_Term('can', 'contents'), - new Zend_Search_Lucene_Index_Term('care', 'contents'), - new Zend_Search_Lucene_Index_Term('carefully', 'contents'), - new Zend_Search_Lucene_Index_Term('case', 'contents'), - new Zend_Search_Lucene_Index_Term('caused', 'contents'), - new Zend_Search_Lucene_Index_Term('cc', 'contents'), - new Zend_Search_Lucene_Index_Term('cd', 'contents'), - new Zend_Search_Lucene_Index_Term('cellpadding', 'contents'), - new Zend_Search_Lucene_Index_Term('cellspacing', 'contents'), - new Zend_Search_Lucene_Index_Term('center', 'contents'), - new Zend_Search_Lucene_Index_Term('certain', 'contents'), - new Zend_Search_Lucene_Index_Term('chances', 'contents'), - new Zend_Search_Lucene_Index_Term('change', 'contents'), - new Zend_Search_Lucene_Index_Term('changed', 'contents'), - new Zend_Search_Lucene_Index_Term('changes', 'contents'), - new Zend_Search_Lucene_Index_Term('changing', 'contents'), - new Zend_Search_Lucene_Index_Term('chapter', 'contents'), - new Zend_Search_Lucene_Index_Term('charset', 'contents'), - new Zend_Search_Lucene_Index_Term('check', 'contents'), - new Zend_Search_Lucene_Index_Term('class', 'contents'), - new Zend_Search_Lucene_Index_Term('classes', 'contents'), - new Zend_Search_Lucene_Index_Term('clay', 'contents'), - new Zend_Search_Lucene_Index_Term('clear', 'contents'), - new Zend_Search_Lucene_Index_Term('click', 'contents'), - new Zend_Search_Lucene_Index_Term('co', 'contents'), - new Zend_Search_Lucene_Index_Term('code', 'contents'), - new Zend_Search_Lucene_Index_Term('coding', 'contents'), - new Zend_Search_Lucene_Index_Term('colspan', 'contents'), - new Zend_Search_Lucene_Index_Term('com', 'contents'), - new Zend_Search_Lucene_Index_Term('commands', 'contents'), - new Zend_Search_Lucene_Index_Term('comment', 'contents'), - new Zend_Search_Lucene_Index_Term('community', 'contents'), - new Zend_Search_Lucene_Index_Term('company', 'contents'), - new Zend_Search_Lucene_Index_Term('compatibility', 'contents'), - new Zend_Search_Lucene_Index_Term('compatible', 'contents'), - new Zend_Search_Lucene_Index_Term('components', 'contents'), - new Zend_Search_Lucene_Index_Term('conditions', 'contents'), - new Zend_Search_Lucene_Index_Term('consequential', 'contents'), - new Zend_Search_Lucene_Index_Term('considered', 'contents'), - new Zend_Search_Lucene_Index_Term('consists', 'contents'), - new Zend_Search_Lucene_Index_Term('contact', 'contents'), - new Zend_Search_Lucene_Index_Term('contains', 'contents'), - new Zend_Search_Lucene_Index_Term('content', 'contents'), - new Zend_Search_Lucene_Index_Term('contents', 'contents'), - new Zend_Search_Lucene_Index_Term('contract', 'contents'), - new Zend_Search_Lucene_Index_Term('contribute', 'contents'), - new Zend_Search_Lucene_Index_Term('contributed', 'contents'), - new Zend_Search_Lucene_Index_Term('contributing', 'contents'), - new Zend_Search_Lucene_Index_Term('contributors', 'contents'), - new Zend_Search_Lucene_Index_Term('convissor', 'contents'), - new Zend_Search_Lucene_Index_Term('copyright', 'contents'), - new Zend_Search_Lucene_Index_Term('core', 'contents'), - new Zend_Search_Lucene_Index_Term('costa', 'contents'), - new Zend_Search_Lucene_Index_Term('could', 'contents'), - new Zend_Search_Lucene_Index_Term('cox', 'contents'), - new Zend_Search_Lucene_Index_Term('create', 'contents'), - new Zend_Search_Lucene_Index_Term('creating', 'contents'), - new Zend_Search_Lucene_Index_Term('cvs', 'contents'), - new Zend_Search_Lucene_Index_Term('cvsread', 'contents'), - new Zend_Search_Lucene_Index_Term('d', 'contents'), - new Zend_Search_Lucene_Index_Term('damage', 'contents'), - new Zend_Search_Lucene_Index_Term('damages', 'contents'), - new Zend_Search_Lucene_Index_Term('daniel', 'contents'), - new Zend_Search_Lucene_Index_Term('data', 'contents'), - new Zend_Search_Lucene_Index_Term('date', 'contents'), - new Zend_Search_Lucene_Index_Term('david', 'contents'), - new Zend_Search_Lucene_Index_Term('depends', 'contents'), - new Zend_Search_Lucene_Index_Term('derivative', 'contents'), - new Zend_Search_Lucene_Index_Term('derived', 'contents'), - new Zend_Search_Lucene_Index_Term('describes', 'contents'), - new Zend_Search_Lucene_Index_Term('details', 'contents'), - new Zend_Search_Lucene_Index_Term('detection', 'contents'), - new Zend_Search_Lucene_Index_Term('dev', 'contents'), - new Zend_Search_Lucene_Index_Term('developer', 'contents'), - new Zend_Search_Lucene_Index_Term('developers', 'contents'), - new Zend_Search_Lucene_Index_Term('diff', 'contents'), - new Zend_Search_Lucene_Index_Term('different', 'contents'), - new Zend_Search_Lucene_Index_Term('direct', 'contents'), - new Zend_Search_Lucene_Index_Term('disclaimed', 'contents'), - new Zend_Search_Lucene_Index_Term('disclaimer', 'contents'), - new Zend_Search_Lucene_Index_Term('distributed', 'contents'), - new Zend_Search_Lucene_Index_Term('distribution', 'contents'), - new Zend_Search_Lucene_Index_Term('div', 'contents'), - new Zend_Search_Lucene_Index_Term('dl', 'contents'), - new Zend_Search_Lucene_Index_Term('do', 'contents'), - new Zend_Search_Lucene_Index_Term('doc', 'contents'), - new Zend_Search_Lucene_Index_Term('docblock', 'contents'), - new Zend_Search_Lucene_Index_Term('docbook', 'contents'), - new Zend_Search_Lucene_Index_Term('docs', 'contents'), - new Zend_Search_Lucene_Index_Term('document', 'contents'), - new Zend_Search_Lucene_Index_Term('documentation', 'contents'), - new Zend_Search_Lucene_Index_Term('does', 'contents'), - new Zend_Search_Lucene_Index_Term('doesn', 'contents'), - new Zend_Search_Lucene_Index_Term('don', 'contents'), - new Zend_Search_Lucene_Index_Term('double', 'contents'), - new Zend_Search_Lucene_Index_Term('dt', 'contents'), - new Zend_Search_Lucene_Index_Term('dumbill', 'contents'), - new Zend_Search_Lucene_Index_Term('each', 'contents'), - new Zend_Search_Lucene_Index_Term('easiest', 'contents'), - new Zend_Search_Lucene_Index_Term('easy', 'contents'), - new Zend_Search_Lucene_Index_Term('edd', 'contents'), - new Zend_Search_Lucene_Index_Term('edit', 'contents'), - new Zend_Search_Lucene_Index_Term('eeeeee', 'contents'), - new Zend_Search_Lucene_Index_Term('email', 'contents'), - new Zend_Search_Lucene_Index_Term('endorse', 'contents'), - new Zend_Search_Lucene_Index_Term('english', 'contents'), - new Zend_Search_Lucene_Index_Term('equal', 'contents'), - new Zend_Search_Lucene_Index_Term('equiv', 'contents'), - new Zend_Search_Lucene_Index_Term('essential', 'contents'), - new Zend_Search_Lucene_Index_Term('even', 'contents'), - new Zend_Search_Lucene_Index_Term('event', 'contents'), - new Zend_Search_Lucene_Index_Term('everyone', 'contents'), - new Zend_Search_Lucene_Index_Term('example', 'contents'), - new Zend_Search_Lucene_Index_Term('exemplary', 'contents'), - new Zend_Search_Lucene_Index_Term('existing', 'contents'), - new Zend_Search_Lucene_Index_Term('expand', 'contents'), - new Zend_Search_Lucene_Index_Term('explanation', 'contents'), - new Zend_Search_Lucene_Index_Term('explanations', 'contents'), - new Zend_Search_Lucene_Index_Term('explicit', 'contents'), - new Zend_Search_Lucene_Index_Term('express', 'contents'), - new Zend_Search_Lucene_Index_Term('extension', 'contents'), - new Zend_Search_Lucene_Index_Term('fairly', 'contents'), - new Zend_Search_Lucene_Index_Term('faq', 'contents'), - new Zend_Search_Lucene_Index_Term('feature', 'contents'), - new Zend_Search_Lucene_Index_Term('feedback', 'contents'), - new Zend_Search_Lucene_Index_Term('feel', 'contents'), - new Zend_Search_Lucene_Index_Term('ff', 'contents'), - new Zend_Search_Lucene_Index_Term('ffffff', 'contents'), - new Zend_Search_Lucene_Index_Term('file', 'contents'), - new Zend_Search_Lucene_Index_Term('fill', 'contents'), - new Zend_Search_Lucene_Index_Term('financial', 'contents'), - new Zend_Search_Lucene_Index_Term('find', 'contents'), - new Zend_Search_Lucene_Index_Term('fine', 'contents'), - new Zend_Search_Lucene_Index_Term('finished', 'contents'), - new Zend_Search_Lucene_Index_Term('first', 'contents'), - new Zend_Search_Lucene_Index_Term('fitness', 'contents'), - new Zend_Search_Lucene_Index_Term('fix', 'contents'), - new Zend_Search_Lucene_Index_Term('fixed', 'contents'), - new Zend_Search_Lucene_Index_Term('following', 'contents'), - new Zend_Search_Lucene_Index_Term('foo', 'contents'), - new Zend_Search_Lucene_Index_Term('footer', 'contents'), - new Zend_Search_Lucene_Index_Term('for', 'contents'), - new Zend_Search_Lucene_Index_Term('force', 'contents'), - new Zend_Search_Lucene_Index_Term('forget', 'contents'), - new Zend_Search_Lucene_Index_Term('form', 'contents'), - new Zend_Search_Lucene_Index_Term('forms', 'contents'), - new Zend_Search_Lucene_Index_Term('forth', 'contents'), - new Zend_Search_Lucene_Index_Term('found', 'contents'), - new Zend_Search_Lucene_Index_Term('free', 'contents'), - new Zend_Search_Lucene_Index_Term('frequently', 'contents'), - new Zend_Search_Lucene_Index_Term('from', 'contents'), - new Zend_Search_Lucene_Index_Term('front', 'contents'), - new Zend_Search_Lucene_Index_Term('fully', 'contents'), - new Zend_Search_Lucene_Index_Term('functionality', 'contents'), - new Zend_Search_Lucene_Index_Term('generally', 'contents'), - new Zend_Search_Lucene_Index_Term('generator', 'contents'), - new Zend_Search_Lucene_Index_Term('giving', 'contents'), - new Zend_Search_Lucene_Index_Term('go', 'contents'), - new Zend_Search_Lucene_Index_Term('good', 'contents'), - new Zend_Search_Lucene_Index_Term('goods', 'contents'), - new Zend_Search_Lucene_Index_Term('gregory', 'contents'), - new Zend_Search_Lucene_Index_Term('groundbraking', 'contents'), - new Zend_Search_Lucene_Index_Term('group', 'contents'), - new Zend_Search_Lucene_Index_Term('guide', 'contents'), - new Zend_Search_Lucene_Index_Term('h', 'contents'), - new Zend_Search_Lucene_Index_Term('happy', 'contents'), - new Zend_Search_Lucene_Index_Term('has', 'contents'), - new Zend_Search_Lucene_Index_Term('hasn', 'contents'), - new Zend_Search_Lucene_Index_Term('have', 'contents'), - new Zend_Search_Lucene_Index_Term('head', 'contents'), - new Zend_Search_Lucene_Index_Term('header', 'contents'), - new Zend_Search_Lucene_Index_Term('help', 'contents'), - new Zend_Search_Lucene_Index_Term('helping', 'contents'), - new Zend_Search_Lucene_Index_Term('her', 'contents'), - new Zend_Search_Lucene_Index_Term('hesitate', 'contents'), - new Zend_Search_Lucene_Index_Term('his', 'contents'), - new Zend_Search_Lucene_Index_Term('holder', 'contents'), - new Zend_Search_Lucene_Index_Term('holders', 'contents'), - new Zend_Search_Lucene_Index_Term('home', 'contents'), - new Zend_Search_Lucene_Index_Term('homepage', 'contents'), - new Zend_Search_Lucene_Index_Term('how', 'contents'), - new Zend_Search_Lucene_Index_Term('however', 'contents'), - new Zend_Search_Lucene_Index_Term('hr', 'contents'), - new Zend_Search_Lucene_Index_Term('href', 'contents'), - new Zend_Search_Lucene_Index_Term('html', 'contents'), - new Zend_Search_Lucene_Index_Term('http', 'contents'), - new Zend_Search_Lucene_Index_Term('i', 'contents'), - new Zend_Search_Lucene_Index_Term('if', 'contents'), - new Zend_Search_Lucene_Index_Term('immoral', 'contents'), - new Zend_Search_Lucene_Index_Term('implied', 'contents'), - new Zend_Search_Lucene_Index_Term('important', 'contents'), - new Zend_Search_Lucene_Index_Term('improvement', 'contents'), - new Zend_Search_Lucene_Index_Term('improving', 'contents'), - new Zend_Search_Lucene_Index_Term('in', 'contents'), - new Zend_Search_Lucene_Index_Term('incidental', 'contents'), - new Zend_Search_Lucene_Index_Term('include', 'contents'), - new Zend_Search_Lucene_Index_Term('including', 'contents'), - new Zend_Search_Lucene_Index_Term('independent', 'contents'), - new Zend_Search_Lucene_Index_Term('index', 'contents'), - new Zend_Search_Lucene_Index_Term('indirect', 'contents'), - new Zend_Search_Lucene_Index_Term('information', 'contents'), - new Zend_Search_Lucene_Index_Term('install', 'contents'), - new Zend_Search_Lucene_Index_Term('installation', 'contents'), - new Zend_Search_Lucene_Index_Term('installer', 'contents'), - new Zend_Search_Lucene_Index_Term('interruption', 'contents'), - new Zend_Search_Lucene_Index_Term('into', 'contents'), - new Zend_Search_Lucene_Index_Term('introduce', 'contents'), - new Zend_Search_Lucene_Index_Term('introduction', 'contents'), - new Zend_Search_Lucene_Index_Term('is', 'contents'), - new Zend_Search_Lucene_Index_Term('iso', 'contents'), - new Zend_Search_Lucene_Index_Term('it', 'contents'), - new Zend_Search_Lucene_Index_Term('its', 'contents'), - new Zend_Search_Lucene_Index_Term('jansen', 'contents'), - new Zend_Search_Lucene_Index_Term('jon', 'contents'), - new Zend_Search_Lucene_Index_Term('keep', 'contents'), - new Zend_Search_Lucene_Index_Term('knowles', 'contents'), - new Zend_Search_Lucene_Index_Term('lack', 'contents'), - new Zend_Search_Lucene_Index_Term('languages', 'contents'), - new Zend_Search_Lucene_Index_Term('later', 'contents'), - new Zend_Search_Lucene_Index_Term('latest', 'contents'), - new Zend_Search_Lucene_Index_Term('left', 'contents'), - new Zend_Search_Lucene_Index_Term('legalnotice', 'contents'), - new Zend_Search_Lucene_Index_Term('li', 'contents'), - new Zend_Search_Lucene_Index_Term('liability', 'contents'), - new Zend_Search_Lucene_Index_Term('liable', 'contents'), - new Zend_Search_Lucene_Index_Term('license', 'contents'), - new Zend_Search_Lucene_Index_Term('licenses', 'contents'), - new Zend_Search_Lucene_Index_Term('like', 'contents'), - new Zend_Search_Lucene_Index_Term('limited', 'contents'), - new Zend_Search_Lucene_Index_Term('link', 'contents'), - new Zend_Search_Lucene_Index_Term('list', 'contents'), - new Zend_Search_Lucene_Index_Term('listed', 'contents'), - new Zend_Search_Lucene_Index_Term('lists', 'contents'), - new Zend_Search_Lucene_Index_Term('literal', 'contents'), - new Zend_Search_Lucene_Index_Term('ll', 'contents'), - new Zend_Search_Lucene_Index_Term('login', 'contents'), - new Zend_Search_Lucene_Index_Term('look', 'contents'), - new Zend_Search_Lucene_Index_Term('lorenzo', 'contents'), - new Zend_Search_Lucene_Index_Term('loss', 'contents'), - new Zend_Search_Lucene_Index_Term('loveless', 'contents'), - new Zend_Search_Lucene_Index_Term('mail', 'contents'), - new Zend_Search_Lucene_Index_Term('mailinglist', 'contents'), - new Zend_Search_Lucene_Index_Term('mailto', 'contents'), - new Zend_Search_Lucene_Index_Term('maintain', 'contents'), - new Zend_Search_Lucene_Index_Term('maintainer', 'contents'), - new Zend_Search_Lucene_Index_Term('maintainers', 'contents'), - new Zend_Search_Lucene_Index_Term('make', 'contents'), - new Zend_Search_Lucene_Index_Term('makes', 'contents'), - new Zend_Search_Lucene_Index_Term('manual', 'contents'), - new Zend_Search_Lucene_Index_Term('martin', 'contents'), - new Zend_Search_Lucene_Index_Term('material', 'contents'), - new Zend_Search_Lucene_Index_Term('materials', 'contents'), - new Zend_Search_Lucene_Index_Term('may', 'contents'), - new Zend_Search_Lucene_Index_Term('mean', 'contents'), - new Zend_Search_Lucene_Index_Term('means', 'contents'), - new Zend_Search_Lucene_Index_Term('meet', 'contents'), - new Zend_Search_Lucene_Index_Term('merchantability', 'contents'), - new Zend_Search_Lucene_Index_Term('merz', 'contents'), - new Zend_Search_Lucene_Index_Term('met', 'contents'), - new Zend_Search_Lucene_Index_Term('meta', 'contents'), - new Zend_Search_Lucene_Index_Term('michael', 'contents'), - new Zend_Search_Lucene_Index_Term('migrating', 'contents'), - new Zend_Search_Lucene_Index_Term('mika', 'contents'), - new Zend_Search_Lucene_Index_Term('mime', 'contents'), - new Zend_Search_Lucene_Index_Term('modification', 'contents'), - new Zend_Search_Lucene_Index_Term('modified', 'contents'), - new Zend_Search_Lucene_Index_Term('modular', 'contents'), - new Zend_Search_Lucene_Index_Term('more', 'contents'), - new Zend_Search_Lucene_Index_Term('must', 'contents'), - new Zend_Search_Lucene_Index_Term('n', 'contents'), - new Zend_Search_Lucene_Index_Term('name', 'contents'), - new Zend_Search_Lucene_Index_Term('names', 'contents'), - new Zend_Search_Lucene_Index_Term('navfooter', 'contents'), - new Zend_Search_Lucene_Index_Term('navheader', 'contents'), - new Zend_Search_Lucene_Index_Term('navigation', 'contents'), - new Zend_Search_Lucene_Index_Term('nbsp', 'contents'), - new Zend_Search_Lucene_Index_Term('need', 'contents'), - new Zend_Search_Lucene_Index_Term('negligence', 'contents'), - new Zend_Search_Lucene_Index_Term('neither', 'contents'), - new Zend_Search_Lucene_Index_Term('net', 'contents'), - new Zend_Search_Lucene_Index_Term('neufeind', 'contents'), - new Zend_Search_Lucene_Index_Term('new', 'contents'), - new Zend_Search_Lucene_Index_Term('newpackage', 'contents'), - new Zend_Search_Lucene_Index_Term('next', 'contents'), - new Zend_Search_Lucene_Index_Term('no', 'contents'), - new Zend_Search_Lucene_Index_Term('nor', 'contents'), - new Zend_Search_Lucene_Index_Term('not', 'contents'), - new Zend_Search_Lucene_Index_Term('note', 'contents'), - new Zend_Search_Lucene_Index_Term('notice', 'contents'), - new Zend_Search_Lucene_Index_Term('now', 'contents'), - new Zend_Search_Lucene_Index_Term('obtain', 'contents'), - new Zend_Search_Lucene_Index_Term('obtained', 'contents'), - new Zend_Search_Lucene_Index_Term('of', 'contents'), - new Zend_Search_Lucene_Index_Term('on', 'contents'), - new Zend_Search_Lucene_Index_Term('one', 'contents'), - new Zend_Search_Lucene_Index_Term('only', 'contents'), - new Zend_Search_Lucene_Index_Term('open', 'contents'), - new Zend_Search_Lucene_Index_Term('opencontent', 'contents'), - new Zend_Search_Lucene_Index_Term('openpub', 'contents'), - new Zend_Search_Lucene_Index_Term('or', 'contents'), - new Zend_Search_Lucene_Index_Term('order', 'contents'), - new Zend_Search_Lucene_Index_Term('org', 'contents'), - new Zend_Search_Lucene_Index_Term('originally', 'contents'), - new Zend_Search_Lucene_Index_Term('other', 'contents'), - new Zend_Search_Lucene_Index_Term('otherwise', 'contents'), - new Zend_Search_Lucene_Index_Term('our', 'contents'), - new Zend_Search_Lucene_Index_Term('out', 'contents'), - new Zend_Search_Lucene_Index_Term('outlook', 'contents'), - new Zend_Search_Lucene_Index_Term('p', 'contents'), - new Zend_Search_Lucene_Index_Term('package', 'contents'), - new Zend_Search_Lucene_Index_Term('packages', 'contents'), - new Zend_Search_Lucene_Index_Term('page', 'contents'), - new Zend_Search_Lucene_Index_Term('paper', 'contents'), - new Zend_Search_Lucene_Index_Term('parise', 'contents'), - new Zend_Search_Lucene_Index_Term('part', 'contents'), - new Zend_Search_Lucene_Index_Term('particular', 'contents'), - new Zend_Search_Lucene_Index_Term('password', 'contents'), - new Zend_Search_Lucene_Index_Term('patch', 'contents'), - new Zend_Search_Lucene_Index_Term('patches', 'contents'), - new Zend_Search_Lucene_Index_Term('pear', 'contents'), - new Zend_Search_Lucene_Index_Term('people', 'contents'), - new Zend_Search_Lucene_Index_Term('perform', 'contents'), - new Zend_Search_Lucene_Index_Term('permission', 'contents'), - new Zend_Search_Lucene_Index_Term('permitted', 'contents'), - new Zend_Search_Lucene_Index_Term('persists', 'contents'), - new Zend_Search_Lucene_Index_Term('php', 'contents'), - new Zend_Search_Lucene_Index_Term('phpfi', 'contents'), - new Zend_Search_Lucene_Index_Term('plain', 'contents'), - new Zend_Search_Lucene_Index_Term('please', 'contents'), - new Zend_Search_Lucene_Index_Term('possibility', 'contents'), - new Zend_Search_Lucene_Index_Term('post', 'contents'), - new Zend_Search_Lucene_Index_Term('postinstall', 'contents'), - new Zend_Search_Lucene_Index_Term('ppm', 'contents'), - new Zend_Search_Lucene_Index_Term('pre', 'contents'), - new Zend_Search_Lucene_Index_Term('preface', 'contents'), - new Zend_Search_Lucene_Index_Term('prefixed', 'contents'), - new Zend_Search_Lucene_Index_Term('presently', 'contents'), - new Zend_Search_Lucene_Index_Term('prev', 'contents'), - new Zend_Search_Lucene_Index_Term('previous', 'contents'), - new Zend_Search_Lucene_Index_Term('prior', 'contents'), - new Zend_Search_Lucene_Index_Term('process', 'contents'), - new Zend_Search_Lucene_Index_Term('procurement', 'contents'), - new Zend_Search_Lucene_Index_Term('products', 'contents'), - new Zend_Search_Lucene_Index_Term('profits', 'contents'), - new Zend_Search_Lucene_Index_Term('prohibited', 'contents'), - new Zend_Search_Lucene_Index_Term('project', 'contents'), - new Zend_Search_Lucene_Index_Term('promote', 'contents'), - new Zend_Search_Lucene_Index_Term('proper', 'contents'), - new Zend_Search_Lucene_Index_Term('provided', 'contents'), - new Zend_Search_Lucene_Index_Term('provides', 'contents'), - new Zend_Search_Lucene_Index_Term('pserver', 'contents'), - new Zend_Search_Lucene_Index_Term('public', 'contents'), - new Zend_Search_Lucene_Index_Term('publication', 'contents'), - new Zend_Search_Lucene_Index_Term('published', 'contents'), - new Zend_Search_Lucene_Index_Term('purpose', 'contents'), - new Zend_Search_Lucene_Index_Term('questions', 'contents'), - new Zend_Search_Lucene_Index_Term('quote', 'contents'), - new Zend_Search_Lucene_Index_Term('read', 'contents'), - new Zend_Search_Lucene_Index_Term('redistribution', 'contents'), - new Zend_Search_Lucene_Index_Term('redistributions', 'contents'), - new Zend_Search_Lucene_Index_Term('regents', 'contents'), - new Zend_Search_Lucene_Index_Term('rejected', 'contents'), - new Zend_Search_Lucene_Index_Term('rel', 'contents'), - new Zend_Search_Lucene_Index_Term('relevant', 'contents'), - new Zend_Search_Lucene_Index_Term('report', 'contents'), - new Zend_Search_Lucene_Index_Term('reported', 'contents'), - new Zend_Search_Lucene_Index_Term('reporting', 'contents'), - new Zend_Search_Lucene_Index_Term('repository', 'contents'), - new Zend_Search_Lucene_Index_Term('representatives', 'contents'), - new Zend_Search_Lucene_Index_Term('reproduce', 'contents'), - new Zend_Search_Lucene_Index_Term('requests', 'contents'), - new Zend_Search_Lucene_Index_Term('requirements', 'contents'), - new Zend_Search_Lucene_Index_Term('reserved', 'contents'), - new Zend_Search_Lucene_Index_Term('restrictions', 'contents'), - new Zend_Search_Lucene_Index_Term('resulting', 'contents'), - new Zend_Search_Lucene_Index_Term('retain', 'contents'), - new Zend_Search_Lucene_Index_Term('revision', 'contents'), - new Zend_Search_Lucene_Index_Term('right', 'contents'), - new Zend_Search_Lucene_Index_Term('rights', 'contents'), - new Zend_Search_Lucene_Index_Term('rpc', 'contents'), - new Zend_Search_Lucene_Index_Term('running', 'contents'), - new Zend_Search_Lucene_Index_Term('s', 'contents'), - new Zend_Search_Lucene_Index_Term('sample', 'contents'), - new Zend_Search_Lucene_Index_Term('schlitt', 'contents'), - new Zend_Search_Lucene_Index_Term('schmidt', 'contents'), - new Zend_Search_Lucene_Index_Term('screen', 'contents'), - new Zend_Search_Lucene_Index_Term('script', 'contents'), - new Zend_Search_Lucene_Index_Term('sect', 'contents'), - new Zend_Search_Lucene_Index_Term('section', 'contents'), - new Zend_Search_Lucene_Index_Term('see', 'contents'), - new Zend_Search_Lucene_Index_Term('send', 'contents'), - new Zend_Search_Lucene_Index_Term('seriously', 'contents'), - new Zend_Search_Lucene_Index_Term('service', 'contents'), - new Zend_Search_Lucene_Index_Term('services', 'contents'), - new Zend_Search_Lucene_Index_Term('set', 'contents'), - new Zend_Search_Lucene_Index_Term('several', 'contents'), - new Zend_Search_Lucene_Index_Term('shall', 'contents'), - new Zend_Search_Lucene_Index_Term('she', 'contents'), - new Zend_Search_Lucene_Index_Term('should', 'contents'), - new Zend_Search_Lucene_Index_Term('similar', 'contents'), - new Zend_Search_Lucene_Index_Term('so', 'contents'), - new Zend_Search_Lucene_Index_Term('software', 'contents'), - new Zend_Search_Lucene_Index_Term('some', 'contents'), - new Zend_Search_Lucene_Index_Term('something', 'contents'), - new Zend_Search_Lucene_Index_Term('source', 'contents'), - new Zend_Search_Lucene_Index_Term('sources', 'contents'), - new Zend_Search_Lucene_Index_Term('span', 'contents'), - new Zend_Search_Lucene_Index_Term('special', 'contents'), - new Zend_Search_Lucene_Index_Term('specific', 'contents'), - new Zend_Search_Lucene_Index_Term('speed', 'contents'), - new Zend_Search_Lucene_Index_Term('standard', 'contents'), - new Zend_Search_Lucene_Index_Term('standards', 'contents'), - new Zend_Search_Lucene_Index_Term('stefan', 'contents'), - new Zend_Search_Lucene_Index_Term('step', 'contents'), - new Zend_Search_Lucene_Index_Term('stephan', 'contents'), - new Zend_Search_Lucene_Index_Term('still', 'contents'), - new Zend_Search_Lucene_Index_Term('strict', 'contents'), - new Zend_Search_Lucene_Index_Term('structure', 'contents'), - new Zend_Search_Lucene_Index_Term('stylesheet', 'contents'), - new Zend_Search_Lucene_Index_Term('subject', 'contents'), - new Zend_Search_Lucene_Index_Term('submit', 'contents'), - new Zend_Search_Lucene_Index_Term('submitting', 'contents'), - new Zend_Search_Lucene_Index_Term('substantively', 'contents'), - new Zend_Search_Lucene_Index_Term('substitute', 'contents'), - new Zend_Search_Lucene_Index_Term('such', 'contents'), - new Zend_Search_Lucene_Index_Term('summary', 'contents'), - new Zend_Search_Lucene_Index_Term('support', 'contents'), - new Zend_Search_Lucene_Index_Term('sure', 'contents'), - new Zend_Search_Lucene_Index_Term('system', 'contents'), - new Zend_Search_Lucene_Index_Term('t', 'contents'), - new Zend_Search_Lucene_Index_Term('table', 'contents'), - new Zend_Search_Lucene_Index_Term('take', 'contents'), - new Zend_Search_Lucene_Index_Term('target', 'contents'), - new Zend_Search_Lucene_Index_Term('task', 'contents'), - new Zend_Search_Lucene_Index_Term('td', 'contents'), - new Zend_Search_Lucene_Index_Term('terms', 'contents'), - new Zend_Search_Lucene_Index_Term('test', 'contents'), - new Zend_Search_Lucene_Index_Term('tested', 'contents'), - new Zend_Search_Lucene_Index_Term('text', 'contents'), - new Zend_Search_Lucene_Index_Term('th', 'contents'), - new Zend_Search_Lucene_Index_Term('that', 'contents'), - new Zend_Search_Lucene_Index_Term('the', 'contents'), - new Zend_Search_Lucene_Index_Term('their', 'contents'), - new Zend_Search_Lucene_Index_Term('them', 'contents'), - new Zend_Search_Lucene_Index_Term('theory', 'contents'), - new Zend_Search_Lucene_Index_Term('there', 'contents'), - new Zend_Search_Lucene_Index_Term('think', 'contents'), - new Zend_Search_Lucene_Index_Term('this', 'contents'), - new Zend_Search_Lucene_Index_Term('thomas', 'contents'), - new Zend_Search_Lucene_Index_Term('those', 'contents'), - new Zend_Search_Lucene_Index_Term('thus', 'contents'), - new Zend_Search_Lucene_Index_Term('time', 'contents'), - new Zend_Search_Lucene_Index_Term('tips', 'contents'), - new Zend_Search_Lucene_Index_Term('title', 'contents'), - new Zend_Search_Lucene_Index_Term('titlepage', 'contents'), - new Zend_Search_Lucene_Index_Term('to', 'contents'), - new Zend_Search_Lucene_Index_Term('tobias', 'contents'), - new Zend_Search_Lucene_Index_Term('toc', 'contents'), - new Zend_Search_Lucene_Index_Term('top', 'contents'), - new Zend_Search_Lucene_Index_Term('tort', 'contents'), - new Zend_Search_Lucene_Index_Term('tr', 'contents'), - new Zend_Search_Lucene_Index_Term('tracking', 'contents'), - new Zend_Search_Lucene_Index_Term('translated', 'contents'), - new Zend_Search_Lucene_Index_Term('translating', 'contents'), - new Zend_Search_Lucene_Index_Term('translation', 'contents'), - new Zend_Search_Lucene_Index_Term('translations', 'contents'), - new Zend_Search_Lucene_Index_Term('translators', 'contents'), - new Zend_Search_Lucene_Index_Term('try', 'contents'), - new Zend_Search_Lucene_Index_Term('tt', 'contents'), - new Zend_Search_Lucene_Index_Term('tuupola', 'contents'), - new Zend_Search_Lucene_Index_Term('txt', 'contents'), - new Zend_Search_Lucene_Index_Term('type', 'contents'), - new Zend_Search_Lucene_Index_Term('u', 'contents'), - new Zend_Search_Lucene_Index_Term('ul', 'contents'), - new Zend_Search_Lucene_Index_Term('unable', 'contents'), - new Zend_Search_Lucene_Index_Term('under', 'contents'), - new Zend_Search_Lucene_Index_Term('understand', 'contents'), - new Zend_Search_Lucene_Index_Term('unified', 'contents'), - new Zend_Search_Lucene_Index_Term('unless', 'contents'), - new Zend_Search_Lucene_Index_Term('up', 'contents'), - new Zend_Search_Lucene_Index_Term('us', 'contents'), - new Zend_Search_Lucene_Index_Term('use', 'contents'), - new Zend_Search_Lucene_Index_Term('used', 'contents'), - new Zend_Search_Lucene_Index_Term('useful', 'contents'), - new Zend_Search_Lucene_Index_Term('usefulinc', 'contents'), - new Zend_Search_Lucene_Index_Term('userinput', 'contents'), - new Zend_Search_Lucene_Index_Term('users', 'contents'), - new Zend_Search_Lucene_Index_Term('using', 'contents'), - new Zend_Search_Lucene_Index_Term('usually', 'contents'), - new Zend_Search_Lucene_Index_Term('v', 'contents'), - new Zend_Search_Lucene_Index_Term('valign', 'contents'), - new Zend_Search_Lucene_Index_Term('verbose', 'contents'), - new Zend_Search_Lucene_Index_Term('version', 'contents'), - new Zend_Search_Lucene_Index_Term('versions', 'contents'), - new Zend_Search_Lucene_Index_Term('vlink', 'contents'), - new Zend_Search_Lucene_Index_Term('wallner', 'contents'), - new Zend_Search_Lucene_Index_Term('warranties', 'contents'), - new Zend_Search_Lucene_Index_Term('way', 'contents'), - new Zend_Search_Lucene_Index_Term('ways', 'contents'), - new Zend_Search_Lucene_Index_Term('we', 'contents'), - new Zend_Search_Lucene_Index_Term('webservices', 'contents'), - new Zend_Search_Lucene_Index_Term('welcome', 'contents'), - new Zend_Search_Lucene_Index_Term('what', 'contents'), - new Zend_Search_Lucene_Index_Term('when', 'contents'), - new Zend_Search_Lucene_Index_Term('whether', 'contents'), - new Zend_Search_Lucene_Index_Term('which', 'contents'), - new Zend_Search_Lucene_Index_Term('width', 'contents'), - new Zend_Search_Lucene_Index_Term('will', 'contents'), - new Zend_Search_Lucene_Index_Term('wish', 'contents'), - new Zend_Search_Lucene_Index_Term('wishlist', 'contents'), - new Zend_Search_Lucene_Index_Term('wishlists', 'contents'), - new Zend_Search_Lucene_Index_Term('with', 'contents'), - new Zend_Search_Lucene_Index_Term('without', 'contents'), - new Zend_Search_Lucene_Index_Term('won', 'contents'), - new Zend_Search_Lucene_Index_Term('work', 'contents'), - new Zend_Search_Lucene_Index_Term('would', 'contents'), - new Zend_Search_Lucene_Index_Term('write', 'contents'), - new Zend_Search_Lucene_Index_Term('writing', 'contents'), - new Zend_Search_Lucene_Index_Term('written', 'contents'), - new Zend_Search_Lucene_Index_Term('www', 'contents'), - new Zend_Search_Lucene_Index_Term('xml', 'contents'), - new Zend_Search_Lucene_Index_Term('xmlrpc', 'contents'), - new Zend_Search_Lucene_Index_Term('you', 'contents'), - new Zend_Search_Lucene_Index_Term('your', 'contents'), - new Zend_Search_Lucene_Index_Term('1178009946', 'modified'), - new Zend_Search_Lucene_Index_Term('about', 'path'), - new Zend_Search_Lucene_Index_Term('authors', 'path'), - new Zend_Search_Lucene_Index_Term('bugs', 'path'), - new Zend_Search_Lucene_Index_Term('contributing', 'path'), - new Zend_Search_Lucene_Index_Term('copyright', 'path'), - new Zend_Search_Lucene_Index_Term('core', 'path'), - new Zend_Search_Lucene_Index_Term('documentation', 'path'), - new Zend_Search_Lucene_Index_Term('html', 'path'), - new Zend_Search_Lucene_Index_Term('indexsource', 'path'), - new Zend_Search_Lucene_Index_Term('newpackage', 'path'), - new Zend_Search_Lucene_Index_Term('patches', 'path'), - new Zend_Search_Lucene_Index_Term('pear', 'path'), - new Zend_Search_Lucene_Index_Term('wishlist', 'path') - )); - - } -} - diff --git a/tests/Zend/Search/Lucene/Index/SegmentInfoTest.php b/tests/Zend/Search/Lucene/Index/SegmentInfoTest.php deleted file mode 100644 index 83bcff11b66f4970d4c3f3acb07609c436f9811c..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/SegmentInfoTest.php +++ /dev/null @@ -1,551 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Index_SegmentInfo - */ -require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_SegmentInfoTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertTrue($segmentInfo instanceof Zend_Search_Lucene_Index_SegmentInfo); - } - - public function testOpenCompoundFile() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $file1 = $segmentInfo->openCompoundFile('.fnm'); - $this->assertTrue($file1 instanceof Zend_Search_Lucene_Storage_File); - - $file2 = $segmentInfo->openCompoundFile('.tii'); - $file3 = $segmentInfo->openCompoundFile('.tii'); - $file4 = $segmentInfo->openCompoundFile('.tii', false); - - $this->assertTrue($file2 instanceof Zend_Search_Lucene_Storage_File); - $this->assertTrue($file2 === $file3); - $this->assertTrue($file4 instanceof Zend_Search_Lucene_Storage_File); - $this->assertTrue($file2 !== $file4); - } - - - public function testCompoundFileLength() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertEquals($segmentInfo->compoundFileLength('.tii'), 58); - } - - public function testGetFieldNum() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertEquals($segmentInfo->getFieldNum('contents'), 2); - $this->assertEquals($segmentInfo->getFieldNum('non-presented-field'), -1); - } - - public function testGetField() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $fieldInfo = $segmentInfo->getField(2); - - $this->assertEquals($fieldInfo->name, 'contents'); - $this->assertTrue((boolean)$fieldInfo->isIndexed); - $this->assertEquals($fieldInfo->number, 2); - $this->assertFalse((boolean)$fieldInfo->storeTermVector); - } - - public function testGetFields() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertTrue($segmentInfo->getFields() == array('path' => 'path', 'modified' => 'modified', 'contents' => 'contents')); - $this->assertTrue($segmentInfo->getFields(true) == array('path' => 'path', 'modified' => 'modified', 'contents' => 'contents')); - } - - public function testGetFieldInfos() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $fieldInfos = $segmentInfo->getFieldInfos(); - - $this->assertEquals($fieldInfos[0]->name, 'path'); - $this->assertTrue((boolean)$fieldInfos[0]->isIndexed); - $this->assertEquals($fieldInfos[0]->number, 0); - $this->assertFalse((boolean)$fieldInfos[0]->storeTermVector); - - $this->assertEquals($fieldInfos[1]->name, 'modified'); - $this->assertTrue((boolean)$fieldInfos[1]->isIndexed); - $this->assertEquals($fieldInfos[1]->number, 1); - $this->assertFalse((boolean)$fieldInfos[1]->storeTermVector); - - $this->assertEquals($fieldInfos[2]->name, 'contents'); - $this->assertTrue((boolean)$fieldInfos[2]->isIndexed); - $this->assertEquals($fieldInfos[2]->number, 2); - $this->assertFalse((boolean)$fieldInfos[2]->storeTermVector); - } - - public function testCount() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertEquals($segmentInfo->count(), 2); - } - - public function testNumDocs() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - - $this->assertEquals($segmentInfo->count(), 2); - $this->assertEquals($segmentInfo->numDocs(), 1); - } - - public function testGetName() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertEquals($segmentInfo->getName(), '_1'); - } - - public function testGetTermInfo() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $termInfo = $segmentInfo->getTermInfo(new Zend_Search_Lucene_Index_Term('apart', 'contents')); - - $this->assertEquals($termInfo->docFreq, 1); - $this->assertEquals($termInfo->freqPointer, 29); - $this->assertEquals($termInfo->proxPointer, 119); - $this->assertEquals($termInfo->skipOffset, 0); - $this->assertEquals($termInfo->indexPointer, null); - - $termInfo1 = $segmentInfo->getTermInfo(new Zend_Search_Lucene_Index_Term('apart', 'contents')); - // test for requesting cached information - $this->assertTrue($termInfo === $termInfo1); - - // request for non-existing term - $this->assertTrue($segmentInfo->getTermInfo(new Zend_Search_Lucene_Index_Term('nonusedterm', 'contents')) === null); - } - - public function testTermFreqs() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $termPositions = $segmentInfo->termFreqs(new Zend_Search_Lucene_Index_Term('bgcolor', 'contents')); - $this->assertTrue($termPositions == array(0 => 3, 1 => 1)); - - $termPositions = $segmentInfo->termFreqs(new Zend_Search_Lucene_Index_Term('bgcolor', 'contents'), 10); - $this->assertTrue($termPositions == array(10 => 3, 11 => 1)); - } - - public function testTermPositions() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $termPositions = $segmentInfo->termPositions(new Zend_Search_Lucene_Index_Term('bgcolor', 'contents')); - $this->assertTrue($termPositions == array(0 => array(69, 239, 370), - 1 => array(58) - )); - - $termPositions = $segmentInfo->termPositions(new Zend_Search_Lucene_Index_Term('bgcolor', 'contents'), 10); - $this->assertTrue($termPositions == array(10 => array(69, 239, 370), - 11 => array(58) - )); - } - - public function testNorm() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertTrue(abs($segmentInfo->norm(1, 'contents') - 0.0546875) < 0.000001); - } - - public function testNormVector() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - - $this->assertEquals($segmentInfo->normVector('contents'), "\x69\x6B"); - } - - public function testHasDeletions() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2); - $this->assertFalse($segmentInfo->hasDeletions()); - - $segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - $this->assertTrue($segmentInfo1->hasDeletions()); - } - - public function testDelete() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, 0 /* search for _1.del file */); - $this->assertFalse($segmentInfo->hasDeletions()); - - $segmentInfo->delete(0); - $this->assertTrue($segmentInfo->hasDeletions()); - $delGen = $segmentInfo->getDelGen(); - // don't write changes - unset($segmentInfo); - - $segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, $delGen); - // Changes wasn't written, segment still has no deletions - $this->assertFalse($segmentInfo1->hasDeletions()); - - $segmentInfo1->delete(0); - $segmentInfo1->writeChanges(); - $delGen = $segmentInfo1->getDelGen(); - unset($segmentInfo1); - - $segmentInfo2 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, $delGen); - $this->assertTrue($segmentInfo2->hasDeletions()); - unset($segmentInfo2); - - $directory->deleteFile('_1_' . base_convert($delGen, 10, 36) . '.del'); - - $segmentInfo3 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, -1 /* no detetions file */); - $this->assertFalse($segmentInfo3->hasDeletions()); - } - - public function testIsDeleted() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_2', 2); - $this->assertFalse($segmentInfo->isDeleted(0)); - - $segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - $this->assertTrue($segmentInfo1->isDeleted(0)); - $this->assertFalse($segmentInfo1->isDeleted(1)); - } - - public function testTermStreamStyleReading() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - - $this->assertEquals($segmentInfo->reset(6, Zend_Search_Lucene_Index_SegmentInfo::SM_FULL_INFO), 8); - - $terms = array(); - - $terms[] = $segmentInfo->currentTerm(); - $firstTermPositions = $segmentInfo->currentTermPositions(); - - $this->assertEquals(count($firstTermPositions), 1); - - reset($firstTermPositions); // go to the first element - $this->assertEquals(key($firstTermPositions), 7); - - $this->assertTrue(current($firstTermPositions) == - array(105, 113, 130, 138, 153, 168, 171, 216, 243, 253, 258, 265, 302, 324, - 331, 351, 359, 366, 370, 376, 402, 410, 418, 425, 433, 441, 460, 467)); - - while (($term = $segmentInfo->nextTerm()) != null) { - $terms[] = $term; - } - - $this->assertTrue($terms == - array(new Zend_Search_Lucene_Index_Term('a', 'contents'), - new Zend_Search_Lucene_Index_Term('about', 'contents'), - new Zend_Search_Lucene_Index_Term('accesskey', 'contents'), - new Zend_Search_Lucene_Index_Term('align', 'contents'), - new Zend_Search_Lucene_Index_Term('alink', 'contents'), - new Zend_Search_Lucene_Index_Term('already', 'contents'), - new Zend_Search_Lucene_Index_Term('and', 'contents'), - new Zend_Search_Lucene_Index_Term('are', 'contents'), - new Zend_Search_Lucene_Index_Term('at', 'contents'), - new Zend_Search_Lucene_Index_Term('b', 'contents'), - new Zend_Search_Lucene_Index_Term('be', 'contents'), - new Zend_Search_Lucene_Index_Term('been', 'contents'), - new Zend_Search_Lucene_Index_Term('bgcolor', 'contents'), - new Zend_Search_Lucene_Index_Term('body', 'contents'), - new Zend_Search_Lucene_Index_Term('border', 'contents'), - new Zend_Search_Lucene_Index_Term('bottom', 'contents'), - new Zend_Search_Lucene_Index_Term('bug', 'contents'), - new Zend_Search_Lucene_Index_Term('bugs', 'contents'), - new Zend_Search_Lucene_Index_Term('can', 'contents'), - new Zend_Search_Lucene_Index_Term('care', 'contents'), - new Zend_Search_Lucene_Index_Term('cellpadding', 'contents'), - new Zend_Search_Lucene_Index_Term('cellspacing', 'contents'), - new Zend_Search_Lucene_Index_Term('center', 'contents'), - new Zend_Search_Lucene_Index_Term('chapter', 'contents'), - new Zend_Search_Lucene_Index_Term('charset', 'contents'), - new Zend_Search_Lucene_Index_Term('check', 'contents'), - new Zend_Search_Lucene_Index_Term('class', 'contents'), - new Zend_Search_Lucene_Index_Term('click', 'contents'), - new Zend_Search_Lucene_Index_Term('colspan', 'contents'), - new Zend_Search_Lucene_Index_Term('contains', 'contents'), - new Zend_Search_Lucene_Index_Term('content', 'contents'), - new Zend_Search_Lucene_Index_Term('contributing', 'contents'), - new Zend_Search_Lucene_Index_Term('developers', 'contents'), - new Zend_Search_Lucene_Index_Term('div', 'contents'), - new Zend_Search_Lucene_Index_Term('docbook', 'contents'), - new Zend_Search_Lucene_Index_Term('documentation', 'contents'), - new Zend_Search_Lucene_Index_Term('does', 'contents'), - new Zend_Search_Lucene_Index_Term('don', 'contents'), - new Zend_Search_Lucene_Index_Term('double', 'contents'), - new Zend_Search_Lucene_Index_Term('easiest', 'contents'), - new Zend_Search_Lucene_Index_Term('equiv', 'contents'), - new Zend_Search_Lucene_Index_Term('existing', 'contents'), - new Zend_Search_Lucene_Index_Term('explanations', 'contents'), - new Zend_Search_Lucene_Index_Term('ff', 'contents'), - new Zend_Search_Lucene_Index_Term('ffffff', 'contents'), - new Zend_Search_Lucene_Index_Term('fill', 'contents'), - new Zend_Search_Lucene_Index_Term('find', 'contents'), - new Zend_Search_Lucene_Index_Term('fixed', 'contents'), - new Zend_Search_Lucene_Index_Term('footer', 'contents'), - new Zend_Search_Lucene_Index_Term('for', 'contents'), - new Zend_Search_Lucene_Index_Term('form', 'contents'), - new Zend_Search_Lucene_Index_Term('found', 'contents'), - new Zend_Search_Lucene_Index_Term('generator', 'contents'), - new Zend_Search_Lucene_Index_Term('guide', 'contents'), - new Zend_Search_Lucene_Index_Term('h', 'contents'), - new Zend_Search_Lucene_Index_Term('hasn', 'contents'), - new Zend_Search_Lucene_Index_Term('have', 'contents'), - new Zend_Search_Lucene_Index_Term('head', 'contents'), - new Zend_Search_Lucene_Index_Term('header', 'contents'), - new Zend_Search_Lucene_Index_Term('hesitate', 'contents'), - new Zend_Search_Lucene_Index_Term('home', 'contents'), - new Zend_Search_Lucene_Index_Term('homepage', 'contents'), - new Zend_Search_Lucene_Index_Term('how', 'contents'), - new Zend_Search_Lucene_Index_Term('hr', 'contents'), - new Zend_Search_Lucene_Index_Term('href', 'contents'), - new Zend_Search_Lucene_Index_Term('html', 'contents'), - new Zend_Search_Lucene_Index_Term('http', 'contents'), - new Zend_Search_Lucene_Index_Term('if', 'contents'), - new Zend_Search_Lucene_Index_Term('in', 'contents'), - new Zend_Search_Lucene_Index_Term('index', 'contents'), - new Zend_Search_Lucene_Index_Term('information', 'contents'), - new Zend_Search_Lucene_Index_Term('is', 'contents'), - new Zend_Search_Lucene_Index_Term('iso', 'contents'), - new Zend_Search_Lucene_Index_Term('it', 'contents'), - new Zend_Search_Lucene_Index_Term('latest', 'contents'), - new Zend_Search_Lucene_Index_Term('left', 'contents'), - new Zend_Search_Lucene_Index_Term('link', 'contents'), - new Zend_Search_Lucene_Index_Term('list', 'contents'), - new Zend_Search_Lucene_Index_Term('manual', 'contents'), - new Zend_Search_Lucene_Index_Term('meet', 'contents'), - new Zend_Search_Lucene_Index_Term('meta', 'contents'), - new Zend_Search_Lucene_Index_Term('modular', 'contents'), - new Zend_Search_Lucene_Index_Term('more', 'contents'), - new Zend_Search_Lucene_Index_Term('n', 'contents'), - new Zend_Search_Lucene_Index_Term('name', 'contents'), - new Zend_Search_Lucene_Index_Term('navfooter', 'contents'), - new Zend_Search_Lucene_Index_Term('navheader', 'contents'), - new Zend_Search_Lucene_Index_Term('navigation', 'contents'), - new Zend_Search_Lucene_Index_Term('net', 'contents'), - new Zend_Search_Lucene_Index_Term('new', 'contents'), - new Zend_Search_Lucene_Index_Term('newpackage', 'contents'), - new Zend_Search_Lucene_Index_Term('next', 'contents'), - new Zend_Search_Lucene_Index_Term('of', 'contents'), - new Zend_Search_Lucene_Index_Term('on', 'contents'), - new Zend_Search_Lucene_Index_Term('out', 'contents'), - new Zend_Search_Lucene_Index_Term('p', 'contents'), - new Zend_Search_Lucene_Index_Term('package', 'contents'), - new Zend_Search_Lucene_Index_Term('packages', 'contents'), - new Zend_Search_Lucene_Index_Term('page', 'contents'), - new Zend_Search_Lucene_Index_Term('patches', 'contents'), - new Zend_Search_Lucene_Index_Term('pear', 'contents'), - new Zend_Search_Lucene_Index_Term('persists', 'contents'), - new Zend_Search_Lucene_Index_Term('php', 'contents'), - new Zend_Search_Lucene_Index_Term('please', 'contents'), - new Zend_Search_Lucene_Index_Term('prev', 'contents'), - new Zend_Search_Lucene_Index_Term('previous', 'contents'), - new Zend_Search_Lucene_Index_Term('proper', 'contents'), - new Zend_Search_Lucene_Index_Term('quote', 'contents'), - new Zend_Search_Lucene_Index_Term('read', 'contents'), - new Zend_Search_Lucene_Index_Term('rel', 'contents'), - new Zend_Search_Lucene_Index_Term('report', 'contents'), - new Zend_Search_Lucene_Index_Term('reported', 'contents'), - new Zend_Search_Lucene_Index_Term('reporting', 'contents'), - new Zend_Search_Lucene_Index_Term('requirements', 'contents'), - new Zend_Search_Lucene_Index_Term('right', 'contents'), - new Zend_Search_Lucene_Index_Term('sect', 'contents'), - new Zend_Search_Lucene_Index_Term('span', 'contents'), - new Zend_Search_Lucene_Index_Term('still', 'contents'), - new Zend_Search_Lucene_Index_Term('stylesheet', 'contents'), - new Zend_Search_Lucene_Index_Term('submitting', 'contents'), - new Zend_Search_Lucene_Index_Term('summary', 'contents'), - new Zend_Search_Lucene_Index_Term('system', 'contents'), - new Zend_Search_Lucene_Index_Term('t', 'contents'), - new Zend_Search_Lucene_Index_Term('table', 'contents'), - new Zend_Search_Lucene_Index_Term('take', 'contents'), - new Zend_Search_Lucene_Index_Term('target', 'contents'), - new Zend_Search_Lucene_Index_Term('td', 'contents'), - new Zend_Search_Lucene_Index_Term('text', 'contents'), - new Zend_Search_Lucene_Index_Term('th', 'contents'), - new Zend_Search_Lucene_Index_Term('that', 'contents'), - new Zend_Search_Lucene_Index_Term('the', 'contents'), - new Zend_Search_Lucene_Index_Term('think', 'contents'), - new Zend_Search_Lucene_Index_Term('this', 'contents'), - new Zend_Search_Lucene_Index_Term('tips', 'contents'), - new Zend_Search_Lucene_Index_Term('title', 'contents'), - new Zend_Search_Lucene_Index_Term('to', 'contents'), - new Zend_Search_Lucene_Index_Term('top', 'contents'), - new Zend_Search_Lucene_Index_Term('tr', 'contents'), - new Zend_Search_Lucene_Index_Term('translating', 'contents'), - new Zend_Search_Lucene_Index_Term('type', 'contents'), - new Zend_Search_Lucene_Index_Term('u', 'contents'), - new Zend_Search_Lucene_Index_Term('unable', 'contents'), - new Zend_Search_Lucene_Index_Term('up', 'contents'), - new Zend_Search_Lucene_Index_Term('using', 'contents'), - new Zend_Search_Lucene_Index_Term('valign', 'contents'), - new Zend_Search_Lucene_Index_Term('version', 'contents'), - new Zend_Search_Lucene_Index_Term('vlink', 'contents'), - new Zend_Search_Lucene_Index_Term('way', 'contents'), - new Zend_Search_Lucene_Index_Term('which', 'contents'), - new Zend_Search_Lucene_Index_Term('width', 'contents'), - new Zend_Search_Lucene_Index_Term('will', 'contents'), - new Zend_Search_Lucene_Index_Term('with', 'contents'), - new Zend_Search_Lucene_Index_Term('writing', 'contents'), - new Zend_Search_Lucene_Index_Term('you', 'contents'), - new Zend_Search_Lucene_Index_Term('your', 'contents'), - new Zend_Search_Lucene_Index_Term('1178009946', 'modified'), - new Zend_Search_Lucene_Index_Term('bugs', 'path'), - new Zend_Search_Lucene_Index_Term('contributing', 'path'), - new Zend_Search_Lucene_Index_Term('html', 'path'), - new Zend_Search_Lucene_Index_Term('indexsource', 'path'), - new Zend_Search_Lucene_Index_Term('newpackage', 'path'), - )); - - unset($segmentInfo); - - - $segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - $this->assertEquals($segmentInfo1->reset(6, Zend_Search_Lucene_Index_SegmentInfo::SM_MERGE_INFO), 7); - } - - public function testTermStreamStyleReadingSkipTo() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - - $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - - $this->assertEquals($segmentInfo->reset(6, Zend_Search_Lucene_Index_SegmentInfo::SM_FULL_INFO), 8); - - $segmentInfo->skipTo(new Zend_Search_Lucene_Index_Term('prefetch', 'contents')); - - $terms = array(); - - $terms[] = $segmentInfo->currentTerm(); - $firstTermPositions = $segmentInfo->currentTermPositions(); - - $this->assertEquals(count($firstTermPositions), 1); - - reset($firstTermPositions); // go to the first element - $this->assertEquals(key($firstTermPositions), 7); - $this->assertTrue(current($firstTermPositions) == array(112, 409)); - - while (($term = $segmentInfo->nextTerm()) != null) { - $terms[] = $term; - } - - $this->assertTrue($terms == - array(new Zend_Search_Lucene_Index_Term('prev', 'contents'), - new Zend_Search_Lucene_Index_Term('previous', 'contents'), - new Zend_Search_Lucene_Index_Term('proper', 'contents'), - new Zend_Search_Lucene_Index_Term('quote', 'contents'), - new Zend_Search_Lucene_Index_Term('read', 'contents'), - new Zend_Search_Lucene_Index_Term('rel', 'contents'), - new Zend_Search_Lucene_Index_Term('report', 'contents'), - new Zend_Search_Lucene_Index_Term('reported', 'contents'), - new Zend_Search_Lucene_Index_Term('reporting', 'contents'), - new Zend_Search_Lucene_Index_Term('requirements', 'contents'), - new Zend_Search_Lucene_Index_Term('right', 'contents'), - new Zend_Search_Lucene_Index_Term('sect', 'contents'), - new Zend_Search_Lucene_Index_Term('span', 'contents'), - new Zend_Search_Lucene_Index_Term('still', 'contents'), - new Zend_Search_Lucene_Index_Term('stylesheet', 'contents'), - new Zend_Search_Lucene_Index_Term('submitting', 'contents'), - new Zend_Search_Lucene_Index_Term('summary', 'contents'), - new Zend_Search_Lucene_Index_Term('system', 'contents'), - new Zend_Search_Lucene_Index_Term('t', 'contents'), - new Zend_Search_Lucene_Index_Term('table', 'contents'), - new Zend_Search_Lucene_Index_Term('take', 'contents'), - new Zend_Search_Lucene_Index_Term('target', 'contents'), - new Zend_Search_Lucene_Index_Term('td', 'contents'), - new Zend_Search_Lucene_Index_Term('text', 'contents'), - new Zend_Search_Lucene_Index_Term('th', 'contents'), - new Zend_Search_Lucene_Index_Term('that', 'contents'), - new Zend_Search_Lucene_Index_Term('the', 'contents'), - new Zend_Search_Lucene_Index_Term('think', 'contents'), - new Zend_Search_Lucene_Index_Term('this', 'contents'), - new Zend_Search_Lucene_Index_Term('tips', 'contents'), - new Zend_Search_Lucene_Index_Term('title', 'contents'), - new Zend_Search_Lucene_Index_Term('to', 'contents'), - new Zend_Search_Lucene_Index_Term('top', 'contents'), - new Zend_Search_Lucene_Index_Term('tr', 'contents'), - new Zend_Search_Lucene_Index_Term('translating', 'contents'), - new Zend_Search_Lucene_Index_Term('type', 'contents'), - new Zend_Search_Lucene_Index_Term('u', 'contents'), - new Zend_Search_Lucene_Index_Term('unable', 'contents'), - new Zend_Search_Lucene_Index_Term('up', 'contents'), - new Zend_Search_Lucene_Index_Term('using', 'contents'), - new Zend_Search_Lucene_Index_Term('valign', 'contents'), - new Zend_Search_Lucene_Index_Term('version', 'contents'), - new Zend_Search_Lucene_Index_Term('vlink', 'contents'), - new Zend_Search_Lucene_Index_Term('way', 'contents'), - new Zend_Search_Lucene_Index_Term('which', 'contents'), - new Zend_Search_Lucene_Index_Term('width', 'contents'), - new Zend_Search_Lucene_Index_Term('will', 'contents'), - new Zend_Search_Lucene_Index_Term('with', 'contents'), - new Zend_Search_Lucene_Index_Term('writing', 'contents'), - new Zend_Search_Lucene_Index_Term('you', 'contents'), - new Zend_Search_Lucene_Index_Term('your', 'contents'), - new Zend_Search_Lucene_Index_Term('1178009946', 'modified'), - new Zend_Search_Lucene_Index_Term('bugs', 'path'), - new Zend_Search_Lucene_Index_Term('contributing', 'path'), - new Zend_Search_Lucene_Index_Term('html', 'path'), - new Zend_Search_Lucene_Index_Term('indexsource', 'path'), - new Zend_Search_Lucene_Index_Term('newpackage', 'path'), - )); - - unset($segmentInfo); - - - $segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_3', 2); - $this->assertEquals($segmentInfo1->reset(6, Zend_Search_Lucene_Index_SegmentInfo::SM_MERGE_INFO), 7); - } -} - diff --git a/tests/Zend/Search/Lucene/Index/SegmentMergerTest.php b/tests/Zend/Search/Lucene/Index/SegmentMergerTest.php deleted file mode 100644 index bbfdf6b3c4952f52dca0eb6467722749246b636d..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/SegmentMergerTest.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Storage_Directory_Filesystem - */ -require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php'; - -/** - * Zend_Search_Lucene_Index_SegmentInfo - */ -require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - - -/** - * Zend_Search_Lucene_Index_SegmentMerger - */ -require_once 'Zend/Search/Lucene/Index/SegmentMerger.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_SegmentMergerTest extends PHPUnit_Framework_TestCase -{ - public function testMerge() - { - $segmentsDirectory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files'); - $outputDirectory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_files'); - $segmentsList = array('_0', '_1', '_2', '_3', '_4'); - - $segmentMerger = new Zend_Search_Lucene_Index_SegmentMerger($outputDirectory, 'mergedSegment'); - - foreach ($segmentsList as $segmentName) { - $segmentMerger->addSource(new Zend_Search_Lucene_Index_SegmentInfo($segmentsDirectory, $segmentName, 2)); - } - - $mergedSegment = $segmentMerger->merge(); - $this->assertTrue($mergedSegment instanceof Zend_Search_Lucene_Index_SegmentInfo); - unset($mergedSegment); - - $mergedFile = $outputDirectory->getFileObject('mergedSegment.cfs'); - $mergedFileData = $mergedFile->readBytes($outputDirectory->fileLength('mergedSegment.cfs')); - - $sampleFile = $outputDirectory->getFileObject('mergedSegment.cfs.sample'); - $sampleFileData = $sampleFile->readBytes($outputDirectory->fileLength('mergedSegment.cfs.sample')); - - $this->assertEquals($mergedFileData, $sampleFileData); - - $outputDirectory->deleteFile('mergedSegment.cfs'); - } -} - diff --git a/tests/Zend/Search/Lucene/Index/TermInfoTest.php b/tests/Zend/Search/Lucene/Index/TermInfoTest.php deleted file mode 100644 index 7f6b812957ffa15e0aa2f5431c74ad058f3f5088..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/TermInfoTest.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Index_TermInfo - */ -require_once 'Zend/Search/Lucene/Index/TermInfo.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_TermInfoTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $termInfo = new Zend_Search_Lucene_Index_TermInfo(0, 1, 2, 3); - $this->assertTrue($termInfo instanceof Zend_Search_Lucene_Index_TermInfo); - - $this->assertEquals($termInfo->docFreq, 0); - $this->assertEquals($termInfo->freqPointer, 1); - $this->assertEquals($termInfo->proxPointer, 2); - $this->assertEquals($termInfo->skipOffset, 3); - $this->assertEquals($termInfo->indexPointer, null); - - $termInfo = new Zend_Search_Lucene_Index_TermInfo(0, 1, 2, 3, 4); - $this->assertEquals($termInfo->indexPointer, 4); - } -} - diff --git a/tests/Zend/Search/Lucene/Index/TermTest.php b/tests/Zend/Search/Lucene/Index/TermTest.php deleted file mode 100644 index 3d0cc05a8090a73583bacc0db50693107d08faec..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/TermTest.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Index_Term - */ -require_once 'Zend/Search/Lucene/Index/Term.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Index_TermTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $term = new Zend_Search_Lucene_Index_Term('term_text'); - $this->assertTrue($term instanceof Zend_Search_Lucene_Index_Term); - - $this->assertEquals($term->text, 'term_text'); - $this->assertEquals($term->field, null); - - $term = new Zend_Search_Lucene_Index_Term('term_text', 'field_name'); - $this->assertEquals($term->text, 'term_text'); - $this->assertEquals($term->field, 'field_name'); - } - - public function testKey() - { - $term1_1 = new Zend_Search_Lucene_Index_Term('term_text1', 'field_name1'); - $term2_1 = new Zend_Search_Lucene_Index_Term('term_text2', 'field_name1'); - $term2_2 = new Zend_Search_Lucene_Index_Term('term_text2', 'field_name2'); - $term2_1Dup = new Zend_Search_Lucene_Index_Term('term_text2', 'field_name1'); - - $this->assertEquals($term1_1->text > $term2_1->text, $term1_1->key() > $term2_1->key()); - $this->assertEquals($term1_1->text >= $term2_1->text, $term1_1->key() >= $term2_1->key()); - - $this->assertEquals($term1_1->field > $term2_2->field, $term1_1->key() > $term2_2->key()); - $this->assertEquals($term1_1->field >= $term2_2->field, $term1_1->key() >= $term2_2->key()); - - $this->assertEquals($term2_1->key(), $term2_1Dup->key()); - } - - public function testGetPrefix() - { - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('term_text', 10), 'term_text'); - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('term_text', 9), 'term_text'); - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('term_text', 4), 'term'); - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('term_text', 0), ''); - } - - public function testGetPrefixUtf8() - { - // UTF-8 string with non-ascii symbols (Russian alphabet) - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('абвгдеёжзийклмнопрÑтуфхцчшщьыъÑÑŽÑ', 64), 'абвгдеёжзийклмнопрÑтуфхцчшщьыъÑÑŽÑ'); - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('абвгдеёжзийклмнопрÑтуфхцчшщьыъÑÑŽÑ', 33), 'абвгдеёжзийклмнопрÑтуфхцчшщьыъÑÑŽÑ'); - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('абвгдеёжзийклмнопрÑтуфхцчшщьыъÑÑŽÑ', 4), 'абвг'); - $this->assertEquals(Zend_Search_Lucene_Index_Term::getPrefix('абвгдеёжзийклмнопрÑтуфхцчшщьыъÑÑŽÑ', 0), ''); - - - - } -} - diff --git a/tests/Zend/Search/Lucene/Index/_files/mergedSegment.cfs.sample b/tests/Zend/Search/Lucene/Index/_files/mergedSegment.cfs.sample deleted file mode 100644 index e75828a2fca7602f01be3ab4402f1843c1547e8c..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_files/mergedSegment.cfs.sample and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_0.cfs b/tests/Zend/Search/Lucene/Index/_source/_files/_0.cfs deleted file mode 100644 index 6ec3d076b26dd50d220271da74c22b9b321ee7fc..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/_0.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_1.cfs b/tests/Zend/Search/Lucene/Index/_source/_files/_1.cfs deleted file mode 100644 index 99e466752288c56e84fb350c6cef9b3d95399ab7..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/_1.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_1.sti b/tests/Zend/Search/Lucene/Index/_source/_files/_1.sti deleted file mode 100644 index 1e455fb5d367278a8f5e9115e61ee1b07d7439f0..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Index/_source/_files/_1.sti +++ /dev/null @@ -1 +0,0 @@ -a:2:{i:0;a:3:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}i:1;a:2:{i:0;i:2;i:1;s:4:"head";}i:2;a:2:{i:0;i:2;i:1;s:3:"toc";}}i:1;a:3:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:20;}i:1;a:5:{i:0;i:2;i:1;i:224;i:2;i:572;i:3;i:0;i:4;i:1259;}i:2;a:5:{i:0;i:1;i:1;i:485;i:2;i:1239;i:3;i:0;i:4;i:2471;}}} \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_2.cfs b/tests/Zend/Search/Lucene/Index/_source/_files/_2.cfs deleted file mode 100644 index 3756c3f2715dec510f3e375de016faef31e78bfa..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/_2.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_3.cfs b/tests/Zend/Search/Lucene/Index/_source/_files/_3.cfs deleted file mode 100644 index aa6b9d8dd7f516e2468981c91186fd1a30a1f98e..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/_3.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_3.del b/tests/Zend/Search/Lucene/Index/_source/_files/_3.del deleted file mode 100644 index f9f8fea01bd11a193bd9b33b6dfe6d609a6b46fe..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/_3.del and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/_4.cfs b/tests/Zend/Search/Lucene/Index/_source/_files/_4.cfs deleted file mode 100644 index 5d882b5cf13f9fffe2edb05599e8f627cf5a9e7c..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/_4.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/deletable b/tests/Zend/Search/Lucene/Index/_source/_files/deletable deleted file mode 100644 index 593f4708db84ac8fd0f5cc47c634f38c013fe9e4..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/deletable and /dev/null differ diff --git a/tests/Zend/Search/Lucene/Index/_source/_files/segments b/tests/Zend/Search/Lucene/Index/_source/_files/segments deleted file mode 100644 index 575bdadb3d0da4a28e32d37d420a1edf4696f1e3..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Index/_source/_files/segments and /dev/null differ diff --git a/tests/Zend/Search/Lucene/LuceneTest.php b/tests/Zend/Search/Lucene/LuceneTest.php deleted file mode 100644 index 3173d13877550a2244a265ab5a7e9de712440b07..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/LuceneTest.php +++ /dev/null @@ -1,487 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene - */ -require_once 'Zend/Search/Lucene.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_LuceneTest extends PHPUnit_Framework_TestCase -{ - private function _clearDirectory($dirName) - { - // remove files from temporary direcytory - $dir = opendir($dirName); - while (($file = readdir($dir)) !== false) { - if (!is_dir($dirName . '/' . $file)) { - @unlink($dirName . '/' . $file); - } - } - closedir($dir); - } - - public function testCreate() - { - $index = Zend_Search_Lucene::create(dirname(__FILE__) . '/_index/_files'); - - $this->assertTrue($index instanceof Zend_Search_Lucene_Interface); - - $this->_clearDirectory(dirname(__FILE__) . '/_index/_files'); - } - - public function testOpen() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue($index instanceof Zend_Search_Lucene_Interface); - } - - public function testOpenNonCompound() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_nonCompoundIndexFiles'); - - $this->assertTrue($index instanceof Zend_Search_Lucene_Interface); - } - - public function testDefaultSearchField() - { - $currentDefaultSearchField = Zend_Search_Lucene::getDefaultSearchField(); - $this->assertEquals($currentDefaultSearchField, null); - - Zend_Search_Lucene::setDefaultSearchField('anotherField'); - $this->assertEquals(Zend_Search_Lucene::getDefaultSearchField(), 'anotherField'); - - Zend_Search_Lucene::setDefaultSearchField($currentDefaultSearchField); - } - - public function testCount() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertEquals($index->count(), 10); - } - - public function testMaxDoc() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertEquals($index->maxDoc(), 10); - } - - public function testNumDocs() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertEquals($index->numDocs(), 9); - } - - public function testIsDeleted() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertFalse($index->isDeleted(3)); - $this->assertTrue($index->isDeleted(6)); - } - - public function testMaxBufferedDocs() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $currentMaxBufferedDocs = $index->getMaxBufferedDocs(); - - $index->setMaxBufferedDocs(234); - $this->assertEquals($index->getMaxBufferedDocs(), 234); - - $index->setMaxBufferedDocs($currentMaxBufferedDocs); - } - - public function testMaxMergeDocs() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $currentMaxMergeDocs = $index->getMaxMergeDocs(); - - $index->setMaxMergeDocs(34); - $this->assertEquals($index->getMaxMergeDocs(), 34); - - $index->setMaxMergeDocs($currentMaxMergeDocs); - } - - public function testMergeFactor() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $currentMergeFactor = $index->getMergeFactor(); - - $index->setMergeFactor(113); - $this->assertEquals($index->getMergeFactor(), 113); - - $index->setMergeFactor($currentMergeFactor); - } - - public function testFind() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('submitting'); - $this->assertEquals(count($hits), 3); - } - - public function testGetFieldNames() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue(array_values($index->getFieldNames()) == array('path', 'modified', 'contents')); - } - - public function testGetDocument() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $doc = $index->getDocument(3); - - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document); - $this->assertEquals($doc->path, 'IndexSource/about-pear.html'); - } - - public function testHasTerm() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue($index->hasTerm(new Zend_Search_Lucene_Index_Term('packages', 'contents'))); - $this->assertFalse($index->hasTerm(new Zend_Search_Lucene_Index_Term('nonusedword', 'contents'))); - } - - public function testTermDocs() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue(array_values( $index->termDocs(new Zend_Search_Lucene_Index_Term('packages', 'contents')) ) == - array(0, 2, 6, 7, 8)); - } - - public function testTermPositions() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue($index->termPositions(new Zend_Search_Lucene_Index_Term('packages', 'contents')) == - array(0 => array(174), - 2 => array(40, 742), - 6 => array(6, 156, 163), - 7 => array(194), - 8 => array(55, 190, 405))); - } - - public function testDocFreq() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertEquals($index->docFreq(new Zend_Search_Lucene_Index_Term('packages', 'contents')), 5); - } - - public function testGetSimilarity() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue($index->getSimilarity() instanceof Zend_Search_Lucene_Search_Similarity); - } - - public function testNorm() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue(abs($index->norm(3, 'contents') - 0.054688) < 0.000001); - } - - public function testHasDeletions() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertTrue($index->hasDeletions()); - } - - public function testDelete() - { - // Copy index sample into _files directory - $sampleIndexDir = dirname(__FILE__) . '/_indexSample/_files'; - $tempIndexDir = dirname(__FILE__) . '/_files'; - - $this->_clearDirectory($tempIndexDir); - - $indexDir = opendir($sampleIndexDir); - while (($file = readdir($indexDir)) !== false) { - if (!is_dir($sampleIndexDir . '/' . $file)) { - copy($sampleIndexDir . '/' . $file, $tempIndexDir . '/' . $file); - } - } - closedir($indexDir); - - - $index = Zend_Search_Lucene::open($tempIndexDir); - - $this->assertFalse($index->isDeleted(2)); - $index->delete(2); - $this->assertTrue($index->isDeleted(2)); - - $index->commit(); - - unset($index); - - $index1 = Zend_Search_Lucene::open($tempIndexDir); - $this->assertTrue($index1->isDeleted(2)); - unset($index1); - - $this->_clearDirectory($tempIndexDir); - } - - public function testAddDocument() - { - $index = Zend_Search_Lucene::create(dirname(__FILE__) . '/_index/_files'); - - $indexSourceDir = dirname(__FILE__) . '/_indexSource/_files'; - $dir = opendir($indexSourceDir); - while (($file = readdir($dir)) !== false) { - if (is_dir($indexSourceDir . '/' . $file)) { - continue; - } - if (strcasecmp(substr($file, strlen($file)-5), '.html') != 0) { - continue; - } - - // Create new Document from a file - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::Text('path', 'IndexSource/' . $file)); - $doc->addField(Zend_Search_Lucene_Field::Keyword( 'modified', filemtime($indexSourceDir . '/' . $file) )); - - $f = fopen($indexSourceDir . '/' . $file,'rb'); - $byteCount = filesize($indexSourceDir . '/' . $file); - - $data = ''; - while ( $byteCount > 0 && ($nextBlock = fread($f, $byteCount)) != false ) { - $data .= $nextBlock; - $byteCount -= strlen($nextBlock); - } - fclose($f); - - $doc->addField(Zend_Search_Lucene_Field::Text('contents', $data, 'ISO-8859-1')); - - // Add document to the index - $index->addDocument($doc); - } - closedir($dir); - - unset($index); - - $index1 = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index/_files'); - $this->assertTrue($index1 instanceof Zend_Search_Lucene_Interface); - - $this->_clearDirectory(dirname(__FILE__) . '/_index/_files'); - } - - public function testOptimize() - { - $index = Zend_Search_Lucene::create(dirname(__FILE__) . '/_index/_files'); - - $index->setMaxBufferedDocs(2); - - $indexSourceDir = dirname(__FILE__) . '/_indexSource/_files'; - $dir = opendir($indexSourceDir); - while (($file = readdir($dir)) !== false) { - if (is_dir($indexSourceDir . '/' . $file)) { - continue; - } - if (strcasecmp(substr($file, strlen($file)-5), '.html') != 0) { - continue; - } - - // Create new Document from a file - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::Keyword('path', 'IndexSource/' . $file)); - $doc->addField(Zend_Search_Lucene_Field::Keyword( 'modified', filemtime($indexSourceDir . '/' . $file) )); - - $f = fopen($indexSourceDir . '/' . $file,'rb'); - $byteCount = filesize($indexSourceDir . '/' . $file); - - $data = ''; - while ( $byteCount > 0 && ($nextBlock = fread($f, $byteCount)) != false ) { - $data .= $nextBlock; - $byteCount -= strlen($nextBlock); - } - fclose($f); - - $doc->addField(Zend_Search_Lucene_Field::Text('contents', $data, 'ISO-8859-1')); - - // Add document to the index - $index->addDocument($doc); - } - closedir($dir); - unset($index); - - $index1 = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index/_files'); - $this->assertTrue($index1 instanceof Zend_Search_Lucene_Interface); - $pathTerm = new Zend_Search_Lucene_Index_Term('IndexSource/contributing.html', 'path'); - $contributingDocs = $index1->termDocs($pathTerm); - foreach ($contributingDocs as $id) { - $index1->delete($id); - } - $index1->optimize(); - unset($index1); - - $index2 = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index/_files'); - $this->assertTrue($index2 instanceof Zend_Search_Lucene_Interface); - - $hits = $index2->find('submitting'); - $this->assertEquals(count($hits), 3); - - $this->_clearDirectory(dirname(__FILE__) . '/_index/_files'); - } - - public function testTerms() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertEquals(count($index->terms()), 607); - } - - public function testTermsStreamInterface() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $terms = array(); - - $index->resetTermsStream(); - while ($index->currentTerm() !== null) { - $terms[] = $index->currentTerm(); - $index->nextTerm(); - } - - $this->assertEquals(count($terms), 607); - } - - public function testTermsStreamInterfaceSkipTo() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $terms = array(); - - $index->resetTermsStream(); - $index->skipTo(new Zend_Search_Lucene_Index_Term('one', 'contents')); - - while ($index->currentTerm() !== null) { - $terms[] = $index->currentTerm(); - $index->nextTerm(); - } - - $this->assertEquals(count($terms), 244); - } - - public function testTermsStreamInterfaceSkipToTermsRetrieving() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $terms = array(); - - $index->resetTermsStream(); - $index->skipTo(new Zend_Search_Lucene_Index_Term('one', 'contents')); - - $terms[] = $index->currentTerm(); - $terms[] = $index->nextTerm(); - $terms[] = $index->nextTerm(); - - $index->closeTermsStream(); - - $this->assertTrue($terms == - array(new Zend_Search_Lucene_Index_Term('one', 'contents'), - new Zend_Search_Lucene_Index_Term('only', 'contents'), - new Zend_Search_Lucene_Index_Term('open', 'contents'), - )); - } - - public function testTermsStreamInterfaceSkipToTermsRetrievingZeroTermsCase() - { - $index = Zend_Search_Lucene::create(dirname(__FILE__) . '/_index/_files'); - - // Zero terms - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::Text('contents', '')); - $index->addDocument($doc); - - unset($index); - - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index/_files'); - - $index->resetTermsStream(); - $index->skipTo(new Zend_Search_Lucene_Index_Term('term', 'contents')); - - $this->assertTrue($index->currentTerm() === null); - - $index->closeTermsStream(); - - $this->_clearDirectory(dirname(__FILE__) . '/_index/_files'); - } - - public function testTermsStreamInterfaceSkipToTermsRetrievingOneTermsCase() - { - $index = Zend_Search_Lucene::create(dirname(__FILE__) . '/_index/_files'); - - // Zero terms - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::Text('contents', 'someterm')); - $index->addDocument($doc); - - unset($index); - - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index/_files'); - - $index->resetTermsStream(); - $index->skipTo(new Zend_Search_Lucene_Index_Term('term', 'contents')); - - $this->assertTrue($index->currentTerm() === null); - - $index->closeTermsStream(); - - $this->_clearDirectory(dirname(__FILE__) . '/_index/_files'); - } - - public function testTermsStreamInterfaceSkipToTermsRetrievingTwoTermsCase() - { - $index = Zend_Search_Lucene::create(dirname(__FILE__) . '/_index/_files'); - - // Zero terms - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::Text('contents', 'someterm word')); - $index->addDocument($doc); - - unset($index); - - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index/_files'); - - $index->resetTermsStream(); - $index->skipTo(new Zend_Search_Lucene_Index_Term('term', 'contents')); - - $this->assertTrue($index->currentTerm() == new Zend_Search_Lucene_Index_Term('word', 'contents')); - - $index->closeTermsStream(); - - $this->_clearDirectory(dirname(__FILE__) . '/_index/_files'); - } -} diff --git a/tests/Zend/Search/Lucene/PriorityQueueTest.php b/tests/Zend/Search/Lucene/PriorityQueueTest.php deleted file mode 100644 index 70219c5519788258d98a9d64d8cd9437710ec0be..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/PriorityQueueTest.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_PriorityQueue - */ -require_once 'Zend/Search/Lucene/PriorityQueue.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_PriorityQueueTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $queue = new Zend_Search_Lucene_PriorityQueue_testClass(); - - $this->assertTrue($queue instanceof Zend_Search_Lucene_PriorityQueue); - } - - public function testPut() - { - $queue = new Zend_Search_Lucene_PriorityQueue_testClass(); - - $queue->put(1); - $queue->put(100); - $queue->put(46); - $queue->put(347); - $queue->put(11); - $queue->put(125); - $queue->put(-10); - $queue->put(100); - } - - public function testPop() - { - $queue = new Zend_Search_Lucene_PriorityQueue_testClass(); - - $queue->put( 1); - $queue->put( 100); - $queue->put( 46); - $queue->put( 347); - $queue->put( 11); - $queue->put( 125); - $queue->put(-10); - $queue->put( 100); - - $this->assertEquals($queue->pop(), -10); - $this->assertEquals($queue->pop(), 1 ); - $this->assertEquals($queue->pop(), 11 ); - $this->assertEquals($queue->pop(), 46 ); - $this->assertEquals($queue->pop(), 100); - $this->assertEquals($queue->pop(), 100); - $this->assertEquals($queue->pop(), 125); - - $queue->put( 144); - $queue->put( 546); - $queue->put( 15); - $queue->put( 125); - $queue->put( 325); - $queue->put(-12); - $queue->put( 347); - - $this->assertEquals($queue->pop(), -12); - $this->assertEquals($queue->pop(), 15 ); - $this->assertEquals($queue->pop(), 125); - $this->assertEquals($queue->pop(), 144); - $this->assertEquals($queue->pop(), 325); - $this->assertEquals($queue->pop(), 347); - $this->assertEquals($queue->pop(), 347); - $this->assertEquals($queue->pop(), 546); - } - - public function testClear() - { - $queue = new Zend_Search_Lucene_PriorityQueue_testClass(); - - $queue->put( 1); - $queue->put( 100); - $queue->put( 46); - $queue->put(-10); - $queue->put( 100); - - $this->assertEquals($queue->pop(), -10); - $this->assertEquals($queue->pop(), 1 ); - $this->assertEquals($queue->pop(), 46 ); - - $queue->clear(); - $this->assertEquals($queue->pop(), null); - - $queue->put( 144); - $queue->put( 546); - $queue->put( 15); - - $this->assertEquals($queue->pop(), 15 ); - $this->assertEquals($queue->pop(), 144); - $this->assertEquals($queue->pop(), 546); - } -} - - -class Zend_Search_Lucene_PriorityQueue_testClass extends Zend_Search_Lucene_PriorityQueue -{ - /** - * Compare elements - * - * Returns true, if $el1 is less than $el2; else otherwise - * - * @param mixed $el1 - * @param mixed $el2 - * @return boolean - */ - protected function _less($el1, $el2) - { - return ($el1 < $el2); - } -} diff --git a/tests/Zend/Search/Lucene/Search23Test.php b/tests/Zend/Search/Lucene/Search23Test.php deleted file mode 100755 index 44e50e50927ccc9b246a28185e936531278f5937..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Search23Test.php +++ /dev/null @@ -1,460 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene - */ -require_once 'Zend/Search/Lucene.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Search23Test extends PHPUnit_Framework_TestCase -{ - public function testQueryParser() - { - $queries = array('title:"The Right Way" AND text:go', - 'title:"Do it right" AND right', - 'title:Do it right', - 'te?t', - 'test*', - 'te*t', - '?Ma*', - // 'te?t~20^0.8', - 'test~', - 'test~0.4', - '"jakarta apache"~10', - 'contents:[business TO by]', - '{wish TO zzz}', - 'jakarta apache', - 'jakarta^4 apache', - '"jakarta apache"^4 "Apache Lucene"', - '"jakarta apache" jakarta', - '"jakarta apache" OR jakarta', - '"jakarta apache" || jakarta', - '"jakarta apache" AND "Apache Lucene"', - '"jakarta apache" && "Apache Lucene"', - '+jakarta apache', - '"jakarta apache" AND NOT "Apache Lucene"', - '"jakarta apache" && !"Apache Lucene"', - '\\ ', - 'NOT "jakarta apache"', - '!"jakarta apache"', - '"jakarta apache" -"Apache Lucene"', - '(jakarta OR apache) AND website', - '(jakarta || apache) && website', - 'title:(+return +"pink panther")', - 'title:(+re\\turn\\ value +"pink panther\\"" +body:cool)', - '+contents:apache +type:1 +id:5', - 'contents:apache AND type:1 AND id:5', - 'f1:word1 f1:word2 and f1:word3', - 'f1:word1 not f1:word2 and f1:word3' - ); - - $rewritedQueries = array('+(title:"the right way") +(text:go)', - '+(title:"do it right") +(path:right modified:right contents:right)', - '(title:do) (path:it modified:it contents:it) (path:right modified:right contents:right)', - '(contents:test contents:text)', - '(contents:test contents:tested)', - '(contents:test contents:text)', - '(contents:amazon contents:email)', - // .... - '((contents:test) (contents:text)^0.5)', - '((contents:test) (contents:text)^0.5833 (contents:latest)^0.1667 (contents:left)^0.1667 (contents:list)^0.1667 (contents:meet)^0.1667 (contents:must)^0.1667 (contents:next)^0.1667 (contents:post)^0.1667 (contents:sect)^0.1667 (contents:task)^0.1667 (contents:tested)^0.1667 (contents:that)^0.1667 (contents:tort)^0.1667)', - '((path:"jakarta apache"~10) (modified:"jakarta apache"~10) (contents:"jakarta apache"~10))', - '(contents:business contents:but contents:buy contents:buying contents:by)', - '(path:wishlist contents:wishlist contents:wishlists contents:with contents:without contents:won contents:work contents:would contents:write contents:writing contents:written contents:www contents:xml contents:xmlrpc contents:you contents:your)', - '(path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)', - '((path:jakarta modified:jakarta contents:jakarta)^4)^4 (path:apache modified:apache contents:apache)', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache"))^4 ((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) +((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) +((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+(path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '(<InsignificantQuery>)', - '<InsignificantQuery>', - '<InsignificantQuery>', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+((path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)) +(path:website modified:website contents:website)', - '+((path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)) +(path:website modified:website contents:website)', - '(+(title:return) +(title:"pink panther"))', - '(+(+title:return +title:value) +(title:"pink panther") +(body:cool))', - '+(contents:apache) +(<InsignificantQuery>) +(<InsignificantQuery>)', - '+(contents:apache) +(<InsignificantQuery>) +(<InsignificantQuery>)', - '(f1:word) (+(f1:word) +(f1:word))', - '(f1:word) (-(f1:word) +(f1:word))'); - - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - foreach ($queries as $id => $queryString) { - $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString); - - $this->assertTrue($query instanceof Zend_Search_Lucene_Search_Query); - - $this->assertEquals($query->rewrite($index)->__toString(), $rewritedQueries[$id]); - } - } - - public function testQueryParserExceptionsHandling() - { - $this->assertTrue(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()); - - try { - $query = Zend_Search_Lucene_Search_QueryParser::parse('contents:[business TO by}'); - } catch (Zend_Search_Lucene_Exception $e) { - $this->fail('exception raised while parsing a query'); - } - - $this->assertEquals('contents business to by', $query->__toString()); - - Zend_Search_Lucene_Search_QueryParser::dontSuppressQueryParsingExceptions(); - $this->assertFalse(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()); - - try { - $query = Zend_Search_Lucene_Search_QueryParser::parse('contents:[business TO by}'); - - $this->fail('exception wasn\'t raised while parsing a query'); - } catch (Zend_Search_Lucene_Exception $e) { - $this->assertEquals('Syntax error at char position 25.', $e->getMessage()); - } - - - Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions(); - $this->assertTrue(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()); - } - - public function testEmptyQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find(''); - - $this->assertEquals(count($hits), 0); - } - - public function testTermQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('submitting'); - - $this->assertEquals(count($hits), 3); - $expectedResultset = array(array(2, 0.114555, 'IndexSource/contributing.patches.html'), - array(7, 0.112241, 'IndexSource/contributing.bugs.html'), - array(8, 0.112241, 'IndexSource/contributing.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testMultiTermQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('submitting AND wishlists'); - - $this->assertEquals(count($hits), 1); - - $this->assertEquals($hits[0]->id, 8); - $this->assertTrue( abs($hits[0]->score - 0.141633) < 0.000001 ); - $this->assertEquals($hits[0]->path, 'IndexSource/contributing.html'); - } - - public function testPraseQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('"reporting bugs"'); - - $this->assertEquals(count($hits), 4); - $expectedResultset = array(array(0, 0.247795, 'IndexSource/contributing.documentation.html'), - array(7, 0.212395, 'IndexSource/contributing.bugs.html'), - array(8, 0.212395, 'IndexSource/contributing.html'), - array(2, 0.176996, 'IndexSource/contributing.patches.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testBooleanQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('submitting AND (wishlists OR requirements)'); - - $this->assertEquals(count($hits), 2); - $expectedResultset = array(array(7, 0.095697, 'IndexSource/contributing.bugs.html'), - array(8, 0.075573, 'IndexSource/contributing.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testBooleanQueryWithPhraseSubquery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('"PEAR developers" AND Home'); - - $this->assertEquals(count($hits), 1); - $expectedResultset = array(array(1, 0.168270, 'IndexSource/contributing.wishlist.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testBooleanQueryWithNonExistingPhraseSubquery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $query = Zend_Search_Lucene_Search_QueryParser::parse('"non-existing phrase" AND Home'); - - $this->assertEquals($query->__toString(), '+("non existing phrase") +(home)'); - $this->assertEquals($query->rewrite($index)->__toString(), - '+((path:"non existing phrase") (modified:"non existing phrase") (contents:"non existing phrase")) +(path:home modified:home contents:home)'); - $this->assertEquals($query->rewrite($index)->optimize($index)->__toString(), '<EmptyQuery>'); - } - - public function testFilteredTokensQueryParserProcessing() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $this->assertEquals(count(Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize('123456787654321')), 0); - - - $hits = $index->find('"PEAR developers" AND Home AND 123456787654321'); - - $this->assertEquals(count($hits), 1); - $expectedResultset = array(array(1, 0.168270, 'IndexSource/contributing.wishlist.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testWildcardQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('*cont*'); - - $this->assertEquals(count($hits), 9); - $expectedResultset = array(array(8, 0.125253, 'IndexSource/contributing.html'), - array(4, 0.112122, 'IndexSource/copyright.html'), - array(2, 0.108491, 'IndexSource/contributing.patches.html'), - array(7, 0.077716, 'IndexSource/contributing.bugs.html'), - array(0, 0.050760, 'IndexSource/contributing.documentation.html'), - array(1, 0.049163, 'IndexSource/contributing.wishlist.html'), - array(3, 0.036159, 'IndexSource/about-pear.html'), - array(5, 0.021500, 'IndexSource/authors.html'), - array(9, 0.007422, 'IndexSource/core.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testFuzzyQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('tesd~0.4'); - - $this->assertEquals(count($hits), 9); - $expectedResultset = array(array(2, 0.037139, 'IndexSource/contributing.patches.html'), - array(0, 0.008735, 'IndexSource/contributing.documentation.html'), - array(7, 0.002449, 'IndexSource/contributing.bugs.html'), - array(1, 0.000483, 'IndexSource/contributing.wishlist.html'), - array(3, 0.000483, 'IndexSource/about-pear.html'), - array(9, 0.000483, 'IndexSource/core.html'), - array(5, 0.000414, 'IndexSource/authors.html'), - array(8, 0.000414, 'IndexSource/contributing.html'), - array(4, 0.000345, 'IndexSource/copyright.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testInclusiveRangeQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('[xml TO zzzzz]'); - - $this->assertEquals(count($hits), 5); - $expectedResultset = array(array(4, 0.156366, 'IndexSource/copyright.html'), - array(2, 0.080458, 'IndexSource/contributing.patches.html'), - array(7, 0.060214, 'IndexSource/contributing.bugs.html'), - array(1, 0.009687, 'IndexSource/contributing.wishlist.html'), - array(5, 0.005871, 'IndexSource/authors.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testNonInclusiveRangeQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('{xml TO zzzzz}'); - - $this->assertEquals(count($hits), 5); - $expectedResultset = array(array(2, 0.1308671, 'IndexSource/contributing.patches.html'), - array(7, 0.0979391, 'IndexSource/contributing.bugs.html'), - array(4, 0.0633930, 'IndexSource/copyright.html'), - array(1, 0.0157556, 'IndexSource/contributing.wishlist.html'), - array(5, 0.0095493, 'IndexSource/authors.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testDefaultSearchField() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $storedDefaultSearchField = Zend_Search_Lucene::getDefaultSearchField(); - - Zend_Search_Lucene::setDefaultSearchField('path'); - $hits = $index->find('contributing'); - - $this->assertEquals(count($hits), 5); - $expectedResultset = array(array(8, 0.847922, 'IndexSource/contributing.html'), - array(0, 0.678337, 'IndexSource/contributing.documentation.html'), - array(1, 0.678337, 'IndexSource/contributing.wishlist.html'), - array(2, 0.678337, 'IndexSource/contributing.patches.html'), - array(7, 0.678337, 'IndexSource/contributing.bugs.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - - Zend_Search_Lucene::setDefaultSearchField($storedDefaultSearchField); - } - - public function testQueryHit() - { - // Restore default search field if it wasn't done by previous test because of failure - Zend_Search_Lucene::setDefaultSearchField(null); - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('submitting AND wishlists'); - $hit = $hits[0]; - - - $this->assertTrue($hit instanceof Zend_Search_Lucene_Search_QueryHit); - $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface); - - $doc = $hit->getDocument(); - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document); - - $this->assertEquals($doc->path, 'IndexSource/contributing.html'); - } - - public function testDelayedResourceCleanUp() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('submitting AND wishlists'); - unset($index); - - $hit = $hits[0]; - $this->assertTrue($hit instanceof Zend_Search_Lucene_Search_QueryHit); - $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface); - - $doc = $hit->getDocument(); - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document); - $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface); - - $this->assertEquals($doc->path, 'IndexSource/contributing.html'); - } - - public function testSortingResult() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $hits = $index->find('"reporting bugs"', 'path'); - - $this->assertEquals(count($hits), 4); - $expectedResultset = array(array(7, 0.212395, 'IndexSource/contributing.bugs.html'), - array(0, 0.247795, 'IndexSource/contributing.documentation.html'), - array(8, 0.212395, 'IndexSource/contributing.html'), - array(2, 0.176996, 'IndexSource/contributing.patches.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testLimitingResult() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files'); - - $storedResultSetLimit = Zend_Search_Lucene::getResultSetLimit(); - - Zend_Search_Lucene::setResultSetLimit(3); - - $hits = $index->find('"reporting bugs"', 'path'); - - $this->assertEquals(count($hits), 3); - $expectedResultset = array(array(7, 0.212395, 'IndexSource/contributing.bugs.html'), - array(0, 0.247795, 'IndexSource/contributing.documentation.html'), - array(2, 0.176996, 'IndexSource/contributing.patches.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - - Zend_Search_Lucene::setResultSetLimit($storedResultSetLimit); - } -} diff --git a/tests/Zend/Search/Lucene/SearchTest.php b/tests/Zend/Search/Lucene/SearchTest.php deleted file mode 100644 index bf6a48d5c673f7cc888844b251467fb16f0dd075..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/SearchTest.php +++ /dev/null @@ -1,460 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene - */ -require_once 'Zend/Search/Lucene.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_SearchTest extends PHPUnit_Framework_TestCase -{ - public function testQueryParser() - { - $queries = array('title:"The Right Way" AND text:go', - 'title:"Do it right" AND right', - 'title:Do it right', - 'te?t', - 'test*', - 'te*t', - '?Ma*', - // 'te?t~20^0.8', - 'test~', - 'test~0.4', - '"jakarta apache"~10', - 'contents:[business TO by]', - '{wish TO zzz}', - 'jakarta apache', - 'jakarta^4 apache', - '"jakarta apache"^4 "Apache Lucene"', - '"jakarta apache" jakarta', - '"jakarta apache" OR jakarta', - '"jakarta apache" || jakarta', - '"jakarta apache" AND "Apache Lucene"', - '"jakarta apache" && "Apache Lucene"', - '+jakarta apache', - '"jakarta apache" AND NOT "Apache Lucene"', - '"jakarta apache" && !"Apache Lucene"', - '\\ ', - 'NOT "jakarta apache"', - '!"jakarta apache"', - '"jakarta apache" -"Apache Lucene"', - '(jakarta OR apache) AND website', - '(jakarta || apache) && website', - 'title:(+return +"pink panther")', - 'title:(+re\\turn\\ value +"pink panther\\"" +body:cool)', - '+contents:apache +type:1 +id:5', - 'contents:apache AND type:1 AND id:5', - 'f1:word1 f1:word2 and f1:word3', - 'f1:word1 not f1:word2 and f1:word3' - ); - - $rewritedQueries = array('+(title:"the right way") +(text:go)', - '+(title:"do it right") +(path:right modified:right contents:right)', - '(title:do) (path:it modified:it contents:it) (path:right modified:right contents:right)', - '(contents:test contents:text)', - '(contents:test contents:tested)', - '(contents:test contents:text)', - '(contents:amazon contents:email)', - // .... - '((contents:test) (contents:text)^0.5)', - '((contents:test) (contents:text)^0.5833 (contents:latest)^0.1667 (contents:left)^0.1667 (contents:list)^0.1667 (contents:meet)^0.1667 (contents:must)^0.1667 (contents:next)^0.1667 (contents:post)^0.1667 (contents:sect)^0.1667 (contents:task)^0.1667 (contents:tested)^0.1667 (contents:that)^0.1667 (contents:tort)^0.1667)', - '((path:"jakarta apache"~10) (modified:"jakarta apache"~10) (contents:"jakarta apache"~10))', - '(contents:business contents:but contents:buy contents:buying contents:by)', - '(path:wishlist contents:wishlist contents:wishlists contents:with contents:without contents:won contents:work contents:would contents:write contents:writing contents:written contents:www contents:xml contents:xmlrpc contents:you contents:your)', - '(path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)', - '((path:jakarta modified:jakarta contents:jakarta)^4)^4 (path:apache modified:apache contents:apache)', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache"))^4 ((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) +((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) +((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+(path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '(<InsignificantQuery>)', - '<InsignificantQuery>', - '<InsignificantQuery>', - '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', - '+((path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)) +(path:website modified:website contents:website)', - '+((path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)) +(path:website modified:website contents:website)', - '(+(title:return) +(title:"pink panther"))', - '(+(+title:return +title:value) +(title:"pink panther") +(body:cool))', - '+(contents:apache) +(<InsignificantQuery>) +(<InsignificantQuery>)', - '+(contents:apache) +(<InsignificantQuery>) +(<InsignificantQuery>)', - '(f1:word) (+(f1:word) +(f1:word))', - '(f1:word) (-(f1:word) +(f1:word))'); - - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - foreach ($queries as $id => $queryString) { - $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString); - - $this->assertTrue($query instanceof Zend_Search_Lucene_Search_Query); - - $this->assertEquals($query->rewrite($index)->__toString(), $rewritedQueries[$id]); - } - } - - public function testQueryParserExceptionsHandling() - { - $this->assertTrue(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()); - - try { - $query = Zend_Search_Lucene_Search_QueryParser::parse('contents:[business TO by}'); - } catch (Zend_Search_Lucene_Exception $e) { - $this->fail('exception raised while parsing a query'); - } - - $this->assertEquals('contents business to by', $query->__toString()); - - Zend_Search_Lucene_Search_QueryParser::dontSuppressQueryParsingExceptions(); - $this->assertFalse(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()); - - try { - $query = Zend_Search_Lucene_Search_QueryParser::parse('contents:[business TO by}'); - - $this->fail('exception wasn\'t raised while parsing a query'); - } catch (Zend_Search_Lucene_Exception $e) { - $this->assertEquals('Syntax error at char position 25.', $e->getMessage()); - } - - - Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions(); - $this->assertTrue(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()); - } - - public function testEmptyQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find(''); - - $this->assertEquals(count($hits), 0); - } - - public function testTermQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('submitting'); - - $this->assertEquals(count($hits), 3); - $expectedResultset = array(array(2, 0.114555, 'IndexSource/contributing.patches.html'), - array(7, 0.112241, 'IndexSource/contributing.bugs.html'), - array(8, 0.112241, 'IndexSource/contributing.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testMultiTermQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('submitting AND wishlists'); - - $this->assertEquals(count($hits), 1); - - $this->assertEquals($hits[0]->id, 8); - $this->assertTrue( abs($hits[0]->score - 0.141633) < 0.000001 ); - $this->assertEquals($hits[0]->path, 'IndexSource/contributing.html'); - } - - public function testPraseQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('"reporting bugs"'); - - $this->assertEquals(count($hits), 4); - $expectedResultset = array(array(0, 0.247795, 'IndexSource/contributing.documentation.html'), - array(7, 0.212395, 'IndexSource/contributing.bugs.html'), - array(8, 0.212395, 'IndexSource/contributing.html'), - array(2, 0.176996, 'IndexSource/contributing.patches.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testBooleanQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('submitting AND (wishlists OR requirements)'); - - $this->assertEquals(count($hits), 2); - $expectedResultset = array(array(7, 0.095697, 'IndexSource/contributing.bugs.html'), - array(8, 0.075573, 'IndexSource/contributing.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testBooleanQueryWithPhraseSubquery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('"PEAR developers" AND Home'); - - $this->assertEquals(count($hits), 1); - $expectedResultset = array(array(1, 0.168270, 'IndexSource/contributing.wishlist.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testBooleanQueryWithNonExistingPhraseSubquery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $query = Zend_Search_Lucene_Search_QueryParser::parse('"non-existing phrase" AND Home'); - - $this->assertEquals($query->__toString(), '+("non existing phrase") +(home)'); - $this->assertEquals($query->rewrite($index)->__toString(), - '+((path:"non existing phrase") (modified:"non existing phrase") (contents:"non existing phrase")) +(path:home modified:home contents:home)'); - $this->assertEquals($query->rewrite($index)->optimize($index)->__toString(), '<EmptyQuery>'); - } - - public function testFilteredTokensQueryParserProcessing() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $this->assertEquals(count(Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize('123456787654321')), 0); - - - $hits = $index->find('"PEAR developers" AND Home AND 123456787654321'); - - $this->assertEquals(count($hits), 1); - $expectedResultset = array(array(1, 0.168270, 'IndexSource/contributing.wishlist.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testWildcardQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('*cont*'); - - $this->assertEquals(count($hits), 9); - $expectedResultset = array(array(8, 0.125253, 'IndexSource/contributing.html'), - array(4, 0.112122, 'IndexSource/copyright.html'), - array(2, 0.108491, 'IndexSource/contributing.patches.html'), - array(7, 0.077716, 'IndexSource/contributing.bugs.html'), - array(0, 0.050760, 'IndexSource/contributing.documentation.html'), - array(1, 0.049163, 'IndexSource/contributing.wishlist.html'), - array(3, 0.036159, 'IndexSource/about-pear.html'), - array(5, 0.021500, 'IndexSource/authors.html'), - array(9, 0.007422, 'IndexSource/core.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testFuzzyQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('tesd~0.4'); - - $this->assertEquals(count($hits), 9); - $expectedResultset = array(array(2, 0.037139, 'IndexSource/contributing.patches.html'), - array(0, 0.008735, 'IndexSource/contributing.documentation.html'), - array(7, 0.002449, 'IndexSource/contributing.bugs.html'), - array(1, 0.000483, 'IndexSource/contributing.wishlist.html'), - array(3, 0.000483, 'IndexSource/about-pear.html'), - array(9, 0.000483, 'IndexSource/core.html'), - array(5, 0.000414, 'IndexSource/authors.html'), - array(8, 0.000414, 'IndexSource/contributing.html'), - array(4, 0.000345, 'IndexSource/copyright.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testInclusiveRangeQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('[xml TO zzzzz]'); - - $this->assertEquals(count($hits), 5); - $expectedResultset = array(array(4, 0.156366, 'IndexSource/copyright.html'), - array(2, 0.080458, 'IndexSource/contributing.patches.html'), - array(7, 0.060214, 'IndexSource/contributing.bugs.html'), - array(1, 0.009687, 'IndexSource/contributing.wishlist.html'), - array(5, 0.005871, 'IndexSource/authors.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testNonInclusiveRangeQuery() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('{xml TO zzzzz}'); - - $this->assertEquals(count($hits), 5); - $expectedResultset = array(array(2, 0.1308671, 'IndexSource/contributing.patches.html'), - array(7, 0.0979391, 'IndexSource/contributing.bugs.html'), - array(4, 0.0633930, 'IndexSource/copyright.html'), - array(1, 0.0157556, 'IndexSource/contributing.wishlist.html'), - array(5, 0.0095493, 'IndexSource/authors.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testDefaultSearchField() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $storedDefaultSearchField = Zend_Search_Lucene::getDefaultSearchField(); - - Zend_Search_Lucene::setDefaultSearchField('path'); - $hits = $index->find('contributing'); - - $this->assertEquals(count($hits), 5); - $expectedResultset = array(array(8, 0.847922, 'IndexSource/contributing.html'), - array(0, 0.678337, 'IndexSource/contributing.documentation.html'), - array(1, 0.678337, 'IndexSource/contributing.wishlist.html'), - array(2, 0.678337, 'IndexSource/contributing.patches.html'), - array(7, 0.678337, 'IndexSource/contributing.bugs.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - - Zend_Search_Lucene::setDefaultSearchField($storedDefaultSearchField); - } - - public function testQueryHit() - { - // Restore default search field if it wasn't done by previous test because of failure - Zend_Search_Lucene::setDefaultSearchField(null); - - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('submitting AND wishlists'); - $hit = $hits[0]; - - $this->assertTrue($hit instanceof Zend_Search_Lucene_Search_QueryHit); - $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface); - - $doc = $hit->getDocument(); - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document); - - $this->assertEquals($doc->path, 'IndexSource/contributing.html'); - } - - public function testDelayedResourceCleanUp() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('submitting AND wishlists'); - unset($index); - - - $hit = $hits[0]; - $this->assertTrue($hit instanceof Zend_Search_Lucene_Search_QueryHit); - $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface); - - $doc = $hit->getDocument(); - $this->assertTrue($doc instanceof Zend_Search_Lucene_Document); - $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface); - - $this->assertEquals($doc->path, 'IndexSource/contributing.html'); - } - - public function testSortingResult() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $hits = $index->find('"reporting bugs"', 'path'); - - $this->assertEquals(count($hits), 4); - $expectedResultset = array(array(7, 0.212395, 'IndexSource/contributing.bugs.html'), - array(0, 0.247795, 'IndexSource/contributing.documentation.html'), - array(8, 0.212395, 'IndexSource/contributing.html'), - array(2, 0.176996, 'IndexSource/contributing.patches.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - } - - public function testLimitingResult() - { - $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_indexSample/_files'); - - $storedResultSetLimit = Zend_Search_Lucene::getResultSetLimit(); - - Zend_Search_Lucene::setResultSetLimit(3); - - $hits = $index->find('"reporting bugs"', 'path'); - - $this->assertEquals(count($hits), 3); - $expectedResultset = array(array(7, 0.212395, 'IndexSource/contributing.bugs.html'), - array(0, 0.247795, 'IndexSource/contributing.documentation.html'), - array(2, 0.176996, 'IndexSource/contributing.patches.html')); - - foreach ($hits as $resId => $hit) { - $this->assertEquals($hit->id, $expectedResultset[$resId][0]); - $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 ); - $this->assertEquals($hit->path, $expectedResultset[$resId][2]); - } - - Zend_Search_Lucene::setResultSetLimit($storedResultSetLimit); - } -} diff --git a/tests/Zend/Search/Lucene/Storage/DirectoryTest.php b/tests/Zend/Search/Lucene/Storage/DirectoryTest.php deleted file mode 100644 index be81e0f2624fe12207409049248f6f98ed14f7b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Storage/DirectoryTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Storage_Directory_Filesystem - */ -require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Storage_DirectoryTest extends PHPUnit_Framework_TestCase -{ - public function testFilesystem() - { - $tempPath = dirname(__FILE__) . '/_tempFiles/_files'; - - // remove files from temporary direcytory - $dir = opendir($tempPath); - while (($file = readdir($dir)) !== false) { - if (!is_dir($tempPath . '/' . $file)) { - @unlink($tempPath . '/' . $file); - } - } - closedir($dir); - - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($tempPath); - - $this->assertTrue($directory instanceof Zend_Search_Lucene_Storage_Directory); - $this->assertEquals(count($directory->fileList()), 0); - - $fileObject = $directory->createFile('file1'); - $this->assertTrue($fileObject instanceof Zend_Search_Lucene_Storage_File); - unset($fileObject); - $this->assertEquals($directory->fileLength('file1'), 0); - - $this->assertEquals(count(array_diff($directory->fileList(), array('file1'))), 0); - - $directory->deleteFile('file1'); - $this->assertEquals(count($directory->fileList()), 0); - - $this->assertFalse($directory->fileExists('file2')); - - $fileObject = $directory->createFile('file2'); - $this->assertEquals($directory->fileLength('file2'), 0); - $fileObject->writeBytes('0123456789'); - unset($fileObject); - $this->assertEquals($directory->fileLength('file2'), 10); - - $directory->renameFile('file2', 'file3'); - $this->assertEquals(count(array_diff($directory->fileList(), array('file3'))), 0); - - $modifiedAt1 = $directory->fileModified('file3'); - clearstatcache(); - $directory->touchFile('file3'); - $modifiedAt2 = $directory->fileModified('file3'); - sleep(1); - clearstatcache(); - $directory->touchFile('file3'); - $modifiedAt3 = $directory->fileModified('file3'); - - $this->assertTrue($modifiedAt2 >= $modifiedAt1); - $this->assertTrue($modifiedAt3 > $modifiedAt2); - - $fileObject = $directory->getFileObject('file3'); - $this->assertEquals($fileObject->readBytes($directory->fileLength('file3')), '0123456789'); - unset($fileObject); - - $fileObject = $directory->createFile('file3'); - $this->assertEquals($fileObject->readBytes($directory->fileLength('file3')), ''); - unset($fileObject); - - $directory->deleteFile('file3'); - $this->assertEquals(count($directory->fileList()), 0); - - $directory->close(); - } - - public function testFilesystemSubfoldersAutoCreation() - { - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_tempFiles/_files/dir1/dir2/dir3'); - $this->assertTrue($directory instanceof Zend_Search_Lucene_Storage_Directory); - $directory->close(); - - rmdir(dirname(__FILE__) . '/_tempFiles/_files/dir1/dir2/dir3'); - rmdir(dirname(__FILE__) . '/_tempFiles/_files/dir1/dir2'); - rmdir(dirname(__FILE__) . '/_tempFiles/_files/dir1'); - } -} - diff --git a/tests/Zend/Search/Lucene/Storage/FileTest.php b/tests/Zend/Search/Lucene/Storage/FileTest.php deleted file mode 100644 index 72eba2e55fd9e61b8fac8e85ad0b1b48bff2fb9e..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/Storage/FileTest.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ - - -/** - * Zend_Search_Lucene_Storage_File_Filesystem - */ -require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php'; - -/** - * Zend_Search_Lucene_Storage_File_Memory - */ -require_once 'Zend/Search/Lucene/Storage/File/Memory.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage UnitTests - */ -class Zend_Search_Lucene_Storage_FileTest extends PHPUnit_Framework_TestCase -{ - public function testFilesystem() - { - $file = new Zend_Search_Lucene_Storage_File_Filesystem(dirname(__FILE__) . '/_files/sample_data'); // open file object for reading - $this->assertTrue($file instanceof Zend_Search_Lucene_Storage_File); - - $fileSize = filesize(dirname(__FILE__) . '/_files/sample_data'); - - $this->assertEquals($file->size(), $fileSize); - - $file->seek(0, SEEK_END); - $this->assertEquals($file->tell(), $fileSize); - - $file->seek(2, SEEK_SET); - $this->assertEquals($file->tell(), 2); - - $file->seek(3, SEEK_CUR); - $this->assertEquals($file->tell(), 5); - - $file->seek(0, SEEK_SET); - $this->assertEquals($file->tell(), 0); - - $this->assertEquals($file->readByte(), 10); - $this->assertEquals($file->readBytes(8), "\xFF\x00\xAA\x11\xBB\x44\x66\x99"); - $this->assertEquals($file->readInt(), 49057123); - $this->assertEquals($file->readLong(), 753823522); - $this->assertEquals($file->readVInt(), 234586758); - $this->assertEquals($file->readString(), "UTF-8 string with non-ascii (Cyrillic) symbols\nUTF-8 Ñтрока Ñ Ð½Ðµ-ASCII (кирилличеÑкими) Ñимволами"); - $this->assertEquals($file->readBinary(), "\xFF\x00\xAA\x11\xBB\x44\x66\x99"); - - $file->seek(0); - $fileData = $file->readBytes($file->size()); - - $file->close(); - unset($file); - - - $testFName = dirname(__FILE__) . '/_files/sample_data_1'; - $file = new Zend_Search_Lucene_Storage_File_Filesystem($testFName, 'wb'); - $file->lock(LOCK_EX); - $file->writeByte(10); - $file->writeBytes("\xFF\x00\xAA\x11\xBB\x44\x66\x99"); - $file->writeInt(49057123); - $file->writeLong(753823522); - $file->writeVInt(234586758); - $file->writeString("UTF-8 string with non-ascii (Cyrillic) symbols\nUTF-8 Ñтрока Ñ Ð½Ðµ-ASCII (кирилличеÑкими) Ñимволами"); - $file->writeVInt(8); $file->writeBytes("\xFF\x00\xAA\x11\xBB\x44\x66\x99"); - $file->flush(); - $file->unlock(); - $file->close(); - - $fh = fopen($testFName, 'rb'); - $this->assertEquals($fileData, fread($fh, filesize($testFName))); - fclose($fh); - - unlink($testFName); - } - - public function testMemory() - { - $file = new Zend_Search_Lucene_Storage_File_Filesystem(dirname(__FILE__) . '/_files/sample_data'); - $fileData = $file->readBytes($file->size()); - $file->close(); - unset($file); - - $file = new Zend_Search_Lucene_Storage_File_Memory($fileData); - $this->assertTrue($file instanceof Zend_Search_Lucene_Storage_File); - - $fileSize = strlen($fileData); - - $file->seek(0, SEEK_END); - $this->assertEquals($file->tell(), $fileSize); - - $file->seek(2, SEEK_SET); - $this->assertEquals($file->tell(), 2); - - $file->seek(3, SEEK_CUR); - $this->assertEquals($file->tell(), 5); - - $file->seek(0, SEEK_SET); - $this->assertEquals($file->tell(), 0); - - $this->assertEquals($file->readByte(), 10); - $this->assertEquals($file->readBytes(8), "\xFF\x00\xAA\x11\xBB\x44\x66\x99"); - $this->assertEquals($file->readInt(), 49057123); - $this->assertEquals($file->readLong(), 753823522); - $this->assertEquals($file->readVInt(), 234586758); - $this->assertEquals($file->readString(), "UTF-8 string with non-ascii (Cyrillic) symbols\nUTF-8 Ñтрока Ñ Ð½Ðµ-ASCII (кирилличеÑкими) Ñимволами"); - $this->assertEquals($file->readBinary(), "\xFF\x00\xAA\x11\xBB\x44\x66\x99"); - - // these methods do nothing, but should be provided by object - $file->lock(LOCK_EX); - $file->unlock(); - } -} - diff --git a/tests/Zend/Search/Lucene/Storage/_files/sample_data b/tests/Zend/Search/Lucene/Storage/_files/sample_data deleted file mode 100644 index 9eded067b5af2fce049d719004c39460b433fbee..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/Storage/_files/sample_data and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/_0.cfs b/tests/Zend/Search/Lucene/_index23Sample/_files/_0.cfs deleted file mode 100755 index fcec84ebc4ed6cb6b31f2f6acd2fd678737ffa52..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/_0.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/_1.cfs b/tests/Zend/Search/Lucene/_index23Sample/_files/_1.cfs deleted file mode 100755 index 37e889b107fc512d964b7b7f694c45f6cace70c4..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/_1.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/_2.cfs b/tests/Zend/Search/Lucene/_index23Sample/_files/_2.cfs deleted file mode 100755 index 9cfd9abc5ba04c29f24d39e67a89d89ac68cba74..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/_2.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/_3.cfs b/tests/Zend/Search/Lucene/_index23Sample/_files/_3.cfs deleted file mode 100755 index 193ba14ed9dab0c16b9d1256abe89cef023b452e..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/_3.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/_3_1.del b/tests/Zend/Search/Lucene/_index23Sample/_files/_3_1.del deleted file mode 100755 index f9f8fea01bd11a193bd9b33b6dfe6d609a6b46fe..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/_3_1.del and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/_4.cfs b/tests/Zend/Search/Lucene/_index23Sample/_files/_4.cfs deleted file mode 100755 index 5ce27abe5afb64777e64b7d8d94d5fecc288356b..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/_4.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/segments.gen b/tests/Zend/Search/Lucene/_index23Sample/_files/segments.gen deleted file mode 100755 index e76c9033a6adb8854f5974cedc48b3ffa36d7dec..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/segments.gen and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_index23Sample/_files/segments_8 b/tests/Zend/Search/Lucene/_index23Sample/_files/segments_8 deleted file mode 100755 index 6d60f965c40ffa061a2ef72ea54ca851d5d6eddf..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_index23Sample/_files/segments_8 and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/_0.cfs b/tests/Zend/Search/Lucene/_indexSample/_files/_0.cfs deleted file mode 100644 index 6ec3d076b26dd50d220271da74c22b9b321ee7fc..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/_0.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/_1.cfs b/tests/Zend/Search/Lucene/_indexSample/_files/_1.cfs deleted file mode 100644 index 99e466752288c56e84fb350c6cef9b3d95399ab7..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/_1.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/_2.cfs b/tests/Zend/Search/Lucene/_indexSample/_files/_2.cfs deleted file mode 100644 index 3756c3f2715dec510f3e375de016faef31e78bfa..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/_2.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/_3.cfs b/tests/Zend/Search/Lucene/_indexSample/_files/_3.cfs deleted file mode 100644 index aa6b9d8dd7f516e2468981c91186fd1a30a1f98e..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/_3.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/_3.del b/tests/Zend/Search/Lucene/_indexSample/_files/_3.del deleted file mode 100644 index f9f8fea01bd11a193bd9b33b6dfe6d609a6b46fe..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/_3.del and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/_4.cfs b/tests/Zend/Search/Lucene/_indexSample/_files/_4.cfs deleted file mode 100644 index 5d882b5cf13f9fffe2edb05599e8f627cf5a9e7c..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/_4.cfs and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/deletable b/tests/Zend/Search/Lucene/_indexSample/_files/deletable deleted file mode 100644 index 593f4708db84ac8fd0f5cc47c634f38c013fe9e4..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/deletable and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_files/segments b/tests/Zend/Search/Lucene/_indexSample/_files/segments deleted file mode 100644 index 575bdadb3d0da4a28e32d37d420a1edf4696f1e3..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_files/segments and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fdt b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fdt deleted file mode 100644 index c22318f12f4b831eaff6d2e3365668b1aa542990..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fdt and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fdx b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fdx deleted file mode 100644 index 8ca623de8bcf42c94f5234bfc765156417798f8a..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fdx and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fnm b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fnm deleted file mode 100644 index 7ac6798265aedf15762bbcf710c8f23d9a44cc7c..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.fnm +++ /dev/null @@ -1 +0,0 @@ -contentspathmodified \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.frq b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.frq deleted file mode 100644 index 535c80e0f659e78c5702d716a04e50072ecf0f6b..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.frq and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.nrm b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.nrm deleted file mode 100644 index 74016c222a86208ea7af711696cd7b4817405c59..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.nrm +++ /dev/null @@ -1 +0,0 @@ -NRMÿkkikijljjkiuuuuvvuuvvv||||||||||| \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.prx b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.prx deleted file mode 100644 index d529bf5b25b689570a11b87d3ac13cf750760c07..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.prx and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.tii b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.tii deleted file mode 100644 index 7d037483ffd2cc021b8f81f72f4a86ba3d2af3ed..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.tii and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.tis b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.tis deleted file mode 100644 index e98135ea064269e5ac14a29bf4da91ce01f45bcd..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/_6.tis and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/segments.gen b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/segments.gen deleted file mode 100644 index e76c9033a6adb8854f5974cedc48b3ffa36d7dec..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/segments.gen and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/segments_8 b/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/segments_8 deleted file mode 100644 index a4803732853b79284fbfdfbc929cd93276f79ed3..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Search/Lucene/_indexSample/_nonCompoundIndexFiles/segments_8 and /dev/null differ diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/about-pear.html b/tests/Zend/Search/Lucene/_indexSource/_files/about-pear.html deleted file mode 100644 index 8a75445e7565cdf39214a6c124c357ffb96120f9..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/about-pear.html +++ /dev/null @@ -1,179 +0,0 @@ -<HTML -><HEAD -><TITLE ->About PEAR</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="PREVIOUS" -TITLE="Authors and Contributors" -HREF="authors.html"><LINK -REL="NEXT" -TITLE="Introduction" -HREF="introduction.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="part" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="authors.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" -></TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="introduction.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="PART" -><A -NAME="about-pear"><DIV -CLASS="TITLEPAGE" -><H1 -CLASS="title" ->I. About PEAR</H1 -></DIV -><DIV -CLASS="TOC" -><DL -><DT -><B ->Table of Contents</B -></DT -><DT ->1. <A -HREF="introduction.html" ->Introduction</A -></DT -><DT ->2. <A -HREF="installation.html" ->Installation</A -></DT -><DT ->3. <A -HREF="support.html" ->Support</A -></DT -><DT ->4. <A -HREF="standards.html" ->Coding Standards</A -></DT -><DT ->5. <A -HREF="contributing.html" ->Contributing</A -></DT -><DT ->6. <A -HREF="faq.html" ->FAQ - Frequently Asked Questions</A -></DT -></DL -></DIV -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="authors.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="introduction.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Authors and Contributors</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -> </TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->Introduction</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/authors.html b/tests/Zend/Search/Lucene/_indexSource/_files/authors.html deleted file mode 100644 index cac8abe95695676639b5d0751d6c4304ba224b64..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/authors.html +++ /dev/null @@ -1,235 +0,0 @@ -<HTML -><HEAD -><TITLE ->Authors and Contributors</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="Preface" -HREF="preface.html"><LINK -REL="PREVIOUS" -TITLE="The structure of the Manual" -HREF="structure.html"><LINK -REL="NEXT" -TITLE="About PEAR" -HREF="about-pear.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="sect1" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="structure.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" ->Preface</TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="about-pear.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="authors">Authors and Contributors</H1 -><P -> The following is a list of people that are helping to maintain this - documentation. If you would like to contact one of them, please - write to <A -HREF="mailto:pear-doc@lists.php.net" -TARGET="_top" ->pear-doc@lists.php.net</A ->. - </P -><P -></P -><UL -><LI -><P -> Lorenzo Alberton - </P -></LI -><LI -><P -> Gregory Beaver - </P -></LI -><LI -><P -> Daniel Convissor - </P -></LI -><LI -><P -> David Costa - </P -></LI -><LI -><P -> Thomas V.V. Cox - </P -></LI -><LI -><P -> Martin Jansen - </P -></LI -><LI -><P -> Alan Knowles - </P -></LI -><LI -><P -> Clay Loveless - </P -></LI -><LI -><P -> Alexander Merz - </P -></LI -><LI -><P -> Stefan Neufeind - </P -></LI -><LI -><P -> Jon Parise - </P -></LI -><LI -><P -> Tobias Schlitt - </P -></LI -><LI -><P -> Stephan Schmidt - </P -></LI -><LI -><P -> Mika Tuupola - </P -></LI -><LI -><P -> Michael Wallner - </P -></LI -></UL -><P -> (In alphabetic order.) - </P -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="structure.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="about-pear.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->The structure of the Manual</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="preface.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->About PEAR</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.bugs.html b/tests/Zend/Search/Lucene/_indexSource/_files/contributing.bugs.html deleted file mode 100644 index 70035c2bb3ee5a98bb299076204b073052fa0752..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.bugs.html +++ /dev/null @@ -1,185 +0,0 @@ -<HTML -><HEAD -><TITLE ->Reporting Bugs</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="Contributing" -HREF="contributing.html"><LINK -REL="PREVIOUS" -TITLE="Submitting Patches" -HREF="contributing.patches.html"><LINK -REL="NEXT" -TITLE="Writing & Translating Documentation" -HREF="contributing.documentation.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="sect1" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="contributing.patches.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" ->Chapter 5. Contributing</TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="contributing.documentation.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="contributing.bugs">Reporting Bugs</H1 -><P -> If you think that you have found a bug in a PEAR package, please - take care that you are using the latest version of the package and - that your system does meet the packages' requirements. - </P -><P -> If the bug still persists with the latest version of the package, - don't hesitate to fill out a bug report. The easiest way is to click - to link <SPAN -CLASS="QUOTE" ->"Package Bugs"</SPAN -> on the package information page - for the package on the <A -HREF="http://pear.php.net/" -TARGET="_top" ->PEAR - Homepage</A ->, which you think contains a bug. This will take you - to a list of existing bugs of the package. Please double check if - the bug hasn't already been reported! If you are unable to find it - in the list, you can click on <SPAN -CLASS="QUOTE" ->"Report a new bug"</SPAN -> to - fill out the bug form. - </P -><P -> More information and tips on how to report bugs in a proper way - can be found at <A -HREF="http://bugs.php.net/how-to-report.php" -TARGET="_top" ->http://bugs.php.net/how-to-report.php</A ->. - </P -><P -> If you have already fixed a bug that you have found in a package, please - read <A -HREF="contributing.patches.html" ->this</A ->. - </P -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="contributing.patches.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="contributing.documentation.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Submitting Patches</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="contributing.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->Writing & Translating Documentation</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.documentation.html b/tests/Zend/Search/Lucene/_indexSource/_files/contributing.documentation.html deleted file mode 100644 index c9ba9c132e171f47cecd4c3212dcb64ebfeb345b..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.documentation.html +++ /dev/null @@ -1,165 +0,0 @@ -<HTML -><HEAD -><TITLE ->Writing & Translating Documentation</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="Contributing" -HREF="contributing.html"><LINK -REL="PREVIOUS" -TITLE="Reporting Bugs" -HREF="contributing.bugs.html"><LINK -REL="NEXT" -TITLE="Wishlists" -HREF="contributing.wishlist.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="sect1" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="contributing.bugs.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" ->Chapter 5. Contributing</TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="contributing.wishlist.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="contributing.documentation">Writing & Translating Documentation</H1 -><P -> Good documentation is essential for users to fully understand any - software. Several PEAR packages lack documentation or have docs which - need improvement. <A -HREF="developers.documentation.html" ->Writing documentation</A -> - provides more information about helping out on this front. - </P -><P -> Translating documentation is another important task. - Not only does new documentation need to be translated - into the existing languages, additional languages are - welcome. Also, existing translations need to be brought - up to date because the English versions have been changed. - Help on how to perform the translation process is in the <A -HREF="faq.translators-revision-tracking.html" ->Revision Tracking</A -> - section of the manual. - </P -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="contributing.bugs.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="contributing.wishlist.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Reporting Bugs</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="contributing.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->Wishlists</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.html b/tests/Zend/Search/Lucene/_indexSource/_files/contributing.html deleted file mode 100644 index e5e672a1f03d59bc7c71808124c56592c3e6d763..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.html +++ /dev/null @@ -1,201 +0,0 @@ -<HTML -><HEAD -><TITLE ->Contributing</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="About PEAR" -HREF="about-pear.html"><LINK -REL="PREVIOUS" -TITLE="Sample File (including Docblock Comment standards)" -HREF="standards.sample.html"><LINK -REL="NEXT" -TITLE="Writing New Packages" -HREF="contributing.newpackage.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="chapter" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="standards.sample.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" -></TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="contributing.newpackage.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="chapter" -><H1 -><A -NAME="contributing" ->Chapter 5. Contributing</A -></H1 -><DIV -CLASS="TOC" -><DL -><DT -><B ->Table of Contents</B -></DT -><DT -><A -HREF="contributing.html#contributing.introduction" ->Introduction</A -></DT -><DT -><A -HREF="contributing.newpackage.html" ->Writing New Packages</A -></DT -><DT -><A -HREF="contributing.patches.html" ->Submitting Patches</A -></DT -><DT -><A -HREF="contributing.bugs.html" ->Reporting Bugs</A -></DT -><DT -><A -HREF="contributing.documentation.html" ->Writing & Translating Documentation</A -></DT -><DT -><A -HREF="contributing.wishlist.html" ->Wishlists</A -></DT -></DL -></DIV -><P -> This chapter describes the different ways in which one could - contribute to PEAR. - </P -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="contributing.introduction">Introduction</H1 -><P -> PEAR is an open source project, which means that everyone can help - improving it. Improving doesn't always mean writing code. It can - also mean reporting bugs, giving feedback, submitting feature - requests and even financial support. - </P -></DIV -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="standards.sample.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="contributing.newpackage.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Sample File (including Docblock Comment standards)</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="about-pear.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->Writing New Packages</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.newpackage.html b/tests/Zend/Search/Lucene/_indexSource/_files/contributing.newpackage.html deleted file mode 100644 index 8ad9c4f0917a86ddedb52ab82b3739470a372857..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.newpackage.html +++ /dev/null @@ -1,151 +0,0 @@ -<HTML -><HEAD -><TITLE ->Writing New Packages</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="Contributing" -HREF="contributing.html"><LINK -REL="PREVIOUS" -TITLE="Contributing" -HREF="contributing.html"><LINK -REL="NEXT" -TITLE="Submitting Patches" -HREF="contributing.patches.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="sect1" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="contributing.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" ->Chapter 5. Contributing</TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="contributing.patches.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="contributing.newpackage">Writing New Packages</H1 -><P -> Explanations about submitting new packages can be found in the - <A -HREF="guide-developers.html" ->Developers' Guide</A ->. - </P -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="contributing.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="contributing.patches.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Contributing</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="contributing.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->Submitting Patches</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.patches.html b/tests/Zend/Search/Lucene/_indexSource/_files/contributing.patches.html deleted file mode 100644 index d7d73f80f245134d0d9ee480a8e7202229865d20..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.patches.html +++ /dev/null @@ -1,274 +0,0 @@ -<HTML -><HEAD -><TITLE ->Submitting Patches</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="Contributing" -HREF="contributing.html"><LINK -REL="PREVIOUS" -TITLE="Writing New Packages" -HREF="contributing.newpackage.html"><LINK -REL="NEXT" -TITLE="Reporting Bugs" -HREF="contributing.bugs.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="sect1" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="contributing.newpackage.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" ->Chapter 5. Contributing</TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="contributing.bugs.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="contributing.patches">Submitting Patches</H1 -><P -> If you have modified a package to expand its functionality or to fix a - bug, you should contribute your changes back to the community (some - licenses force you to do so, and it is generally considered immoral not to). - </P -><P -> Before creating the patch, you must first obtain the latest sources of the - package you wish to patch from CVS by running the commands (the package - in this example is Foo_Bar): - <TABLE -WIDTH="100%" -CELLSPACING="0" -CELLPADDING="0" -BORDER="0" -BGCOLOR="#EEEEEE" -><TR -><TD -><PRE -CLASS="screen" -><TT -CLASS="userinput" -><B -> cvs -d:pserver:cvsread@cvs.php.net:/repository login -</B -></TT -> -password is <TT -CLASS="userinput" -><B ->phpfi</B -></TT -> -<TT -CLASS="userinput" -><B -> cvs -d:pserver:cvsread@cvs.php.net:/repository co pear/Foo_Bar -</B -></TT -></PRE -></TD -></TR -></TABLE -> - Now that you have the latest sources, you can edit the relevant file(s). - Make sure that your patch is fully compatible with the PEAR <A -HREF="standards.html" ->coding -standards.</A ->. - </P -><P -> After you have finished adding/changing the code, TEST it: We will not - accept code that hasn't been carefully tested. - When you are absolutely sure the new code doesn't introduce bugs, create a - unified diff by running: - <TABLE -WIDTH="100%" -CELLSPACING="0" -CELLPADDING="0" -BORDER="0" -BGCOLOR="#EEEEEE" -><TR -><TD -><PRE -CLASS="screen" -><TT -CLASS="userinput" -><B ->cd pear/Foo_Bar</B -></TT -> -<TT -CLASS="userinput" -><B ->cvs diff -u >Foo_Bar.diff</B -></TT -></PRE -></TD -></TR -></TABLE -> - The resulting .diff file contains your patch. This diff makes it easy - for us to see what has been changed. - </P -><P -> Next step is to submit the patch. Send a mail to pear-dev@lists.php.net and - Cc the maintainer(s) of the package. The subject of the mail should be - prefixed with '[Patch]' to make it clear you are submitting a patch. Also - include a verbose explanation of what the patch does. - Don't forget to attach the .diff file to the mail. The maintainers of - the package are usually listed in the header of each source file. Apart - from that their email adresses are available on the package information - page on http://pear.php.net/. - </P -><DIV -CLASS="note" -><BLOCKQUOTE -CLASS="note" -><P -><B ->Note: </B -> - If you are using Outlook or Outlook Express, please change the file - extension of the diff file to .txt, because Outlook's MIME-Type - detection depends on the file extension and attachments with a - MIME-Type not equal to <TT -CLASS="literal" ->text/plain</TT -> will be rejected - by our mailinglist software. - </P -></BLOCKQUOTE -></DIV -><DIV -CLASS="note" -><BLOCKQUOTE -CLASS="note" -><P -><B ->Note: </B -> - If your patch does break backwards compatibility, the chances are fairly - good that the maintainers won't be happy about it. Thus you should always - try to fix a bug in a way that does not seriously change the public API. - But if there is absolutely no way to keep backwards compatibility and/or - if your patch contains a groundbraking improvement, even API changes are - fine. - </P -></BLOCKQUOTE -></DIV -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="contributing.newpackage.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="contributing.bugs.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Writing New Packages</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="contributing.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->Reporting Bugs</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.wishlist.html b/tests/Zend/Search/Lucene/_indexSource/_files/contributing.wishlist.html deleted file mode 100644 index f5d13cecb5f068cb11f0f47c504f60e628fe3648..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/contributing.wishlist.html +++ /dev/null @@ -1,158 +0,0 @@ -<HTML -><HEAD -><TITLE ->Wishlists</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="UP" -TITLE="Contributing" -HREF="contributing.html"><LINK -REL="PREVIOUS" -TITLE="Writing & Translating Documentation" -HREF="contributing.documentation.html"><LINK -REL="NEXT" -TITLE="FAQ - Frequently Asked Questions" -HREF="faq.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="sect1" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="contributing.documentation.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" ->Chapter 5. Contributing</TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="faq.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="sect1" -><H1 -CLASS="sect1" -><A -NAME="contributing.wishlist">Wishlists</H1 -><P -> Some of the PEAR developers have wishlists at Amazon or a similar - service. If you appreciate the work of a certain developer, feel - free to buy something for her from her wishlist. To find out if - a developer has one of those wishlists, go to the - <A -HREF="http://pear.php.net/accounts.php" -TARGET="_top" ->account browser</A ->, - look for the details of the developer and there you'll see if she - has a wishlist. Buying something from people's wishlists may even - speed up the time in which annoying bugs are fixed ;-). - </P -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="contributing.documentation.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="faq.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Writing & Translating Documentation</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="contributing.html" -ACCESSKEY="U" ->Up</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->FAQ - Frequently Asked Questions</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/copyright.html b/tests/Zend/Search/Lucene/_indexSource/_files/copyright.html deleted file mode 100644 index d4e082bd837e2a8b39eeb5f5f6cf3f6bc25c3237..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/copyright.html +++ /dev/null @@ -1,196 +0,0 @@ -<HTML -><HEAD -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="NEXT" -TITLE="Preface" -HREF="preface.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="legalnotice" -><A -NAME="copyright"><P -><B ->Copyright</B -></P -><P -> Copyright © 2001 - 2006 by the PEAR Documentation Group. - This material may be distributed only subject to the terms and - conditions set forth in the Open Publication License, v1.0 or - later (the latest version is presently available at - <A -HREF="http://www.opencontent.org/openpub/" -TARGET="_top" ->http://www.opencontent.org/openpub/</A ->). - </P -><P -> Distribution of substantively modified versions of this document - is prohibited without the explicit permission of the copyright - holder. - </P -><P -> Distribution of the work or derivative of the work in any - standard (paper) book form is prohibited unless prior permission - is obtained from the copyright holder. - </P -><P -> The PEAR Documentation Group consists of all the people that - have contributed documentation to the PEAR manual. - Representatives are listed on the front page of this manual. - In case you would like to contact the group, please write to - <A -HREF="mailto:pear-doc@lists.php.net" -TARGET="_top" ->pear-doc@lists.php.net</A ->. - </P -></DIV -><DIV -CLASS="legalnotice" -><A -NAME="copyright.xml-rpc"><P -><B -> Copyright for the XML_RPC documentation - </B -></P -><P -> The <A -HREF="package.webservices.xml-rpc.html" ->documentation</A -> - of the XML_RPC package has originally been written by <A -HREF="http://usefulinc.com/" -TARGET="_top" ->Edd Dumbill</A -> as an independent - document on <A -HREF="http://xmlrpc.usefulinc.com/doc/" -TARGET="_top" ->his - homepage</A -> and is published as part of the PEAR Manual under - the following license restrictions: - </P -><P -> Copyright © 1999,2000,2001 by Edd Dumbill, Useful Information Company - </P -><P -> All rights reserved. - </P -><P -> Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - </P -><P -> <P -></P -><UL -><LI -><P -> Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - </P -></LI -><LI -><P -> Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - </P -></LI -><LI -><P -> Neither the name of the "XML-RPC for PHP" nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - </P -></LI -></UL -> - </P -><P -> - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - OF SUCH DAMAGE. - </P -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -> </TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -> </TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Search/Lucene/_indexSource/_files/core.html b/tests/Zend/Search/Lucene/_indexSource/_files/core.html deleted file mode 100644 index cf811503a24e13f2ec704583668fab4e6dab1932..0000000000000000000000000000000000000000 --- a/tests/Zend/Search/Lucene/_indexSource/_files/core.html +++ /dev/null @@ -1,159 +0,0 @@ -<HTML -><HEAD -><TITLE ->Core components</TITLE -><META -NAME="GENERATOR" -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ -"><LINK -REL="HOME" -TITLE="PEAR Manual" -HREF="index.html"><LINK -REL="PREVIOUS" -TITLE="Structure of a post-install script" -HREF="guide.migrating.postinstall.structure.html"><LINK -REL="NEXT" -TITLE="PEAR base classes" -HREF="core.pear.html"><META -HTTP-EQUIV="Content-type" -CONTENT="text/html; charset=ISO-8859-1"></HEAD -><BODY -CLASS="part" -BGCOLOR="#FFFFFF" -TEXT="#000000" -LINK="#0000FF" -VLINK="#840084" -ALINK="#0000FF" -><DIV -CLASS="NAVHEADER" -><TABLE -SUMMARY="Header navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TH -COLSPAN="3" -ALIGN="center" ->PEAR Manual</TH -></TR -><TR -><TD -WIDTH="10%" -ALIGN="left" -VALIGN="bottom" -><A -HREF="guide.migrating.postinstall.structure.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="80%" -ALIGN="center" -VALIGN="bottom" -></TD -><TD -WIDTH="10%" -ALIGN="right" -VALIGN="bottom" -><A -HREF="core.pear.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -></TABLE -><HR -ALIGN="LEFT" -WIDTH="100%"></DIV -><DIV -CLASS="PART" -><A -NAME="core"><DIV -CLASS="TITLEPAGE" -><H1 -CLASS="title" ->V. Core components</H1 -></DIV -><DIV -CLASS="TOC" -><DL -><DT -><B ->Table of Contents</B -></DT -><DT ->26. <A -HREF="core.pear.html" ->PEAR base classes</A -></DT -><DT ->27. <A -HREF="core.ppm.html" ->PEAR Installer classes</A -></DT -></DL -></DIV -></DIV -><DIV -CLASS="NAVFOOTER" -><HR -ALIGN="LEFT" -WIDTH="100%"><TABLE -SUMMARY="Footer navigation table" -WIDTH="100%" -BORDER="0" -CELLPADDING="0" -CELLSPACING="0" -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" -><A -HREF="guide.migrating.postinstall.structure.html" -ACCESSKEY="P" ->Prev</A -></TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -><A -HREF="index.html" -ACCESSKEY="H" ->Home</A -></TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" -><A -HREF="core.pear.html" -ACCESSKEY="N" ->Next</A -></TD -></TR -><TR -><TD -WIDTH="33%" -ALIGN="left" -VALIGN="top" ->Structure of a post-install script</TD -><TD -WIDTH="34%" -ALIGN="center" -VALIGN="top" -> </TD -><TD -WIDTH="33%" -ALIGN="right" -VALIGN="top" ->PEAR base classes</TD -></TR -></TABLE -></DIV -></BODY -></HTML -> \ No newline at end of file diff --git a/tests/Zend/Server/AllTests.php b/tests/Zend/Server/AllTests.php deleted file mode 100644 index a1473c84d7e09d2eba5d202e0bbadcdc3ecff6a6..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/AllTests.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Server_AllTests::main'); - set_include_path( - dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . get_include_path()); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Server/ReflectionTest.php'; -require_once 'Zend/Server/Reflection/ClassTest.php'; -require_once 'Zend/Server/Reflection/FunctionTest.php'; -require_once 'Zend/Server/Reflection/MethodTest.php'; -require_once 'Zend/Server/Reflection/NodeTest.php'; -require_once 'Zend/Server/Reflection/ParameterTest.php'; -require_once 'Zend/Server/Reflection/PrototypeTest.php'; -require_once 'Zend/Server/Reflection/ReturnValueTest.php'; - -class Zend_Server_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Server'); - - $suite->addTestSuite('Zend_Server_ReflectionTest'); - $suite->addTestSuite('Zend_Server_Reflection_ClassTest'); - $suite->addTestSuite('Zend_Server_Reflection_FunctionTest'); - $suite->addTestSuite('Zend_Server_Reflection_MethodTest'); - $suite->addTestSuite('Zend_Server_Reflection_NodeTest'); - $suite->addTestSuite('Zend_Server_Reflection_ParameterTest'); - $suite->addTestSuite('Zend_Server_Reflection_PrototypeTest'); - $suite->addTestSuite('Zend_Server_Reflection_ReturnValueTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Server_AllTests::main') { - Zend_Server_AllTests::main(); -} diff --git a/tests/Zend/Server/Reflection/ClassTest.php b/tests/Zend/Server/Reflection/ClassTest.php deleted file mode 100644 index da09ed8854ef5755d879a82c85026a56bd880c27..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/ClassTest.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/Class.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -require_once 'Zend/Server/Reflection.php'; - -/** - * Test case for Zend_Server_Reflection_Class - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: ClassTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_Reflection_ClassTest extends PHPUnit_Framework_TestCase -{ - /** - * __construct() test - * - * Call as method call - * - * Expects: - * - reflection: - * - namespace: Optional; - * - argv: Optional; has default; - * - * Returns: void - */ - public function test__construct() - { - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - $this->assertTrue($r instanceof Zend_Server_Reflection_Class); - $this->assertEquals('', $r->getNamespace()); - - $methods = $r->getMethods(); - $this->assertTrue(is_array($methods)); - foreach ($methods as $m) { - $this->assertTrue($m instanceof Zend_Server_Reflection_Method); - } - - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection'), 'namespace'); - $this->assertEquals('namespace', $r->getNamespace()); - } - - /** - * __call() test - * - * Call as method call - * - * Expects: - * - method: - * - args: - * - * Returns: mixed - */ - public function test__call() - { - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - $this->assertTrue(is_string($r->getName())); - $this->assertEquals('Zend_Server_Reflection', $r->getName()); - } - - /** - * test __get/set - */ - public function testGetSet() - { - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - $r->system = true; - $this->assertTrue($r->system); - } - - /** - * getMethods() test - * - * Call as method call - * - * Returns: array - */ - public function testGetMethods() - { - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - - $methods = $r->getMethods(); - $this->assertTrue(is_array($methods)); - foreach ($methods as $m) { - $this->assertTrue($m instanceof Zend_Server_Reflection_Method); - } - } - - /** - * namespace test - */ - public function testGetNamespace() - { - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - $this->assertEquals('', $r->getNamespace()); - $r->setNamespace('namespace'); - $this->assertEquals('namespace', $r->getNamespace()); - } - - /** - * __wakeup() test - * - * Call as method call - * - * Returns: void - */ - public function test__wakeup() - { - $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - $s = serialize($r); - $u = unserialize($s); - - $this->assertTrue($u instanceof Zend_Server_Reflection_Class); - $this->assertEquals('', $u->getNamespace()); - $this->assertEquals($r->getName(), $u->getName()); - $rMethods = $r->getMethods(); - $uMethods = $r->getMethods(); - - $this->assertEquals(count($rMethods), count($uMethods)); - } -} diff --git a/tests/Zend/Server/Reflection/FunctionTest.php b/tests/Zend/Server/Reflection/FunctionTest.php deleted file mode 100644 index ed065c64c73cd66d02386a9f5199a6cab2d7bf1e..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/FunctionTest.php +++ /dev/null @@ -1,177 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/Function.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_Server_Reflection_Function - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: FunctionTest.php 3916 2007-03-14 11:42:22Z matthew $ - */ -class Zend_Server_Reflection_FunctionTest extends PHPUnit_Framework_TestCase -{ - public function test__construct() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function); - $this->assertTrue($r instanceof Zend_Server_Reflection_Function); - $this->assertTrue($r instanceof Zend_Server_Reflection_Function_Abstract); - $params = $r->getParameters(); - try { - $r = new Zend_Server_Reflection_Function($params[0]); - $this->fail('Should not be able to construct with non-function'); - } catch (Exception $e) { - // do nothing - } - - $r = new Zend_Server_Reflection_Function($function, 'namespace'); - $this->assertEquals('namespace', $r->getNamespace()); - - $argv = array('string1', 'string2'); - $r = new Zend_Server_Reflection_Function($function, 'namespace', $argv); - $this->assertTrue(is_array($r->getInvokeArguments())); - $this->assertTrue($argv === $r->getInvokeArguments()); - - $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); - $this->assertTrue(0 < count($prototypes)); - } - - public function test__getSet() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function); - - $r->system = true; - $this->assertTrue($r->system); - } - - - public function testNamespace() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function, 'namespace'); - $this->assertEquals('namespace', $r->getNamespace()); - $r->setNamespace('framework'); - $this->assertEquals('framework', $r->getNamespace()); - } - - public function testDescription() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function); - $this->assertContains('function for reflection', $r->getDescription()); - $r->setDescription('Testing setting descriptions'); - $this->assertEquals('Testing setting descriptions', $r->getDescription()); - } - - public function testGetPrototypes() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function); - - $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); - $this->assertTrue(0 < count($prototypes)); - $this->assertEquals(8, count($prototypes)); - - foreach ($prototypes as $p) { - $this->assertTrue($p instanceof Zend_Server_Reflection_Prototype); - } - } - - public function testGetPrototypes2() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function2'); - $r = new Zend_Server_Reflection_Function($function); - - $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); - $this->assertTrue(0 < count($prototypes)); - $this->assertEquals(1, count($prototypes)); - - foreach ($prototypes as $p) { - $this->assertTrue($p instanceof Zend_Server_Reflection_Prototype); - } - } - - - public function testGetInvokeArguments() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function); - $args = $r->getInvokeArguments(); - $this->assertTrue(is_array($args)); - $this->assertEquals(0, count($args)); - - $argv = array('string1', 'string2'); - $r = new Zend_Server_Reflection_Function($function, null, $argv); - $args = $r->getInvokeArguments(); - $this->assertTrue(is_array($args)); - $this->assertEquals(2, count($args)); - $this->assertTrue($argv === $args); - } - - public function test__wakeup() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); - $r = new Zend_Server_Reflection_Function($function); - $s = serialize($r); - $u = unserialize($s); - $this->assertTrue($u instanceof Zend_Server_Reflection_Function); - $this->assertEquals('', $u->getNamespace()); - } - - public function testMultipleWhitespaceBetweenDoctagsAndTypes() - { - $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function3'); - $r = new Zend_Server_Reflection_Function($function); - - $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); - $this->assertTrue(0 < count($prototypes)); - $this->assertEquals(1, count($prototypes)); - - $proto = $prototypes[0]; - $params = $proto->getParameters(); - $this->assertTrue(is_array($params)); - $this->assertEquals(1, count($params)); - $this->assertEquals('string', $params[0]->getType()); - } -} - -/** - * Zend_Server_Reflection_FunctionTest_function - * - * Test function for reflection unit tests - * - * @param string $var1 - * @param string|array $var2 - * @param array $var3 - * @return null|array - */ -function Zend_Server_Reflection_FunctionTest_function($var1, $var2, $var3 = null) -{ -} - -/** - * Zend_Server_Reflection_FunctionTest_function2 - * - * Test function for reflection unit tests; test what happens when no return - * value or params specified in docblock. - */ -function Zend_Server_Reflection_FunctionTest_function2() -{ -} - -/** - * Zend_Server_Reflection_FunctionTest_function3 - * - * @param string $var1 - * @return void - */ -function Zend_Server_Reflection_FunctionTest_function3($var1) -{ -} diff --git a/tests/Zend/Server/Reflection/MethodTest.php b/tests/Zend/Server/Reflection/MethodTest.php deleted file mode 100644 index 55f80b3f7300b96a7f2957f9071d122821aaa6a0..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/MethodTest.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/Method.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -require_once 'Zend/Server/Reflection.php'; - -/** - * Test case for Zend_Server_Reflection_Method - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: MethodTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_Reflection_MethodTest extends PHPUnit_Framework_TestCase -{ - protected $_classRaw; - protected $_class; - protected $_method; - - protected function setUp() - { - $this->_classRaw = new ReflectionClass('Zend_Server_Reflection'); - $this->_method = $this->_classRaw->getMethod('reflectClass'); - $this->_class = new Zend_Server_Reflection_Class($this->_classRaw); - } - - /** - * __construct() test - * - * Call as method call - * - * Expects: - * - class: - * - r: - * - namespace: Optional; - * - argv: Optional; has default; - * - * Returns: void - */ - public function test__construct() - { - $r = new Zend_Server_Reflection_Method($this->_class, $this->_method); - $this->assertTrue($r instanceof Zend_Server_Reflection_Method); - $this->assertTrue($r instanceof Zend_Server_Reflection_Function_Abstract); - - $r = new Zend_Server_Reflection_Method($this->_class, $this->_method, 'namespace'); - $this->assertEquals('namespace', $r->getNamespace()); - } - - /** - * getDeclaringClass() test - * - * Call as method call - * - * Returns: Zend_Server_Reflection_Class - */ - public function testGetDeclaringClass() - { - $r = new Zend_Server_Reflection_Method($this->_class, $this->_method); - - $class = $r->getDeclaringClass(); - - $this->assertTrue($class instanceof Zend_Server_Reflection_Class); - $this->assertTrue($this->_class === $class); - } - - /** - * __wakeup() test - * - * Call as method call - * - * Returns: void - */ - public function test__wakeup() - { - $r = new Zend_Server_Reflection_Method($this->_class, $this->_method); - $s = serialize($r); - $u = unserialize($s); - - $this->assertTrue($u instanceof Zend_Server_Reflection_Method); - $this->assertTrue($u instanceof Zend_Server_Reflection_Function_Abstract); - $this->assertEquals($r->getName(), $u->getName()); - $this->assertEquals($r->getDeclaringClass()->getName(), $u->getDeclaringClass()->getName()); - } - - -} diff --git a/tests/Zend/Server/Reflection/NodeTest.php b/tests/Zend/Server/Reflection/NodeTest.php deleted file mode 100644 index 2b34948006ade371acc1ddd768d41502fa67704e..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/NodeTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/Node.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_Server_Reflection_Node - * - * @package ortus - * @version $Id: NodeTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_Reflection_NodeTest extends PHPUnit_Framework_TestCase -{ - /** - * __construct() test - */ - public function test__construct() - { - $node = new Zend_Server_Reflection_Node('string'); - $this->assertTrue($node instanceof Zend_Server_Reflection_Node); - $this->assertEquals('string', $node->getValue()); - $this->assertTrue(null === $node->getParent()); - $children = $node->getChildren(); - $this->assertTrue(empty($children)); - - $child = new Zend_Server_Reflection_Node('array', $node); - $this->assertTrue($child instanceof Zend_Server_Reflection_Node); - $this->assertEquals('array', $child->getValue()); - $this->assertTrue($node === $child->getParent()); - $children = $child->getChildren(); - $this->assertTrue(empty($children)); - - $children = $node->getChildren(); - $this->assertTrue($child === $children[0]); - } - - /** - * setParent() test - */ - public function testSetParent() - { - $parent = new Zend_Server_Reflection_Node('string'); - $child = new Zend_Server_Reflection_Node('array'); - - $child->setParent($parent); - - $this->assertTrue($parent === $child->getParent()); - } - - /** - * createChild() test - */ - public function testCreateChild() - { - $parent = new Zend_Server_Reflection_Node('string'); - $child = $parent->createChild('array'); - - $this->assertTrue($child instanceof Zend_Server_Reflection_Node); - $this->assertTrue($parent === $child->getParent()); - $children = $parent->getChildren(); - $this->assertTrue($child === $children[0]); - } - - /** - * attachChild() test - */ - public function testAttachChild() - { - $parent = new Zend_Server_Reflection_Node('string'); - $child = new Zend_Server_Reflection_Node('array'); - - $parent->attachChild($child); - $this->assertTrue($parent === $child->getParent()); - $children = $parent->getChildren(); - $this->assertTrue($child === $children[0]); - } - - /** - * getChildren() test - */ - public function testGetChildren() - { - $parent = new Zend_Server_Reflection_Node('string'); - $child = $parent->createChild('array'); - - $children = $parent->getChildren(); - $types = array(); - foreach ($children as $c) { - $types[] = $c->getValue(); - } - $this->assertTrue(is_array($children)); - $this->assertEquals(1, count($children), var_export($types, 1)); - $this->assertTrue($child === $children[0]); - } - - /** - * hasChildren() test - */ - public function testHasChildren() - { - $parent = new Zend_Server_Reflection_Node('string'); - - $this->assertFalse($parent->hasChildren()); - $parent->createChild('array'); - $this->assertTrue($parent->hasChildren()); - } - - /** - * getParent() test - */ - public function testGetParent() - { - $parent = new Zend_Server_Reflection_Node('string'); - $child = $parent->createChild('array'); - - $this->assertTrue(null === $parent->getParent()); - $this->assertTrue($parent === $child->getParent()); - } - - /** - * getValue() test - */ - public function testGetValue() - { - $parent = new Zend_Server_Reflection_Node('string'); - $this->assertEquals('string', $parent->getValue()); - } - - /** - * setValue() test - */ - public function testSetValue() - { - $parent = new Zend_Server_Reflection_Node('string'); - $this->assertEquals('string', $parent->getValue()); - $parent->setValue('array'); - $this->assertEquals('array', $parent->getValue()); - } - - /** - * getEndPoints() test - */ - public function testGetEndPoints() - { - $root = new Zend_Server_Reflection_Node('root'); - $child1 = $root->createChild('child1'); - $child2 = $root->createChild('child2'); - $child1grand1 = $child1->createChild(null); - $child1grand2 = $child1->createChild('child1grand2'); - $child2grand1 = $child2->createChild('child2grand1'); - $child2grand2 = $child2->createChild('child2grand2'); - $child2grand2great1 = $child2grand2->createChild(null); - $child2grand2great2 = $child2grand2->createChild('child2grand2great2'); - - $endPoints = $root->getEndPoints(); - $endPointsArray = array(); - foreach ($endPoints as $endPoint) { - $endPointsArray[] = $endPoint->getValue(); - } - - $test = array( - 'child1', - 'child1grand2', - 'child2grand1', - 'child2grand2', - 'child2grand2great2' - ); - - $this->assertTrue($test === $endPointsArray, 'Test was [' . var_export($test, 1) . ']; endPoints were [' . var_export($endPointsArray, 1) . ']'); - } -} diff --git a/tests/Zend/Server/Reflection/ParameterTest.php b/tests/Zend/Server/Reflection/ParameterTest.php deleted file mode 100644 index 5bc87303586e38fccd09b8d1304bc44f2c7155ea..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/ParameterTest.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/Parameter.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_Server_Reflection_Parameter - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: ParameterTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_Reflection_ParameterTest extends PHPUnit_Framework_TestCase -{ - protected function _getParameter() - { - $method = new ReflectionMethod('Zend_Server_Reflection_Parameter', 'setType'); - $parameters = $method->getParameters(); - return $parameters[0]; - } - - /** - * __construct() test - * - * Call as method call - * - * Expects: - * - r: - * - type: Optional; has default; - * - description: Optional; has default; - * - * Returns: void - */ - public function test__construct() - { - $parameter = $this->_getParameter(); - - $reflection = new Zend_Server_Reflection_Parameter($parameter); - $this->assertTrue($reflection instanceof Zend_Server_Reflection_Parameter); - } - - /** - * __call() test - * - * Call as method call - * - * Expects: - * - method: - * - args: - * - * Returns: mixed - */ - public function test__call() - { - $r = new Zend_Server_Reflection_Parameter($this->_getParameter()); - - // just test a few call proxies... - $this->assertTrue(is_bool($r->allowsNull())); - $this->assertTrue(is_bool($r->isOptional())); - } - - /** - * get/setType() test - */ - public function testGetSetType() - { - $r = new Zend_Server_Reflection_Parameter($this->_getParameter()); - $this->assertEquals('mixed', $r->getType()); - - $r->setType('string'); - $this->assertEquals('string', $r->getType()); - } - - /** - * get/setDescription() test - */ - public function testGetDescription() - { - $r = new Zend_Server_Reflection_Parameter($this->_getParameter()); - $this->assertEquals('', $r->getDescription()); - - $r->setDescription('parameter description'); - $this->assertEquals('parameter description', $r->getDescription()); - } - - /** - * get/setPosition() test - */ - public function testSetPosition() - { - $r = new Zend_Server_Reflection_Parameter($this->_getParameter()); - $this->assertEquals(null, $r->getPosition()); - - $r->setPosition(3); - $this->assertEquals(3, $r->getPosition()); - } -} diff --git a/tests/Zend/Server/Reflection/PrototypeTest.php b/tests/Zend/Server/Reflection/PrototypeTest.php deleted file mode 100644 index 24b84e6b57e0680b9bb86ad187e4ecf62cd04a50..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/PrototypeTest.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/Prototype.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -require_once 'Zend/Server/Reflection.php'; -require_once 'Zend/Server/Reflection/Parameter.php'; -require_once 'Zend/Server/Reflection/ReturnValue.php'; - -/** - * Test case for Zend_Server_Reflection_Prototype - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: PrototypeTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_Reflection_PrototypeTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Server_Reflection_Prototype object - * @var Zend_Server_Reflection_Prototype - */ - protected $_r; - - /** - * Array of ReflectionParameters - * @var array - */ - protected $_parametersRaw; - - /** - * Array of Zend_Server_Reflection_Parameters - * @var array - */ - protected $_parameters; - - /** - * Setup environment - */ - public function setUp() - { - $class = new ReflectionClass('Zend_Server_Reflection'); - $method = $class->getMethod('reflectClass'); - $parameters = $method->getParameters(); - $this->_parametersRaw = $parameters; - - $fParameters = array(); - foreach ($parameters as $p) { - $fParameters[] = new Zend_Server_Reflection_Parameter($p); - } - $this->_parameters = $fParameters; - - $this->_r = new Zend_Server_Reflection_Prototype(new Zend_Server_Reflection_ReturnValue('void', 'No return')); - } - - /** - * Teardown environment - */ - public function tearDown() - { - unset($this->_r); - unset($this->_parameters); - unset($this->_parametersRaw); - } - - /** - * __construct() test - * - * Call as method call - * - * Expects: - * - return: - * - params: Optional; - * - * Returns: void - */ - public function test__construct() - { - $this->assertTrue($this->_r instanceof Zend_Server_Reflection_Prototype); - - try { - $r1 = new Zend_Server_Reflection_Prototype($this->_r->getReturnValue(), $this->_parametersRaw); - $this->fail('Construction should only accept Z_S_R_Parameters'); - } catch (Exception $e) { - // do nothing - } - - try { - $r1 = new Zend_Server_Reflection_Prototype($this->_r->getReturnValue(), 'string'); - $this->fail('Construction requires an array of parameters'); - } catch (Exception $e) { - // do nothing - } - } - - /** - * getReturnType() test - * - * Call as method call - * - * Returns: string - */ - public function testGetReturnType() - { - $this->assertEquals('void', $this->_r->getReturnType()); - } - - /** - * getReturnValue() test - * - * Call as method call - * - * Returns: Zend_Server_Reflection_ReturnValue - */ - public function testGetReturnValue() - { - $this->assertTrue($this->_r->getReturnValue() instanceof Zend_Server_Reflection_ReturnValue); - } - - /** - * getParameters() test - * - * Call as method call - * - * Returns: array - */ - public function testGetParameters() - { - $r = new Zend_Server_Reflection_Prototype($this->_r->getReturnValue(), $this->_parameters); - $p = $r->getParameters(); - - $this->assertTrue(is_array($p)); - foreach ($p as $parameter) { - $this->assertTrue($parameter instanceof Zend_Server_Reflection_Parameter); - } - - $this->assertTrue($p === $this->_parameters); - } -} diff --git a/tests/Zend/Server/Reflection/ReturnValueTest.php b/tests/Zend/Server/Reflection/ReturnValueTest.php deleted file mode 100644 index d163288f0ecc79c059182e1deb051ccaca509cc6..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/Reflection/ReturnValueTest.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection/ReturnValue.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_Server_Reflection_ReturnValue - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: ReturnValueTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_Reflection_ReturnValueTest extends PHPUnit_Framework_TestCase -{ - /** - * __construct() test - * - * Call as method call - * - * Expects: - * - type: Optional; has default; - * - description: Optional; has default; - * - * Returns: void - */ - public function test__construct() - { - $obj = new Zend_Server_Reflection_ReturnValue(); - $this->assertTrue($obj instanceof Zend_Server_Reflection_ReturnValue); - } - - /** - * getType() test - * - * Call as method call - * - * Returns: string - */ - public function testGetType() - { - $obj = new Zend_Server_Reflection_ReturnValue(); - $this->assertEquals('mixed', $obj->getType()); - - $obj->setType('array'); - $this->assertEquals('array', $obj->getType()); - } - - /** - * setType() test - * - * Call as method call - * - * Expects: - * - type: - * - * Returns: void - */ - public function testSetType() - { - $obj = new Zend_Server_Reflection_ReturnValue(); - - $obj->setType('array'); - $this->assertEquals('array', $obj->getType()); - } - - /** - * getDescription() test - * - * Call as method call - * - * Returns: string - */ - public function testGetDescription() - { - $obj = new Zend_Server_Reflection_ReturnValue('string', 'Some description'); - $this->assertEquals('Some description', $obj->getDescription()); - - $obj->setDescription('New Description'); - $this->assertEquals('New Description', $obj->getDescription()); - } - - /** - * setDescription() test - * - * Call as method call - * - * Expects: - * - description: - * - * Returns: void - */ - public function testSetDescription() - { - $obj = new Zend_Server_Reflection_ReturnValue(); - - $obj->setDescription('New Description'); - $this->assertEquals('New Description', $obj->getDescription()); - } -} diff --git a/tests/Zend/Server/ReflectionTest.php b/tests/Zend/Server/ReflectionTest.php deleted file mode 100644 index 876f46fadc41e4558efef288ffeebf379da0e6d3..0000000000000000000000000000000000000000 --- a/tests/Zend/Server/ReflectionTest.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -require_once 'Zend/Server/Reflection.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_Server_Reflection - * - * @package Zend_Server - * @subpackage UnitTests - * @version $Id: ReflectionTest.php 1625 2006-11-15 17:45:10Z darby $ - */ -class Zend_Server_ReflectionTest extends PHPUnit_Framework_TestCase -{ - /** - * reflectClass() test - */ - public function testReflectClass() - { - try { - $reflection = Zend_Server_Reflection::reflectClass('Zend_Server_Reflection_testClass'); - $this->assertTrue($reflection instanceof Zend_Server_Reflection_Class); - } catch (Exception $e) { - $this->fail('Failed to perform class reflection: ' . $e->getMessage()); - } - - try { - $reflection = Zend_Server_Reflection::reflectClass(new Zend_Server_Reflection_testClass()); - $this->assertTrue($reflection instanceof Zend_Server_Reflection_Class); - } catch (Exception $e) { - $this->fail('Failed to perform object reflection: ' . $e->getMessage()); - } - - try { - $reflection = Zend_Server_Reflection::reflectClass('Zend_Server_Reflection_testClass', 'string'); - $this->fail('Passing non-array for argv should fail'); - } catch (Exception $e) { - // do nothing - } - - try { - $reflection = Zend_Server_Reflection::reflectClass(false); - $this->fail('Passing non-object/class should fail'); - } catch (Exception $e) { - // do nothing - } - } - - /** - * reflectClass() test; test namespaces - */ - public function testReflectClass2() - { - $reflection = Zend_Server_Reflection::reflectClass('Zend_Server_Reflection_testClass', false, 'zsr'); - $this->assertEquals('zsr', $reflection->getNamespace()); - } - - /** - * reflectFunction() test - */ - public function testReflectFunction() - { - try { - $reflection = Zend_Server_Reflection::reflectFunction('Zend_Server_Reflection_testFunction'); - $this->assertTrue($reflection instanceof Zend_Server_Reflection_Function); - } catch (Exception $e) { - $this->fail('Function reflection failed: ' . $e->getMessage()); - } - - try { - $reflection = Zend_Server_Reflection::reflectFunction(false); - $this->fail('Function reflection should require valid function'); - } catch (Exception $e) { - // do nothing - } - - try { - $reflection = Zend_Server_Reflection::reflectFunction('Zend_Server_Reflection_testFunction', 'string'); - $this->fail('Argv array should be an array'); - } catch (Exception $e) { - // do nothing - } - } - - /** - * reflectFunction() test; test namespaces - */ - public function testReflectFunction2() - { - $reflection = Zend_Server_Reflection::reflectFunction('Zend_Server_Reflection_testFunction', false, 'zsr'); - $this->assertEquals('zsr', $reflection->getNamespace()); - } -} - -/** - * Zend_Server_Reflection_testFunction - * - * Used to test reflectFunction generation of signatures - * - * @param boolean $arg1 - * @param string|array $arg2 - * @param string $arg3 Optional argument - * @param string|struct|false $arg4 Optional argument - * @return boolean|array - */ -function Zend_Server_Reflection_testFunction($arg1, $arg2, $arg3 = 'string', $arg4 = 'array') -{ -} - -/** - * Zend_Server_Reflection_testClass -- test class reflection - */ -class Zend_Server_Reflection_testClass -{ - /** - * Constructor - * - * This shouldn't be reflected - * - * @param mixed $arg - * @return void - */ - public function __construct($arg = null) - { - } - - /** - * Public one - * - * @param string $arg1 - * @param array $arg2 - * @return string - */ - public function one($arg1, $arg2 = null) - { - } - - /** - * Protected _one - * - * Should not be reflected - * - * @param string $arg1 - * @param array $arg2 - * @return string - */ - protected function _one($arg1, $arg2 = null) - { - } - - /** - * Public two - * - * @param string $arg1 - * @param string $arg2 - * @return boolean|array - */ - public static function two($arg1, $arg2) - { - } -} diff --git a/tests/Zend/Service/AkismetTest.php b/tests/Zend/Service/AkismetTest.php deleted file mode 100644 index c8f8f3531bf2fc1da10b6c05725ba0e6e8bfb799..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/AkismetTest.php +++ /dev/null @@ -1,235 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Service_Akismet - */ -require_once 'Zend/Service/Akismet.php'; - -/** - * @see Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - - -/** - * @package Zend_Service - * @subpackage UnitTests - */ -class Zend_Service_AkismetTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->akismet = new Zend_Service_Akismet('somebogusapikey', 'http://framework.zend.com/wiki/'); - $adapter = new Zend_Http_Client_Adapter_Test(); - $client = new Zend_Http_Client(null, array( - 'adapter' => $adapter - )); - $this->adapter = $adapter; - Zend_Service_Akismet::setHttpClient($client); - - $this->comment = array( - 'user_ip' => '71.161.221.76', - 'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1)', - 'comment_type' => 'comment', - 'comment_content' => 'spam check' - ); - } - - public function testBlogUrl() - { - $this->assertEquals('http://framework.zend.com/wiki/', $this->akismet->getBlogUrl()); - $this->akismet->setBlogUrl('http://framework.zend.com/'); - $this->assertEquals('http://framework.zend.com/', $this->akismet->getBlogUrl()); - } - - public function testApiKey() - { - $this->assertEquals('somebogusapikey', $this->akismet->getApiKey()); - $this->akismet->setApiKey('invalidapikey'); - $this->assertEquals('invalidapikey', $this->akismet->getApiKey()); - } - - public function testCharset() - { - $this->assertEquals('UTF-8', $this->akismet->getCharset()); - $this->akismet->setCharset('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $this->akismet->getCharset()); - } - - public function testPort() - { - $this->assertEquals(80, $this->akismet->getPort()); - $this->akismet->setPort(8080); - $this->assertEquals(8080, $this->akismet->getPort()); - } - - public function testUserAgent() - { - $this->akismet->setUserAgent('MyUserAgent/1.0 | Akismet/1.11'); - $this->assertEquals('MyUserAgent/1.0 | Akismet/1.11', $this->akismet->getUserAgent()); - } - - public function testUserAgentDefaultMatchesFrameworkVersion() - { - $this->assertContains('Zend Framework/' . Zend_Version::VERSION, $this->akismet->getUserAgent()); - } - - public function testVerifyKey() - { - $response = "HTTP/1.0 200 OK\r\n" - . "Content-type: text/plain; charset=utf-8\r\n" - . "Content-length: 5\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 14:41:24 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "valid"; - $this->adapter->setResponse($response); - $this->assertTrue($this->akismet->verifyKey()); - - $response = "HTTP/1.0 200 OK\r\n" - . "Content-type: text/plain; charset=utf-8\r\n" - . "Content-length: 7\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 14:41:24 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "invalid"; - $this->adapter->setResponse($response); - $this->assertFalse($this->akismet->verifyKey()); - } - - public function testIsSpamThrowsExceptionOnInvalidKey() - { - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/4.4.2\r\n" - . "Content-type: text/plain; charset=utf-8\r\n" - . "X-akismet-server: 72.21.44.242\r\n" - . "Content-length: 7\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 14:50:24 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "invalid"; - $this->adapter->setResponse($response); - try { - $this->akismet->isSpam($this->comment); - $this->fail('Response of "invalid" should trigger exception'); - } catch (Exception $e) { - // success - } - } - - public function testIsSpam() - { - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/4.4.2\r\n" - . "Content-type: text/plain; charset=utf-8\r\n" - . "X-akismet-server: 72.21.44.242\r\n" - . "Content-length: 4\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 14:50:24 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "true"; - $this->adapter->setResponse($response); - $this->assertTrue($this->akismet->isSpam($this->comment)); - - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/4.4.2\r\n" - . "Content-type: text/plain; charset=utf-8\r\n" - . "X-akismet-server: 72.21.44.242\r\n" - . "Content-length: 5\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 14:50:24 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "false"; - $this->adapter->setResponse($response); - $this->assertFalse($this->akismet->isSpam($this->comment)); - } - - public function testSubmitSpamThrowsExceptionOnInvalidKey() - { - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/4.4.2\r\n" - . "Content-type: text/plain; charset=utf-8\r\n" - . "X-akismet-server: 72.21.44.242\r\n" - . "Content-length: 7\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 14:50:24 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "invalid"; - $this->adapter->setResponse($response); - try { - $this->akismet->submitSpam($this->comment); - $this->fail('Response of "invalid" should trigger exception'); - } catch (Exception $e) { - // success - } - } - - public function testSubmitSpam() - { - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/4.4.2\r\n" - . "Content-type: text/html\r\n" - . "Content-length: 41\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "Thanks for making the web a better place."; - $this->adapter->setResponse($response); - try { - $this->akismet->submitSpam($this->comment); - } catch (Exception $e) { - $this->fail('Valid key should not throw exceptions'); - } - } - - public function testSubmitHam() - { - $response = "HTTP/1.0 200 OK\r\n" - . "X-powered-by: PHP/4.4.2\r\n" - . "Content-type: text/html\r\n" - . "Content-length: 41\r\n" - . "Server: LiteSpeed\r\n" - . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" - . "Connection: close\r\n" - . "\r\n" - . "Thanks for making the web a better place."; - $this->adapter->setResponse($response); - try { - $this->akismet->submitHam($this->comment); - } catch (Exception $e) { - $this->fail('Valid key should not throw exceptions'); - } - } -} diff --git a/tests/Zend/Service/AllTests.php b/tests/Zend/Service/AllTests.php deleted file mode 100644 index 6f37919ab53f875339ace9fd13f4c5f006db02c8..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/AllTests.php +++ /dev/null @@ -1,151 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10743 2008-08-07 02:24:43Z matthew $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_AkismetTest - */ -require_once 'Zend/Service/AkismetTest.php'; - -/** - * @see Zend_Service_Amazon_AllTests - */ -require_once 'Zend/Service/Amazon/AllTests.php'; - -/** - * @see Zend_Service_Audioscrobbler_AllTests - */ -require_once 'Zend/Service/Audioscrobbler/AllTests.php'; - -/** - * @see Zend_Service_Delicious_AllTests - */ -require_once 'Zend/Service/Delicious/AllTests.php'; - -/** - * @see Zend_Service_Flickr_AllTests - */ -require_once 'Zend/Service/Flickr/AllTests.php'; - -/** - * @see Zend_Service_Nirvanix_AllTests - */ -require_once 'Zend/Service/Nirvanix/AllTests.php'; - -/** - * @see Zend_Service_ReCaptcha_AllTests - */ -require_once 'Zend/Service/ReCaptcha/AllTests.php'; - -/** - * @see Zend_Service_SimpyTest - */ -require_once 'Zend/Service/SimpyTest.php'; - -/** - * @see Zend_Service_SlideShareTest - */ -require_once 'Zend/Service/SlideShareTest.php'; - -/** - * @see Zend_Service_StrikeIron_AllTests - */ -require_once 'Zend/Service/StrikeIron/AllTests.php'; - -/** - * @see Zend_Service_Technorati_AllTests - */ -require_once 'Zend/Service/Technorati/AllTests.php'; - -/** - * @see Zend_Service_Yahoo_AllTests - */ -require_once 'Zend/Service/Yahoo/AllTests.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service'); - - $suite->addTestSuite('Zend_Service_AkismetTest'); - $suite->addTest(Zend_Service_Amazon_AllTests::suite()); - $suite->addTest(Zend_Service_Audioscrobbler_AllTests::suite()); - $suite->addTest(Zend_Service_Delicious_AllTests::suite()); - $suite->addTest(Zend_Service_Flickr_AllTests::suite()); - $suite->addTest(Zend_Service_Nirvanix_AllTests::suite()); - $suite->addTest(Zend_Service_ReCaptcha_AllTests::suite()); - if (defined('TESTS_ZEND_SERVICE_SIMPY_ENABLED') && constant('TESTS_ZEND_SERVICE_SIMPY_ENABLED')) { - $suite->addTestSuite('Zend_Service_SimpyTest'); - } else { - $suite->addTestSuite('Zend_Service_SimpyTest_Skip'); - } - $suite->addTestSuite('Zend_Service_SlideShareTest'); - $suite->addTest(Zend_Service_StrikeIron_AllTests::suite()); - $suite->addTest(Zend_Service_Technorati_AllTests::suite()); - $suite->addTest(Zend_Service_Yahoo_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_AllTests::main') { - Zend_Service_AllTests::main(); -} diff --git a/tests/Zend/Service/Amazon/AllTests.php b/tests/Zend/Service/Amazon/AllTests.php deleted file mode 100644 index 51ecf1c322cffa97fc23f467940167fe6cc011b1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Amazon/AllTests.php +++ /dev/null @@ -1,93 +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_Service_Amazon - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Amazon_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_Amazon_OfflineTest - */ -require_once 'Zend/Service/Amazon/OfflineTest.php'; - -/** - * @see Zend_Service_Amazon_OnlineTest - */ -require_once 'Zend/Service/Amazon/OnlineTest.php'; - - -/** - * @category Zend - * @package Zend_Service_Amazon - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Amazon_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Amazon'); - - $suite->addTestSuite('Zend_Service_Amazon_OfflineTest'); - if (defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED') && - constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED') && - defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID')) { - $suite->addTestSuite('Zend_Service_Amazon_OnlineTest'); - } else { - $suite->addTestSuite('Zend_Service_Amazon_OnlineTest_Skip'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_Amazon_AllTests::main') { - Zend_Service_Amazon_AllTests::main(); -} diff --git a/tests/Zend/Service/Amazon/OfflineTest.php b/tests/Zend/Service/Amazon/OfflineTest.php deleted file mode 100644 index 2a0d38faccec5d2af00fd69039909f7ac4d63070..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Amazon/OfflineTest.php +++ /dev/null @@ -1,95 +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_Service_Amazon - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OfflineTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Amazon - */ -require_once 'Zend/Service/Amazon.php'; - -/** - * @see Zend_Http_Client_Adapter_Socket - */ -require_once 'Zend/Http/Client/Adapter/Socket.php'; - -/** - * @see Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - - -/** - * @category Zend - * @package Zend_Service_Amazon - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Amazon_OfflineTest extends PHPUnit_Framework_TestCase -{ - /** - * Reference to Amazon service consumer object - * - * @var Zend_Service_Amazon - */ - protected $_amazon; - - /** - * HTTP client adapter for testing - * - * @var Zend_Http_Client_Adapter_Test - */ - protected $_httpClientAdapterTest; - - /** - * Sets up this test case - * - * @return void - */ - public function setUp() - { - $this->_amazon = new Zend_Service_Amazon(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID')); - - $this->_httpClientAdapterTest = new Zend_Http_Client_Adapter_Test(); - } - - /** - * Ensures that __construct() throws an exception when given an invalid country code - * - * @return void - */ - public function testConstructExceptionCountryCodeInvalid() - { - try { - $amazon = new Zend_Service_Amazon(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), 'oops'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('Unknown country code', $e->getMessage()); - } - } -} diff --git a/tests/Zend/Service/Amazon/OnlineTest.php b/tests/Zend/Service/Amazon/OnlineTest.php deleted file mode 100644 index 5ecc15595e022752cfe06fa93978b0c7be3dc7df..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Amazon/OnlineTest.php +++ /dev/null @@ -1,337 +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_Service_Amazon - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OnlineTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Amazon - */ -require_once 'Zend/Service/Amazon.php'; - -/** - * @see Zend_Service_Amazon_Query - */ -require_once 'Zend/Service/Amazon/Query.php'; - -/** - * @see Zend_Http_Client_Adapter_Socket - */ -require_once 'Zend/Http/Client/Adapter/Socket.php'; - - -/** - * @category Zend - * @package Zend_Service_Amazon - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Amazon_OnlineTest extends PHPUnit_Framework_TestCase -{ - /** - * Reference to Amazon service consumer object - * - * @var Zend_Service_Amazon - */ - protected $_amazon; - - /** - * Reference to Amazon query API object - * - * @var Zend_Service_Amazon_Query - */ - protected $_query; - - /** - * Socket based HTTP client adapter - * - * @var Zend_Http_Client_Adapter_Socket - */ - protected $_httpClientAdapterSocket; - - /** - * Sets up this test case - * - * @return void - */ - public function setUp() - { - $this->_amazon = new Zend_Service_Amazon(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID')); - - $this->_query = new Zend_Service_Amazon_Query(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID')); - - $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket(); - - $this->_amazon->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterSocket); - - // terms of use compliance: no more than one query per second - sleep(1); - } - - /** - * Ensures that itemSearch() works as expected when searching for PHP books - * - * @return void - */ - public function testItemSearchBooksPhp() - { - $resultSet = $this->_amazon->itemSearch(array( - 'SearchIndex' => 'Books', - 'Keywords' => 'php', - 'ResponseGroup' => 'Small,ItemAttributes,Images,SalesRank,Reviews,EditorialReview,Similarities,' - . 'ListmaniaLists' - )); - - $this->assertTrue(10 < $resultSet->totalResults()); - $this->assertTrue(1 < $resultSet->totalPages()); - $this->assertEquals(0, $resultSet->key()); - - try { - $resultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->seek(9); - - try { - $resultSet->seek(10); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - foreach ($resultSet as $item) { - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } - - $this->assertTrue(simplexml_load_string($item->asXml()) instanceof SimpleXMLElement); - } - - /** - * Ensures that itemSearch() works as expected when searching for music with keyword of Mozart - * - * @return void - */ - public function testItemSearchMusicMozart() - { - $resultSet = $this->_amazon->itemSearch(array( - 'SearchIndex' => 'Music', - 'Keywords' => 'Mozart', - 'ResponseGroup' => 'Small,Tracks,Offers' - )); - - foreach ($resultSet as $item) { - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } - } - - /** - * Ensures that itemSearch() works as expected when searching for digital cameras - * - * @return void - */ - public function testItemSearchElectronicsDigitalCamera() - { - $resultSet = $this->_amazon->itemSearch(array( - 'SearchIndex' => 'Electronics', - 'Keywords' => 'digital camera', - 'ResponseGroup' => 'Accessories' - )); - - foreach ($resultSet as $item) { - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } - } - - /** - * Ensures that itemSearch() works as expected when sorting - * - * @return void - */ - public function testItemSearchBooksPHPSort() - { - $resultSet = $this->_amazon->itemSearch(array( - 'SearchIndex' => 'Books', - 'Keywords' => 'php', - 'Sort' => '-titlerank' - )); - - foreach ($resultSet as $item) { - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } - } - - /** - * Ensures that itemSearch() throws an exception when provided an invalid city - * - * @return void - */ - public function testItemSearchExceptionCityInvalid() - { - try { - $this->_amazon->itemSearch(array( - 'SearchIndex' => 'Restaurants', - 'Keywords' => 'seafood', - 'City' => 'Des Moines' - )); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - } - } - - /** - * Ensures that itemLookup() works as expected - * - * @return void - */ - public function testItemLookup() - { - $item = $this->_amazon->itemLookup('B0000A432X'); - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } - - /** - * Ensures that itemLookup() throws an exception when provided an invalid ASIN - * - * @return void - */ - public function testItemLookupExceptionAsinInvalid() - { - try { - $this->_amazon->itemLookup('oops'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('not a valid value for ItemId', $e->getMessage()); - } - } - - /** - * Ensures that itemLookup() works as expected when provided multiple ASINs - * - * @return void - */ - public function testItemLookupMultiple() - { - $resultSet = $this->_amazon->itemLookup('0596006810,1590593804'); - - $count = 0; - foreach ($resultSet as $item) { - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - $count++; - } - - $this->assertEquals(2, $count); - } - - /** - * Ensures that itemLookup() throws an exception when given a SearchIndex - * - * @return void - */ - public function testItemLookupExceptionSearchIndex() - { - try { - $this->_amazon->itemLookup('oops', array('SearchIndex' => 'Books')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('restricted parameter combination', $e->getMessage()); - } - } - - /** - * Ensures that the query API works as expected when searching for PHP books - * - * @return void - */ - public function testQueryBooksPhp() - { - $resultSet = $this->_query->category('Books')->Keywords('php')->search(); - - foreach ($resultSet as $item) { - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } - } - - /** - * Ensures that the query API throws an exception when a category is not first provided - * - * @return void - */ - public function testQueryExceptionCategoryMissing() - { - try { - $this->_query->Keywords('php'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('set a category', $e->getMessage()); - } - } - - /** - * Ensures that the query API throws an exception when the category is invalid - * - * @return void - */ - public function testQueryExceptionCategoryInvalid() - { - try { - $this->_query->category('oops')->search(); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('SearchIndex is invalid', $e->getMessage()); - } - } - - /** - * Ensures that the query API works as expected when searching by ASIN - * - * @return void - */ - public function testQueryAsin() - { - $item = $this->_query->asin('B0000A432X')->search(); - $this->assertTrue($item instanceof Zend_Service_Amazon_Item); - } -} - - -class Zend_Service_Amazon_OnlineTest_Skip extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped('Zend_Service_Amazon online tests not enabled with an access key ID in ' - . 'TestConfiguration.php'); - } - - public function testNothing() - { - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Audioscrobbler/AlbumDataTest.php b/tests/Zend/Service/Audioscrobbler/AlbumDataTest.php deleted file mode 100644 index c8a8510221cb69a59be81f5317928ac7e155ad6c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/AlbumDataTest.php +++ /dev/null @@ -1,127 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AlbumDataTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_AlbumDataTest extends PHPUnit_Framework_TestCase -{ - var $header = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n"; - - public function testGetAlbumInfo() - { - try { - $test_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<album artist="Metallica" title="Metallica"> - <reach>85683</reach> - <url>http://www.last.fm/music/Metallica/Metallica</url> - <releasedate> 1 Jan 1994, 00:00</releasedate> - <coverart> - <small>http://static.last.fm/coverart/50x50/1411800.jpg</small> - <medium>http://static.last.fm/coverart/130x130/1411800.jpg</medium> - <large>http://static.last.fm/coverart/300x300/1411800.jpg</large> - </coverart> - <mbid>3750d9e2-59f5-471d-8916-463433069bd1</mbid> - <tracks> - <track title="Enter Sandman (LP Version)"> - <reach>26</reach> - <url>http://www.last.fm/music/Metallica/_/Enter+Sandman+%28LP+Version%29</url> - </track> - <track title="Sad But True (LP Version)"> - <reach>22</reach> - <url>http://www.last.fm/music/Metallica/_/Sad+But+True+%28LP+Version%29</url> - </track> - <track title="Holier Than Thou (LP Version)"> - <reach>2</reach> - <url>http://www.last.fm/music/Metallica/_/Holier+Than+Thou+%28LP+Version%29</url> - </track> - <track title="The Unforgiven (LP Version)"> - <reach>10</reach> - <url>http://www.last.fm/music/Metallica/_/The+Unforgiven+%28LP+Version%29</url> - </track> - <track title="Wherever I May Roam (LP Version)"> - <reach>4</reach> - <url>http://www.last.fm/music/Metallica/_/Wherever+I+May+Roam+%28LP+Version%29</url> - </track> - <track title="Don\'t Tread On Me (LP Version)"> - <reach>3</reach> - <url>http://www.last.fm/music/Metallica/_/Don%27t+Tread+On+Me+%28LP+Version%29</url> - </track> - <track title="Through The Never (LP Version)"> - <reach>3</reach> - <url>http://www.last.fm/music/Metallica/_/Through+The+Never+%28LP+Version%29</url> - </track> - <track title="Nothing Else Matters (LP Version)"> - <reach>26</reach> - <url>http://www.last.fm/music/Metallica/_/Nothing+Else+Matters+%28LP+Version%29</url> - </track> - <track title="Of Wolf And Man (LP Version)"> - <reach>3</reach> - <url>http://www.last.fm/music/Metallica/_/Of+Wolf+And+Man+%28LP+Version%29</url> - </track> - <track title="The God That Failed (LP Version)"> - <reach>2</reach> - <url>http://www.last.fm/music/Metallica/_/The+God+That+Failed+%28LP+Version%29</url> - </track> - <track title="My Friend Of Misery (LP Version)"> - <reach>3</reach> - <url>http://www.last.fm/music/Metallica/_/My+Friend+Of+Misery+%28LP+Version%29</url> - </track> - <track title="The Struggle Within (LP Version)"> - <reach>3</reach> - <url>http://www.last.fm/music/Metallica/_/The+Struggle+Within+%28LP+Version%29</url> - </track> - </tracks> -</album> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); - $as->set('album', 'Metallica'); - $as->set('artist', 'Metallica'); - $response = $as->albumGetInfo(); - $track = $response->tracks->track[0]; - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$response['title'], 'Metallica'); - $this->assertEquals((string)$track->url, 'http://www.last.fm/music/Metallica/_/Enter+Sandman+%28LP+Version%29'); - $this->assertEquals(count($response->tracks->track), 12); - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } -} diff --git a/tests/Zend/Service/Audioscrobbler/AllTests.php b/tests/Zend/Service/Audioscrobbler/AllTests.php deleted file mode 100644 index 1d95197ce49e5aa7063a76219ac5479ed531f8de..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/AllTests.php +++ /dev/null @@ -1,104 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Audioscrobbler_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_Audioscrobbler_AudioscrobblerTest - */ -require_once 'Zend/Service/Audioscrobbler/AudioscrobblerTest.php'; - -/** - * @see Zend_Service_Audioscrobbler_ProfileTest - */ -require_once 'Zend/Service/Audioscrobbler/ProfileTest.php'; - -/** - * @see Zend_Service_Audioscrobbler_ArtistTest - */ -require_once 'Zend/Service/Audioscrobbler/ArtistTest.php'; - -/** - * @see Zend_Service_Audioscrobbler_AlbumDataTest - */ -require_once 'Zend/Service/Audioscrobbler/AlbumDataTest.php'; - -/** - * @see Zend_Service_Audioscrobbler_TrackDataTest - */ -require_once 'Zend/Service/Audioscrobbler/TrackDataTest.php'; - -/** - * @see Zend_Service_Audioscrobbler_TagDataTest - */ -require_once 'Zend/Service/Audioscrobbler/TagDataTest.php'; - -/** - * @see Zend_Service_Audioscrobbler_GroupTest - */ -require_once 'Zend/Service/Audioscrobbler/GroupTest.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Audioscrobbler'); - - $suite->addTestSuite('Zend_Service_Audioscrobbler_AudioscrobblerTest'); - $suite->addTestSuite('Zend_Service_Audioscrobbler_ProfileTest'); - $suite->addTestSuite('Zend_Service_Audioscrobbler_ArtistTest'); - $suite->addTestSuite('Zend_Service_Audioscrobbler_AlbumDataTest'); - $suite->addTestSuite('Zend_Service_Audioscrobbler_TrackDataTest'); - $suite->addTestSuite('Zend_Service_Audioscrobbler_TagDataTest'); - $suite->addTestSuite('Zend_Service_Audioscrobbler_GroupTest'); - - return $suite; - } -} - diff --git a/tests/Zend/Service/Audioscrobbler/ArtistTest.php b/tests/Zend/Service/Audioscrobbler/ArtistTest.php deleted file mode 100644 index 2faffdd386f3e9f8f25734b9a669ec9e516a4b3f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/ArtistTest.php +++ /dev/null @@ -1,227 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ArtistTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_ArtistTest extends PHPUnit_Framework_TestCase -{ - var $header = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n"; - - public function testGetRelatedArtists() - { - try { - $test_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <similarartists artist="Metallica" streamable="1" picture="http://static.last.fm/proposedimages/sidebar/6/1000024/1285.jpg" mbid="65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab"> - <artist> - <name>Iron Maiden</name> - <mbid>ca891d65-d9b0-4258-89f7-e6ba29d83767</mbid> - <match>100</match> - <url>http://www.last.fm/music/Iron+Maiden</url> - <image_small>http://static.last.fm/proposedimages/thumbnail/6/1000107/459375.jpg</image_small> - <image>http://static.last.fm/proposedimages/sidebar/6/1000107/459375.jpg</image> - <streamable>1</streamable> - </artist> - <artist> - <name>System of a Down</name> - <mbid>cc0b7089-c08d-4c10-b6b0-873582c17fd6</mbid> - <match>96</match> - <url>http://www.last.fm/music/System+of+a+Down</url> - <image_small>http://static.last.fm/proposedimages/thumbnail/6/4468/52383.jpg</image_small> - <image>http://static.last.fm/proposedimages/sidebar/6/4468/52383.jpg</image> - <streamable>1</streamable> - </artist> - </similarartists>'; - $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); - $as->set('artist', 'Metallica'); - $response = $as->artistGetRelatedArtists(); - $artist = $response->artist[0]; - $this->assertEquals(count($response->artist), 2); - $this->assertEquals((string)$artist->name, 'Iron Maiden'); - $this->assertEquals((string)$response['artist'], 'Metallica'); - return; - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - - } - - public function testGetFans() - { - try { - $test_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <fans artist="Metallica"> - <user username="Liquid_Fire"> - <url>http://www.last.fm/user/Liquid_Fire/</url> - <image>http://static.last.fm/avatar/d8d9af8246e537078a57d5dc826cb34a.gif</image> - <weight>617010250</weight> - </user> - <user username="CeciltheDark"> - <url>http://www.last.fm/user/CeciltheDark/</url> - <image>http://static.last.fm/avatar/30f0417393b696ac2ea06213bc5777d9.png</image> - <weight>382812500</weight> - </user> - </fans> - '; - $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); - $as->set('artist', 'Metallica'); - $response = $as->artistGetTopFans(); - $user = $response->user[0]; - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$user->url, 'http://www.last.fm/user/Liquid_Fire/'); - return; - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testTopTracks() - { - try { - $test_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <mostknowntracks artist="Metallica"> - <track> - <name>Nothing Else Matters</name> - <mbid></mbid> - <reach>7481</reach> - <url>http://www.last.fm/music/Metallica/_/Nothing+Else+Matters</url> - </track> - <track> - <name>Enter Sandman</name> - <mbid></mbid> - <reach>7139</reach> - <url>http://www.last.fm/music/Metallica/_/Enter+Sandman</url> - </track> - </mostknowntracks>'; - $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); - $as->set('artist', 'Metallica'); - $response = $as->artistGetTopTracks(); - $track = $response->track[0]; - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$track->name, 'Nothing Else Matters'); - $this->assertEquals((int)$track->reach, 7481); - return; - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testTopAlbums() - { - try { - $test_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <topalbums artist="Metallica"> - <album> - <name>Master of Puppets</name> - <mbid>fed37cfc-2a6d-4569-9ac0-501a7c7598eb</mbid> - <reach>28940</reach> - <url>http://www.last.fm/music/Metallica/Master+of+Puppets</url> - <releasedate>7 Oct 1986, 00:00</releasedate> - <coverart> - <small>http://static.last.fm/coverart/50x50/1411810.jpg</small> - <medium>http://static.last.fm/coverart/130x130/1411810.jpg</medium> - <large>http://static.last.fm/coverart/300x300/1411810.jpg</large> - </coverart> - </album> - <album> - <name>Reload</name> - <mbid>b05cf8e3-67ad-4d40-9dc1-3a697e3a1bf8</mbid> - <reach>27226</reach> - <url>http://www.last.fm/music/Metallica/Reload</url> - <releasedate>18 Nov 1997, 00:00</releasedate> - <coverart> - <small>http://images.amazon.com/images/P/B000002HRE.01._SCMZZZZZZZ_.jpg</small> - <medium>http://images.amazon.com/images/P/B000002HRE.01._SCMZZZZZZZ_.jpg</medium> - <large>http://images.amazon.com/images/P/B000002HRE.01._SCMZZZZZZZ_.jpg</large> - </coverart> - </album> - </topalbums> - '; - $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); - $as->set('artist', 'Metallica'); - $response = $as->artistGetTopAlbums(); - $album = $response->album[0]; - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$album->name, 'Master of Puppets'); - $this->assertEquals((string)$album->coverart->small, 'http://static.last.fm/coverart/50x50/1411810.jpg'); - return; - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testTopTags() - { - try { - $test_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <toptags artist="Metallica"> - <tag> - <name>metal</name> - <count>100</count> - <url>http://www.last.fm/tag/metal</url> - </tag> - <tag> - <name>heavy metal</name> - <count>24</count> - <url>http://www.last.fm/tag/heavy%20metal</url> - </tag> - <tag> - <name>thrash metal</name> - <count>18</count> - <url>http://www.last.fm/tag/thrash%20metal</url> - </tag> - </toptags> - '; - $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); - $as->set('artist', 'Metallica'); - $response = $as->artistGetTopTags(); - $tag = $response->tag[0]; - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$tag->name, 'metal'); - $this->assertEquals((int)$tag->count, 100); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } -} diff --git a/tests/Zend/Service/Audioscrobbler/AudioscrobblerTest.php b/tests/Zend/Service/Audioscrobbler/AudioscrobblerTest.php deleted file mode 100644 index be8dc026d6fe279b6f7664d4532ac8469561c565..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/AudioscrobblerTest.php +++ /dev/null @@ -1,81 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AudioscrobblerTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_AudioscrobblerTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - } - - public function testRequestThrowsHttpClientExceptionWithNoUserError() - { - $as = new Zend_Service_Audioscrobbler(true, self::readTestResponse('errorNoUserExists')); - $as->set('user', 'foobarfoo'); - - try { - $response = $as->userGetProfileInformation(); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Http_Client_Exception $e) { - $this->assertContains("No user exists with this name", $e->getMessage()); - } - } - - public function testRequestThrowsHttpClientExceptionWithoutSuccessfulResponse() - { - $as = new Zend_Service_Audioscrobbler(true, self::readTestResponse('errorResponseStatusError')); - $as->set('user', 'foobarfoo'); - - try { - $response = $as->userGetProfileInformation(); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Http_Client_Exception $e) { - $this->assertContains("404", $e->getMessage()); - } - } - - public static function readTestResponse($file) - { - return file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $file); - } - - -} diff --git a/tests/Zend/Service/Audioscrobbler/GroupTest.php b/tests/Zend/Service/Audioscrobbler/GroupTest.php deleted file mode 100644 index 00607a61658d187b67b553c97ca9fca2eefc9571..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/GroupTest.php +++ /dev/null @@ -1,309 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: GroupTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_GroupTest extends PHPUnit_Framework_TestCase -{ - var $header = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n"; - - public function testWeeklyChartList() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<weeklychartlist group="Jazz Club"> - <chart from="1159099200" to="1159704000"/> - <chart from="1159704000" to="1160308800"/> - <chart from="1160308800" to="1160913600"/> - <chart from="1160913600" to="1161518400"/> - <chart from="1161518400" to="1162123200"/> - <chart from="1162123200" to="1162728000"/> - <chart from="1162728000" to="1163332800"/> - <chart from="1163332800" to="1163937600"/> - <chart from="1163937600" to="1164542400"/> - <chart from="1164542400" to="1165147200"/> - <chart from="1165147200" to="1165752000"/> - <chart from="1165752000" to="1166356800"/> - <chart from="1166356800" to="1166961600"/> - <chart from="1166961600" to="1167566400"/> - <chart from="1167566400" to="1168171200"/> - <chart from="1168171200" to="1168776000"/> - <chart from="1168776000" to="1169380800"/> - <chart from="1169380800" to="1169985600"/> - <chart from="1169985600" to="1170590400"/> - <chart from="1170590400" to="1171195200"/> - <chart from="1171195200" to="1171800000"/> - <chart from="1171800000" to="1172404800"/> - <chart from="1172404800" to="1173009600"/> -</weeklychartlist> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('group', urlencode('Jazz Club')); - $response = $as->groupGetWeeklyChartList(); - $chart = $response->chart[0]; - $this->assertEquals((int)$chart['from'], 1159099200); - $this->assertEquals((string)$response['group'], 'Jazz Club'); - return; - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - - } - - public function testWeeklyArtistChartList() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<weeklyartistchart group="Jazz Club" from="1172404800" to="1173009600"> -<artist> - <name>Miles Davis</name> - <mbid>561d854a-6a28-4aa7-8c99-323e6ce46c2a</mbid> - <chartposition>1</chartposition> - <reach>194</reach> - <url>http://www.last.fm/music/Miles+Davis</url> -</artist> -<artist> - <name>The Beatles</name> - <mbid>b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d</mbid> - <chartposition>2</chartposition> - <reach>156</reach> - <url>http://www.last.fm/music/The+Beatles</url> -</artist> -<artist> - <name>Pink Floyd</name> - <mbid>83d91898-7763-47d7-b03b-b92132375c47</mbid> - <chartposition>3</chartposition> - <reach>132</reach> - <url>http://www.last.fm/music/Pink+Floyd</url> -</artist> -<artist> - <name>John Coltrane</name> - <mbid>b625448e-bf4a-41c3-a421-72ad46cdb831</mbid> - <chartposition>4</chartposition> - <reach>124</reach> - <url>http://www.last.fm/music/John+Coltrane</url> -</artist> -<artist> - <name>Radiohead</name> - <mbid>a74b1b7f-71a5-4011-9441-d0b5e4122711</mbid> - <chartposition>4</chartposition> - <reach>124</reach> - <url>http://www.last.fm/music/Radiohead</url> -</artist> -<artist> - <name>Herbie Hancock</name> - <mbid>27613b78-1b9d-4ec3-9db5-fa0743465fdd</mbid> - <chartposition>6</chartposition> - <reach>106</reach> - <url>http://www.last.fm/music/Herbie+Hancock</url> -</artist> -<artist> - <name>Led Zeppelin</name> - <mbid>678d88b2-87b0-403b-b63d-5da7465aecc3</mbid> - <chartposition>7</chartposition> - <reach>104</reach> - <url>http://www.last.fm/music/Led+Zeppelin</url> -</artist> -<artist> - <name>David Bowie</name> - <mbid>5441c29d-3602-4898-b1a1-b77fa23b8e50</mbid> - <chartposition>8</chartposition> - <reach>102</reach> - <url>http://www.last.fm/music/David+Bowie</url> -</artist> -<artist> - <name>AIR</name> - <mbid>cb67438a-7f50-4f2b-a6f1-2bb2729fd538</mbid> - <chartposition>9</chartposition> - <reach>96</reach> - <url>http://www.last.fm/music/AIR</url> -</artist> -<artist> - <name>Red Hot Chili Peppers</name> - <mbid>8bfac288-ccc5-448d-9573-c33ea2aa5c30</mbid> - <chartposition>9</chartposition> - <reach>96</reach> - <url>http://www.last.fm/music/Red+Hot+Chili+Peppers</url> -</artist> -</weeklyartistchart> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('group', urlencode('Jazz Club')); - $response = $as->groupGetWeeklyArtistChartList(); - $this->assertNotNull(count($response)); - $artist = $response->artist[1]; - $this->assertEquals((string)$artist->name, 'The Beatles'); - $this->assertEquals((string)$artist->url, 'http://www.last.fm/music/The+Beatles'); - $this->assertEquals((string)$response['group'], 'Jazz Club'); - return; - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testWeeklyAlbumChartList() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<weeklyalbumchart group="Jazz Club" from="1172404800" to="1173009600"> -<album> - <artist mbid="561d854a-6a28-4aa7-8c99-323e6ce46c2a">Miles Davis</artist> - <name>Kind of Blue</name> - <mbid>bee5e0cd-1767-4a8e-9578-6455e87ba60b</mbid> - <chartposition>1</chartposition> - <reach>56</reach> - <url>http://www.last.fm/music/Miles+Davis/Kind+of+Blue</url> -</album> -<album> - <artist mbid="a74b1b7f-71a5-4011-9441-d0b5e4122711">Radiohead</artist> - <name>OK Computer</name> - <mbid>fba5f8fe-c6c8-4511-8562-c9febf482674</mbid> - <chartposition>2</chartposition> - <reach>42</reach> - <url>http://www.last.fm/music/Radiohead/OK+Computer</url> -</album> -<album> - <artist mbid="8f6bd1e4-fbe1-4f50-aa9b-94c450ec0f11">Portishead</artist> - <name>Dummy</name> - <mbid>87888070-1b25-4830-aebc-dee490058b74</mbid> - <chartposition>3</chartposition> - <reach>37</reach> - <url>http://www.last.fm/music/Portishead/Dummy</url> -</album> -<album> - <artist mbid="">The Arcade Fire</artist> - <name>Funeral</name> - <mbid></mbid> - <chartposition>3</chartposition> - <reach>37</reach> - <url>http://www.last.fm/music/The+Arcade+Fire/Funeral</url> -</album> -<album> - <artist mbid="cc197bad-dc9c-440d-a5b5-d52ba2e14234">Coldplay</artist> - <name>A Rush of Blood to the Head</name> - <mbid>b83b32dd-aa1a-4f18-a5af-00e418041617</mbid> - <chartposition>5</chartposition> - <reach>34</reach> - <url>http://www.last.fm/music/Coldplay/A+Rush+of+Blood+to+the+Head</url> -</album> -<album> - <artist mbid="b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d">The Beatles</artist> - <name>Abbey Road</name> - <mbid>03503af3-a0e0-4f7e-8a0d-a1cd4d7225c5</mbid> - <chartposition>6</chartposition> - <reach>32</reach> - <url>http://www.last.fm/music/The+Beatles/Abbey+Road</url> -</album> -<album> - <artist mbid="b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d">The Beatles</artist> - <name>Rubber Soul</name> - <mbid>34b8cb33-5f91-4e0c-b4ec-3fb2d3f2f926</mbid> - <chartposition>6</chartposition> - <reach>32</reach> - <url>http://www.last.fm/music/The+Beatles/Rubber+Soul</url> -</album> -<album> - <artist mbid="10adbe5e-a2c0-4bf3-8249-2b4cbf6e6ca8">Massive Attack</artist> - <name>Mezzanine</name> - <mbid>0d33ef7a-1f5d-4365-b807-b412271b99c3</mbid> - <chartposition>8</chartposition> - <reach>31</reach> - <url>http://www.last.fm/music/Massive+Attack/Mezzanine</url> -</album> -<album> - <artist mbid="cc197bad-dc9c-440d-a5b5-d52ba2e14234">Coldplay</artist> - <name>Parachutes</name> - <mbid>8fb50f96-279e-4d44-92aa-d49ea56f5c08</mbid> - <chartposition>8</chartposition> - <reach>31</reach> - <url>http://www.last.fm/music/Coldplay/Parachutes</url> -</album> -<album> - <artist mbid="">Gnarls Barkley</artist> - <name>St. Elsewhere</name> - <mbid></mbid> - <chartposition>8</chartposition> - <reach>31</reach> - <url>http://www.last.fm/music/Gnarls+Barkley/St.+Elsewhere</url> -</album> -</weeklyalbumchart> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('group', urlencode('Jazz Club')); - $response = $as->groupGetWeeklyAlbumChartList(); - $this->assertNotNull(count($response)); - $album = $response->album[0]; - $this->assertEquals((string)$album->artist, 'Miles Davis'); - $this->assertEquals((string)$album->name, 'Kind of Blue'); - $this->assertEquals((string)$album->chartposition, 1); - $this->assertEquals((string)$response['group'], 'Jazz Club'); - return; - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testPreviousWeeklyChartList() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<weeklyartistchart group="Jazz Club" from="1114965332" to="1115570132"> -</weeklyartistchart> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('group', urlencode('Jazz Club')); - $from = 1114965332; - $to = 1115570132; - $response = $as->groupGetWeeklyChartList($from, $to); - $this->assertNotNull(count($response)); - $this->assertEquals((string)$response['group'], 'Jazz Club'); - $this->assertEquals((int)$response['from'], $from); - $this->assertEquals((int)$response['to'], $to); - return; - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - -} diff --git a/tests/Zend/Service/Audioscrobbler/ProfileTest.php b/tests/Zend/Service/Audioscrobbler/ProfileTest.php deleted file mode 100644 index 63348fab6438cd47ee692b58626351977a45ad16..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/ProfileTest.php +++ /dev/null @@ -1,715 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ProfileTest.php 11891 2008-10-12 10:33:12Z alexander $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_ProfileTest extends PHPUnit_Framework_TestCase -{ - public function testConstructValid() - { - try { - $response = new Zend_Service_Audioscrobbler( ); - $this->assertNotNull($response); - return; - } catch (Exception $e) { - $this->fail("Exception $e->message thrown by test"); - } - - } - - public function testGetProfileInfo() - { - try { - $test_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <profile id="1000002" cluster="2" username="RJ"> - <url>http://www.last.fm/user/RJ/</url> - - <realname>Richard Jones</realname> - <mbox_sha1sum>1b374543545e01bc8d555a6a57c637f61f999fdf</mbox_sha1sum> - <registered unixtime="1037793040">Nov 20, 2002</registered> - <age>24</age> - <gender>m</gender> - <country>United Kingdom</country> - <playcount>45043</playcount> - <avatar>http://static.last.fm/avatar/0f4bda3a8e49e714c26ef610e2893454.jpg</avatar> - </profile>'; - $as = new Zend_Service_Audioscrobbler(true, $test_response); - $as->set('user', 'RJ'); - $response = $as->userGetProfileInformation(); - $this->assertNotNull($response); - return; - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - - } - - public function testGetBadProfileInfo() - { - $as = new Zend_Service_Audioscrobbler(); - $as->set('user', 'kljadsfjllkj'); - - try { - $response = $as->userGetProfileInformation(); - $this->assertNull($response); - - } catch (Exception $e) { - return; - } - - $this->fail('Exception was not thrown when submitting bad user info'); - } - - public function testUserGetTopArtists( ) - { - try { - $test_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <topartists user="RJ"> - <artist> - <name>Dream Theater</name> - <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid> - <playcount>854</playcount> - <rank>1</rank> - <url>http://www.last.fm/music/Dream+Theater</url> - <thumbnail>http://static.last.fm/proposedimages/thumbnail/6/4209/432600.jpg</thumbnail> - <image>http://static.last.fm/proposedimages/sidebar/6/4209/432600.jpg</image> - </artist> - </topartists>'; - $as = new Zend_Service_Audioscrobbler(true, $test_response); - $as->set('user', 'RJ'); - $response = $as->userGetTopArtists(); - $artist = $response->artist[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((string)$artist->name, 'Dream Theater'); - $this->assertNotNull($artist->rank, 1); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test" ); - } - } - - - public function testUserGetTopAlbums( ) - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <topalbums user="Frith"> - <album> - <artist mbid="d8915e13-d67a-4aa0-9c0b-1f126af951af">Hot Chip</artist> - <name>The Warning</name> - <mbid></mbid> - <playcount>227</playcount> - <rank>1</rank> - <url>http://www.last.fm/music/Hot+Chip/The+Warning</url> - <image> - <large>http://images.amazon.com/images/P/B000FBFSVU.01._SCMZZZZZZZ_.jpg</large> - <medium>http://images.amazon.com/images/P/B000FBFSVU.01._SCMZZZZZZZ_.jpg</medium> - <small>http://images.amazon.com/images/P/B000FBFSVU.01._SCMZZZZZZZ_.jpg</small> - </image> - </album> - </topalbums>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'Frith'); - $response = $as->userGetTopAlbums(); - $album = $response->album[0]; - $this->assertEquals((string)$response['user'], 'Frith'); - $this->assertNotNull($album); - $this->assertEquals((string)$album->name, 'The Warning'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e ."] thrown by test"); - } - } - - public function testUserGetTopTracks( ) - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <toptracks user="RJ"> - <track> - <artist mbid="12ff8858-bfcb-4812-a8dd-7e9debf0cbee">Steppenwolf</artist> - <name>The Pusher</name> - <mbid></mbid> - <playcount>31</playcount> - <rank>1</rank> - <url>http://www.last.fm/music/Steppenwolf/_/The+Pusher</url> - </track> - <track> - <artist mbid="8f6bd1e4-fbe1-4f50-aa9b-94c450ec0f11">Portishead</artist> - <name>Cowboys</name> - <mbid></mbid> - <playcount>28</playcount> - <rank>2</rank> - <url>http://www.last.fm/music/Portishead/_/Cowboys</url> - </track> - </toptracks>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetTopTracks(); - $track = $response->track[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertNotNull($track); - $this->assertEquals((string)$track->artist, 'Steppenwolf'); - $this->assertEquals((int)$track->playcount, 31); - } catch (Exception $e ) { - $this->fail("Exception: [$e] thrown by test"); - } - } - - public function testUserGetTopTags( ) - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <toptags user="RJ"> - <tag> - <name>rock</name> - <count>9</count> - <url>http://www.last.fm/tag/rock</url> - </tag> - <tag> - <name>metal</name> - <count>8</count> - <url>http://www.last.fm/tag/metal</url> - </tag> - <tag> - <name>mellow</name> - <count>5</count> - <url>http://www.last.fm/tag/mellow</url> - </tag> - </toptags>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetTopTags(); - $tag = $response->tag[1]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertNotNull($tag); - $this->assertEquals((string)$tag->name, 'metal'); - $this->assertEquals((int)$tag->count, 8); - } catch (Exception $e) { - $this->fail("Exception: [$e] thrown by test"); - } - } - - public function testUserGetTopTagsForArtist() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <artisttags user="RJ" artist="Metallica"> - <tag> - <name>metal</name> - <count>1</count> - <url>http://www.last.fm/tag/metal</url> - </tag> - <tag> - <name>80s</name> - <count>1</count> - <url>http://www.last.fm/tag/80s</url> - </tag> - </artisttags>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $as->set('artist', 'Metallica'); - $response = $as->userGetTopTagsForArtist(); - $tag = $response->tag[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertNotNull($tag); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - /** - * Ensures that userGetTopTagsForArtist() throws an exception when based on bad parameters - * - * @return void - */ - public function testBadUserGetTopTagsForArtist() - { - $testingResponse = "HTTP/1.1 200 OK\r\n" - . "Content-type: text/xml\r\n" - . "\r\n" - . "ERROR: Missing 'subject' parameter in querystring"; - $as = new Zend_Service_Audioscrobbler(true, $testingResponse); - try { - $response = $as->userGetTopTagsForArtist(); - $this->fail('userGetTopTagsForArtist() did not throw exception based on bad parameters'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('SimpleXML', $e->getMessage()); - } - } - - public function testUserGetTopTagsForAlbum() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <albumtags user="RJ" album="Ride the Lightning" artist="Metallica"> - </albumtags>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $as->set('artist', 'Metallica'); - $as->set('album', 'Ride The Lightning'); - $response = $as->userGetTopTagsForAlbum(); - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((string)strtolower($response['artist']), strtolower('Metallica')); - $this->assertEquals((string)strtolower($response['album']), strtolower('Ride The Lightning')); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserGetTopTagsForTrack() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <tracktags user="RJ" artist="Metallica" track="Nothing Else Matters"> - </tracktags>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $as->set('artist', 'Metallica'); - $as->set('track', 'Nothing Else Matters'); - $response = $as->userGetTopTagsForTrack(); - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$response['track'], 'Nothing Else Matters'); - } catch ( Exception $e) { - $this->fail("Exception: ]" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserGetFriends() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <friends user="RJ"> - <user username="julians"> - <url>http://www.last.fm/user/julians/</url> - <image>http://static.last.fm/avatar/9ca899b8f20b7173d47983cc0533be8c.gif</image> - <connections> - </connections> - - </user> - <user username="Korean_Cowboy"> - <url>http://www.last.fm/user/Korean_Cowboy/</url> - <image>http://static.last.fm/avatar/091614ec2288764362c94f047d207336.jpg</image> - <connections> - </connections> - - </user> - </friends>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetFriends(); - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals(count($response->user), 2); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserGetNeighbours() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <neighbours user="RJ"> - <user username="count-bassy"> - <url>http://www.last.fm/user/count-bassy/</url> - <image>http://static.last.fm/avatar/3da65e2f347f64c033c9eced171e7a21.gif</image> - <match>100</match> - </user> - <user username="arcymarcy"> - <url>http://www.last.fm/user/arcymarcy/</url> - <image>http://static.last.fm/avatar/eed7d6afea225f85cfcd6ee61eac19aa.jpg</image> - <match>93.12</match> - </user> - </neighbours>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetNeighbours(); - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals(count($response->user), 2); - $user = $response->user[1]; - $this->assertEquals((string)$user['username'], 'arcymarcy'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserRecentTracks() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\n" . - "Content-type: text/xml\r\n" . - "\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <recenttracks user="RJ"> - <track> - <artist mbid="97d9060d-2cd5-4acd-b44f-c39ea2da4753">Tok Tok Tok</artist> - <name>Always An Excuse</name> - <mbid></mbid> - <url>http://www.last.fm/music/Tok+Tok+Tok/_/Always+An+Excuse</url> - <date uts="1173203133">6 Mar 2007, 17:45</date> - </track> - <track> - <artist mbid="97d9060d-2cd5-4acd-b44f-c39ea2da4753">Tok Tok Tok</artist> - <name>What Has Roots</name> - <mbid></mbid> - <url>http://www.last.fm/music/Tok+Tok+Tok/_/What+Has+Roots</url> - <date uts="1173202787">6 Mar 2007, 17:39</date> - </track> - </recenttracks>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetRecentTracks(); - $track = $response->track[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals(count($response->track), 2); - $this->assertEquals((string)$track->name, 'Always An Excuse'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserRecentBannedTracks() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <recentbannedtracks user="RJ"> - <track> - <artist mbid="27613b78-1b9d-4ec3-9db5-fa0743465fdd">Herbie Hancock</artist> - <name>Rockit</name> - <mbid></mbid> - <url>http://www.last.fm/music/Herbie+Hancock/_/Rockit</url> - <date uts="1171126557">10 Feb 2007, 16:55</date> - </track> - <track> - <artist mbid="7e54d133-2525-4bc0-ae94-65584145a386">Plaid</artist> - <name>Plaid Rmx</name> - <mbid></mbid> - <url>http://www.last.fm/music/Plaid/_/Plaid+Rmx</url> - <date uts="1161129235">17 Oct 2006, 23:53</date> - </track> - </recentbannedtracks>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetRecentBannedTracks(); - $track = $response->track[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals(count($response->track), 2); - $this->assertEquals((string)$track->artist, 'Herbie Hancock'); - $this->assertEquals((string)$track->name, 'Rockit'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserRecentLovedTracks() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <recentlovedtracks user="RJ"> - <track> - <artist mbid="9a7c8025-1af8-42cd-8df8-857220610bc5">Spyro Gyra</artist> - <name>Morning Dance</name> - <mbid></mbid> - <url>http://www.last.fm/music/Spyro+Gyra/_/Morning+Dance</url> - <date uts="1163006139">8 Nov 2006, 17:15</date> - </track> - <track> - <artist mbid="149e6720-4e4a-41a4-afca-6d29083fc091">Bad Religion</artist> - <name>I Love My Computer</name> - <mbid></mbid> - <url>http://www.last.fm/music/Bad+Religion/_/I+Love+My+Computer</url> - <date uts="1162310037">31 Oct 2006, 15:53</date> - </track> - </recentlovedtracks>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetRecentLovedTracks(); - $track = $response->track[1]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertNotNull((string)$track->name, 'Morning Dance'); - $this->assertNotNull((string)$track->date, '31 Oct 2006, 15:53'); - $this->assertNotNull($response->track); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testUserGetWeeklyChartList() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <weeklychartlist user="RJ"> - <chart from="1108296002" to="1108900802"/> - <chart from="1108900801" to="1109505601"/> - <chart from="1109505601" to="1110110401"/> - <chart from="1110715201" to="1111320001"/> - <chart from="1111320001" to="1111924801"/> - <chart from="1111924801" to="1112529601"/> - <chart from="1112529601" to="1113134401"/> - </weeklychartlist>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetWeeklyChartList(); - $chart = $response->chart[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals(count($response->chart), 7); - $this->assertEquals((string)$chart['from'], '1108296002'); - $this->assertEquals((string)$chart['to'], '1108900802'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage(). "] thrown by test"); - } - } - - public function testUserGetRecentWeeklyArtistChart() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <weeklyartistchart user="RJ" from="1172404800" to="1173009600"> - <artist> - <name>Miles Davis</name> - <mbid>561d854a-6a28-4aa7-8c99-323e6ce46c2a</mbid> - <chartposition>1</chartposition> - <playcount>30</playcount> - <url>http://www.last.fm/music/Miles+Davis</url> - </artist> - <artist> - <name>Guano Apes</name> - <mbid>66da25f9-1534-4dd1-b88c-718bc24e1ccd</mbid> - <chartposition>2</chartposition> - <playcount>28</playcount> - <url>http://www.last.fm/music/Guano+Apes</url> - </artist> - </weeklyartistchart>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetWeeklyArtistChart(); - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertNotNull($response->weeklyartistchart); - $this->assertNotNull($response->artist); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage(). "] thrown by test"); - } - } - - public function testUserGetWeeklyAlbumChart() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <weeklyalbumchart user="RJ" from="1172404800" to="1173009600"> - <album> - <artist mbid="6da0515e-a27d-449d-84cc-00713c38a140">Skid Row</artist> - <name>Slave To The Grid</name> - <mbid></mbid> - <chartposition>1</chartposition> - <playcount>12</playcount> - <url>http://www.last.fm/music/Skid+Row/Slave+To+The+Grid</url> - </album> - <album> - <artist mbid="66da25f9-1534-4dd1-b88c-718bc24e1ccd">Guano Apes</artist> - <name>Walking on a Thin Line</name> - <mbid>769a46de-52e2-4322-9db0-cbd6b789e3f8</mbid> - <chartposition>1</chartposition> - <playcount>12</playcount> - <url>http://www.last.fm/music/Guano+Apes/Walking+on+a+Thin+Line</url> - </album> - </weeklyalbumchart>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $response = $as->userGetWeeklyAlbumChart(); - $album = $response->album[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals(count($response->album), 2); - $this->assertEquals((string)$album->artist, 'Skid Row'); - $this->assertEquals((string)$album->name, 'Slave To The Grid'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage(). "] thrown by test"); - } - } - - public function testUserGetPreviousWeeklyArtistChart() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <weeklyartistchart user="RJ" from="1114965332" to="1115570132"> - <artist> - <name>Nine Inch Nails</name> - <mbid>b7ffd2af-418f-4be2-bdd1-22f8b48613da</mbid> - <chartposition>1</chartposition> - <playcount>23</playcount> - <url>http://www.last.fm/music/Nine+Inch+Nails</url> - </artist> - <artist> - <name>The Doors</name> - <mbid>9efff43b-3b29-4082-824e-bc82f646f93d</mbid> - <chartposition>2</chartposition> - <playcount>3</playcount> - <url>http://www.last.fm/music/The+Doors</url> - </artist> - </weeklyartistchart>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $from = 1114965332; - $to = 1115570132; - $response = $as->userGetWeeklyArtistChart($from, $to); - $artist = $response->artist[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((int)$response['from'], $from); - $this->assertEquals((int)$response['to'], $to); - $this->assertEquals((string)$artist->name, 'Nine Inch Nails'); - $this->assertEquals(count($response->artist), 2); - } catch ( Exception $e) { - $this->fail("Exception: [" . $e->getMessage(). "] thrown by test"); - } - } - - public function testUserGetPreviousWeeklyAlbumChart() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <weeklyalbumchart user="RJ" from="1114965332" to="1115570132"> - <album> - <artist mbid="9efff43b-3b29-4082-824e-bc82f646f93d">The Doors</artist> - <name>The Doors Box Set</name> - <mbid></mbid> - <chartposition>1</chartposition> - <playcount>2</playcount> - <url>http://www.last.fm/music/The+Doors/The+Doors+Box+Set</url> - </album> - <album> - <artist mbid="5b11f4ce-a62d-471e-81fc-a69a8278c7da">Nirvana</artist> - <name>Nirvana</name> - <mbid>d8f9547d-5e46-45f0-b694-0d9af9e2de63</mbid> - <chartposition>1</chartposition> - <playcount>2</playcount> - <url>http://www.last.fm/music/Nirvana/Nirvana</url> - </album> - </weeklyalbumchart>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $from = 1114965332; - $to = 1115570132; - $response = $as->userGetWeeklyAlbumChart($from, $to); - $album = $response->album[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((int)$response['from'], 1114965332); - $this->assertEquals((int)$response['to'], 1115570132); - $this->assertEquals(count($response->album), 2); - } catch ( Exception $e) { - $this->fail("Exception: [" . $e->getMessage(). "] thrown by test"); - } - - } - - public function testUserGetPreviousWeeklyTrackChart() - { - try { - $testing_response = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n" . - '<?xml version="1.0" encoding="UTF-8"?> - <weeklytrackchart user="RJ" from="1114965332" to="1115570132"> - <track> - <artist mbid="f73b2b70-33d5-4118-923b-05ba8ad7e702">The Kleptones</artist> - <name>Question</name> - <mbid></mbid> - <chartposition>1</chartposition> - <playcount>3</playcount> - <url>http://www.last.fm/music/The+Kleptones/_/Question</url> - </track> - <track> - <artist mbid="b7ffd2af-418f-4be2-bdd1-22f8b48613da">Nine Inch Nails</artist> - <name>All the Love in the World</name> - <mbid></mbid> - <chartposition>2</chartposition> - <playcount>2</playcount> - <url>http://www.last.fm/music/Nine+Inch+Nails/_/All+the+Love+in+the+World</url> - </track> - </weeklytrackchart>'; - $as = new Zend_Service_Audioscrobbler(true, $testing_response); - $as->set('user', 'RJ'); - $from = 1114965332; - $to = 1115570132; - $response = $as->userGetWeeklyTrackChart($from, $to); - $track = $response->track[0]; - $this->assertEquals((string)$response['user'], 'RJ'); - $this->assertEquals((int)$response['from'], $from); - $this->assertEquals((int)$response['to'], $to); - $this->assertEquals((string)$track->artist, 'The Kleptones'); - $this->assertEquals(count($response->track), 2); - } catch ( Exception $e) { - $this->fail("Exception: [" . $e->getMessage(). "] thrown by test"); - } - } -} diff --git a/tests/Zend/Service/Audioscrobbler/TagDataTest.php b/tests/Zend/Service/Audioscrobbler/TagDataTest.php deleted file mode 100644 index 87247737c3fd409951bf977a1c7758858fbbf686..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/TagDataTest.php +++ /dev/null @@ -1,177 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TagDataTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_TagDataTest extends PHPUnit_Framework_TestCase -{ - var $header = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n"; - - public function testGetTopTags() - { - try { - $as = new Zend_Service_Audioscrobbler(); - $response = $as->tagGetTopTags(); - $this->assertNotNull(count($response->tag)); - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testGetTopArtists() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<tag tag="rock" count="785147"> -<artist name="Red Hot Chili Peppers" count="5097" streamable="yes"> - <mbid>8bfac288-ccc5-448d-9573-c33ea2aa5c30</mbid> - <url>http://www.last.fm/music/Red+Hot+Chili+Peppers</url> - <thumbnail>http://static.last.fm/proposedimages/thumbnail/6/1274/447958.jpg</thumbnail> - <image>http://static.last.fm/proposedimages/sidebar/6/1274/447958.jpg</image> -</artist> -<artist name="Foo Fighters" count="3566" streamable="yes"> - <mbid>67f66c07-6e61-4026-ade5-7e782fad3a5d</mbid> - <url>http://www.last.fm/music/Foo+Fighters</url> - <thumbnail>http://static.last.fm/proposedimages/thumbnail/6/1000062/458.jpg</thumbnail> - <image>http://static.last.fm/proposedimages/sidebar/6/1000062/458.jpg</image> -</artist> -<artist name="Radiohead" count="3457" streamable="yes"> - <mbid>a74b1b7f-71a5-4011-9441-d0b5e4122711</mbid> - <url>http://www.last.fm/music/Radiohead</url> - <thumbnail>http://static.last.fm/proposedimages/thumbnail/6/979/453678.jpg</thumbnail> - <image>http://static.last.fm/proposedimages/sidebar/6/979/453678.jpg</image> -</artist> -</tag> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('tag', 'Rock'); - $response = $as->tagGetTopArtists(); - $this->assertNotNull($response->artist); - $this->assertEquals((string)$response['tag'], strtolower($as->get('tag'))); - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testGetTopAlbums() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<tag tag="rock" count="786251"> -<album name="Fallen" count="79" streamable="yes"> - <artist name="Evanescence"> - <mbid>f4a31f0a-51dd-4fa7-986d-3095c40c5ed9</mbid> - <url>http://www.last.fm/music/Evanescence</url> - </artist> - <url>http://www.last.fm/music/Evanescence/Fallen</url> - <coverart> - <small>http://images.amazon.com/images/P/B00008US8R.01._SCMZZZZZZZ_.jpg</small> - <medium>http://images.amazon.com/images/P/B00008US8R.01._SCMZZZZZZZ_.jpg</medium> - <large>http://images.amazon.com/images/P/B00008US8R.01._SCMZZZZZZZ_.jpg</large> - </coverart> -</album> -<album name="Elephant" count="74" streamable="yes"> - <artist name="The White Stripes"> - <mbid>11ae9fbb-f3d7-4a47-936f-4c0a04d3b3b5</mbid> - <url>http://www.last.fm/music/The+White+Stripes</url> - </artist> - <url>http://www.last.fm/music/The+White+Stripes/Elephant</url> - <coverart> - <small>http://images-eu.amazon.com/images/P/B00007KN36.02.THUMBZZZ.jpg</small> - <medium>http://images-eu.amazon.com/images/P/B00007KN36.02.MZZZZZZZ.jpg</medium> - <large>http://images-eu.amazon.com/images/P/B00007KN36.02.LZZZZZZZ.jpg</large> - </coverart> -</album> -</tag> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('tag', 'Rock'); - $response = $as->tagGetTopAlbums(); - $this->assertNotNull(count($response->album)); - $this->assertEquals((string)$response['tag'], strtolower($as->get('tag'))); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testGetTopTracks() - { - try { - $testing_response = $this->header . -'<?xml version="1.0" encoding="UTF-8"?> -<tag tag="rock" count="785836"> -<track name="Dani California" count="295" streamable="yes"> - <artist name="Red Hot Chili Peppers"> - <mbid>8bfac288-ccc5-448d-9573-c33ea2aa5c30</mbid> - <url>http://www.last.fm/music/Red+Hot+Chili+Peppers</url> - </artist> - <url>http://www.last.fm/music/Red+Hot+Chili+Peppers/_/Dani+California</url> -</track> -<track name="Wonderwall" count="290" streamable="yes"> - <artist name="Oasis"> - <mbid>39ab1aed-75e0-4140-bd47-540276886b60</mbid> - <url>http://www.last.fm/music/Oasis</url> - </artist> - <url>http://www.last.fm/music/Oasis/_/Wonderwall</url> -</track> -<track name="Boulevard of Broken Dreams" count="271" streamable="yes"> - <artist name="Green Day"> - <mbid></mbid> - <url>http://www.last.fm/music/Green+Day</url> - </artist> - <url>http://www.last.fm/music/Green+Day/_/Boulevard+of+Broken+Dreams</url> -</track> -</tag> -'; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('tag', 'Rock'); - $response = $as->tagGetTopTracks(); - $artist = $response->track[0]; - $this->assertNotNull(count($response->track)); - $this->assertNotNull((string)$artist->name); - $this->assertEquals((string)$response['tag'], strtolower($as->get('tag'))); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - -} diff --git a/tests/Zend/Service/Audioscrobbler/TrackDataTest.php b/tests/Zend/Service/Audioscrobbler/TrackDataTest.php deleted file mode 100644 index f60cd812a6665d6273e322c8787e4459de1f6c5c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/TrackDataTest.php +++ /dev/null @@ -1,116 +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_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TrackDataTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Audioscrobbler - */ -require_once 'Zend/Service/Audioscrobbler.php'; - - -/** - * @category Zend - * @package Zend_Service_Audioscrobbler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Audioscrobbler_TrackDataTest extends PHPUnit_Framework_TestCase -{ - var $header = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n"; - - public function testGetTopFans() - { - try { - $testing_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <fans artist="Metallica" track="Enter Sandman"> - <user username="suhis"> - <url>http://www.last.fm/user/suhis/</url> - <image>http://static.last.fm/depth/catalogue/noimage/nouser_140px.jpg</image> - <weight>2816666</weight> - </user> - <user username="M4lu5"> - <url>http://www.last.fm/user/M4lu5/</url> - <image>http://static.last.fm/avatar/ea9c0ddf6b6cc236dfc4297e376e9901.jpg</image> - <weight>2380500</weight> - </user> - <user username="Ceniza666"> - <url>http://www.last.fm/user/Ceniza666/</url> - <image>http://static.last.fm/depth/catalogue/noimage/nouser_140px.jpg</image> - <weight>1352000</weight> - </user> - </fans> - '; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('artist', 'Metallica'); - $as->set('track', 'Enter Sandman'); - $response = $as->trackGetTopFans(); - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$response['track'], 'Enter Sandman'); - $this->assertNotNull(count($response->user)); - } catch (Exception $e ) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } - - public function testGetTopTags() - { - try { - $testing_response = $this->header . - '<?xml version="1.0" encoding="UTF-8"?> - <toptags artist="Metallica" track="Enter Sandman"> - <tag> - <name>metal</name> - <count>100</count> - <url>http://www.last.fm/tag/metal</url> - </tag> - <tag> - <name>heavy metal</name> - <count>55</count> - <url>http://www.last.fm/tag/heavy%20metal</url> - </tag> - <tag> - <name>rock</name> - <count>21</count> - <url>http://www.last.fm/tag/rock</url> - </tag> - </toptags> - '; - $as = new Zend_Service_Audioscrobbler(TRUE, $testing_response); - $as->set('artist', 'Metallica'); - $as->set('track', 'Enter Sandman'); - $response = $as->trackGetTopTags(); - $this->assertNotNull(count($response->tag)); - $this->assertEquals((string)$response['artist'], 'Metallica'); - $this->assertEquals((string)$response['track'], 'Enter Sandman'); - } catch (Exception $e) { - $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); - } - } -} diff --git a/tests/Zend/Service/Audioscrobbler/_files/errorNoUserExists b/tests/Zend/Service/Audioscrobbler/_files/errorNoUserExists deleted file mode 100644 index 73ed1b795d3ece0cc0a7cb2099947392dfd750ba..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/_files/errorNoUserExists +++ /dev/null @@ -1,13 +0,0 @@ -HTTP/1.1 404 Not Found -Date: Sun, 13 Jan 2008 23:53:03 GMT -Server: Apache/1.3.33 (Unix) PHP/4.4.3 -X-Proxy-Fix-Up: headers fixed up -X-Powered-By: PHP/4.4.3 -Vary: Accept-Encoding -Content-Type: text/html; charset=utf-8 -X-Cache: MISS from cache7.int.last.fm -X-Cache-Lookup: MISS from cache7.int.last.fm:8081 -Via: 1.0 cache7.int.last.fm:8081 (squid/2.HEAD-20071216) -Connection: close - -No user exists with this name. diff --git a/tests/Zend/Service/Audioscrobbler/_files/errorResponseStatusError b/tests/Zend/Service/Audioscrobbler/_files/errorResponseStatusError deleted file mode 100644 index a8769b1d499dfd467c47bfc1bad8196db986c8bd..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Audioscrobbler/_files/errorResponseStatusError +++ /dev/null @@ -1,18 +0,0 @@ -HTTP/1.1 404 Not Found -Date: Mon, 14 Jan 2008 00:06:52 GMT -Server: Apache/1.3.33 (Unix) PHP/4.4.3 -Content-Type: text/html; charset=iso-8859-1 -X-Cache: MISS from cache5.int.last.fm -X-Cache-Lookup: MISS from cache5.int.last.fm:8081 -Via: 1.0 cache5.int.last.fm:8081 (squid/2.6.STABLE17) -Connection: close - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<HTML><HEAD> -<TITLE>404 Not Found</TITLE> -</HEAD><BODY> -<H1>Not Found</H1> -The requested URL /1.0/group/ was not found on this server.<P> -<HR> -<ADDRESS>Apache/1.3.33 Server at ws.audioscrobbler.com Port 80</ADDRESS> -</BODY></HTML> diff --git a/tests/Zend/Service/Delicious/AllTests.php b/tests/Zend/Service/Delicious/AllTests.php deleted file mode 100644 index e5d08fd122f912a09ef84dfa0505602f1a1a0b07..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Delicious/AllTests.php +++ /dev/null @@ -1,111 +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_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Delicious_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -/** - * @category Zend - * @package Zend_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Delicious_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Delicious'); - - if (!defined('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED') || - !constant('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED')) { - - /** - * @see Zend_Service_Delicious_SkipTests - */ - require_once 'Zend/Service/Delicious/SkipTests.php'; - $suite->addTestSuite('Zend_Service_Delicious_SkipTests'); - - } else { - - /** - * @see Zend_Service_Delicious_PublicDataTest - */ - require_once 'Zend/Service/Delicious/PublicDataTest.php'; - $suite->addTestSuite('Zend_Service_Delicious_PublicDataTest'); - - /** - * @see Zend_Service_Delicious_PrivateDataTest - */ - require_once 'Zend/Service/Delicious/PrivateDataTest.php'; - $suite->addTestSuite('Zend_Service_Delicious_PrivateDataTest'); - } - - /** - * @see Zend_Service_Delicious_SimplePostTest - */ - require_once 'Zend/Service/Delicious/SimplePostTest.php'; - $suite->addTestSuite('Zend_Service_Delicious_SimplePostTest'); - - /** - * @see Zend_Service_Delicious_PostTest - */ - require_once 'Zend/Service/Delicious/PostTest.php'; - $suite->addTestSuite('Zend_Service_Delicious_PostTest'); - - return $suite; - } -} - - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_Delicious_AllTests::main') { - Zend_Service_Delicious_AllTests::main(); -} diff --git a/tests/Zend/Service/Delicious/PostTest.php b/tests/Zend/Service/Delicious/PostTest.php deleted file mode 100644 index f799fd66a83669b4babb165c95484b12dd0c511a..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Delicious/PostTest.php +++ /dev/null @@ -1,232 +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_Service - * @subpackage Delicious - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PostTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Delicious - */ -require_once 'Zend/Service/Delicious.php'; - -/** - * @see Zend_Service_Delicious_Post - */ -require_once 'Zend/Service/Delicious/Post.php'; - - -/** - * @category Zend_Service - * @package Zend_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Delicious_PostTest extends PHPUnit_Framework_TestCase -{ - const UNAME = 'zfTestUser'; - const PASS = 'zfuser'; - - /** - * Service consumer object - * - * @var Zend_Service_Delicious - */ - protected $_delicious; - - /** - * Post object - * - * @var Zend_Service_Delicious_Post - */ - protected $_post; - - /** - * Creates an instance of Zend_Service_Delicious for each test method - * - * @return void - */ - public function setUp() - { - $this->_delicious = new Zend_Service_Delicious(self::UNAME, self::PASS); - - $values = array( - 'title' => 'anything', - 'url' => 'anything' - ); - $this->_post = new Zend_Service_Delicious_Post($this->_delicious, $values); - } - - /** - * Ensures that the constructor throws an exception when the title is missing from the values - * - * @return void - */ - public function testConstructExceptionValuesTitleMissing() - { - try { - $post = new Zend_Service_Delicious_Post($this->_delicious, array('url' => 'anything')); - $this->fail('Expected Zend_Service_Delicious_Exception not thrown'); - } catch (Zend_Service_Delicious_Exception $e) { - $this->assertContains("'url' and 'title'", $e->getMessage()); - } - } - - /** - * Ensures that the constructor throws an exception when the URL is missing from the values - * - * @return void - */ - public function testConstructExceptionValuesUrlMissing() - { - try { - $post = new Zend_Service_Delicious_Post($this->_delicious, array('title' => 'anything')); - $this->fail('Expected Zend_Service_Delicious_Exception not thrown'); - } catch (Zend_Service_Delicious_Exception $e) { - $this->assertContains("'url' and 'title'", $e->getMessage()); - } - } - - /** - * Ensures that the constructor throws an exception when the date value is not an instance of Zend_Date - * - * @return void - */ - public function testConstructExceptionValuesDateInvalid() - { - $values = array( - 'title' => 'anything', - 'url' => 'anything', - 'date' => 'invalid' - ); - try { - $post = new Zend_Service_Delicious_Post($this->_delicious, $values); - $this->fail('Expected Zend_Service_Delicious_Exception not thrown'); - } catch (Zend_Service_Delicious_Exception $e) { - $this->assertContains('instance of Zend_Date', $e->getMessage()); - } - } - - /** - * Ensures that setTitle() provides a fluent interface - * - * @return void - */ - public function testSetTitleFluent() - { - $this->assertSame($this->_post, $this->_post->setTitle('something')); - } - - /** - * Ensures that setNotes() provides a fluent interface - * - * @return void - */ - public function testSetNotesFluent() - { - $this->assertSame($this->_post, $this->_post->setNotes('something')); - } - - /** - * Ensures that setTags() provides a fluent interface - * - * @return void - */ - public function testSetTagsFluent() - { - $this->assertSame($this->_post, $this->_post->setTags(array('something'))); - } - - /** - * Ensures that addTag() provides a fluent interface - * - * @return void - */ - public function testAddTagFluent() - { - $this->assertSame($this->_post, $this->_post->addTag('another')); - } - - /** - * Ensures that removeTag() provides a fluent interface - * - * @return void - */ - public function testRemoveTagFluent() - { - $this->assertSame($this->_post, $this->_post->removeTag('missing')); - } - - /** - * Ensures that getDate() provides expected behavior - * - * @return void - */ - public function testGetDate() - { - $this->assertNull($this->_post->getDate()); - } - - /** - * Ensures that getOthers() provides expected behavior - * - * @return void - */ - public function testGetOthers() - { - $this->assertNull($this->_post->getOthers()); - } - - /** - * Ensures that getHash() provides expected behavior - * - * @return void - */ - public function testGetHash() - { - $this->assertNull($this->_post->getHash()); - } - - /** - * Ensures that getShared() provides expected behavior - * - * @return void - */ - public function testGetShared() - { - $this->assertTrue($this->_post->getShared()); - } - - /** - * Ensures that setShared() provides a fluent interface - * - * @return void - */ - public function testSetSharedFluent() - { - $this->assertSame($this->_post, $this->_post->setShared(true)); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Delicious/PrivateDataTest.php b/tests/Zend/Service/Delicious/PrivateDataTest.php deleted file mode 100644 index 84de32d4c74c03c44bb182021e652a5f37120a76..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Delicious/PrivateDataTest.php +++ /dev/null @@ -1,251 +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_Service - * @subpackage Delicious - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PrivateDataTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Delicious - */ -require_once 'Zend/Service/Delicious.php'; - - -/** - * @category Zend_Service - * @package Zend_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Delicious_PrivateDataTest extends PHPUnit_Framework_TestCase -{ - const TEST_UNAME = 'zfTestUser'; - const TEST_PASS = 'zfuser'; - - private static $TEST_POST_TITLE = 'test - title'; - private static $TEST_POST_URL = 'http://zfdev.com/unittests/delicious/test_url_1'; - private static $TEST_POST_NOTES = 'test - note'; - private static $TEST_POST_TAGS = array('testTag1','testTag2'); - private static $TEST_POST_SHARED = false; - - /** - * @var Zend_Service_Delicious - */ - protected $_delicious; - - /** - * - * @return void - */ - public function setUp() - { - $httpClient = new Zend_Http_Client(); - $httpClient->setConfig(array( - 'useragent' => 'Zend_Service_Delicious - Unit tests/0.1', - 'keepalive' => true - )); - Zend_Rest_Client::setHttpClient($httpClient); - - $this->_delicious = new Zend_Service_Delicious(self::TEST_UNAME, self::TEST_PASS); - } - - /** - * - * @return void - */ - public function testLastUpdate() - { - $this->assertType('Zend_Date', $this->_delicious->getLastUpdate()); - } - - /** - * - * @return void - */ - public function testTagsAndBundles() - { - // get tags - $tags = $this->_delicious->getTags(); - $this->assertType('array', $tags); - $tags = array_keys($tags); - - if (count($tags) < 1) { - $this->fail('Test account corrupted - no tags'); - } - - $oldTagName = $tags[0]; - $newTagName = uniqid('tag'); - - // rename tag - $this->_delicious->renameTag($oldTagName, $newTagName); - - sleep(15); - - // get renamed tags - $tags = $this->_delicious->getTags(); - - $this->assertArrayHasKey($newTagName, $tags); - $this->assertArrayNotHasKey($oldTagName, $tags); - - $tags = array_keys($tags); - - // add new bundle - $newBundleName = uniqid('bundle'); - $this->_delicious->addBundle($newBundleName, $tags); - - sleep(15); - - // check if bundle was added - $bundles = $this->_delicious->getBundles(); - $this->assertType('array', $bundles); - $this->assertArrayHasKey($newBundleName, $bundles); - $this->assertEquals($tags, $bundles[$newBundleName]); - - // delete bundle - $this->_delicious->deleteBundle($newBundleName); - - sleep(15); - - // check if bundle was deleted - $bundles = $this->_delicious->getBundles(); - $this->assertArrayNotHasKey($newBundleName, $bundles); - } - - /** - * - * @return void - */ - public function _testAddDeletePost() - { - $newPost = $this->_delicious->createNewPost(self::$TEST_POST_TITLE, self::$TEST_POST_URL) - ->setNotes(self::$TEST_POST_NOTES) - ->setTags(self::$TEST_POST_TAGS) - ->setShared(self::$TEST_POST_SHARED); - - // check if post was created correctly - $this->assertEquals(self::$TEST_POST_TITLE, $newPost->getTitle()); - $this->assertEquals(self::$TEST_POST_URL, $newPost->getUrl()); - $this->assertEquals(self::$TEST_POST_NOTES, $newPost->getNotes()); - $this->assertEquals(self::$TEST_POST_TAGS, $newPost->getTags()); - $this->assertEquals(self::$TEST_POST_SHARED, $newPost->getShared()); - - // test tag adding to tag - $newTagName = uniqid('tag'); - $newPost->addTag($newTagName); - $this->assertContains($newTagName, $newPost->getTags()); - - // test tag removeing - $newPost->removeTag($newTagName); - $this->assertNotContains($newTagName, $newPost->getTags()); - - // send post to del.icio.us - $newPost->save(); - - sleep(15); - - // get the post back - $returnedPosts = $this->_delicious->getPosts(null, null, self::$TEST_POST_URL); - - $this->assertEquals(1, count($returnedPosts)); - - $savedPost = $returnedPosts[0]; - - // check if post was saved correctly - $this->assertEquals(self::$TEST_POST_TITLE, $savedPost->getTitle()); - $this->assertEquals(self::$TEST_POST_URL, $savedPost->getUrl()); - $this->assertEquals(self::$TEST_POST_NOTES, $savedPost->getNotes()); - $this->assertEquals(self::$TEST_POST_TAGS, $savedPost->getTags()); - $this->assertEquals(self::$TEST_POST_SHARED, $savedPost->getShared()); - $this->assertType('Zend_Date', $savedPost->getDate()); - $this->assertType('string', $savedPost->getHash()); - $this->assertType('int', $savedPost->getOthers()); - - // delete post - $savedPost->delete(); - - sleep(15); - - // check if post was realy deleted - $returnedPosts = $this->_delicious->getPosts(null, null, self::$TEST_POST_URL); - $this->assertEquals(0, count($returnedPosts)); - } - - /** - * Ensures that getAllPosts() provides expected behavior - * - * @return void - */ - public function testGetAllPosts() - { - $posts = $this->_delicious->getAllPosts('zfSite'); - $this->assertType('Zend_Service_Delicious_PostList', $posts); - - foreach ($posts as $post) { - $this->assertContains('zfSite', $post->getTags()); - } - } - - /** - * Ensures that getRecentPosts() provides expected behavior - * - * @return void - */ - public function testGetRecentPosts() - { - $posts = $this->_delicious->getRecentPosts('zfSite', 10); - $this->assertType('Zend_Service_Delicious_PostList', $posts); - $this->assertTrue(count($posts) <= 10); - - foreach ($posts as $post) { - $this->assertContains('zfSite', $post->getTags()); - } - } - - /** - * Ensures that getPosts() provides expected behavior - * - * @return void - */ - public function testGetPosts() - { - $posts = $this->_delicious->getPosts('zfSite', new Zend_Date(), 'help'); - $this->assertType('Zend_Service_Delicious_PostList', $posts); - $this->assertTrue(count($posts) <= 10); - - foreach ($posts as $post) { - $this->assertContains('zfSite', $post->getTags()); - } - } - - /** - * - * @return void - */ - public function testDates() - { - $this->assertType('array', $this->_delicious->getDates()); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Delicious/PublicDataTest.php b/tests/Zend/Service/Delicious/PublicDataTest.php deleted file mode 100644 index 1e21819b6c2baa2d70e10c91118b7c33569717d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Delicious/PublicDataTest.php +++ /dev/null @@ -1,166 +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_Service - * @subpackage Delicious - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PublicDataTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Delicious - */ -require_once 'Zend/Service/Delicious.php'; - - -/** - * @category Zend_Service - * @package Zend_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Delicious_PublicDataTest extends PHPUnit_Framework_TestCase -{ - const TEST_UNAME = 'zfTestUser'; - const TEST_PASS = 'zfuser'; - const TEST_URL = 'http://framework.zend.com/'; - - /** - * @var Zend_Service_Delicious - */ - protected $_delicious; - - /** - * @return void - */ - public function setUp() - { - $httpClient = new Zend_Http_Client(); - $httpClient->setConfig(array( - 'useragent' => 'Zend_Service_Delicious - Unit tests/0.1', - 'keepalive' => true - )); - Zend_Rest_Client::setHttpClient($httpClient); - - $this->_delicious = new Zend_Service_Delicious(); - } - - /** - * Try to get tags of some user - * - * @return void - */ - public function testGetTags() - { - $tags = $this->_delicious->getUserTags(self::TEST_UNAME); - - $this->assertType('array', $tags); - } - - /** - * @return void - */ - public function testGetTagsWithCount() - { - $tags = $this->_delicious->getUserTags(self::TEST_UNAME, null, 20); - - $this->assertType('array', $tags); - $this->assertTrue(count($tags) <= 20); - } - - /** - * @return void - */ - public function testGetTagsWithAtLeast() - { - $tags = $this->_delicious->getUserTags(self::TEST_UNAME, 5); - - $this->assertType('array', $tags); - foreach ($tags as $count) { - $this->assertTrue($count >= 5); - } - } - - /** - * @return void - */ - public function testGetNetwork() - { - $network = $this->_delicious->getUserNetwork(self::TEST_UNAME); - - $this->assertType('array', $network); - } - - /** - * @return void - */ - public function testGetFans() - { - $fans = $this->_delicious->getUserFans(self::TEST_UNAME); - - $this->assertType('array', $fans); - } - - /** - * @return void - */ - public function testGetUserPosts() - { - $posts = $this->_delicious->getUserPosts(self::TEST_UNAME, 10); - - $this->assertType('Zend_Service_Delicious_PostList', $posts); - - // check if all objects in returned Zend_Service_Delicious_PostList - // are instances of Zend_Service_Delicious_SimplePost - foreach ($posts as $post) { - $this->assertType('Zend_Service_Delicious_SimplePost', $post); - } - - // test filtering of Zend_Service_Delicious_PostList by tag name - $filterPostList = $posts->withTag('zfSite'); - - foreach ($filterPostList as $post) { - $this->assertType('array', $post->getTags()); - $this->assertContains('zfSite', $post->getTags()); - } - } - - /** - * Try to get details of some URL - * - * @return void - */ - public function testGetUrlDetails() { - $details = $this->_delicious->getUrlDetails(self::TEST_URL); - - $this->assertType('array', $details); - $this->assertArrayHasKey('hash', $details); - $this->assertArrayHasKey('top_tags', $details); - $this->assertArrayHasKey('url', $details); - $this->assertArrayHasKey('total_posts', $details); - - $this->assertEquals(self::TEST_URL, $details['url']); - $this->assertType('array', $details['top_tags']); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Delicious/SimplePostTest.php b/tests/Zend/Service/Delicious/SimplePostTest.php deleted file mode 100644 index 605a01a37369b20583e30a0bf0ddb0f9510d5d75..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Delicious/SimplePostTest.php +++ /dev/null @@ -1,158 +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_Service - * @subpackage Delicious - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SimplePostTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Delicious_SimplePost - */ -require_once 'Zend/Service/Delicious/SimplePost.php'; - - -/** - * @category Zend_Service - * @package Zend_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Delicious_SimplePostTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the constructor throws an exception when the title is missing - * - * @return void - */ - public function testConstructExceptionTitleMissing() - { - $post = array('u' => 'anything'); - try { - $simplePost = new Zend_Service_Delicious_SimplePost($post); - $this->fail('Expected Zend_Service_Delicious_Exception not thrown'); - } catch (Zend_Service_Delicious_Exception $e) { - $this->assertContains('Title and URL', $e->getMessage()); - } - } - - /** - * Ensures that the constructor throws an exception when the URL is missing - * - * @return void - */ - public function testConstructExceptionUrlMissing() - { - $post = array('d' => 'anything'); - try { - $simplePost = new Zend_Service_Delicious_SimplePost($post); - $this->fail('Expected Zend_Service_Delicious_Exception not thrown'); - } catch (Zend_Service_Delicious_Exception $e) { - $this->assertContains('Title and URL', $e->getMessage()); - } - } - - /** - * Ensures that getUrl() behaves as expected - * - * @return void - */ - public function testGetUrl() - { - $url = 'something'; - $post = array( - 'd' => 'anything', - 'u' => $url - ); - $simplePost = new Zend_Service_Delicious_SimplePost($post); - $this->assertEquals( - $url, - $result = $simplePost->getUrl(), - "Expected getUrl() to return '$url'; got '$result' instead" - ); - } - - /** - * Ensures that getTitle() behaves as expected - * - * @return void - */ - public function testGetTitle() - { - $title = 'something'; - $post = array( - 'd' => $title, - 'u' => 'anything' - ); - $simplePost = new Zend_Service_Delicious_SimplePost($post); - $this->assertEquals( - $title, - $result = $simplePost->getTitle(), - "Expected getTitle() to return '$title'; got '$result' instead" - ); - } - - /** - * Ensures that getNotes() behaves as expected - * - * @return void - */ - public function testGetNotes() - { - $notes = 'something'; - $post = array( - 'd' => 'anything', - 'u' => 'anything', - 'n' => $notes - ); - $simplePost = new Zend_Service_Delicious_SimplePost($post); - $this->assertEquals( - $notes, - $result = $simplePost->getNotes(), - "Expected getNotes() to return '$notes'; got '$result' instead" - ); - } - - /** - * Ensures that getTags() behaves as expected - * - * @return void - */ - public function testGetTags() - { - $tags = 'something'; - $post = array( - 'd' => 'anything', - 'u' => 'anything', - 't' => $tags - ); - $simplePost = new Zend_Service_Delicious_SimplePost($post); - $this->assertEquals( - $tags, - $result = $simplePost->getTags(), - "Expected getTags() to return '$tags'; got '$result' instead" - ); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Delicious/SkipTests.php b/tests/Zend/Service/Delicious/SkipTests.php deleted file mode 100644 index 3cd9998a2a9d575089b4682fdeea76ff5bc657de..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Delicious/SkipTests.php +++ /dev/null @@ -1,48 +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_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SkipTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - - -/** - * @category Zend - * @package Zend_Service_Delicious - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Delicious_SkipTests extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped('Zend_Service_Delicious tests not enabled in TestConfiguration.php'); - } - - public function testNothing() - { - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Flickr/AllTests.php b/tests/Zend/Service/Flickr/AllTests.php deleted file mode 100644 index 46e1a84f0898c7a4d9aaaf228bb7f88c0b1d1dd4..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/AllTests.php +++ /dev/null @@ -1,92 +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_Service_Flickr - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Flickr_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_Flickr_OfflineTest - */ -require_once 'Zend/Service/Flickr/OfflineTest.php'; - -/** - * @see Zend_Service_Flickr_OnlineTest - */ -require_once 'Zend/Service/Flickr/OnlineTest.php'; - - -/** - * @category Zend - * @package Zend_Service_Flickr - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Flickr_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Flickr'); - - $suite->addTestSuite('Zend_Service_Flickr_OfflineTest'); - if (defined('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED') && - constant('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED')) { - $suite->addTestSuite('Zend_Service_Flickr_OnlineTest'); - } else { - $suite->addTestSuite('Zend_Service_Flickr_OnlineTest_Skip'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_Flickr_AllTests::main') { - Zend_Service_Flickr_AllTests::main(); -} diff --git a/tests/Zend/Service/Flickr/OfflineTest.php b/tests/Zend/Service/Flickr/OfflineTest.php deleted file mode 100644 index 697b1960bd1a05d3fc5ce9fde43f02850db51c14..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/OfflineTest.php +++ /dev/null @@ -1,568 +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_Service_Flickr - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OfflineTest.php 8733 2008-03-10 15:56:48Z jokke $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Flickr - */ -require_once 'Zend/Service/Flickr.php'; - - -/** - * @category Zend - * @package Zend_Service_Flickr - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Flickr_OfflineTest extends PHPUnit_Framework_TestCase -{ - /** - * Reference to Flickr service consumer object - * - * @var Zend_Service_Flickr - */ - protected $_flickr; - - /** - * Proxy to protected methods of Zend_Service_Flickr - * - * @var Zend_Service_Flickr_OfflineTest_FlickrProtectedMethodProxy - */ - protected $_flickrProxy; - - /** - * Path to test data files - * - * @var string - */ - protected $_filesPath; - - /** - * HTTP client adapter for testing - * - * @var Zend_Http_Client_Adapter_Test - */ - protected $_httpClientAdapterTest; - - /** - * Socket based HTTP client adapter - * - * @var Zend_Http_Client_Adapter_Socket - */ - protected $_httpClientAdapterSocket; - - /** - * Sets up this test case - * - * @return void - */ - public function setUp() - { - $this->_flickr = new Zend_Service_Flickr(constant('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY')); - $this->_flickrProxy = new Zend_Service_Flickr_OfflineTest_FlickrProtectedMethodProxy( - constant('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY') - ); - $this->_filesPath = dirname(__FILE__) . '/_files'; - - /** - * @see Zend_Http_Client_Adapter_Socket - */ - require_once 'Zend/Http/Client/Adapter/Socket.php'; - $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket(); - - /** - * @see Zend_Http_Client_Adapter_Test - */ - require_once 'Zend/Http/Client/Adapter/Test.php'; - $this->_httpClientAdapterTest = new Zend_Http_Client_Adapter_Test(); - } - - /** - * Basic testing to ensure that tagSearch() works as expected - * - * @return void - */ - public function testTagSearchBasic() - { - $this->_flickr->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterTest); - - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); - - $options = array( - 'per_page' => 10, - 'page' => 1, - 'tag_mode' => 'or', - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server' - ); - - $resultSet = $this->_flickr->tagSearch('php', $options); - - $this->assertEquals(4285, $resultSet->totalResultsAvailable); - $this->assertEquals(10, $resultSet->totalResults()); - $this->assertEquals(10, $resultSet->totalResultsReturned); - $this->assertEquals(1, $resultSet->firstResultPosition); - - $this->assertEquals(0, $resultSet->key()); - - try { - $resultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->seek(9); - - try { - $resultSet->seek(10); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->rewind(); - - $resultSetIds = array( - '428222530', - '427883929', - '427884403', - '427887192', - '427883923', - '427884394', - '427883930', - '427884398', - '427883924', - '427884401' - ); - - $this->assertTrue($resultSet->valid()); - - foreach ($resultSetIds as $resultSetId) { - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__ . "-result_$resultSetId")); - $result = $resultSet->current(); - $this->assertTrue($result instanceof Zend_Service_Flickr_Result); - $resultSet->next(); - } - - $this->assertFalse($resultSet->valid()); - } - - /** - * Ensures that userSearch() throws an exception when an invalid username is given - * - * @return void - */ - public function testUserSearchExceptionUsernameInvalid() - { - $this->_flickr->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterTest); - - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); - - try { - $this->_flickr->userSearch('2e38a9d9425d7e2c9d0788455e9ccc61'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('User not found', $e->getMessage()); - } - } - - /** - * Ensures that userSearch() throws an exception when an invalid e-mail address is given - * - * @return void - */ - public function testUserSearchExceptionEmailInvalid() - { - $this->_flickr->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterTest); - - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); - - try { - $this->_flickr->userSearch('2e38a9d9425d7e2c9d0788455e9ccc61@example.com'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('User not found', $e->getMessage()); - } - } - - /** - * Ensures that getIdByUsername() throws an exception given an empty argument - * - * @return void - */ - public function testGetIdByUsernameExceptionUsernameEmpty() - { - try { - $this->_flickr->getIdByUsername('0'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('supply a username', $e->getMessage()); - } - } - - /** - * Ensures that getIdByEmail() throws an exception given an empty argument - * - * @return void - */ - public function testGetIdByEmailExceptionEmailEmpty() - { - try { - $this->_flickr->getIdByEmail('0'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('supply an e-mail address', $e->getMessage()); - } - } - - /** - * Ensures that getImageDetails() throws an exception given an empty argument - * - * @return void - */ - public function testGetImageDetailsExceptionIdEmpty() - { - try { - $this->_flickr->getImageDetails('0'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('supply a photo ID', $e->getMessage()); - } - } - - /** - * Ensures that _validateUserSearch() throws an exception when the per_page option is invalid - * - * @return void - */ - public function testValidateUserSearchExceptionPerPageInvalid() - { - try { - $this->_flickrProxy->proxyValidateUserSearch(array('per_page' => -1)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('"per_page" option', $e->getMessage()); - } - } - - /** - * Ensures that _validateUserSearch() throws an exception when the page option is invalid - * - * @return void - */ - public function testValidateUserSearchExceptionPageInvalid() - { - try { - $this->_flickrProxy->proxyValidateUserSearch(array('per_page' => 10, 'page' => 1.23)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('"page" option', $e->getMessage()); - } - } - - /** - * Ensures that _validateTagSearch() throws an exception when the per_page option is invalid - * - * @return void - */ - public function testValidateTagSearchExceptionPerPageInvalid() - { - try { - $this->_flickrProxy->proxyValidateTagSearch(array('per_page' => -1)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('"per_page" option', $e->getMessage()); - } - } - - /** - * Ensures that _validateTagSearch() throws an exception when the page option is invalid - * - * @return void - */ - public function testValidateTagSearchExceptionPageInvalid() - { - try { - $this->_flickrProxy->proxyValidateTagSearch(array('per_page' => 10, 'page' => 1.23)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('"page" option', $e->getMessage()); - } - } - - /** - * Ensures that _compareOptions() throws an exception when an option is invalid - * - * @return void - */ - public function testCompareOptionsExceptionOptionInvalid() - { - try { - $this->_flickrProxy->proxyCompareOptions(array('unexpected' => null), array()); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('parameters are invalid', $e->getMessage()); - } - } - - /** - * Ensures that tagSearch() throws an exception when an option is invalid - * - * @return void - */ - public function testTagSearchExceptionOptionInvalid() - { - try { - $this->_flickr->tagSearch('irrelevant', array('unexpected' => null)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('parameters are invalid', $e->getMessage()); - } - } - - /** - * Basic testing to ensure that groupPoolGetPhotos() works as expected - * - * @return void - */ - public function testGroupPoolGetPhotosBasic() - { - $this->_flickr->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterTest); - - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); - - $options = array( - 'per_page' => 10, - 'page' => 1, - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server' - ); - - $resultSet = $this->_flickr->groupPoolGetPhotos('20083316@N00', $options); - - $this->assertEquals(4285, $resultSet->totalResultsAvailable); - $this->assertEquals(10, $resultSet->totalResults()); - $this->assertEquals(10, $resultSet->totalResultsReturned); - $this->assertEquals(1, $resultSet->firstResultPosition); - - $this->assertEquals(0, $resultSet->key()); - - try { - $resultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->seek(9); - - try { - $resultSet->seek(10); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->rewind(); - - $resultSetIds = array( - '428222530', - '427883929', - '427884403', - '427887192', - '427883923', - '427884394', - '427883930', - '427884398', - '427883924', - '427884401' - ); - - $this->assertTrue($resultSet->valid()); - - foreach ($resultSetIds as $resultSetId) { - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__ . "-result_$resultSetId")); - $result = $resultSet->current(); - $this->assertTrue($result instanceof Zend_Service_Flickr_Result); - $resultSet->next(); - } - - $this->assertFalse($resultSet->valid()); - } - - /** - * Ensures that groupPoolGetPhotos() throws an exception when an option is invalid - * - * @return void - */ - public function testGroupPoolGetPhotosExceptionOptionInvalid() - { - try { - $this->_flickr->groupPoolGetPhotos('irrelevant', array('unexpected' => null)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('parameters are invalid', $e->getMessage()); - } - } - - /** - * Ensures that _validateGroupPoolGetPhotos() throws an exception when the per_page option is invalid - * - * @return void - */ - public function testValidateGroupPoolGetPhotosExceptionPerPageInvalid() - { - try { - $this->_flickrProxy->proxyValidateGroupPoolGetPhotos(array('per_page' => -1)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('"per_page" option', $e->getMessage()); - } - } - - /** - * Ensures that _validateGroupPoolGetPhotos() throws an exception when the page option is invalid - * - * @return void - */ - public function testValidateGroupPoolGetPhotosExceptionPageInvalid() - { - try { - $this->_flickrProxy->proxyValidateGroupPoolGetPhotos(array('per_page' => 10, 'page' => 1.23)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('"page" option', $e->getMessage()); - } - } - - /** - * Ensures that groupPoolGetPhotos() throws an exception when an invalid group_id is given - * - * @return void - */ - public function testGroupPoolGetPhotosExceptionGroupIdInvalid() - { - $this->_flickr->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterTest); - - $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); - - try { - $this->_flickr->groupPoolGetPhotos('2e38a9d9425d7e2c9d0788455e9ccc61'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('Group not found', $e->getMessage()); - } - } - - /** - * Ensures that groupPoolGetPhotos() throws an exception when an invalid group_id is given - * - * @return void - */ - public function testGroupPoolGetPhotosExceptionGroupIdEmpty() - { - try { - $this->_flickr->groupPoolGetPhotos('0'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('supply a group id', $e->getMessage()); - } - } - - /** - * Ensures that groupPoolGetPhotos() throws an exception when an array is given for group_id - * - * @return void - */ - public function testGroupPoolGetPhotosExceptionGroupIdArray() - { - try { - $this->_flickr->groupPoolGetPhotos(array()); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('supply a group id', $e->getMessage()); - } - } - - /** - * Utility method that saves an HTTP response to a file - * - * @param string $name - * @return void - */ - protected function _saveResponse($name) - { - file_put_contents("$this->_filesPath/$name.response", - $this->_flickr->getRestClient()->getHttpClient()->getLastResponse()->asString()); - } - - /** - * Utility method for returning a string HTTP response, which is loaded from a file - * - * @param string $name - * @return string - */ - protected function _loadResponse($name) - { - return file_get_contents("$this->_filesPath/$name.response"); - } -} - - -class Zend_Service_Flickr_OfflineTest_FlickrProtectedMethodProxy extends Zend_Service_Flickr -{ - public function proxyValidateUserSearch(array $options) - { - $this->_validateUserSearch($options); - } - - public function proxyValidateTagSearch(array $options) - { - $this->_validateTagSearch($options); - } - - public function proxyValidateGroupPoolGetPhotos(array $options) - { - $this->_validateGroupPoolGetPhotos($options); - } - - public function proxyCompareOptions(array $options, array $validOptions) - { - $this->_compareOptions($options, $validOptions); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Flickr/OnlineTest.php b/tests/Zend/Service/Flickr/OnlineTest.php deleted file mode 100644 index c0e088238907230c370ecea5c6cedc6a2534b658..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/OnlineTest.php +++ /dev/null @@ -1,222 +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_Service_Flickr - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OnlineTest.php 8733 2008-03-10 15:56:48Z jokke $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - - -/** - * @category Zend - * @package Zend_Service_Flickr - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Flickr_OnlineTest extends PHPUnit_Framework_TestCase -{ - /** - * Reference to Flickr service consumer object - * - * @var Zend_Service_Flickr - */ - protected $_flickr; - - /** - * Socket based HTTP client adapter - * - * @var Zend_Http_Client_Adapter_Socket - */ - protected $_httpClientAdapterSocket; - - /** - * Sets up this test case - * - * @return void - */ - public function setUp() - { - /** - * @see Zend_Service_Flickr - */ - require_once 'Zend/Service/Flickr.php'; - $this->_flickr = new Zend_Service_Flickr(constant('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY')); - - /** - * @see Zend_Http_Client_Adapter_Socket - */ - require_once 'Zend/Http/Client/Adapter/Socket.php'; - $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket(); - - $this->_flickr->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterSocket); - } - - /** - * Basic testing to ensure that groupPoolGetPhotos works as expected - * - * @return void - */ - public function testGroupPoolGetPhotosBasic() - { - $options = array('per_page' => 10, - 'page' => 1, - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server'); - - $resultSet = $this->_flickr->groupPoolGetPhotos('20083316@N00', $options); - - $this->assertEquals(21770, $resultSet->totalResultsAvailable); - $this->assertEquals(10, $resultSet->totalResults()); - $this->assertEquals(10, $resultSet->totalResultsReturned); - $this->assertEquals(1, $resultSet->firstResultPosition); - - $this->assertEquals(0, $resultSet->key()); - - try { - $resultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->seek(9); - - try { - $resultSet->seek(10); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->rewind(); - - $count = 0; - foreach ($resultSet as $result) { - $this->assertTrue($result instanceof Zend_Service_Flickr_Result); - $count++; - } - - $this->assertEquals(10, $count); - } - - /** - * Basic testing to ensure that userSearch() works as expected - * - * @return void - */ - public function testUserSearchBasic() - { - $options = array('per_page' => 10, - 'page' => 1, - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server'); - - $resultSet = $this->_flickr->userSearch('darby.felton@yahoo.com', $options); - - $this->assertEquals(16, $resultSet->totalResultsAvailable); - $this->assertEquals(10, $resultSet->totalResults()); - $this->assertEquals(10, $resultSet->totalResultsReturned); - $this->assertEquals(1, $resultSet->firstResultPosition); - - $this->assertEquals(0, $resultSet->key()); - - try { - $resultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->seek(9); - - try { - $resultSet->seek(10); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - $resultSet->rewind(); - - $count = 0; - foreach ($resultSet as $result) { - $this->assertTrue($result instanceof Zend_Service_Flickr_Result); - $count++; - } - - $this->assertEquals(10, $count); - } - - /** - * Basic testing to ensure that getIdByUsername() works as expected - * - * @return void - */ - public function testGetIdByUsernameBasic() - { - $userId = $this->_flickr->getIdByUsername('darby.felton'); - $this->assertEquals('7414329@N07', $userId); - } - - /** - * Ensures that tagSearch() works as expected with the sort option - * - * @return void - */ - public function testTagSearchOptionSort() - { - $options = array( - 'per_page' => 10, - 'page' => 1, - 'tag_mode' => 'or', - 'sort' => 'date-taken-asc', - 'extras' => 'license, date_upload, date_taken, owner_name, icon_server' - ); - - $resultSet = $this->_flickr->tagSearch('php', $options); - - $this->assertTrue(10 < $resultSet->totalResultsAvailable); - $this->assertEquals(10, $resultSet->totalResults()); - $this->assertEquals(10, $resultSet->totalResultsReturned); - $this->assertEquals(1, $resultSet->firstResultPosition); - - foreach ($resultSet as $result) { - $this->assertTrue($result instanceof Zend_Service_Flickr_Result); - if (isset($dateTakenPrevious)) { - $this->assertTrue(strcmp($result->datetaken, $dateTakenPrevious) > 0); - } - $dateTakenPrevious = $result->datetaken; - } - } -} - - -class Zend_Service_Flickr_OnlineTest_Skip extends PHPUnit_Framework_TestCase -{ - public function testNothing() - { - $this->markTestSkipped('Zend_Service_Flickr online tests not enabled in TestConfiguration.php'); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883923.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883923.response deleted file mode 100644 index 14179fc5c5fe97a6dc81d5ee6eb20c75e75dca27..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883923.response +++ /dev/null @@ -1,16 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:47 GMT -Server: Apache/2.0.52 -Content-length: 828 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/146/427883923_25902ff728_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=sq" /> - <size label="Thumbnail" width="100" height="8" source="http://farm1.static.flickr.com/146/427883923_25902ff728_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=t" /> - <size label="Small" width="221" height="17" source="http://farm1.static.flickr.com/146/427883923_25902ff728_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=s" /> - <size label="Large" width="221" height="17" source="http://farm1.static.flickr.com/146/427883923_398e28d146_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883924.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883924.response deleted file mode 100644 index fc7c240ae022156325fa5ef658365a8f31a3cfa0..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883924.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:48 GMT -Server: Apache/2.0.52 -Content-length: 1012 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=sq" /> - <size label="Thumbnail" width="100" height="3" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=t" /> - <size label="Small" width="240" height="8" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=s" /> - <size label="Medium" width="500" height="16" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=m" /> - <size label="Large" width="531" height="17" source="http://farm1.static.flickr.com/162/427883924_e27b0e1bf3_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883929.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883929.response deleted file mode 100644 index e7abc41d967391f2b8fae6d62897e7e3ca052e31..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883929.response +++ /dev/null @@ -1,16 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:46 GMT -Server: Apache/2.0.52 -Content-length: 829 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/163/427883929_e46c580947_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=sq" /> - <size label="Thumbnail" width="100" height="11" source="http://farm1.static.flickr.com/163/427883929_e46c580947_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=t" /> - <size label="Small" width="116" height="13" source="http://farm1.static.flickr.com/163/427883929_e46c580947_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=s" /> - <size label="Large" width="116" height="13" source="http://farm1.static.flickr.com/163/427883929_f0230e0d5a_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883930.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883930.response deleted file mode 100644 index 0c6facd9a8c17346c06278d18980797999ee0f07..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427883930.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:48 GMT -Server: Apache/2.0.52 -Content-length: 639 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/163/427883930_37e83d6bde_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883930&size=sq" /> - <size label="Thumbnail" width="23" height="3" source="http://farm1.static.flickr.com/163/427883930_37e83d6bde_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883930&size=t" /> - <size label="Large" width="23" height="3" source="http://farm1.static.flickr.com/163/427883930_edb91cc3a2_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883930&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884394.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884394.response deleted file mode 100644 index c9db414814144b47d564a7bd9dd2907a4f3b2aa4..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884394.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:47 GMT -Server: Apache/2.0.52 -Content-length: 641 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/145/427884394_48678fb007_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884394&size=sq" /> - <size label="Thumbnail" width="92" height="37" source="http://farm1.static.flickr.com/145/427884394_48678fb007_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884394&size=t" /> - <size label="Large" width="92" height="37" source="http://farm1.static.flickr.com/145/427884394_d1e788022b_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884394&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884398.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884398.response deleted file mode 100644 index ed426ded98007cdff6dae4153a87fdabfbd361a1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884398.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:48 GMT -Server: Apache/2.0.52 -Content-length: 1012 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=sq" /> - <size label="Thumbnail" width="100" height="3" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=t" /> - <size label="Small" width="240" height="7" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=s" /> - <size label="Medium" width="500" height="14" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=m" /> - <size label="Large" width="531" height="15" source="http://farm1.static.flickr.com/154/427884398_c372035a18_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884401.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884401.response deleted file mode 100644 index 25e075d772d87c84d4a3d078ee67dc631ad7f14f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884401.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:49 GMT -Server: Apache/2.0.52 -Content-length: 1012 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/160/427884401_b561b6636a_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=sq" /> - <size label="Thumbnail" width="100" height="3" source="http://farm1.static.flickr.com/160/427884401_b561b6636a_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=t" /> - <size label="Small" width="240" height="8" source="http://farm1.static.flickr.com/160/427884401_b561b6636a_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=s" /> - <size label="Medium" width="500" height="16" source="http://farm1.static.flickr.com/160/427884401_b561b6636a.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=m" /> - <size label="Large" width="531" height="17" source="http://farm1.static.flickr.com/160/427884401_6356f5fae7_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884403.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884403.response deleted file mode 100644 index 5edaa170510f0745d1d5e866b59ca3f38ae40514..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427884403.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:46 GMT -Server: Apache/2.0.52 -Content-length: 639 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/183/427884403_fb2ebbb275_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884403&size=sq" /> - <size label="Thumbnail" width="23" height="3" source="http://farm1.static.flickr.com/183/427884403_fb2ebbb275_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884403&size=t" /> - <size label="Large" width="23" height="3" source="http://farm1.static.flickr.com/183/427884403_bd4c170074_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884403&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427887192.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427887192.response deleted file mode 100644 index 8d3f6230b1b41c9a76c1109eabded49aa568280f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_427887192.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:47 GMT -Server: Apache/2.0.52 -Content-length: 639 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/156/427887192_a5a5781ea0_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427887192&size=sq" /> - <size label="Thumbnail" width="11" height="1" source="http://farm1.static.flickr.com/156/427887192_a5a5781ea0_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427887192&size=t" /> - <size label="Large" width="11" height="1" source="http://farm1.static.flickr.com/156/427887192_ebd45dbf31_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427887192&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_428222530.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_428222530.response deleted file mode 100644 index 5a1c379d39ddc3cbfb08bf53d50c085635a6680a..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic-result_428222530.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:45 GMT -Server: Apache/2.0.52 -Content-length: 1020 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=sq" /> - <size label="Thumbnail" width="100" height="86" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=t" /> - <size label="Small" width="240" height="208" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=s" /> - <size label="Medium" width="500" height="432" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=m" /> - <size label="Original" width="769" height="665" source="http://farm1.static.flickr.com/146/428222530_d1bfe0bc57_o.png" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic.response deleted file mode 100644 index 30af253a0ec6cb082863e3097f8134c8a594c337..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosBasic.response +++ /dev/null @@ -1,22 +0,0 @@ -HTTP/1.1 200 OK -Date: Wed, 21 Mar 2007 20:00:46 GMT -Server: Apache/2.0.52 -Content-length: 3023 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<photos page="1" pages="429" perpage="10" total="4285"> - <photo id="428222530" owner="36046768@N00" secret="6d2e56ed92" server="146" farm="1" title="Our mobile solution" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174407931" datetaken="2007-03-20 12:25:31" datetakengranularity="0" ownername="jrodgers" iconserver="8" iconfarm="1" /> - <photo id="427883929" owner="87185455@N00" secret="e46c580947" server="163" farm="1" title="moreoptions" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377640" datetaken="2007-03-20 01:00:40" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884403" owner="87185455@N00" secret="fb2ebbb275" server="183" farm="1" title="right4" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377693" datetaken="2007-03-20 01:01:33" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427887192" owner="87185455@N00" secret="a5a5781ea0" server="156" farm="1" title="left3" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377980" datetaken="2007-03-20 01:06:20" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427883923" owner="87185455@N00" secret="25902ff728" server="146" farm="1" title="left4" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377639" datetaken="2007-03-20 01:00:39" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884394" owner="87185455@N00" secret="48678fb007" server="145" farm="1" title="rbutton" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377692" datetaken="2007-03-20 01:01:32" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427883930" owner="87185455@N00" secret="37e83d6bde" server="163" farm="1" title="right4" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377640" datetaken="2007-03-20 01:00:40" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884398" owner="87185455@N00" secret="ab68b726ae" server="154" farm="1" title="right1" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377693" datetaken="2007-03-20 01:01:33" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427883924" owner="87185455@N00" secret="bbfdee1f96" server="162" farm="1" title="right3" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377639" datetaken="2007-03-20 01:00:39" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884401" owner="87185455@N00" secret="b561b6636a" server="160" farm="1" title="right3" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377693" datetaken="2007-03-20 01:01:33" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> -</photos> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosExceptionGroupIdInvalid.response b/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosExceptionGroupIdInvalid.response deleted file mode 100644 index 9a11cb62c83bd04658e6b2a32d83ce8f0368419c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testGroupPoolGetPhotosExceptionGroupIdInvalid.response +++ /dev/null @@ -1,11 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 29 Mar 2007 23:28:10 GMT -Server: Apache/2.0.52 -Content-length: 105 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="fail"> - <err code="1" msg="Group not found" /> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883923.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883923.response deleted file mode 100644 index 14179fc5c5fe97a6dc81d5ee6eb20c75e75dca27..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883923.response +++ /dev/null @@ -1,16 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:47 GMT -Server: Apache/2.0.52 -Content-length: 828 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/146/427883923_25902ff728_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=sq" /> - <size label="Thumbnail" width="100" height="8" source="http://farm1.static.flickr.com/146/427883923_25902ff728_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=t" /> - <size label="Small" width="221" height="17" source="http://farm1.static.flickr.com/146/427883923_25902ff728_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=s" /> - <size label="Large" width="221" height="17" source="http://farm1.static.flickr.com/146/427883923_398e28d146_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883923&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883924.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883924.response deleted file mode 100644 index fc7c240ae022156325fa5ef658365a8f31a3cfa0..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883924.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:48 GMT -Server: Apache/2.0.52 -Content-length: 1012 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=sq" /> - <size label="Thumbnail" width="100" height="3" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=t" /> - <size label="Small" width="240" height="8" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=s" /> - <size label="Medium" width="500" height="16" source="http://farm1.static.flickr.com/162/427883924_bbfdee1f96.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=m" /> - <size label="Large" width="531" height="17" source="http://farm1.static.flickr.com/162/427883924_e27b0e1bf3_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883924&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883929.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883929.response deleted file mode 100644 index e7abc41d967391f2b8fae6d62897e7e3ca052e31..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883929.response +++ /dev/null @@ -1,16 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:46 GMT -Server: Apache/2.0.52 -Content-length: 829 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/163/427883929_e46c580947_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=sq" /> - <size label="Thumbnail" width="100" height="11" source="http://farm1.static.flickr.com/163/427883929_e46c580947_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=t" /> - <size label="Small" width="116" height="13" source="http://farm1.static.flickr.com/163/427883929_e46c580947_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=s" /> - <size label="Large" width="116" height="13" source="http://farm1.static.flickr.com/163/427883929_f0230e0d5a_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883929&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883930.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883930.response deleted file mode 100644 index 0c6facd9a8c17346c06278d18980797999ee0f07..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427883930.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:48 GMT -Server: Apache/2.0.52 -Content-length: 639 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/163/427883930_37e83d6bde_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883930&size=sq" /> - <size label="Thumbnail" width="23" height="3" source="http://farm1.static.flickr.com/163/427883930_37e83d6bde_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427883930&size=t" /> - <size label="Large" width="23" height="3" source="http://farm1.static.flickr.com/163/427883930_edb91cc3a2_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427883930&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884394.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884394.response deleted file mode 100644 index c9db414814144b47d564a7bd9dd2907a4f3b2aa4..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884394.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:47 GMT -Server: Apache/2.0.52 -Content-length: 641 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/145/427884394_48678fb007_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884394&size=sq" /> - <size label="Thumbnail" width="92" height="37" source="http://farm1.static.flickr.com/145/427884394_48678fb007_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884394&size=t" /> - <size label="Large" width="92" height="37" source="http://farm1.static.flickr.com/145/427884394_d1e788022b_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884394&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884398.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884398.response deleted file mode 100644 index ed426ded98007cdff6dae4153a87fdabfbd361a1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884398.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:48 GMT -Server: Apache/2.0.52 -Content-length: 1012 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=sq" /> - <size label="Thumbnail" width="100" height="3" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=t" /> - <size label="Small" width="240" height="7" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=s" /> - <size label="Medium" width="500" height="14" source="http://farm1.static.flickr.com/154/427884398_ab68b726ae.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=m" /> - <size label="Large" width="531" height="15" source="http://farm1.static.flickr.com/154/427884398_c372035a18_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884398&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884401.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884401.response deleted file mode 100644 index 25e075d772d87c84d4a3d078ee67dc631ad7f14f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884401.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:49 GMT -Server: Apache/2.0.52 -Content-length: 1012 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/160/427884401_b561b6636a_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=sq" /> - <size label="Thumbnail" width="100" height="3" source="http://farm1.static.flickr.com/160/427884401_b561b6636a_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=t" /> - <size label="Small" width="240" height="8" source="http://farm1.static.flickr.com/160/427884401_b561b6636a_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=s" /> - <size label="Medium" width="500" height="16" source="http://farm1.static.flickr.com/160/427884401_b561b6636a.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=m" /> - <size label="Large" width="531" height="17" source="http://farm1.static.flickr.com/160/427884401_6356f5fae7_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884401&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884403.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884403.response deleted file mode 100644 index 5edaa170510f0745d1d5e866b59ca3f38ae40514..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427884403.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:46 GMT -Server: Apache/2.0.52 -Content-length: 639 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/183/427884403_fb2ebbb275_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884403&size=sq" /> - <size label="Thumbnail" width="23" height="3" source="http://farm1.static.flickr.com/183/427884403_fb2ebbb275_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427884403&size=t" /> - <size label="Large" width="23" height="3" source="http://farm1.static.flickr.com/183/427884403_bd4c170074_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427884403&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427887192.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427887192.response deleted file mode 100644 index 8d3f6230b1b41c9a76c1109eabded49aa568280f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_427887192.response +++ /dev/null @@ -1,15 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:47 GMT -Server: Apache/2.0.52 -Content-length: 639 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/156/427887192_a5a5781ea0_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427887192&size=sq" /> - <size label="Thumbnail" width="11" height="1" source="http://farm1.static.flickr.com/156/427887192_a5a5781ea0_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=427887192&size=t" /> - <size label="Large" width="11" height="1" source="http://farm1.static.flickr.com/156/427887192_ebd45dbf31_o.gif" url="http://www.flickr.com/photo_zoom.gne?id=427887192&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_428222530.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_428222530.response deleted file mode 100644 index 5a1c379d39ddc3cbfb08bf53d50c085635a6680a..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic-result_428222530.response +++ /dev/null @@ -1,17 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 22 Mar 2007 19:09:45 GMT -Server: Apache/2.0.52 -Content-length: 1020 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<sizes> - <size label="Square" width="75" height="75" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92_s.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=sq" /> - <size label="Thumbnail" width="100" height="86" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92_t.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=t" /> - <size label="Small" width="240" height="208" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92_m.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=s" /> - <size label="Medium" width="500" height="432" source="http://farm1.static.flickr.com/146/428222530_6d2e56ed92.jpg" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=m" /> - <size label="Original" width="769" height="665" source="http://farm1.static.flickr.com/146/428222530_d1bfe0bc57_o.png" url="http://www.flickr.com/photo_zoom.gne?id=428222530&size=o" /> -</sizes> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testTagSearchBasic.response b/tests/Zend/Service/Flickr/_files/testTagSearchBasic.response deleted file mode 100644 index 30af253a0ec6cb082863e3097f8134c8a594c337..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testTagSearchBasic.response +++ /dev/null @@ -1,22 +0,0 @@ -HTTP/1.1 200 OK -Date: Wed, 21 Mar 2007 20:00:46 GMT -Server: Apache/2.0.52 -Content-length: 3023 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="ok"> -<photos page="1" pages="429" perpage="10" total="4285"> - <photo id="428222530" owner="36046768@N00" secret="6d2e56ed92" server="146" farm="1" title="Our mobile solution" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174407931" datetaken="2007-03-20 12:25:31" datetakengranularity="0" ownername="jrodgers" iconserver="8" iconfarm="1" /> - <photo id="427883929" owner="87185455@N00" secret="e46c580947" server="163" farm="1" title="moreoptions" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377640" datetaken="2007-03-20 01:00:40" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884403" owner="87185455@N00" secret="fb2ebbb275" server="183" farm="1" title="right4" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377693" datetaken="2007-03-20 01:01:33" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427887192" owner="87185455@N00" secret="a5a5781ea0" server="156" farm="1" title="left3" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377980" datetaken="2007-03-20 01:06:20" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427883923" owner="87185455@N00" secret="25902ff728" server="146" farm="1" title="left4" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377639" datetaken="2007-03-20 01:00:39" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884394" owner="87185455@N00" secret="48678fb007" server="145" farm="1" title="rbutton" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377692" datetaken="2007-03-20 01:01:32" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427883930" owner="87185455@N00" secret="37e83d6bde" server="163" farm="1" title="right4" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377640" datetaken="2007-03-20 01:00:40" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884398" owner="87185455@N00" secret="ab68b726ae" server="154" farm="1" title="right1" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377693" datetaken="2007-03-20 01:01:33" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427883924" owner="87185455@N00" secret="bbfdee1f96" server="162" farm="1" title="right3" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377639" datetaken="2007-03-20 01:00:39" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> - <photo id="427884401" owner="87185455@N00" secret="b561b6636a" server="160" farm="1" title="right3" ispublic="1" isfriend="0" isfamily="0" license="0" dateupload="1174377693" datetaken="2007-03-20 01:01:33" datetakengranularity="0" ownername="wcbzero2006" iconserver="0" iconfarm="0" /> -</photos> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testUserSearchExceptionEmailInvalid.response b/tests/Zend/Service/Flickr/_files/testUserSearchExceptionEmailInvalid.response deleted file mode 100644 index 29fb4e7d6eaeb6ecefdc9a16eab3b1c4defb819e..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testUserSearchExceptionEmailInvalid.response +++ /dev/null @@ -1,11 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 29 Mar 2007 23:28:10 GMT -Server: Apache/2.0.52 -Content-length: 104 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="fail"> - <err code="1" msg="User not found" /> -</rsp> diff --git a/tests/Zend/Service/Flickr/_files/testUserSearchExceptionUsernameInvalid.response b/tests/Zend/Service/Flickr/_files/testUserSearchExceptionUsernameInvalid.response deleted file mode 100644 index 29fb4e7d6eaeb6ecefdc9a16eab3b1c4defb819e..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Flickr/_files/testUserSearchExceptionUsernameInvalid.response +++ /dev/null @@ -1,11 +0,0 @@ -HTTP/1.1 200 OK -Date: Thu, 29 Mar 2007 23:28:10 GMT -Server: Apache/2.0.52 -Content-length: 104 -Connection: close -Content-type: text/xml; charset=utf-8 - -<?xml version="1.0" encoding="utf-8" ?> -<rsp stat="fail"> - <err code="1" msg="User not found" /> -</rsp> diff --git a/tests/Zend/Service/Nirvanix/AllTests.php b/tests/Zend/Service/Nirvanix/AllTests.php deleted file mode 100644 index d002e7db3d52b9c85666b91fe940063e572e8c97..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/AllTests.php +++ /dev/null @@ -1,92 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Nirvanix_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_Nirvanix_NirvanixTest - */ -require_once 'Zend/Service/Nirvanix/NirvanixTest.php'; - -/** - * @see Zend_Service_Nirvanix_ExceptionTest - */ -require_once 'Zend/Service/Nirvanix/ExceptionTest.php'; - -/** - * @see Zend_Service_Nirvanix_ResponseTest - */ -require_once 'Zend/Service/Nirvanix/ResponseTest.php'; - -/** - * @see Zend_Service_Nirvanix_Namespace_BaseTest - */ -require_once 'Zend/Service/Nirvanix/Namespace/BaseTest.php'; - -/** - * @see Zend_Service_Nirvanix_Namespace_ImfsTest - */ -require_once 'Zend/Service/Nirvanix/Namespace/ImfsTest.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Nirvanix'); - - $suite->addTestSuite('Zend_Service_Nirvanix_NirvanixTest'); - $suite->addTestSuite('Zend_Service_Nirvanix_ExceptionTest'); - $suite->addTestSuite('Zend_Service_Nirvanix_ResponseTest'); - $suite->addTestSuite('Zend_Service_Nirvanix_Namespace_BaseTest'); - $suite->addTestSuite('Zend_Service_Nirvanix_Namespace_ImfsTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_Nirvanix_AllTests::main') { - Zend_Service_Nirvanix_AllTests::main(); -} diff --git a/tests/Zend/Service/Nirvanix/ExceptionTest.php b/tests/Zend/Service/Nirvanix/ExceptionTest.php deleted file mode 100644 index 9e453f22b6fba0a839b8b14800ae141a00e18760..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/ExceptionTest.php +++ /dev/null @@ -1,41 +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_Service - * @subpackage Nirvanix - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Service_Nirvanix_Exception - */ -require_once 'Zend/Service/Nirvanix/Exception.php'; - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_ExceptionTest extends PHPUnit_Framework_TestCase -{ - public function testInheritsFromZendException() - { - $exc = new Zend_Service_Nirvanix_Exception(); - $this->assertType('Zend_Exception', $exc); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/Nirvanix/FunctionalTestCase.php b/tests/Zend/Service/Nirvanix/FunctionalTestCase.php deleted file mode 100644 index 14d102c92fbbbf81f9371478be2bf4fa864ba8c7..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/FunctionalTestCase.php +++ /dev/null @@ -1,78 +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_Service - * @subpackage Nirvanix - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Service_Nirvanix - */ -require_once 'Zend/Service/Nirvanix.php'; - -/** - * @see Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_FunctionalTestCase extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->httpAdapter = new Zend_Http_Client_Adapter_Test(); - $this->httpClient = new Zend_Http_Client('http://foo', - array('adapter' => $this->httpAdapter)); - - $this->auth = array('username' => 'foo', 'password' => 'bar', 'appKey' => 'baz'); - $this->options = array('httpClient' => $this->httpClient); - - // set first nirvanix response to successful login - $this->httpAdapter->setResponse( - $this->makeNirvanixResponse(array('ResponseCode' => '0', - 'SessionToken' => 'foo')) - ); - - $this->nirvanix = new Zend_Service_Nirvanix($this->auth, $this->options); - } - - public function makeNirvanixResponse($hash) - { - $xml = "<?xml version='1.0'?><Response>"; - foreach ($hash as $k => $v) { $xml .= "<$k>$v</$k>"; } - $xml .= "</Response>"; - - $resp = $this->makeHttpResponseFrom($xml); - return $resp; - } - - public function makeHttpResponseFrom($data, $status=200, $message='OK') - { - $headers = array("HTTP/1.1 $status $message", - "Status: $status", - 'Content_Type: text/xml; charset=utf-8', - 'Content-Length: ' . strlen($data) - ); - return implode("\r\n", $headers) . "\r\n\r\n$data\r\n\r\n"; - } -} diff --git a/tests/Zend/Service/Nirvanix/Namespace/BaseTest.php b/tests/Zend/Service/Nirvanix/Namespace/BaseTest.php deleted file mode 100644 index 85ff17134f8a85e7094b77e2aafc5b5dbc4535ff..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/Namespace/BaseTest.php +++ /dev/null @@ -1,47 +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_Service - * @subpackage Nirvanix - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Service_Nirvanix_Namespace_Base - */ -require_once 'Zend/Service/Nirvanix/Namespace/Base.php'; - -/** - * @see Zend_Service_Nirvanix_FunctionalTestCase - */ -require_once 'Zend/Service/Nirvanix/FunctionalTestCase.php'; - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_Namespace_BaseTest extends Zend_Service_Nirvanix_FunctionalTestCase -{ - public function testGetHttpClient() - { - $foo = $this->nirvanix->getService('Foo'); - $this->assertSame($this->httpClient, $foo->getHttpClient()); - } - -} \ No newline at end of file diff --git a/tests/Zend/Service/Nirvanix/Namespace/ImfsTest.php b/tests/Zend/Service/Nirvanix/Namespace/ImfsTest.php deleted file mode 100644 index bf0fb25ef08225edffebb761ca37d4b42a79eb40..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/Namespace/ImfsTest.php +++ /dev/null @@ -1,107 +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_Service - * @subpackage Nirvanix - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Service_Nirvanix_Namespace_Imfs - */ -require_once 'Zend/Service/Nirvanix/Namespace/Imfs.php'; - -/** - * @see Zend_Service_Nirvanix_FunctionalTestCase - */ -require_once 'Zend/Service/Nirvanix/FunctionalTestCase.php'; - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_FunctionalTestCase -{ - public function testInheritsFromNirvanixBase() - { - $imfs = new Zend_Service_Nirvanix_Namespace_Imfs(); - $this->assertType('Zend_Service_Nirvanix_Namespace_Base', $imfs); - } - - // putContents() - - public function testPutContents() - { - $imfs = $this->nirvanix->getService('IMFS'); - - // response for call to GetStorageNode - $this->httpAdapter->addResponse( - $this->makeNirvanixResponse( - array('ResponseCode' => '0', - 'GetStorageNode' => '<UploadHost>node1.nirvanix.com</UploadHost> - <UploadToken>bar</UploadToken>')) - ); - - $imfs->putContents('/foo', 'contents for foo'); - } - - // getContents() - - public function testGetContents() - { - $imfs = $this->nirvanix->getService('IMFS'); - - // response for call to GetOptimalUrlss - $this->httpAdapter->addResponse( - $this->makeNirvanixResponse( - array('ResponseCode' => '0', - 'Download' => '<DownloadURL>http://get-it-here</DownloadURL>')) - ); - - // response for file download - $this->httpAdapter->addResponse( - $this->makeHttpResponseFrom('contents for foo') - ); - - $actual = $imfs->getContents('/foo.txt'); - $expected = $this->httpClient->getLastResponse()->getBody(); - $this->assertEquals($expected, $actual); - } - - // unlink() - - public function testUnlink() - { - $imfs = $this->nirvanix->getService('IMFS'); - - // response for call to DeleteFiles - $this->httpAdapter->addResponse( - $this->makeNirvanixResponse(array('ResponseCode' => '0')) - ); - - $imfs->unlink('foo'); - } - -} - - - - - - diff --git a/tests/Zend/Service/Nirvanix/NirvanixTest.php b/tests/Zend/Service/Nirvanix/NirvanixTest.php deleted file mode 100644 index 858c2683051978e464ab4f636c6137b4b2a6380e..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/NirvanixTest.php +++ /dev/null @@ -1,68 +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_Service - * @subpackage Nirvanix - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Service_Nirvanix_FunctionalTestCase - */ -require_once 'Zend/Service/Nirvanix/FunctionalTestCase.php'; - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_NirvanixTest extends Zend_Service_Nirvanix_FunctionalTestCase -{ - // getService() - - public function testFactoryReturnsBaseWhenNoSubclassAvailable() - { - $base = $this->nirvanix->getService('Foo'); - $this->assertType('Zend_Service_Nirvanix_Namespace_Base', $base); - } - - public function testFactoryReturnsImfsSubclassForImfsNamespace() - { - $imfs = $this->nirvanix->getService('IMFS'); - $this->assertType('Zend_Service_Nirvanix_Namespace_Imfs', $imfs); - } - - public function testFactoryPassesHttpClientInstanceWithOptions() - { - $nirvanixOptions = $this->nirvanix->getOptions(); - $this->assertSame($this->httpClient, $nirvanixOptions['httpClient']); - - $foo = $this->nirvanix->getService('Foo'); - $fooOptions = $foo->getOptions(); - $this->assertSame($this->httpClient, $nirvanixOptions['httpClient']); - } - - // getOptions() - - public function testGetOptionsReturnsOptions() - { - $options = $this->nirvanix->getOptions(); - $this->assertSame($this->httpClient, $options['httpClient']); - } - -} \ No newline at end of file diff --git a/tests/Zend/Service/Nirvanix/ResponseTest.php b/tests/Zend/Service/Nirvanix/ResponseTest.php deleted file mode 100644 index 9b895f3aeddcc1ef6b3a27a59356b9d96518dfae..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Nirvanix/ResponseTest.php +++ /dev/null @@ -1,114 +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_Service - * @subpackage Nirvanix - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * @see Zend_Service_Nirvanix_Response - */ -require_once 'Zend/Service/Nirvanix/Response.php'; - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Nirvanix_ResponseTest extends PHPUnit_Framework_TestCase -{ - // Constructor - - public function testThrowsWhenInputStringIsNotXML() - { - $notXml = 'foo'; - try { - new Zend_Service_Nirvanix_Response($notXml); - } catch (Zend_Service_Nirvanix_Exception $e) { - $this->assertRegExp('/xml could not be parsed/i', $e->getMessage()); - } - } - - public function testThrowsWhenXmlElementNameIsNotResponse() - { - $xml = "<?xml version='1.0'?> - <foo></foo>"; - try { - new Zend_Service_Nirvanix_Response($xml); - } catch (Zend_Service_Nirvanix_Exception $e) { - $this->assertRegExp('/expected xml element response/i', $e->getMessage()); - } - } - - public function testThrowsCodeAndMessageWhenResponseCodeIsNotZero() - { - $xml = "<?xml version='1.0'?> - <Response> - <ResponseCode>42</ResponseCode> - <ErrorMessage>foo</ErrorMessage> - </Response>"; - try { - new Zend_Service_Nirvanix_Response($xml); - } catch (Zend_Service_Nirvanix_Exception $e) { - $this->assertEquals(42, $e->getCode()); - $this->assertEquals('foo', $e->getMessage()); - } - } - - // getSxml() - - public function testGetSxmlReturnsSimpleXmlElement() - { - $xml = "<?xml version='1.0'?> - <Response> - <ResponseCode>0</ResponseCode> - <foo>bar</foo> - </Response>"; - - $resp = new Zend_Service_Nirvanix_Response($xml); - $this->assertType('SimpleXMLElement', $resp->getSxml()); - } - - // __get() - - public function testUndefinedPropertyIsDelegatedToSimpleXMLElement() - { - $xml = "<?xml version='1.0'?> - <Response> - <ResponseCode>0</ResponseCode> - <foo>bar</foo> - </Response>"; - $resp = new Zend_Service_Nirvanix_Response($xml); - $this->assertEquals('bar', (string)$resp->foo); - } - - // __call() - - public function testUndefinedMethodIsDelegatedToSimpleXMLElement() - { - $xml = "<?xml version='1.0'?> - <Response> - <ResponseCode>0</ResponseCode> - <foo>bar</foo> - </Response>"; - $resp = new Zend_Service_Nirvanix_Response($xml); - $this->assertEquals('Response', $resp->getName()); - } - -} \ No newline at end of file diff --git a/tests/Zend/Service/ReCaptcha/AllTests.php b/tests/Zend/Service/ReCaptcha/AllTests.php deleted file mode 100644 index 0f026c9daf1ab8e35017f843992745cc24662987..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/ReCaptcha/AllTests.php +++ /dev/null @@ -1,97 +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_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_ReCaptcha_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** @see Zend_Service_ReCaptcha_ReCaptchaTest */ -require_once 'Zend/Service/ReCaptcha/ReCaptchaTest.php'; - -/** @see Zend_Service_ReCaptcha_ResponseTest */ -require_once 'Zend/Service/ReCaptcha/ResponseTest.php'; - -/** @see Zend_Service_ReCaptcha_MailHideTest */ -require_once 'Zend/Service/ReCaptcha/MailHideTest.php'; - -/** - * @category Zend - * @package Zend_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_ReCaptcha_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_ReCaptcha'); - - if (defined('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED') && - constant('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED') && - defined('TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY') && - defined('TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY')) { - - $suite->addTestSuite('Zend_Service_ReCaptcha_ReCaptchaTest'); - $suite->addTestSuite('Zend_Service_ReCaptcha_ResponseTest'); - } - - if (defined('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED') && - constant('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED') && - defined('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY') && - defined('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY')) { - - $suite->addTestSuite('Zend_Service_ReCaptcha_MailHideTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_ReCaptcha_AllTests::main') { - Zend_Service_ReCaptcha_AllTests::main(); -} diff --git a/tests/Zend/Service/ReCaptcha/MailHideTest.php b/tests/Zend/Service/ReCaptcha/MailHideTest.php deleted file mode 100644 index 39d3bdbd9582c7a35f315b263c4d1c17f44f337a..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/ReCaptcha/MailHideTest.php +++ /dev/null @@ -1,149 +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_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** @see Zend_Service_ReCaptcha_MailHide */ -require_once 'Zend/Service/ReCaptcha/MailHide.php'; - -/** - * @category Zend - * @package Zend_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_ReCaptcha_MailHideTest extends PHPUnit_Framework_TestCase -{ - protected $_publicKey = TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY; - protected $_privateKey = TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY; - protected $_mailHide = null; - - public function setUp() { - $this->_mailHide = new Zend_Service_ReCaptcha_MailHide(); - } - - public function testSetGetPrivateKey() { - $this->_mailHide->setPrivateKey($this->_privateKey); - $this->assertSame($this->_privateKey, $this->_mailHide->getPrivateKey()); - } - - public function testSetGetEmail() { - $mail = 'mail@example.com'; - - $this->_mailHide->setEmail($mail); - $this->assertSame($mail, $this->_mailHide->getEmail()); - $this->assertSame('example.com', $this->_mailHide->getEmailDomainPart()); - } - - public function testEmailLocalPart() { - $this->_mailHide->setEmail('abcd@example.com'); - $this->assertSame('a', $this->_mailHide->getEmailLocalPart()); - - $this->_mailHide->setEmail('abcdef@example.com'); - $this->assertSame('abc', $this->_mailHide->getEmailLocalPart()); - - $this->_mailHide->setEmail('abcdefg@example.com'); - $this->assertSame('abcd', $this->_mailHide->getEmailLocalPart()); - } - - public function testConstructor() { - $mail = 'mail@example.com'; - - $options = array( - 'theme' => 'black', - 'lang' => 'no', - ); - - $config = new Zend_Config($options); - - $mailHide = new Zend_Service_ReCaptcha_MailHide($this->_publicKey, $this->_privateKey, $mail, $config); - $_options = $mailHide->getOptions(); - - $this->assertSame($this->_publicKey, $mailHide->getPublicKey()); - $this->assertSame($this->_privateKey, $mailHide->getPrivateKey()); - $this->assertSame($mail, $mailHide->getEmail()); - $this->assertSame($options['theme'], $_options['theme']); - $this->assertSame($options['lang'], $_options['lang']); - } - - protected function _checkHtml($html) { - $server = Zend_Service_ReCaptcha_MailHide::MAILHIDE_SERVER; - $pubKey = $this->_publicKey; - - $this->assertNotSame(false, strstr($html, 'm<a href="' . $server . '?k=' . $pubKey . '&c=mX82V4Dce5Y9dNGvrJszhI2ld_eMWxpNsMNovQGRrXs=" onclick="window.open(\'' . $server . '?k=' . $pubKey . '&c=mX82V4Dce5Y9dNGvrJszhI2ld_eMWxpNsMNovQGRrXs=\', \'\', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300\'); return false;" title="Reveal this e-mail address">...</a>@example.com')); - } - - public function testGetHtml() { - $mail = 'mail@example.com'; - - $this->_mailHide->setEmail($mail); - $this->_mailHide->setPublicKey($this->_publicKey); - $this->_mailHide->setPrivateKey($this->_privateKey); - - $html = $this->_mailHide->getHtml(); - - $this->_checkHtml($html); - } - - public function testGetHtmlWithNoEmail() { - $this->setExpectedException('Zend_Service_ReCaptcha_MailHide_Exception'); - - $html = $this->_mailHide->getHtml(); - } - - public function testGetHtmlWithMissingPublicKey() { - $this->setExpectedException('Zend_Service_ReCaptcha_MailHide_Exception'); - - $mail = 'mail@example.com'; - - $this->_mailHide->setEmail($mail); - $this->_mailHide->setPrivateKey($this->_privateKey); - - $html = $this->_mailHide->getHtml(); - } - - public function testGetHtmlWithMissingPrivateKey() { - $this->setExpectedException('Zend_Service_ReCaptcha_MailHide_Exception'); - - $mail = 'mail@example.com'; - - $this->_mailHide->setEmail($mail); - $this->_mailHide->setPublicKey($this->_publicKey); - - $html = $this->_mailHide->getHtml(); - } - - public function testGetHtmlWithParamter() { - $mail = 'mail@example.com'; - - $this->_mailHide->setPublicKey($this->_publicKey); - $this->_mailHide->setPrivateKey($this->_privateKey); - - $html = $this->_mailHide->getHtml($mail); - - $this->_checkHtml($html); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/ReCaptcha/ReCaptchaTest.php b/tests/Zend/Service/ReCaptcha/ReCaptchaTest.php deleted file mode 100644 index a4e39349d3297d2966b43dcaa0d55125695afb88..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/ReCaptcha/ReCaptchaTest.php +++ /dev/null @@ -1,288 +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_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** @see Zend_Service_ReCaptcha */ -require_once 'Zend/Service/ReCaptcha.php'; - -/** @see Zend_Http_Client_Adapter_Test */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** @see Zend_Config */ -require_once 'Zend/Config.php'; - -/** - * @category Zend - * @package Zend_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_ReCaptcha_ReCaptchaTest extends PHPUnit_Framework_TestCase -{ - protected $_publicKey = TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY; - protected $_privateKey = TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY; - protected $_reCaptcha = null; - - public function setUp() { - $this->_reCaptcha = new Zend_Service_ReCaptcha(); - } - - public function testSetAndGet() { - /* Set and get IP address */ - $ip = '127.0.0.1'; - $this->_reCaptcha->setIp($ip); - $this->assertSame($ip, $this->_reCaptcha->getIp()); - - /* Set and get public key */ - $this->_reCaptcha->setPublicKey($this->_publicKey); - $this->assertSame($this->_publicKey, $this->_reCaptcha->getPublicKey()); - - /* Set and get private key */ - $this->_reCaptcha->setPrivateKey($this->_privateKey); - $this->assertSame($this->_privateKey, $this->_reCaptcha->getPrivateKey()); - } - - public function testSingleParam() { - $key = 'ssl'; - $value = true; - - $this->_reCaptcha->setParam($key, $value); - $this->assertSame($value, $this->_reCaptcha->getParam($key)); - } - - public function tetsGetNonExistingParam() { - $this->assertNull($this->_reCaptcha->getParam('foobar')); - } - - public function testMultipleParams() { - $params = array( - 'ssl' => true, - 'error' => 'errorMsg', - 'xhtml' => true, - ); - - $this->_reCaptcha->setParams($params); - $_params = $this->_reCaptcha->getParams(); - - $this->assertSame($params['ssl'], $_params['ssl']); - $this->assertSame($params['error'], $_params['error']); - $this->assertSame($params['xhtml'], $_params['xhtml']); - } - - public function testSingleOption() { - $key = 'theme'; - $value = 'black'; - - $this->_reCaptcha->setOption($key, $value); - $this->assertSame($value, $this->_reCaptcha->getOption($key)); - } - - public function tetsGetNonExistingOption() { - $this->assertNull($this->_reCaptcha->getOption('foobar')); - } - - public function testMultipleOptions() { - $options = array( - 'theme' => 'black', - 'lang' => 'no', - ); - - $this->_reCaptcha->setOptions($options); - $_options = $this->_reCaptcha->getOptions(); - - $this->assertSame($options['theme'], $_options['theme']); - $this->assertSame($options['lang'], $_options['lang']); - } - - public function testSetMultipleParamsFromZendConfig() { - $params = array( - 'ssl' => true, - 'error' => 'errorMsg', - 'xhtml' => true, - ); - - $config = new Zend_Config($params); - - $this->_reCaptcha->setParams($config); - $_params = $this->_reCaptcha->getParams(); - - $this->assertSame($params['ssl'], $_params['ssl']); - $this->assertSame($params['error'], $_params['error']); - $this->assertSame($params['xhtml'], $_params['xhtml']); - } - - public function testSetInvalidParams() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - $var = 'string'; - $this->_reCaptcha->setParams($var); - } - - public function testSetMultipleOptionsFromZendConfig() { - $options = array( - 'theme' => 'black', - 'lang' => 'no', - ); - - $config = new Zend_Config($options); - - $this->_reCaptcha->setOptions($config); - $_options = $this->_reCaptcha->getOptions(); - - $this->assertSame($options['theme'], $_options['theme']); - $this->assertSame($options['lang'], $_options['lang']); - } - - public function testSetInvalidOptions() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - $var = 'string'; - $this->_reCaptcha->setOptions($var); - } - - public function testConstructor() { - $params = array( - 'ssl' => true, - 'error' => 'errorMsg', - 'xhtml' => true, - ); - - $options = array( - 'theme' => 'black', - 'lang' => 'no', - ); - - $ip = '127.0.0.1'; - - $reCaptcha = new Zend_Service_ReCaptcha($this->_publicKey, $this->_privateKey, $params, $options, $ip); - - $_params = $reCaptcha->getParams(); - $_options = $reCaptcha->getOptions(); - - $this->assertSame($this->_publicKey, $reCaptcha->getPublicKey()); - $this->assertSame($this->_privateKey, $reCaptcha->getPrivateKey()); - $this->assertSame($params['ssl'], $_params['ssl']); - $this->assertSame($params['error'], $_params['error']); - $this->assertSame($params['xhtml'], $_params['xhtml']); - $this->assertSame($options['theme'], $_options['theme']); - $this->assertSame($options['lang'], $_options['lang']); - $this->assertSame($ip, $reCaptcha->getIp()); - } - - public function testConstructorWithNoIp() { - // Fake the _SERVER value - $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; - - $reCaptcha = new Zend_Service_ReCaptcha(null, null, null, null, null); - - $this->assertSame($_SERVER['REMOTE_ADDR'], $reCaptcha->getIp()); - - unset($_SERVER['REMOTE_ADDR']); - } - - public function testGetHtmlWithNoPublicKey() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - - $html = $this->_reCaptcha->getHtml(); - } - - public function testVerify() { - $this->_reCaptcha->setPublicKey($this->_publicKey); - $this->_reCaptcha->setPrivateKey($this->_privateKey); - $this->_reCaptcha->setIp('127.0.0.1'); - - if (defined('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED') && - constant('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED')) { - - $this->_testVerifyOnline(); - } else { - $this->_testVerifyOffline(); - } - } - - protected function _testVerifyOnline() { - - } - - protected function _testVerifyOffline() { - $adapter = new Zend_Http_Client_Adapter_Test(); - $client = new Zend_Http_Client(null, array( - 'adapter' => $adapter - )); - - Zend_Service_ReCaptcha::setHttpClient($client); - - $resp = $this->_reCaptcha->verify('challengeField', 'responseField'); - - // See if we have a valid object and that the status is false - $this->assertTrue($resp instanceof Zend_Service_ReCaptcha_Response); - $this->assertFalse($resp->getStatus()); - } - - public function testGetHtml() { - $this->_reCaptcha->setPublicKey($this->_publicKey); - $errorMsg = 'errorMsg'; - $this->_reCaptcha->setParam('ssl', true); - $this->_reCaptcha->setParam('xhtml', true); - $this->_reCaptcha->setParam('error', $errorMsg); - - $html = $this->_reCaptcha->getHtml(); - - // See if the options for the captcha exist in the string - $this->assertNotSame(false, strstr($html, 'var RecaptchaOptions = {"theme":"red","lang":"en"};')); - - // See if the js/iframe src is correct - $this->assertNotSame(false, strstr($html, 'src="' . Zend_Service_ReCaptcha::API_SECURE_SERVER . '/challenge?k=' . $this->_publicKey . '&error=' . $errorMsg . '"')); - } - - public function testVerifyWithMissingPrivateKey() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - - $this->_reCaptcha->verify('challenge', 'response'); - } - - public function testVerifyWithMissingIp() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - - $this->_reCaptcha->setPrivateKey($this->_privateKey); - $this->_reCaptcha->verify('challenge', 'response'); - } - - public function testVerifyWithMissingChallengeField() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - - $this->_reCaptcha->setPrivateKey($this->_privateKey); - $this->_reCaptcha->setIp('127.0.0.1'); - $this->_reCaptcha->verify('', 'response'); - } - - public function testVerifyWithMissingResponseField() { - $this->setExpectedException('Zend_Service_ReCaptcha_Exception'); - - $this->_reCaptcha->setPrivateKey($this->_privateKey); - $this->_reCaptcha->setIp('127.0.0.1'); - $this->_reCaptcha->verify('challenge', ''); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/ReCaptcha/ResponseTest.php b/tests/Zend/Service/ReCaptcha/ResponseTest.php deleted file mode 100644 index 5519583e77dffba2be5101b3978fd23203582a3b..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/ReCaptcha/ResponseTest.php +++ /dev/null @@ -1,105 +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_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** @see Zend_Service_ReCaptcha_Response */ -require_once 'Zend/Service/ReCaptcha/Response.php'; - -/** - * @category Zend - * @package Zend_Service_ReCaptcha - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_ReCaptcha_ResponseTest extends PHPUnit_Framework_TestCase -{ - protected $_response = null; - - public function setUp() { - $this->_response = new Zend_Service_ReCaptcha_Response(); - } - - public function testSetAndGet() { - /* Set and get status */ - $status = 'true'; - $this->_response->setStatus($status); - $this->assertSame(true, $this->_response->getStatus()); - - $status = 'false'; - $this->_response->setStatus($status); - $this->assertSame(false, $this->_response->getStatus()); - - /* Set and get the error code */ - $errorCode = 'foobar'; - $this->_response->setErrorCode($errorCode); - $this->assertSame($errorCode, $this->_response->getErrorCode()); - } - - public function testIsValid() { - $this->_response->setStatus('true'); - $this->assertSame(true, $this->_response->isValid()); - } - - public function testIsInvalid() { - $this->_response->setStatus('false'); - $this->assertSame(false, $this->_response->isValid()); - } - - public function testSetFromHttpResponse() { - $status = 'false'; - $errorCode = 'foobar'; - $responseBody = $status . "\n" . $errorCode; - $httpResponse = new Zend_Http_Response(200, array('Content-Type' => 'text/html'), $responseBody); - - $this->_response->setFromHttpResponse($httpResponse); - - $this->assertSame(false, $this->_response->getStatus()); - $this->assertSame($errorCode, $this->_response->getErrorCode()); - } - - public function testConstructor() { - $status = 'true'; - $errorCode = 'ok'; - - $response = new Zend_Service_ReCaptcha_Response($status, $errorCode); - - $this->assertSame(true, $response->getStatus()); - $this->assertSame($errorCode, $response->getErrorCode()); - } - - public function testConstructorWithHttpResponse() { - $status = 'false'; - $errorCode = 'foobar'; - $responseBody = $status . "\n" . $errorCode; - $httpResponse = new Zend_Http_Response(200, array('Content-Type' => 'text/html'), $responseBody); - - $response = new Zend_Service_ReCaptcha_Response(null, null, $httpResponse); - - $this->assertSame(false, $response->getStatus()); - $this->assertSame($errorCode, $response->getErrorCode()); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/SimpyTest.php b/tests/Zend/Service/SimpyTest.php deleted file mode 100644 index 86e87f59301279103f9850eb767926def5e0d41c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/SimpyTest.php +++ /dev/null @@ -1,603 +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_Service_Simpy - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SimpyTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Service_Simpy - */ -require_once 'Zend/Service/Simpy.php'; - - -/** - * @category Zend - * @package Zend_Service_Simpy - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_SimpyTest extends PHPUnit_Framework_TestCase -{ - /** - * Simpy service consumer - * - * @var Zend_Service_Simpy - */ - protected $_simpy; - - /** - * Sample link data - * - * @var array - */ - protected $_link = array( - 'title' => 'Zend Framework', - 'href' => 'http://framework.zend.com', - 'accessType' => 'public', - 'tags' => array('zend', 'framework', 'php'), - 'urlNickname' => 'Zend Framework web site', - 'note' => 'This web site rules!' - ); - - /** - * Sample note data - * - * @var array - */ - protected $_note = array( - 'title' => 'Test Note', - 'tags' => array('test'), - 'description' => 'This is a test note.' - ); - - public function setUp() - { - sleep(5); - - $this->_simpy = new Zend_Service_Simpy('syapizend', 'mgt37ge'); - - /** - * Until Simpy includes time zone support, timestamp values must be - * tested against the time zone in use by Simpy's servers - */ - date_default_timezone_set('America/New_York'); - } - - public function testException() - { - try { - $this->_simpy->deleteNote(null); - $this->fail('Exception not thrown'); - } catch (Zend_Service_Exception $e) { - // success - } - } - - public function testSaveLink() - { - try { - extract($this->_link); - - /** - * Delete the link if it already exists and bypass the exception - * that would be thrown as a result - */ - try { - $this->_simpy->deleteLink($href); - } catch (Zend_Service_Exception $e) { - // ignore exception - } - - /** - * @see Zend_Service_Simpy_Link - */ - require_once 'Zend/Service/Simpy/Link.php'; - - $this->_simpy->saveLink( - $title, - $href, - Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, - $tags, - $urlNickname, - $note - ); - } catch (Zend_Service_Exception $e) { - $this->fail('Could not save link: ' . $e->getMessage()); - } - } - - public function testGetLinks() - { - $linkSet = $this->_simpy->getLinks(); - - $this->assertEquals( - $linkSet->getLength(), - 1, - 'Link set does not have expected size' - ); - - $link = $linkSet->getIterator()->current(); - $date = date('Y-m-d'); - extract($this->_link); - - $this->assertEquals( - $link->getAccessType(), - $accessType, - 'Access type does not match' - ); - - $this->assertEquals( - $link->getUrl(), - $href, - 'URL does not match' - ); - - $this->assertEquals( - substr($link->getModDate(), 0, 10), - $date, - 'Mod date does not match' - ); - - $this->assertEquals( - substr($link->getAddDate(), 0, 10), - $date, - 'Add date does not match' - ); - - $this->assertEquals( - $link->getTitle(), - $title, - 'Title does not match' - ); - - $this->assertEquals( - $link->getNickname(), - $urlNickname, - 'Nickname does not match' - ); - - $this->assertEquals( - $link->getTags(), - $tags, - 'Tags do not match' - ); - - $this->assertEquals( - $link->getNote(), - $note, - 'Note does not match' - ); - } - - public function testLinkQuery() - { - $date = date('Y-m-d'); - - /** - * @see Zend_Service_Simpy_LinkQuery - */ - require_once 'Zend/Service/Simpy/LinkQuery.php'; - $linkQuery = new Zend_Service_Simpy_LinkQuery; - $linkQuery->setQueryString($this->_link['title']); - $linkQuery->setBeforeDate($date); - - $this->assertNull( - $linkQuery->getDate(), - 'Date has been initialized' - ); - - $linkQuery->setAfterDate($date); - - $this->assertNull( - $linkQuery->getDate(), - 'Date has been initialized' - ); - - $linkQuery->setDate($date); - - $this->assertNull( - $linkQuery->getBeforeDate(), - 'Before date has retained its value' - ); - - $this->assertNull( - $linkQuery->getAfterDate(), - 'After date has retained its value' - ); - - $linkQuery->setLimit(1); - - $this->assertEquals( - $linkQuery->getLimit(), - 1, - 'Limit was not set' - ); - - $linkQuery->setLimit(array()); - - $this->assertNull( - $linkQuery->getLimit(), - 'Invalid limit value was accepted' - ); - - $linkSet = $this->_simpy->getLinks($linkQuery); - - $this->assertEquals( - $linkSet->getLength(), - 1, - 'Link set does not have the expected size' - ); - } - - public function testGetTags() - { - $tagSet = $this->_simpy->getTags(); - - $this->assertEquals( - $tagSet->getLength(), - count($this->_link['tags']), - 'Tag set does not have the expected size' - ); - - foreach ($tagSet as $tag) { - $this->assertContains( - $tag->getTag(), - $this->_link['tags'], - 'Tag ' . $tag->getTag() . ' does not exist' - ); - - $this->assertEquals( - $tag->getCount(), - 1, - 'Tag count does not match' - ); - } - } - - public function testRenameTag() - { - $fromTag = 'framework'; - $toTag = 'frameworks'; - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $fromTag, - $tagsArray, - 'Source tag was not found' - ); - - $this->assertNotContains( - $toTag, - $tagsArray, - 'Destination tag already exists' - ); - - $this->_simpy->renameTag($fromTag, $toTag); - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $toTag, - $tagsArray, - 'Destination tag was not found' - ); - } - - public function testSplitTag() - { - $fromTag = 'frameworks'; - $toTag1 = 'framework'; - $toTag2 = 'frameworks'; - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $fromTag, - $tagsArray, - 'Source tag was not found' - ); - - $this->_simpy->splitTag($fromTag, $toTag1, $toTag2); - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $toTag1, - $tagsArray, - 'First destination tag was not found' - ); - - $this->assertContains( - $toTag2, - $tagsArray, - 'Second destination tag was not found' - ); - } - - public function testMergeTags() - { - $fromTag1 = 'framework'; - $fromTag2 = 'frameworks'; - $toTag = 'framework'; - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $fromTag1, - $tagsArray, - 'First source tag was not found' - ); - - $this->assertContains( - $fromTag2, - $tagsArray, - 'Second source tag was not found' - ); - - $this->_simpy->mergeTags($fromTag1, $fromTag2, $toTag); - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $toTag, - $tagsArray, - 'Destination tag was not found' - ); - } - - public function testRemoveTag() - { - $tag = 'zend'; - - $tagsArray = $this->_getTagsArray(); - - $this->assertContains( - $tag, - $tagsArray, - 'Tag to remove was not found' - ); - - $this->_simpy->removeTag($tag); - - $tagsArray = $this->_getTagsArray(); - - $this->assertNotContains( - $tag, - $tagsArray, - 'Tag was not removed' - ); - } - - public function testDeleteLink() - { - $this->_simpy->deleteLink($this->_link['href']); - - $linkSet = $this->_simpy->getLinks(); - - $this->assertEquals( - $linkSet->getLength(), - 0, - 'Link was not deleted' - ); - } - - public function testSaveNote() - { - try { - extract($this->_note); - - $this->_simpy->saveNote( - $title, - $tags, - $description - ); - } catch (Zend_Service_Exception $e) { - $this->fail('Could not save note: ' . $e->getMessage()); - } - } - - public function testGetNotes() - { - $date = date('Y-m-d'); - $noteSet = $this->_simpy->getNotes(); - - $this->assertEquals( - $noteSet->getLength(), - 1, - 'Note set does not have the expected size' - ); - - $note = $noteSet->getIterator()->current(); - extract($this->_note); - - $this->assertEquals( - $note->getAccessType(), - 'private', - 'Access type does not match' - ); - - $this->assertEquals( - $note->getUri(), - 'http://www.simpy.com/simpy/NoteDetails.do?noteId=' . $note->getId(), - 'URI does not match' - ); - - $this->assertEquals( - $note->getTitle(), - $title, - 'Title does not match' - ); - - $this->assertEquals( - $note->getTags(), - $tags, - 'Tags do not match' - ); - - $this->assertEquals( - $note->getDescription(), - $description, - 'Description does not match' - ); - - $this->assertEquals( - $note->getAddDate(), - $date, - 'Add date does not match' - ); - - $this->assertEquals( - $note->getModDate(), - $date, - 'Mod date does not match' - ); - } - - public function testDeleteNote() - { - $noteSet = $this->_simpy->getNotes(); - $noteId = $noteSet->getIterator()->current()->getId(); - $this->_simpy->deleteNote($noteId); - $noteSet = $this->_simpy->getNotes(); - foreach ($noteSet as $note) { - $this->assertNotEquals( - $note->getId(), - $noteId, - 'Note was not deleted' - ); - } - } - - public function testGetWatchlists() - { - $watchlistSet = $this->_simpy->getWatchlists(); - $watchlist = $watchlistSet->getIterator()->current(); - - $this->assertEquals( - $watchlistSet->getLength(), - 1, - 'Watchlist set does not have the expected size' - ); - - $this->assertNotNull( - $watchlist, - 'Watchlist is invalid' - ); - } - - public function testGetWatchlist() - { - $watchlist = $this->_simpy->getWatchlist('1331'); - - $this->assertEquals( - $watchlist->getId(), - '1331', - 'ID does not match' - ); - - $this->assertEquals( - $watchlist->getName(), - 'Test Watchlist', - 'Name does not match' - ); - - $this->assertEquals( - $watchlist->getDescription(), - 'This is a watchlist for testing purposes. Please do not remove it.', - 'Description does not match' - ); - - $this->assertEquals( - $watchlist->getAddDate(), - 'Fri Dec 08 21:40:56 EST 2006', - 'Add date does not match' - ); - - $this->assertEquals( - $watchlist->getNewLinks(), - 0, - 'New link count does not match' - ); - - $this->assertEquals( - $watchlist->getUsers(), - array('otis'), - 'User list does not match' - ); - } - - public function testWatchlistFilters() - { - $filterSet = $this->_simpy->getWatchlist('1331')->getFilters(); - - $this->assertEquals( - $filterSet->getLength(), - 1, - 'Filter set does not have the expected size' - ); - - $filter = $filterSet->getIterator()->current(); - - $this->assertEquals( - $filter->getName(), - 'Test Filter', - 'Name does not match' - ); - - $this->assertEquals( - $filter->getQuery(), - 'zend', - 'Query does not match' - ); - } - - protected function _getTagsArray() - { - $tagSet = $this->_simpy->getTags(); - $tagArray = array(); - - foreach ($tagSet as $tag) { - $tagArray[] = $tag->getTag(); - } - - return $tagArray; - } -} - - -class Zend_Service_SimpyTest_Skip extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped('Zend_Service_Simpy tests not enabled in TestConfiguration.php'); - } - - public function testNothing() - { - } -} \ No newline at end of file diff --git a/tests/Zend/Service/SlideShare/_files/demo.ppt b/tests/Zend/Service/SlideShare/_files/demo.ppt deleted file mode 100644 index f7692a1de7833e327a6d6bbab830e63531b3c317..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Service/SlideShare/_files/demo.ppt and /dev/null differ diff --git a/tests/Zend/Service/SlideShareTest.php b/tests/Zend/Service/SlideShareTest.php deleted file mode 100644 index 3f04a96e2cf1795ffb9bb6fe7f3a69776d9ebe34..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/SlideShareTest.php +++ /dev/null @@ -1,229 +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_Service_SlideShare - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SlideShareTest.php 9094 2008-03-30 18:36:55Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Service_SlideShare - */ -require_once 'Zend/Service/SlideShare.php'; - - -/** - * @category Zend - * @package Zend_Service_SlideShare - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_SlideShareTest extends PHPUnit_Framework_TestCase -{ - /** - * The Slide share object instance - * - * @var Zend_Service_SlideShare - */ - protected static $_ss; - - /** - * Enter description here... - * - * @return Zend_Service_SlideShare - */ - protected function _getSSObject() - { - $ss = new Zend_Service_SlideShare(TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY, - TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET, - TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME, - TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD, - TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID); - - $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 0, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__)."/SlideShare/_files")); - $ss->setCacheObject($cache); - return $ss; - } - - public function setUp() - { - - if(!defined("TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY") || - !defined("TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET") || - !defined("TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME") || - !defined("TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD") || - (TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY == "") || - (TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET == "") || - (TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME == "") || - (TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD == "")) { - - $this->markTestSkipped("You must configure an account for slideshare to run these tests"); - } - } - - - public function testGetSlideShow() - { - - if(!defined("TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID") || - (TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID <= 0)) { - $this->markTestSkipped("You must provide a Slideshow ID to retrieve to perform this test"); - } - - $ss = $this->_getSSObject(); - try { - $result = $ss->getSlideShow(TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID); - } catch(Exception $e) { - $this->fail("Exception Caught retrieving Slideshow"); - } - - $this->assertTrue($result instanceof Zend_Service_SlideShare_SlideShow); - - } - - public function testGetSlideShowByTag() - { - - $ss = $this->_getSSObject(); - - try { - $results = $ss->getSlideShowsByTag('zend', 0, 1); - } catch(Exception $e) { - $this->fail("Exception Caught retrieving Slideshow List (tag)"); - } - - $this->assertTrue(is_array($results)); - $this->assertTrue(count($results) == 1); - $this->assertTrue($results[0] instanceof Zend_Service_SlideShare_SlideShow); - - } - - public function testGetSlideShowByTags() - { - - $ss = $this->_getSSObject(); - - try { - $results = $ss->getSlideShowsByTag(array('zend', 'php'), 0, 1); - } catch(Exception $e) { - $this->fail("Exception Caught retrieving Slideshow List (tag)"); - } - - $this->assertTrue(is_array($results)); - - if(!empty($results)) { - $this->assertTrue(count($results) == 1); - $this->assertTrue($results[0] instanceof Zend_Service_SlideShare_SlideShow); - } - } - - public function testGetSlideShowByUsername() - { - - $ss = $this->_getSSObject(); - - try { - $results = $ss->getSlideShowsByUsername(TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME, 0, 1); - } catch(Exception $e) { - $this->fail("Exception Caught retrieving Slideshow List (tag)"); - } - - $this->assertTrue(is_array($results)); - $this->assertTrue(count($results) == 1); - $this->assertTrue($results[0] instanceof Zend_Service_SlideShare_SlideShow); - - } - - public function testUploadSlideShow() - { - $ss = $this->_getSSObject(); - - $title = "Unit Test for ZF SlideShare Component"; - $ppt_file = dirname(__FILE__)."/SlideShare/_files/demo.ppt"; - - $show = new Zend_Service_SlideShare_SlideShow(); - $show->setFilename($ppt_file); - $show->setDescription("Unit Test"); - $show->setTitle($title); - $show->setTags(array('unittest')); - $show->setID(0); - - try { - $result = $ss->uploadSlideShow($show, false); - } catch(Exception $e) { - - if($e->getCode() == Zend_Service_SlideShare::SERVICE_ERROR_NOT_SOURCEOBJ) { - // We ignore this exception, the web service sometimes throws this - // error code because it seems to be buggy. Unfortunately it seems - // to be sparatic so we can't code around it and have to call this - // test a success - return; - } else { - $this->fail("Exception Caught uploading slideshow"); - } - } - - $this->assertTrue($result instanceof Zend_Service_SlideShare_SlideShow); - $this->assertTrue($result->getId() > 0); - $this->assertTrue($result->getTitle() === $title); - - } - - public function testSlideShowObj() - { - $ss = new Zend_Service_SlideShare_SlideShow(); - - $ss->setDescription("Foo"); - $ss->setEmbedCode("Bar"); - $ss->setFilename("Baz"); - $ss->setId(123); - $ss->setLocation("Somewhere"); - $ss->setNumViews(4432); - $ss->setPermaLink("nowhere"); - $ss->setStatus(124); - $ss->setStatusDescription("Boo"); - $ss->setTags(array('bar', 'baz')); - $ss->addTag('fon'); - $ss->setThumbnailUrl('asdf'); - $ss->setTitle('title'); - $ss->setTranscript('none'); - - $this->assertEquals($ss->getDescription(), "Foo"); - $this->assertEquals($ss->getEmbedCode(), "Bar"); - $this->assertEquals($ss->getFilename(), "Baz"); - $this->assertEquals($ss->getId(), 123); - $this->assertEquals($ss->getLocation(), "Somewhere"); - $this->assertEquals($ss->getNumViews(), 4432); - $this->assertEquals($ss->getPermaLink(), "nowhere"); - $this->assertEquals($ss->getStatus(), 124); - $this->assertEquals($ss->getStatusDescription(), "Boo"); - $this->assertEquals($ss->getTags(), array('bar', 'baz', 'fon')); - $this->assertEquals($ss->getThumbnailUrl(), "asdf"); - $this->assertEquals($ss->getTitle(), "title"); - $this->assertEquals($ss->getTranscript(), "none"); - - } -} diff --git a/tests/Zend/Service/StrikeIron/AllTests.php b/tests/Zend/Service/StrikeIron/AllTests.php deleted file mode 100644 index 6f3f95f8720a80a190fdac3eb26343915ba024c8..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/AllTests.php +++ /dev/null @@ -1,115 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_StrikeIron_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_StrikeIron_StrikeIronTest - */ -require_once 'Zend/Service/StrikeIron/StrikeIronTest.php'; - -/** - * @see Zend_Service_StrikeIron_BaseTest - */ -require_once 'Zend/Service/StrikeIron/BaseTest.php'; - -/** - * @see Zend_Service_StrikeIron_DecoratorTest - */ -require_once 'Zend/Service/StrikeIron/DecoratorTest.php'; - -/** - * @see Zend_Service_StrikeIron_ExceptionTest - */ -require_once 'Zend/Service/StrikeIron/ExceptionTest.php'; - -/** - * @see Zend_Service_StrikeIron_SalesUseTaxBasicTest - */ -require_once 'Zend/Service/StrikeIron/SalesUseTaxBasicTest.php'; - -/** - * @see Zend_Service_StrikeIron_USAddressVerificationBasicTest - */ -require_once 'Zend/Service/StrikeIron/USAddressVerificationTest.php'; - -/** - * @see Zend_Service_StrikeIron_ZipCodeInfoTest.php - */ -require_once 'Zend/Service/StrikeIron/ZipCodeInfoTest.php'; - -/** - * @see Zend_Service_StrikeIron_NoSoapTest.php - */ -require_once 'Zend/Service/StrikeIron/NoSoapTest.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_StrikeIron'); - - $suite->addTestSuite('Zend_Service_StrikeIron_NoSoapTest'); - - if (!extension_loaded('soap')) { - return $suite; - } - - $suite->addTestSuite('Zend_Service_StrikeIron_StrikeIronTest'); - $suite->addTestSuite('Zend_Service_StrikeIron_DecoratorTest'); - $suite->addTestSuite('Zend_Service_StrikeIron_ExceptionTest'); - $suite->addTestSuite('Zend_Service_StrikeIron_BaseTest'); - $suite->addTestSuite('Zend_Service_StrikeIron_SalesUseTaxBasicTest'); - $suite->addTestSuite('Zend_Service_StrikeIron_USAddressVerificationTest'); - $suite->addTestSuite('Zend_Service_StrikeIron_ZipCodeInfoTest'); - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_StrikeIron_AllTests::main') { - Zend_Service_StrikeIron_AllTests::main(); -} diff --git a/tests/Zend/Service/StrikeIron/BaseTest.php b/tests/Zend/Service/StrikeIron/BaseTest.php deleted file mode 100644 index b34c8dbccef408b4c6271de38f74218f3a69bba8..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/BaseTest.php +++ /dev/null @@ -1,301 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BaseTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @ see Zend_Service_StrikeIron_BaseTest - */ -require_once 'Zend/Service/StrikeIron/BaseTest.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_BaseTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->soapClient = new Zend_Service_StrikeIron_BaseTest_MockSoapClient; - $this->base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'username' => 'user', - 'password' => 'pass')); - } - - public function testHasNoPredefinedWsdl() - { - $this->assertSame(null, $this->base->getWsdl()); - } - - public function testSettingWsdl() - { - $wsdl = 'http://example.com/foo'; - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'wsdl' => $wsdl)); - $this->assertEquals($wsdl, $base->getWsdl()); - } - - public function testSoapClientDependencyInjection() - { - $this->assertSame($this->soapClient, $this->base->getSoapClient()); - } - - public function testSoapClientInitializesDefaultSOAPClient() - { - // set soapclient options to non-wsdl mode just to get a - // soapclient instance without hitting the network - $base = new Zend_Service_StrikeIron_Base(array('options' => array('location' => '', - 'uri' => ''))); - $this->assertType('SOAPClient', $base->getSoapClient()); - } - - public function testDefaultSoapHeadersHasTheLicenseInfoHeader() - { - $this->base->foo(); - $headers = $this->soapClient->calls[0]['headers']; - - $this->assertType('array', $headers); - $this->assertEquals(1, count($headers)); - $header = $headers[0]; - - $this->assertType('SoapHeader', $header); - $this->assertEquals('LicenseInfo', $header->name); - $this->assertEquals('user', $header->data['RegisteredUser']['UserID']); - $this->assertEquals('pass', $header->data['RegisteredUser']['Password']); - } - - public function testAddingInvalidSoapHeaderThrows() - { - $invalidHeaders = 'foo'; - try { - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'headers' => $invalidHeaders)); - $this->fail(); - } catch (Zend_Service_StrikeIron_Exception $e) { - $this->assertRegExp('/instance of soapheader/i', $e->getMessage()); - } - } - - public function testAddingInvalidSoapHeaderArrayThrows() - { - $invalidHeaders = array('foo'); - try { - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'headers' => $invalidHeaders)); - $this->fail(); - } catch (Zend_Service_StrikeIron_Exception $e) { - $this->assertRegExp('/instance of soapheader/i', $e->getMessage()); - } - } - - public function testAddingScalarSoapHeaderNotLicenseInfo() - { - $header = new SoapHeader('foo', 'bar'); - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'headers' => $header)); - $base->foo(); - - $headers = $this->soapClient->calls[0]['headers']; - $this->assertEquals(2, count($headers)); - $this->assertEquals($header->name, $headers[0]->name); - $this->assertEquals('LicenseInfo', $headers[1]->name); - } - - public function testAddingScalarSoapHeaderThatOverridesLicenseInfo() - { - $soapHeaders = new SoapHeader('http://ws.strikeiron.com', - 'LicenseInfo', - array('RegisteredUser' => array('UserID' => 'foo', - 'Password' => 'bar'))); - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'headers' => $soapHeaders)); - $base->foo(); - - $headers = $this->soapClient->calls[0]['headers']; - - $this->assertType('array', $headers); - $this->assertEquals(1, count($headers)); - $header = $headers[0]; - - $this->assertType('SoapHeader', $header); - $this->assertEquals('LicenseInfo', $header->name); - $this->assertEquals('foo', $header->data['RegisteredUser']['UserID']); - $this->assertEquals('bar', $header->data['RegisteredUser']['Password']); - } - - public function testAddingArrayOfSoapHeaders() - { - $headers = array(new SoapHeader('foo', 'bar'), - new SoapHeader('baz', 'qux')); - - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'headers' => $headers)); - $base->foo(); - - $headers = $this->soapClient->calls[0]['headers']; - - $this->assertType('array', $headers); - $this->assertEquals(3, count($headers)); // these 2 + default LicenseInfo - } - - public function testMethodInflection() - { - $this->base->foo(); - $this->assertEquals('Foo', $this->soapClient->calls[0]['method']); - } - - public function testMethodResultNotWrappingNonObject() - { - $this->assertEquals(42, $this->base->returnThe42()); - } - - public function testMethodResultWrappingAnyObject() - { - $this->assertType('Zend_Service_StrikeIron_Decorator', - $this->base->returnTheObject()); - } - - public function testMethodResultWrappingAnObjectAndSelectingDefaultResultProperty() - { - $this->assertEquals('unwraped', $this->base->wrapThis()); - } - - public function testMethodExceptionsAreWrapped() - { - try { - $this->base->throwTheException(); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_Service_StrikeIron_Exception', $e); - $this->assertEquals('Exception: foo', $e->getMessage()); - $this->assertEquals(43, $e->getCode()); - } - } - - public function testGettingOutputHeaders() - { - $this->assertSame(array(), $this->base->getLastOutputHeaders()); - $info = $this->base->foo(); - $this->assertEquals(Zend_Service_StrikeIron_BaseTest_MockSoapClient::$outputHeaders, - $this->base->getLastOutputHeaders()); - } - - public function testGettingSubscriptionInfo() - { - $this->assertEquals(0, count($this->soapClient->calls)); - $info = $this->base->getSubscriptionInfo(); - $this->assertEquals(1, count($this->soapClient->calls)); - $this->assertEquals(3, $info->remainingHits); - } - - public function testGettingSubscriptionInfoWithCaching() - { - $this->assertEquals(0, count($this->soapClient->calls)); - $this->base->foo(); - $this->base->getSubscriptionInfo(); - $this->assertEquals(1, count($this->soapClient->calls)); - } - - public function testGettingSubscriptionOverridingCache() - { - $this->assertEquals(0, count($this->soapClient->calls)); - $this->base->getSubscriptionInfo(); - $this->assertEquals(1, count($this->soapClient->calls)); - $this->base->getSubscriptionInfo(true); - $this->assertEquals(2, count($this->soapClient->calls)); - } - - public function testGettingSubscriptionInfoWithDefaultQueryMethod() - { - $this->base->getSubscriptionInfo(); - $this->assertEquals('GetRemainingHits', $this->soapClient->calls[0]['method']); - } - - public function testGettingSubscriptionInfoWithCustomQueryMethod() - { - $method = 'SendSubscriptionInfoHeaderPlease'; - $this->base->getSubscriptionInfo(true, $method); - $this->assertEquals($method, $this->soapClient->calls[0]['method']); - } - - public function testGettingSubscriptionInfoThrowsWhenHeaderNotFound() - { - try { - $this->base->getSubscriptionInfo(true, 'ReturnNoOutputHeaders'); - $this->fail(); - } catch (Zend_Service_StrikeIron_Exception $e) { - $this->assertRegExp('/no subscriptioninfo header/i', $e->getMessage()); - } - } -} - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_BaseTest_MockSoapClient -{ - public static $outputHeaders = array('SubscriptionInfo' => array('RemainingHits' => 3)); - - public $calls = array(); - - public function __soapCall($method, $params, $options, $headers, &$outputHeaders) - { - $outputHeaders = self::$outputHeaders; - - $this->calls[] = array('method' => $method, - 'params' => $params, - 'options' => $options, - 'headers' => $headers); - - if ($method == 'ReturnTheObject') { - // testMethodResultWrappingAnyObject - return new stdclass(); - - } else if ($method == 'WrapThis') { - // testMethodResultWrappingAnObjectAndSelectingDefaultResultProperty - return (object)array('WrapThisResult' => 'unwraped'); - - } else if ($method == 'ThrowTheException') { - // testMethodExceptionsAreWrapped - throw new Exception('foo', 43); - - } else if ($method == 'ReturnNoOutputHeaders') { - // testGettingSubscriptionInfoThrowsWhenHeaderNotFound - $outputHeaders = array(); - - } else { - return 42; - } - } -} \ No newline at end of file diff --git a/tests/Zend/Service/StrikeIron/DecoratorTest.php b/tests/Zend/Service/StrikeIron/DecoratorTest.php deleted file mode 100644 index 6f96240ecaf7adaf4020ee5c634605dbbab772d9..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/DecoratorTest.php +++ /dev/null @@ -1,110 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DecoratorTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron_Decorator - */ -require_once 'Zend/Service/StrikeIron/Decorator.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_DecoratorTest extends PHPUnit_Framework_TestCase -{ - public function testNoNoticesWhenDecoratedObjectIsNotAnObject() - { - $decorator = new Zend_Service_StrikeIron_Decorator(3.1415); - $this->assertSame(null, $decorator->foo); - } - - public function testDecoratorReturnsNullWhenPropertyIsMissing() - { - $object = new stdclass(); - $decorator = new Zend_Service_StrikeIron_Decorator($object); - $this->assertSame(null, $decorator->foo); - } - - public function testDecoratorReturnsPropertyByItsName() - { - $object = (object)array('Foo' => 'bar', - 'Baz' => 'qux'); - $decorator = new Zend_Service_StrikeIron_Decorator($object); - $this->assertEquals('qux', $decorator->Baz); - } - - public function testDecoratorReturnsPropertyByInflectedName() - { - $object = (object)array('Foo' => 'bar', - 'Baz' => 'qux'); - $decorator = new Zend_Service_StrikeIron_Decorator($object); - $this->assertEquals('qux', $decorator->baz); - } - - public function testDecoratorTriesActualPropertyNameBeforeInflecting() - { - $object = (object)array('foo' => 'bar', - 'Foo' => 'qux'); - $decorator = new Zend_Service_StrikeIron_Decorator($object); - $this->assertEquals('bar', $decorator->foo); - } - - public function testDecoratorReturnsAnotherDecoratorWhenValueIsAnObject() - { - $object = (object)array('Foo' => new stdclass); - $decorator = new Zend_Service_StrikeIron_Decorator($object); - $this->assertType(get_class($decorator), $decorator->Foo); - } - - public function testDecoratorProxiesMethodCalls() - { - $decorator = new Zend_Service_StrikeIron_Decorator($this); - $this->assertEquals('bar', $decorator->foo()); - } - - public function foo() - { - return 'bar'; - } - - public function testGettingTheDecoratedObject() - { - $decorator = new Zend_Service_StrikeIron_Decorator($this); - $this->assertSame($this, $decorator->getDecoratedObject()); - } - - public function testGettingDecoratedObjectName() - { - $decorator = new Zend_Service_StrikeIron_Decorator($this, 'foo'); - $this->assertSame('foo', $decorator->getDecoratedObjectName()); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/StrikeIron/ExceptionTest.php b/tests/Zend/Service/StrikeIron/ExceptionTest.php deleted file mode 100644 index a5335ae6011868eae047219b9d0d3416a5dadaf9..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/ExceptionTest.php +++ /dev/null @@ -1,49 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExceptionTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron_Exception - */ -require_once 'Zend/Service/StrikeIron/Exception.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_ExceptionTest extends PHPUnit_Framework_TestCase -{ - public function testInheritsFromZendException() - { - $exception = new Zend_Service_StrikeIron_Exception(); - $this->assertType('Zend_Exception', $exception); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/StrikeIron/NoSoapTest.php b/tests/Zend/Service/StrikeIron/NoSoapTest.php deleted file mode 100644 index 9c5523333b4edd6bd582a4990eed5d39f9e7a2c1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/NoSoapTest.php +++ /dev/null @@ -1,67 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NoSoapTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron_BaseTest - */ -require_once 'Zend/Service/StrikeIron/BaseTest.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_NoSoapTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - $this->soapClient = new Zend_Service_StrikeIron_BaseTest_MockSoapClient; - if (extension_loaded('soap')) { - $this->markTestSkipped('SOAP extension is loaded, so cannot test for exception'); - } - } - - public function testNoSoapException() - { - try { - $base = new Zend_Service_StrikeIron_Base(array('client' => $this->soapClient, - 'username' => 'user', - 'password' => 'pass')); - $this->fail('Expecting exception of type Zend_Service_StrikeIron_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Service_StrikeIron_Exception', $e, - 'Expecting exception of type Zend_Service_StrikeIron_Exception, got '.get_class($e)); - $this->assertEquals('SOAP extension is not enabled', $e->getMessage()); - } - } - -} diff --git a/tests/Zend/Service/StrikeIron/SalesUseTaxBasicTest.php b/tests/Zend/Service/StrikeIron/SalesUseTaxBasicTest.php deleted file mode 100644 index 11358cf4a3a80d7be65f3864c977e0db447813cb..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/SalesUseTaxBasicTest.php +++ /dev/null @@ -1,73 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SalesUseTaxBasicTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron - */ -require_once 'Zend/Service/StrikeIron.php'; - -/** - * @see Zend_Service_StrikeIron_SalesUseTaxBasic - */ -require_once 'Zend/Service/StrikeIron/SalesUseTaxBasic.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_SalesUseTaxBasicTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->soapClient = new stdclass(); - $this->service = new Zend_Service_StrikeIron_SalesUseTaxBasic(array('client' => $this->soapClient)); - } - - public function testInheritsFromBase() - { - $this->assertType('Zend_Service_StrikeIron_Base', $this->service); - } - - public function testWsdl() - { - $wsdl = 'http://ws.strikeiron.com/zf1.StrikeIron/taxdatabasic4?WSDL'; - $this->assertEquals($wsdl, $this->service->getWsdl()); - } - - public function testInstantiationFromFactory() - { - $strikeIron = new Zend_Service_StrikeIron(array('client' => $this->soapClient)); - $client = $strikeIron->getService(array('class' => 'SalesUseTaxBasic')); - - $this->assertType('Zend_Service_StrikeIron_SalesUseTaxBasic', $client); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/StrikeIron/StrikeIronTest.php b/tests/Zend/Service/StrikeIron/StrikeIronTest.php deleted file mode 100644 index d084b63d2c48305487a506ffade22ca72052f763..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/StrikeIronTest.php +++ /dev/null @@ -1,122 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StrikeIronTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron - */ -require_once 'Zend/Service/StrikeIron.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_StrikeIronTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - // stub out SOAPClient instance - $this->soapClient = new stdclass(); - $this->options = array('client' => $this->soapClient); - $this->strikeIron = new Zend_Service_StrikeIron($this->options); - } - - public function testFactoryThrowsOnBadName() - { - try { - $this->strikeIron->getService(array('class' => 'BadServiceNameHere')); - $this->fail(); - } catch (Zend_Service_StrikeIron_Exception $e) { - $this->assertRegExp('/could not be loaded/i', $e->getMessage()); - $this->assertRegExp('/not found/i', $e->getMessage()); - } - } - - public function testFactoryReturnsServiceByStrikeIronClass() - { - $base = $this->strikeIron->getService(array('class' => 'Base')); - $this->assertType('Zend_Service_StrikeIron_Base', $base); - $this->assertSame(null, $base->getWsdl()); - $this->assertSame($this->soapClient, $base->getSoapClient()); - } - - public function testFactoryReturnsServiceAnyUnderscoredClass() - { - $class = 'Zend_Service_StrikeIron_StrikeIronTest_StubbedBase'; - $stub = $this->strikeIron->getService(array('class' => $class)); - $this->assertType($class, $stub); - } - - public function testFactoryReturnsServiceByWsdl() - { - $wsdl = 'http://strikeiron.com/foo'; - $base = $this->strikeIron->getService(array('wsdl' => $wsdl)); - $this->assertEquals($wsdl, $base->getWsdl()); - } - - public function testFactoryPassesOptionsFromConstructor() - { - $class = 'Zend_Service_StrikeIron_StrikeIronTest_StubbedBase'; - $stub = $this->strikeIron->getService(array('class' => $class)); - $this->assertEquals($this->options, $stub->options); - } - - public function testFactoryMergesItsOptionsWithConstructorOptions() - { - $options = array('class' => 'Zend_Service_StrikeIron_StrikeIronTest_StubbedBase', - 'foo' => 'bar'); - - $mergedOptions = array_merge($options, $this->options); - unset($mergedOptions['class']); - - $stub = $this->strikeIron->getService($options); - $this->assertEquals($mergedOptions, $stub->options); - } - -} - - -/** - * Stub for Zend_Service_StrikeIron_Base - * - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_StrikeIronTest_StubbedBase -{ - public function __construct($options) - { - $this->options = $options; - } -} \ No newline at end of file diff --git a/tests/Zend/Service/StrikeIron/USAddressVerificationTest.php b/tests/Zend/Service/StrikeIron/USAddressVerificationTest.php deleted file mode 100644 index a408b1b181a6e70aa2cab979b10d43dcfa190183..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/USAddressVerificationTest.php +++ /dev/null @@ -1,73 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: USAddressVerificationTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron - */ -require_once 'Zend/Service/StrikeIron.php'; - -/** - * @see Zend_Service_StrikeIron_USAddressVerification - */ -require_once 'Zend/Service/StrikeIron/USAddressVerification.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_USAddressVerificationTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->soapClient = new stdclass(); - $this->service = new Zend_Service_StrikeIron_USAddressVerification(array('client' => $this->soapClient)); - } - - public function testInheritsFromBase() - { - $this->assertType('Zend_Service_StrikeIron_Base', $this->service); - } - - public function testHasCorrectWsdl() - { - $wsdl = 'http://ws.strikeiron.com/zf1.StrikeIron/USAddressVerification4_0?WSDL'; - $this->assertEquals($wsdl, $this->service->getWsdl()); - } - - public function testInstantiationFromFactory() - { - $strikeIron = new Zend_Service_StrikeIron(array('client' => $this->soapClient)); - $client = $strikeIron->getService(array('class' => 'USAddressVerification')); - - $this->assertType('Zend_Service_StrikeIron_USAddressVerification', $client); - } -} \ No newline at end of file diff --git a/tests/Zend/Service/StrikeIron/ZipCodeInfoTest.php b/tests/Zend/Service/StrikeIron/ZipCodeInfoTest.php deleted file mode 100644 index 717b70936417e1b7e4eefe98a71bf8d98be0dcc4..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/StrikeIron/ZipCodeInfoTest.php +++ /dev/null @@ -1,74 +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_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ZipCodeInfoTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_StrikeIron - */ -require_once 'Zend/Service/StrikeIron.php'; - -/** - * @see Zend_Service_StrikeIron_ZipCodeInfo - */ -require_once 'Zend/Service/StrikeIron/ZipCodeInfo.php'; - - -/** - * @category Zend - * @package Zend_Service - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_StrikeIron_ZipCodeInfoTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->soapClient = new stdclass(); - $this->service = new Zend_Service_StrikeIron_ZipCodeInfo(array('client' => $this->soapClient)); - } - - public function testInheritsFromBase() - { - $this->assertType('Zend_Service_StrikeIron_Base', $this->service); - } - - public function testHasCorrectWsdl() - { - $wsdl = 'http://sdpws.strikeiron.com/zf1.StrikeIron/sdpZIPCodeInfo?WSDL'; - $this->assertEquals($wsdl, $this->service->getWsdl()); - } - - public function testInstantiationFromFactory() - { - $strikeIron = new Zend_Service_StrikeIron(array('client' => $this->soapClient)); - $client = $strikeIron->getService(array('class' => 'ZipCodeInfo')); - - $this->assertType('Zend_Service_StrikeIron_ZipCodeInfo', $client); - } - -} \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/AllTests.php b/tests/Zend/Service/Technorati/AllTests.php deleted file mode 100644 index 94a9929d740e2e21cf55d7c44c02a8dd3167d12f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/AllTests.php +++ /dev/null @@ -1,102 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Technorati_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - - -require_once 'Zend/Service/Technorati/TechnoratiTest.php'; -require_once 'Zend/Service/Technorati/ResultSetTest.php'; -require_once 'Zend/Service/Technorati/ResultTest.php'; -require_once 'Zend/Service/Technorati/AuthorTest.php'; -require_once 'Zend/Service/Technorati/WeblogTest.php'; -require_once 'Zend/Service/Technorati/BlogInfoResultTest.php'; -require_once 'Zend/Service/Technorati/GetInfoResultTest.php'; -require_once 'Zend/Service/Technorati/KeyInfoResultTest.php'; -require_once 'Zend/Service/Technorati/CosmosResultTest.php'; -require_once 'Zend/Service/Technorati/CosmosResultSetTest.php'; -require_once 'Zend/Service/Technorati/DailyCountsResultTest.php'; -require_once 'Zend/Service/Technorati/DailyCountsResultSetTest.php'; -require_once 'Zend/Service/Technorati/SearchResultTest.php'; -require_once 'Zend/Service/Technorati/SearchResultSetTest.php'; -require_once 'Zend/Service/Technorati/TagResultTest.php'; -require_once 'Zend/Service/Technorati/TagResultSetTest.php'; -require_once 'Zend/Service/Technorati/TagsResultTest.php'; -require_once 'Zend/Service/Technorati/TagsResultSetTest.php'; -require_once 'Zend/Service/Technorati/UtilsTest.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Technorati'); - - $suite->addTestSuite('Zend_Service_Technorati_TechnoratiTest'); - $suite->addTestSuite('Zend_Service_Technorati_ResultSetTest'); - $suite->addTestSuite('Zend_Service_Technorati_ResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_AuthorTest'); - $suite->addTestSuite('Zend_Service_Technorati_WeblogTest'); - $suite->addTestSuite('Zend_Service_Technorati_BlogInfoResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_GetInfoResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_KeyInfoResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_CosmosResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_CosmosResultSetTest'); - $suite->addTestSuite('Zend_Service_Technorati_DailyCountsResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_DailyCountsResultSetTest'); - $suite->addTestSuite('Zend_Service_Technorati_SearchResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_SearchResultSetTest'); - $suite->addTestSuite('Zend_Service_Technorati_TagResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_TagResultSetTest'); - $suite->addTestSuite('Zend_Service_Technorati_TagsResultTest'); - $suite->addTestSuite('Zend_Service_Technorati_TagsResultSetTest'); - $suite->addTestSuite('Zend_Service_Technorati_UtilsTest'); - - return $suite; - } -} - diff --git a/tests/Zend/Service/Technorati/AuthorTest.php b/tests/Zend/Service/Technorati/AuthorTest.php deleted file mode 100644 index 9ffa1bb5dabcc92d53ae3cfda99f2901b7b543f0..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/AuthorTest.php +++ /dev/null @@ -1,137 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AuthorTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_Author - */ -require_once 'Zend/Service/Technorati/Author.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_AuthorTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElement = self::getTestFileElementAsDom('TestAuthor.xml', '//author'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_Author', array($this->domElement)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_Author', 'DOMElement'); - } - - public function testAuthor() - { - $author = new Zend_Service_Technorati_Author($this->domElement); - - $this->assertType('string', $author->getFirstName()); - $this->assertEquals('Cesare', $author->getFirstName()); - - $this->assertType('string', $author->getLastName()); - $this->assertEquals('Lamanna', $author->getLastName()); - - $this->assertType('string', $author->getUsername()); - $this->assertEquals('cesarehtml', $author->getUsername()); - - $this->assertType('string', $author->getDescription()); - $this->assertEquals('This is a description.', $author->getDescription()); - - $this->assertType('string', $author->getFirstName()); - $this->assertEquals('This is a bio.', $author->getBio()); - - $this->assertType('Zend_Uri_Http', $author->getThumbnailPicture()); - $this->assertEquals(Zend_Uri::factory('http://static.technorati.com/progimages/photo.jpg?uid=117217'), $author->getThumbnailPicture()); - } - - public function testSetGet() - { - $author = new Zend_Service_Technorati_Author($this->domElement); - - // check first name - $set = 'first'; - $get = $author->setFirstName($set)->getFirstName(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - - // check last name - $set = 'last'; - $get = $author->setLastName($set)->getLastName(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - - // check username - $set = 'user'; - $get = $author->setUsername($set)->getUsername(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - - // check description - $set = 'desc'; - $get = $author->setUsername($set)->getUsername(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - - // check bio - $set = 'biography'; - $get = $author->setBio($set)->getBio(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - - // check thubmnail picture - - $set = Zend_Uri::factory('http://www.simonecarletti.com/'); - $get = $author->setThumbnailPicture($set)->getThumbnailPicture(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals($set, $get); - - $set = 'http://www.simonecarletti.com/'; - $get = $author->setThumbnailPicture($set)->getThumbnailPicture(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals(Zend_Uri::factory($set), $get); - - $set = 'http:::/foo'; - try { - $author->setThumbnailPicture($set); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid URI", $e->getMessage()); - } - } -} diff --git a/tests/Zend/Service/Technorati/BlogInfoResultTest.php b/tests/Zend/Service/Technorati/BlogInfoResultTest.php deleted file mode 100644 index 183c08120fdb32d13fbb442088405ec7dd972c7c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/BlogInfoResultTest.php +++ /dev/null @@ -1,91 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BlogInfoResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_BlogInfoResult - */ -require_once 'Zend/Service/Technorati/BlogInfoResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_BlogInfoResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestBlogInfoResult.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_BlogInfoResult', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_BlogInfoResult', 'DOMDocument'); - } - - public function testBlogInfoResult() - { - $object = new Zend_Service_Technorati_BlogInfoResult($this->dom); - - // check weblog - $weblog = $object->getWeblog(); - $this->assertType('Zend_Service_Technorati_Weblog', $weblog); - $this->assertEquals('Simone Carletti\'s Blog', $weblog->getName()); - - // check url - $this->assertType('Zend_Uri_Http', $object->getUrl()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com/blog'), $object->getUrl()); - - // check inboundblogs - $this->assertType('integer', $object->getInboundBlogs()); - $this->assertEquals(86, $object->getInboundBlogs()); - - // check inboundlinks - $this->assertType('integer', $object->getInboundLinks()); - $this->assertEquals(114, $object->getInboundLinks()); - } - - public function testBlogInfoResultUrlWithInvalidSchemaEqualsToWeblogUrl() - { - $dom = self::getTestFileContentAsDom('TestBlogInfoResultUrlWithInvalidSchema.xml'); - $object = new Zend_Service_Technorati_BlogInfoResult($dom); - - // check url - $this->assertType('Zend_Uri_Http', $object->getUrl()); - $this->assertEquals($object->getWeblog()->getUrl(), $object->getUrl()); - } -} diff --git a/tests/Zend/Service/Technorati/CosmosResultSetTest.php b/tests/Zend/Service/Technorati/CosmosResultSetTest.php deleted file mode 100644 index 2f35519ac3ee2b0d475c970a223347b9d0f672b3..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/CosmosResultSetTest.php +++ /dev/null @@ -1,169 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CosmosResultSetTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_CosmosResultSet - */ -require_once 'Zend/Service/Technorati/CosmosResultSet.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_CosmosResultSetTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestCosmosResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_CosmosResultSet', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_CosmosResultSet', 'DOMDocument'); - } - - public function testCosmosResultSet() - { - $object = new Zend_Service_Technorati_CosmosResultSet($this->dom); - - // check counts - $this->assertType('integer', $object->totalResults()); - $this->assertEquals(2, $object->totalResults()); - $this->assertType('integer', $object->totalResultsAvailable()); - $this->assertEquals(278, $object->totalResultsAvailable()); - - // check properties - $this->assertType('Zend_Uri_Http', $object->getUrl()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com/blog'), $object->getUrl()); - $this->assertType('integer', $object->getInboundLinks()); - $this->assertEquals(278, $object->getInboundLinks()); - - // check weblog - $this->assertType('Zend_Service_Technorati_Weblog', $object->getWeblog()); - $this->assertEquals('Simone Carletti\'s Blog', $object->getWeblog()->getName()); - } - - public function testCosmosResultSetItemsInstanceOfResult() - { - $this->_testResultSetItemsInstanceOfResult( - 'Zend_Service_Technorati_CosmosResultSet', - array($this->dom), - 'Zend_Service_Technorati_CosmosResult'); - } - - public function testCosmosResultSetSerialization() - { - $this->_testResultSetSerialization(new Zend_Service_Technorati_CosmosResultSet($this->dom)); - } - - public function testCosmosResultSetSiteLink() - { - $dom = self::getTestFileContentAsDom('TestCosmosResultSetSiteLink.xml'); - $object = new Zend_Service_Technorati_CosmosResultSet($dom); - - $this->assertEquals(3, $object->totalResults()); - $this->assertEquals(949, $object->totalResultsAvailable()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com'), $object->getUrl()); - $this->assertEquals(949, $object->getInboundLinks()); - } - - public function testCosmosResultSetSiteWeblog() - { - $dom = self::getTestFileContentAsDom('TestCosmosResultSetSiteWeblog.xml'); - $object = new Zend_Service_Technorati_CosmosResultSet($dom); - - $this->assertEquals(3, $object->totalResults()); - $this->assertEquals(39, $object->totalResultsAvailable()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com'), $object->getUrl()); - $this->assertEquals(39, $object->getInboundBlogs()); - } - - public function testCosmosResultSetSiteWeblogWithMissingInboundblogs() - { - // I can't do nothing to fix this issue in charge of Technorati - // I only have to ensure the class doens't fail and $object->totalResultsAvailable == 0 - - $dom = self::getTestFileContentAsDom('TestCosmosResultSetSiteWeblogWithMissingInboundblogs.xml'); - $object = new Zend_Service_Technorati_CosmosResultSet($dom); - - $this->assertEquals(3, $object->totalResults()); - $this->assertEquals(0, $object->totalResultsAvailable()); - $this->assertEquals(null, $object->getInboundBlogs()); - } - - public function testCosmosResultSetSiteUrlWithInvalidSchema() - { - // FIXME - // Technorati allows 'url' parameter to be specified with or without www and/or schema. - // Technorati interface works well but returned responses may include invalid URIs. - // I have 2 possibility to fix the following issue: - // 1. using a default http schema when URL has an invalid one - // 2. force developers to provide a valid schema with 'url' parameter - // The second options is the best one because not only <url> - // but other tags are affected by this issue if you don't provide a valid schema - - // $dom = self::getTestFileContentAsDom('TestCosmosResultSetSiteUrlWithInvalidSchema.xml'); - // $object = new Zend_Service_Technorati_CosmosResultSet($dom); - - // $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com'), $object->getUrl()); - } - - public function testCosmosResultSetBlogLink() - { - $dom = self::getTestFileContentAsDom('TestCosmosResultSetBlogLink.xml'); - $object = new Zend_Service_Technorati_CosmosResultSet($dom); - - $this->assertEquals(20, $object->totalResults()); - $this->assertEquals(298, $object->totalResultsAvailable()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com/blog'), $object->getUrl()); - $this->assertEquals(298, $object->getInboundLinks()); - $this->assertEquals('Simone Carletti\'s Blog', $object->getWeblog()->getName()); - } - - public function testCosmosResultSetBlogWeblog() - { - $dom = self::getTestFileContentAsDom('TestCosmosResultSetBlogWeblog.xml'); - $object = new Zend_Service_Technorati_CosmosResultSet($dom); - - $this->assertEquals(20, $object->totalResults()); - $this->assertEquals(85, $object->totalResultsAvailable()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com/blog'), $object->getUrl()); - $this->assertEquals(85, $object->getInboundBlogs()); - $this->assertEquals('Simone Carletti\'s Blog', $object->getWeblog()->getName()); - } -} diff --git a/tests/Zend/Service/Technorati/CosmosResultTest.php b/tests/Zend/Service/Technorati/CosmosResultTest.php deleted file mode 100644 index 85f4c512589003508cf4d64f53b7b221b118cf83..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/CosmosResultTest.php +++ /dev/null @@ -1,128 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CosmosResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_CosmosResult - */ -require_once 'Zend/Service/Technorati/CosmosResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_CosmosResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElements = self::getTestFileElementsAsDom('TestCosmosResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_CosmosResult', array($this->domElements->item(0))); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_CosmosResult', 'DOMElement'); - } - - public function testCosmosResultSerialization() - { - $this->_testResultSerialization(new Zend_Service_Technorati_CosmosResult($this->domElements->item(0))); - } - - public function testCosmosResultSiteLink() - { - $domElements = self::getTestFileElementsAsDom('TestCosmosResultSetSiteLink.xml'); - $object = new Zend_Service_Technorati_CosmosResult($domElements->item(0)); - - $this->assertType('Zend_Service_Technorati_Weblog', $object->getWeblog()); - $this->assertContains('Gioxx', $object->getWeblog()->getName()); - - $this->assertType('Zend_Uri_Http', $object->getNearestPermalink()); - $this->assertEquals(Zend_Uri::factory('http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/'), $object->getNearestPermalink()); - - $this->assertType('string', $object->getExcerpt()); - $this->assertContains('Ho intenzione di prendere il modello bianco', $object->getExcerpt()); - - $this->assertType('Zend_Date', $object->getLinkCreated()); - $this->assertEquals(new Zend_Date('2007-11-11 20:07:11 GMT'), $object->getLinkCreated()); - - $this->assertType('Zend_Uri_Http', $object->getLinkUrl()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php'), $object->getLinkUrl()); - - // test an other element to prevent cached values - $object = new Zend_Service_Technorati_CosmosResult($domElements->item(1)); - $this->assertContains('Progetto-Seo', $object->getWeblog()->getName()); - $this->assertEquals(Zend_Uri::factory('http://www.progetto-seo.com/motori-di-ricerca/links-interni'), $object->getNearestPermalink()); - $this->assertContains('soprattutto Google', $object->getExcerpt()); - $this->assertEquals(new Zend_Date('2007-11-10 08:57:22 GMT'), $object->getLinkCreated()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php'), $object->getLinkUrl()); - } - - public function testCosmosResultSiteLinkNearestPermalinkIsNull() - { - $domElements = self::getTestFileElementsAsDom('TestCosmosResultSetSiteLink.xml'); - $object = new Zend_Service_Technorati_CosmosResult($domElements->item(2)); - $this->assertContains('Controrete', $object->getWeblog()->getName()); - $this->assertNull($object->getNearestPermalink()); - } - - public function testCosmosResultSiteWeblog() - { - $domElements = self::getTestFileElementsAsDom('TestCosmosResultSetSiteWeblog.xml'); - $object = new Zend_Service_Technorati_CosmosResult($domElements->item(0)); - - $this->assertType('Zend_Service_Technorati_Weblog', $object->getWeblog()); - $this->assertContains('Simone Carletti', $object->getWeblog()->getName()); - - $this->assertType('Zend_Uri_Http', $object->getLinkUrl()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com'), $object->getLinkUrl()); - - // test an other element to prevent cached values - $object = new Zend_Service_Technorati_CosmosResult($domElements->item(1)); - $this->assertContains('Gioxx', $object->getWeblog()->getName()); - $this->assertEquals(Zend_Uri::factory('http://www.simonecarletti.com'), $object->getLinkUrl()); - } - - public function testCosmosResultBlogLink() - { - // same as testSearchResultSiteLink - } - - public function testCosmosResultBlogWeblog() - { - // same as testSearchResultSiteWeblog - } -} diff --git a/tests/Zend/Service/Technorati/DailyCountsResultSetTest.php b/tests/Zend/Service/Technorati/DailyCountsResultSetTest.php deleted file mode 100644 index 2a365dff459cd94a6758ea303bd38bc693299058..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/DailyCountsResultSetTest.php +++ /dev/null @@ -1,87 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DailyCountsResultSetTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_DailyCountsResultSet - */ -require_once 'Zend/Service/Technorati/DailyCountsResultSet.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_DailyCountsResultSetTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestDailyCountsResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_DailyCountsResultSet', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_DailyCountsResultSet', 'DOMDocument'); - } - - public function testDailyCountsResultSet() - { - $object = new Zend_Service_Technorati_DailyCountsResultSet($this->dom); - - // check counts - $this->assertType('integer', $object->totalResults()); - $this->assertEquals(5, $object->totalResults()); - $this->assertType('integer', $object->totalResultsAvailable()); - $this->assertEquals(5, $object->totalResultsAvailable()); - - // check properties - $this->assertType('Zend_Uri_Http', $object->getSearchUrl()); - $this->assertEquals(Zend_Uri::factory('http://technorati.com/search/google'), $object->getSearchUrl()); - } - - public function testDailyCountsResultSetItemsInstanceOfResult() - { - $this->_testResultSetItemsInstanceOfResult( - 'Zend_Service_Technorati_DailyCountsResultSet', - array($this->dom), - 'Zend_Service_Technorati_DailyCountsResult'); - } - - public function testDailyCountsResultSetSerialization() - { - $this->_testResultSetSerialization(new Zend_Service_Technorati_DailyCountsResultSet($this->dom)); - } -} diff --git a/tests/Zend/Service/Technorati/DailyCountsResultTest.php b/tests/Zend/Service/Technorati/DailyCountsResultTest.php deleted file mode 100644 index f566a2e8bf2ef11d8f316c4cd1aaf4d975f98d66..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/DailyCountsResultTest.php +++ /dev/null @@ -1,75 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DailyCountsResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_DailyCountsResult - */ -require_once 'Zend/Service/Technorati/DailyCountsResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_DailyCountsResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElements = self::getTestFileElementsAsDom('TestDailyCountsResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_CosmosResult', array($this->domElements->item(0))); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_DailyCountsResult', 'DOMElement'); - } - - public function testDailyCountsResult() - { - $object = new Zend_Service_Technorati_DailyCountsResult($this->domElements->item(1)); - - // check properties - $this->assertType('Zend_Date', $object->getDate()); - $this->assertEquals(new Zend_Date(strtotime('2007-11-13')), $object->getDate()); - $this->assertType('integer', $object->getCount()); - $this->assertEquals(54414, $object->getCount()); - } - - public function testDailyCountsResultSerialization() - { - $this->_testResultSerialization(new Zend_Service_Technorati_DailyCountsResult($this->domElements->item(0))); - } -} diff --git a/tests/Zend/Service/Technorati/GetInfoResultTest.php b/tests/Zend/Service/Technorati/GetInfoResultTest.php deleted file mode 100644 index abeb720a3768002efef8199c7d84df466b414dc8..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/GetInfoResultTest.php +++ /dev/null @@ -1,75 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: GetInfoResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_GetInfoResult - */ -require_once 'Zend/Service/Technorati/GetInfoResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_GetInfoResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestGetInfoResult.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_GetInfoResult', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_GetInfoResult', 'DOMDocument'); - } - - public function testGetInfoResult() - { - $object = new Zend_Service_Technorati_GetInfoResult($this->dom); - - // check author - $author = $object->getAuthor(); - $this->assertType('Zend_Service_Technorati_Author', $author); - $this->assertEquals('weppos', $author->getUsername()); - - // check weblogs - $weblogs = $object->getWeblogs(); - $this->assertType('array', $weblogs); - $this->assertEquals(2, count($weblogs)); - $this->assertType('Zend_Service_Technorati_Weblog', $weblogs[0]); - } -} diff --git a/tests/Zend/Service/Technorati/KeyInfoResultTest.php b/tests/Zend/Service/Technorati/KeyInfoResultTest.php deleted file mode 100644 index 4b162f729d09a355d7f6ba3b6789384e0bb11852..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/KeyInfoResultTest.php +++ /dev/null @@ -1,89 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: KeyInfoResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_KeyInfoResult - */ -require_once 'Zend/Service/Technorati/KeyInfoResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_KeyInfoResultTest extends Zend_Service_Technorati_TestCase -{ - const TEST_API_KEY = 'avalidapikey'; - - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestKeyInfoResult.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_KeyInfoResult', array($this->dom, self::TEST_API_KEY)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_KeyInfoResult', 'DOMDocument'); - } - - public function testKeyInfoResult() - { - $object = new Zend_Service_Technorati_KeyInfoResult($this->dom, self::TEST_API_KEY); - - $this->assertType('string', $object->getApiKey()); - $this->assertEquals(self::TEST_API_KEY, $object->getApiKey()); - $this->assertType('integer', $object->getApiQueries()); - $this->assertEquals(27, $object->getApiQueries()); - $this->assertType('integer', $object->getMaxQueries()); - $this->assertEquals(1500, $object->getMaxQueries()); - } - - public function testApiKeyIsNullByDefault() - { - $object = new Zend_Service_Technorati_KeyInfoResult($this->dom); - $this->assertEquals(null, $object->getApiKey()); - } - - public function testSetGet() - { - $object = new Zend_Service_Technorati_KeyInfoResult($this->dom, self::TEST_API_KEY); - - $set = 'anewapikey'; - $get = $object->setApiKey($set)->getApiKey(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - } -} diff --git a/tests/Zend/Service/Technorati/ResultSetTest.php b/tests/Zend/Service/Technorati/ResultSetTest.php deleted file mode 100644 index 0b6604d78752765303f63144c07e92574ff6e54e..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/ResultSetTest.php +++ /dev/null @@ -1,130 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ResultSetTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_ResultSet - */ -require_once 'Zend/Service/Technorati/ResultSet.php'; - -/** - * @see Zend_Service_Technorati_SearchResultSet - */ -require_once 'Zend/Service/Technorati/SearchResultSet.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_ResultSetTest extends Zend_Service_Technorati_TestCase -{ - /** - * Even if Zend_Service_Technorati_ResultSet is an abstract class - * it's useful to check whether it correctly implements - * SeekableIterator interface as requested. - * - * Any *ResultSet class should be a child of ResultSet - * thus it's safe to test basic methods on such child class. - */ - public function setUp() - { - $this->ref = new ReflectionClass('Zend_Service_Technorati_ResultSet'); - $this->dom = self::getTestFileContentAsDom('TestSearchResultSet.xml'); - $this->object = new Zend_Service_Technorati_SearchResultSet($this->dom); - $this->objectRef = new ReflectionObject($this->object); - } - - public function testResultSetIsAbstract() - { - $this->assertTrue($this->ref->isAbstract()); - } - - public function testResultSetImplementsSeekableIteratorInterface() - { - $this->assertTrue($this->ref->isIterateable()); - } - - /** - * Security check - */ - public function testResultSetIsParentOfThisObjectClass() - { - $this->assertTrue($this->objectRef->isSubclassOf($this->ref)); - } - - - public function testResultSetSeek() - { - $this->assertEquals(0, $this->object->key()); - $this->object->seek(2); - $this->assertEquals(2, $this->object->key()); - } - - public function testResultSetSeekThrowsOutOfBoundsExceptionWithInvalidIndex() - { - try { - $this->object->seek(1000); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - } - - public function testResultSetKey() - { - $this->assertEquals(0, $this->object->key()); - $this->object->seek(2); - $this->assertEquals(2, $this->object->key()); - // don't move forward - $this->assertEquals(2, $this->object->key()); - } - - public function testResultSetNext() - { - $this->assertEquals(0, $this->object->key()); - $this->object->next(); - $this->assertEquals(1, $this->object->key()); - } - - public function testResultSetRewind() - { - $this->assertEquals(0, $this->object->key()); - $this->object->seek(2); - $this->assertTrue($this->object->rewind()); - $this->assertEquals(0, $this->object->key()); - } - - public function testResultSetSerialization() - { - $this->_testResultSetSerialization($this->object); - } -} diff --git a/tests/Zend/Service/Technorati/ResultTest.php b/tests/Zend/Service/Technorati/ResultTest.php deleted file mode 100644 index 68396e49c101d462587a7c8945bffaf4e2a19ece..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/ResultTest.php +++ /dev/null @@ -1,79 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_Result - */ -require_once 'Zend/Service/Technorati/Result.php'; - -/** - * @see Zend_Service_Technorati_SearchResult - */ -require_once 'Zend/Service/Technorati/SearchResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_ResultTest extends Zend_Service_Technorati_TestCase -{ - /** - * Any *Result class should be a child of Result - * thus it's safe to test basic methods on such child class. - */ - public function setUp() - { - $this->ref = new ReflectionClass('Zend_Service_Technorati_Result'); - $this->domElements = self::getTestFileElementsAsDom('TestSearchResultSet.xml'); - $this->object = new Zend_Service_Technorati_SearchResult($this->domElements->item(0)); - $this->objectRef = new ReflectionObject($this->object); - } - - public function testResultIsAbstract() - { - $this->assertTrue($this->ref->isAbstract()); - } - - /** - * Security check - */ - public function testResultIsParentOfThisObjectClass() - { - $this->assertTrue($this->objectRef->isSubclassOf($this->ref)); - } - - public function testResultSerialization() - { - $this->_testResultSerialization($this->object); - } -} diff --git a/tests/Zend/Service/Technorati/SearchResultSetTest.php b/tests/Zend/Service/Technorati/SearchResultSetTest.php deleted file mode 100644 index 0f8bb399b36320510b6e70171dcfc9e8b1fbefc8..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/SearchResultSetTest.php +++ /dev/null @@ -1,83 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SearchResultSetTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_SearchResultSet - */ -require_once 'Zend/Service/Technorati/SearchResultSet.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_SearchResultSetTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestSearchResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_SearchResultSet', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_SearchResultSet', 'DOMDocument'); - } - - public function testSearchResultSet() - { - $object = new Zend_Service_Technorati_SearchResultSet($this->dom); - - // check counts - $this->assertType('integer', $object->totalResults()); - $this->assertEquals(3, $object->totalResults()); - $this->assertType('integer', $object->totalResultsAvailable()); - $this->assertEquals(4298362, $object->totalResultsAvailable()); - } - - public function testSearchResultSetItemsInstanceOfResult() - { - $this->_testResultSetItemsInstanceOfResult( - 'Zend_Service_Technorati_SearchResultSet', - array($this->dom), - 'Zend_Service_Technorati_SearchResult'); - } - - public function testSearchResultSetSerialization() - { - $this->_testResultSetSerialization(new Zend_Service_Technorati_SearchResultSet($this->dom)); - } -} diff --git a/tests/Zend/Service/Technorati/SearchResultTest.php b/tests/Zend/Service/Technorati/SearchResultTest.php deleted file mode 100644 index ccccee42ee3210f995bf4e52900ddf4b8f834e4c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/SearchResultTest.php +++ /dev/null @@ -1,90 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SearchResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_SearchResult - */ -require_once 'Zend/Service/Technorati/SearchResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_SearchResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElements = self::getTestFileElementsAsDom('TestSearchResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_SearchResult', array($this->domElements->item(0))); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_SearchResult', 'DOMElement'); - } - - public function testSearchResult() - { - $object = new Zend_Service_Technorati_SearchResult($this->domElements->item(0)); - - // check properties - $this->assertType('string', $object->getTitle()); - $this->assertContains('El SDK de Android', $object->getTitle()); - $this->assertType('string', $object->getExcerpt()); - $this->assertContains('[ Android]', $object->getExcerpt()); - $this->assertType('Zend_Uri_Http', $object->getPermalink()); - $this->assertEquals(Zend_Uri_Http::factory('http://blogs.eurielec.etsit.upm.es/miotroblog/?p=271'), $object->getPermalink()); - $this->assertType('Zend_Date', $object->getCreated()); - $this->assertEquals(new Zend_Date('2007-11-14 22:18:04 GMT'), $object->getCreated()); - - // check weblog - $this->assertType('Zend_Service_Technorati_Weblog', $object->getWeblog()); - $this->assertContains('Mi otro blog', $object->getWeblog()->getName()); - } - - public function testSearchResultSerialization() - { - $this->_testResultSerialization(new Zend_Service_Technorati_SearchResult($this->domElements->item(0))); - } - - public function testSearchResultSpecialEncoding() - { - $object = new Zend_Service_Technorati_SearchResult($this->domElements->item(1)); - - $this->assertContains('質ã®è¶…濃ã„èªè€…ã‚’ã©ã‹ã‚“ã¨5000件集ã‚ã¾ã™', $object->getTitle()); - } -} diff --git a/tests/Zend/Service/Technorati/TagResultSetTest.php b/tests/Zend/Service/Technorati/TagResultSetTest.php deleted file mode 100644 index bcc2a55210ef42c5e0821d9f807f0e82428b3158..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/TagResultSetTest.php +++ /dev/null @@ -1,89 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TagResultSetTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_TagResultSet - */ -require_once 'Zend/Service/Technorati/TagResultSet.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_TagResultSetTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestTagResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_TagResultSet', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_TagResultSet', 'DOMDocument'); - } - - public function testTagResultSet() - { - $object = new Zend_Service_Technorati_TagResultSet($this->dom); - - // check counts - $this->assertType('integer', $object->totalResults()); - $this->assertEquals(3, $object->totalResults()); - $this->assertType('integer', $object->totalResultsAvailable()); - $this->assertEquals(268877, $object->totalResultsAvailable()); - - // check properties - $this->assertType('integer', $object->getPostsMatched()); - $this->assertEquals(268877, $object->getPostsMatched()); - $this->assertType('integer', $object->getBlogsMatched()); - $this->assertEquals(1812, $object->getBlogsMatched()); - } - - public function testTagResultSetItemsInstanceOfResult() - { - $this->_testResultSetItemsInstanceOfResult( - 'Zend_Service_Technorati_TagResultSet', - array($this->dom), - 'Zend_Service_Technorati_TagResult'); - } - - public function testTagResultSetSerialization() - { - $this->_testResultSetSerialization(new Zend_Service_Technorati_TagResultSet($this->dom)); - } -} diff --git a/tests/Zend/Service/Technorati/TagResultTest.php b/tests/Zend/Service/Technorati/TagResultTest.php deleted file mode 100644 index 89de841b33daff95520bff4339366c64fb41a976..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/TagResultTest.php +++ /dev/null @@ -1,85 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TagResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_TagsResult - */ -require_once 'Zend/Service/Technorati/TagResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_TagResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElements = self::getTestFileElementsAsDom('TestTagResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_TagResult', array($this->domElements->item(0))); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_TagResult', 'DOMElement'); - } - - public function testTagResult() - { - $object = new Zend_Service_Technorati_TagResult($this->domElements->item(1)); - - // check properties - $this->assertType('string', $object->getTitle()); - $this->assertContains('Permalink for : VerveEarth', $object->getTitle()); - $this->assertType('string', $object->getExcerpt()); - $this->assertContains('VerveEarth: Locate Your Blog!', $object->getExcerpt()); - $this->assertType('Zend_Uri_Http', $object->getPermalink()); - $this->assertEquals(Zend_Uri::factory('http://scienceroll.com/2007/11/14/verveearth-locate-your-blog/'), $object->getPermalink()); - $this->assertType('Zend_Date', $object->getCreated()); - $this->assertEquals(new Zend_Date('2007-11-14 21:52:11'), $object->getCreated()); - $this->assertType('Zend_Date', $object->getUpdated()); - $this->assertEquals(new Zend_Date('2007-11-14 21:57:59'), $object->getUpdated()); - - // check weblog - $this->assertType('Zend_Service_Technorati_Weblog', $object->getWeblog()); - $this->assertEquals(' ScienceRoll', $object->getWeblog()->getName()); - } - - public function testTagResultSerialization() - { - $this->_testResultSerialization(new Zend_Service_Technorati_TagResult($this->domElements->item(0))); - } -} diff --git a/tests/Zend/Service/Technorati/TagsResultSetTest.php b/tests/Zend/Service/Technorati/TagsResultSetTest.php deleted file mode 100644 index b3992c970f651d6a02a38a0dfdf5678919feb5f6..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/TagsResultSetTest.php +++ /dev/null @@ -1,84 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TagsResultSetTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_TagsResultSet - */ -require_once 'Zend/Service/Technorati/TagsResultSet.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_TagsResultSetTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->dom = self::getTestFileContentAsDom('TestTagsResultSet.xml'); - $this->object = new Zend_Service_Technorati_TagsResultSet($this->dom); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_TagsResultSet', array($this->dom)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_TagsResultSet', 'DOMDocument'); - } - - public function testTagsResultSet() - { - $object = new Zend_Service_Technorati_TagsResultSet($this->dom); - - // check counts - $this->assertType('integer', $object->totalResults()); - $this->assertEquals(3, $object->totalResults()); - $this->assertType('integer', $object->totalResultsAvailable()); - $this->assertEquals(3, $object->totalResultsAvailable()); - } - - public function testTagsResultSetItemsInstanceOfResult() - { - $this->_testResultSetItemsInstanceOfResult( - 'Zend_Service_Technorati_TagsResultSet', - array($this->dom), - 'Zend_Service_Technorati_TagsResult'); - } - - public function testTagsResultSetSerialization() - { - $this->_testResultSetSerialization(new Zend_Service_Technorati_TagsResultSet($this->dom)); - } -} diff --git a/tests/Zend/Service/Technorati/TagsResultTest.php b/tests/Zend/Service/Technorati/TagsResultTest.php deleted file mode 100644 index e4c65ea190f37636de7ae1cadd75bb204546a4f7..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/TagsResultTest.php +++ /dev/null @@ -1,82 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TagsResultTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_TagsResult - */ -require_once 'Zend/Service/Technorati/TagsResult.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_TagsResultTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElements = self::getTestFileElementsAsDom('TestTagsResultSet.xml'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_TagsResult', array($this->domElements->item(0))); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_TagsResult', 'DOMElement'); - } - - public function testTagsResult() - { - $object = new Zend_Service_Technorati_TagsResult($this->domElements->item(2)); - - // check properties - $this->assertType('string', $object->getTag()); - $this->assertEquals('Weblog', $object->getTag()); - $this->assertType('integer', $object->getPosts()); - $this->assertEquals(8336350, $object->getPosts()); - } - - public function testTagsResultSerialization() - { - $this->_testResultSerialization(new Zend_Service_Technorati_TagsResult($this->domElements->item(0))); - } - - public function testTagsResultSpecialEncoding() - { - $object = new Zend_Service_Technorati_TagsResult($this->domElements->item(0)); - $this->assertEquals('練習用', $object->getTag()); - $this->assertEquals(19655999, $object->getPosts()); - } -} diff --git a/tests/Zend/Service/Technorati/TechnoratiTest.php b/tests/Zend/Service/Technorati/TechnoratiTest.php deleted file mode 100644 index 7c878900c61ae780d6208f7e849cf6e56160c96b..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/TechnoratiTest.php +++ /dev/null @@ -1,637 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TechnoratiTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_TechnoratiTest extends Zend_Service_Technorati_TestCase -{ - const TEST_APY_KEY = 'somevalidapikey'; - const TEST_PARAM_COSMOS = 'http://www.simonecarletti.com/blog/'; - const TEST_PARAM_SEARCH = 'google'; - const TEST_PARAM_TAG = 'google'; - const TEST_PARAM_DAILYCOUNT = 'google'; - const TEST_PARAM_GETINFO = 'weppos'; - const TEST_PARAM_BLOGINFO = 'http://www.simonecarletti.com/blog/'; - const TEST_PARAM_BLOGPOSTTAGS = 'http://www.simonecarletti.com/blog/'; - - public function setUp() - { - /** - * @see Zend_Http_Client_Adapter_Test - */ - require_once 'Zend/Http/Client/Adapter/Test.php'; - $adapter = new Zend_Http_Client_Adapter_Test(); - - /** - * @see Zend_Http_Client - */ - require_once 'Zend/Http/Client.php'; - $client = new Zend_Http_Client(Zend_Service_Technorati::API_URI_BASE, array( - 'adapter' => $adapter - )); - - $this->technorati = new Zend_Service_Technorati(self::TEST_APY_KEY); - $this->adapter = $adapter; - $this->technorati->getRestClient()->setHttpClient($client); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati', array(self::TEST_APY_KEY)); - } - - public function testApiKeyMatches() - { - $object = $this->technorati; - $this->assertEquals(self::TEST_APY_KEY, $object->getApiKey()); - } - - public function testSetGetApiKey() - { - $object = $this->technorati; - - $set = 'just a test'; - $get = $object->setApiKey($set)->getApiKey(); - $this->assertEquals($set, $get); - } - - public function testCosmos() - { - $result = $this->_setResponseFromFile('TestCosmosSuccess.xml')->cosmos(self::TEST_PARAM_COSMOS); - - $this->assertType('Zend_Service_Technorati_CosmosResultSet', $result); - $this->assertEquals(2, $result->totalResults()); - $result->seek(0); - $this->assertType('Zend_Service_Technorati_CosmosResult', $result->current()); - // content is validated in Zend_Service_Technorati_CosmosResultSet tests - } - - public function testCosmosThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestCosmosError.xml')->cosmos(self::TEST_PARAM_COSMOS); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid request: url is required", $e->getMessage()); - } - } - - public function testCosmosThrowsExceptionWithInvalidUrl() - { - // url is mandatory --> validated by PHP interpreter - // url must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('cosmos', 'url'); - } - - public function testCosmosThrowsExceptionWithInvalidOption() - { - $options = array( - array('type' => 'foo'), - array('limit' => 'foo'), - array('limit' => 0), - array('limit' => 101), - array('start' => 0), - // 'current' => // cast to int - // 'claim' => // cast to int - // 'highlight' => // cast to int - ); - $this->_testThrowsExceptionWithInvalidOption($options, 'TestCosmosSuccess.xml', 'cosmos', array(self::TEST_PARAM_COSMOS)); - } - - public function testCosmosOption() - { - $options = array( - array('type' => 'link'), - array('type' => 'weblog'), - array('limit' => 1), - array('limit' => 50), - array('limit' => 100), - array('start' => 1), - array('start' => 1000), - array('current' => false), // cast to int - array('current' => 0), // cast to int - array('claim' => false), // cast to int - array('claim' => 0), // cast to int - array('highlight' => false), // cast to int - array('highlight' => 0), // cast to int - ); - $this->_testOption($options, 'TestCosmosSuccess.xml', 'cosmos', array(self::TEST_PARAM_COSMOS)); - } - - public function testSearch() - { - $result = $this->_setResponseFromFile('TestSearchSuccess.xml')->search(self::TEST_PARAM_SEARCH); - - $this->assertType('Zend_Service_Technorati_SearchResultSet', $result); - $this->assertEquals(2, $result->totalResults()); - $result->seek(0); - $this->assertType('Zend_Service_Technorati_SearchResult', $result->current()); - // content is validated in Zend_Service_Technorati_SearchResultSet tests - } - - /** - * @see /_files/MISSING - * - public function testSearchThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestSearchError.xml')->cosmos(self::TEST_PARAM_COSMOS); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid request: url is required", $e->getMessage()); - } - } */ - - public function testSearchThrowsExceptionWithInvalidQuery() - { - // query is mandatory --> validated by PHP interpreter - // query must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('search', 'query'); - } - - public function testSearchThrowsExceptionWithInvalidOption() - { - $options = array( - array('authority' => 'foo'), - array('limit' => 'foo'), - array('limit' => 0), - array('limit' => 101), - array('start' => 0), - // 'claim' => // cast to int - ); - $this->_testThrowsExceptionWithInvalidOption($options, 'TestSearchSuccess.xml', 'search', array(self::TEST_PARAM_SEARCH)); - } - - public function testSearchOption() - { - $options = array( - array('language' => 'en'), // not validated - array('authority' => 'n'), - array('authority' => 'a1'), - array('authority' => 'a4'), - array('authority' => 'a7'), - array('limit' => 1), - array('limit' => 50), - array('limit' => 100), - array('start' => 1), - array('start' => 1000), - array('claim' => false), // cast to int - array('claim' => 0), // cast to int - ); - $this->_testOption($options, 'TestSearchSuccess.xml', 'search', array(self::TEST_PARAM_SEARCH)); - } - - public function testTag() - { - $result = $this->_setResponseFromFile('TestTagSuccess.xml')->tag(self::TEST_PARAM_TAG); - - $this->assertType('Zend_Service_Technorati_TagResultSet', $result); - $this->assertEquals(2, $result->totalResults()); - $result->seek(0); - $this->assertType('Zend_Service_Technorati_TagResult', $result->current()); - // content is validated in Zend_Service_Technorati_TagResultSet tests - } - - public function testTagThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestTagError.xml')->tag(self::TEST_PARAM_TAG); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid request.", $e->getMessage()); - } - } - - public function testTagThrowsExceptionWithInvalidTag() - { - // tag is mandatory --> validated by PHP interpreter - // tag must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('tag', 'tag'); - } - - public function testTagThrowsExceptionWithInvalidOption() - { - $options = array( - array('limit' => 'foo'), - array('limit' => 0), - array('limit' => 101), - array('start' => 0), - // 'excerptsize' => // cast to int - // 'topexcerptsize' => // cast to int - ); - $this->_testThrowsExceptionWithInvalidOption($options, 'TestTagSuccess.xml', 'tag', array(self::TEST_PARAM_TAG)); - } - - public function testTagOption() - { - $options = array( - array('excerptsize' => 150), // cast to int - array('excerptsize' => '150'), // cast to int - array('topexcerptsize' => 150), // cast to int - array('topexcerptsize' => '150'), // cast to int - array('limit' => 1), - array('limit' => 50), - array('limit' => 100), - array('start' => 1), - array('start' => 1000), - ); - $this->_testOption($options, 'TestTagSuccess.xml', 'tag', array(self::TEST_PARAM_TAG)); - } - - public function testDailyCounts() - { - $result = $this->_setResponseFromFile('TestDailyCountsSuccess.xml')->dailyCounts(self::TEST_PARAM_DAILYCOUNT); - - $this->assertType('Zend_Service_Technorati_DailyCountsResultSet', $result); - $this->assertEquals(180, $result->totalResults()); - $result->seek(0); - $this->assertType('Zend_Service_Technorati_DailyCountsResult', $result->current()); - // content is validated in Zend_Service_Technorati_DailyCountsResultSet tests - } - - public function testDailyCountsThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestDailyCountsError.xml')->dailyCounts(self::TEST_PARAM_DAILYCOUNT); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Missing required parameter", $e->getMessage()); - } - } - - public function testDailyCountsThrowsExceptionWithInvalidQuery() - { - // q is mandatory --> validated by PHP interpreter - // q must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('dailyCounts', 'q'); - } - - public function testDailyCountsThrowsExceptionWithInvalidOption() - { - $options = array( - array('days' => 0), - array('days' => '0'), - array('days' => 181), - array('days' => '181'), - ); - $this->_testThrowsExceptionWithInvalidOption($options, 'TestDailyCountsSuccess.xml', 'dailyCounts', array(self::TEST_PARAM_DAILYCOUNT)); - } - - public function testDailyCountsOption() - { - $options = array( - array('days' => 120), // cast to int - array('days' => '120'), // cast to int - array('days' => 180), // cast to int - array('days' => '180'), // cast to int - ); - $this->_testOption($options, 'TestDailyCountsSuccess.xml', 'dailyCounts', array(self::TEST_PARAM_DAILYCOUNT)); - } - - public function testBlogInfo() - { - $result = $this->_setResponseFromFile('TestBlogInfoSuccess.xml')->blogInfo(self::TEST_PARAM_BLOGINFO); - - $this->assertType('Zend_Service_Technorati_BlogInfoResult', $result); - // content is validated in Zend_Service_Technorati_BlogInfoResult tests - } - - public function testBlogInfoThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestBlogInfoError.xml')->blogInfo(self::TEST_PARAM_BLOGINFO); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid request: url is required", $e->getMessage()); - } - } - - public function testBlogInfoThrowsExceptionWithInvalidUrl() - { - // url is mandatory --> validated by PHP interpreter - // url must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('blogInfo', 'url'); - } - - public function testBlogInfoThrowsExceptionWithUrlNotWeblog() - { - // emulate Technorati exception - // when URL is not a recognized weblog - try { - $this->_setResponseFromFile('TestBlogInfoErrorUrlNotWeblog.xml')->blogInfo('www.simonecarletti.com'); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Technorati weblog", $e->getMessage()); - } - } - - public function testBlogPostTags() - { - $result = $this->_setResponseFromFile('TestBlogPostTagsSuccess.xml')->blogPostTags(self::TEST_PARAM_BLOGPOSTTAGS); - - $this->assertType('Zend_Service_Technorati_TagsResultSet', $result); - // content is validated in Zend_Service_Technorati_TagsResultSet tests - } - - public function testBlogPostTagsThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestBlogPostTagsError.xml')->blogPostTags(self::TEST_PARAM_BLOGPOSTTAGS); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid request: url is required", $e->getMessage()); - } - } - - public function testBlogPostTagsThrowsExceptionWithInvalidUrl() - { - // url is mandatory --> validated by PHP interpreter - // url must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('blogPostTags', 'url'); - } - - public function testBlogPostTagsThrowsExceptionWithInvalidOption() - { - $options = array( - array('limit' => 'foo'), - array('limit' => 0), - array('limit' => 101), - array('start' => 0), - ); - $this->_testThrowsExceptionWithInvalidOption($options, 'TestBlogPostTagsSuccess.xml', 'blogPostTags', array(self::TEST_PARAM_BLOGPOSTTAGS)); - } - - public function testBlogPostTagsOption() - { - $options = array( - array('limit' => 1), - array('limit' => 50), - array('limit' => 100), - array('start' => 1), - array('start' => 1000), - ); - $this->_testOption($options, 'TestBlogPostTagsSuccess.xml', 'blogPostTags', array(self::TEST_PARAM_BLOGPOSTTAGS)); - } - - public function testTopTags() - { - $result = $this->_setResponseFromFile('TestTopTagsSuccess.xml')->topTags(); - - $this->assertType('Zend_Service_Technorati_TagsResultSet', $result); - // content is validated in Zend_Service_Technorati_TagsResultSet tests - } - - public function testTopTagsThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestTopTagsError.xml')->topTags(); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid key.", $e->getMessage()); - } - } - - public function testTopTagsThrowsExceptionWithInvalidOption() - { - $options = array( - array('limit' => 'foo'), - array('limit' => 0), - array('limit' => 101), - array('start' => 0), - ); - $this->_testThrowsExceptionWithInvalidOption($options, 'TestTopTagsSuccess.xml', 'topTags'); - } - - public function testTopTagsOption() - { - $options = array( - array('limit' => 1), - array('limit' => 50), - array('limit' => 100), - array('start' => 1), - array('start' => 1000), - ); - $this->_testOption($options, 'TestTopTagsSuccess.xml', 'topTags'); - } - - public function testGetInfo() - { - $result = $this->_setResponseFromFile('TestGetInfoSuccess.xml')->getInfo(self::TEST_PARAM_GETINFO); - - $this->assertType('Zend_Service_Technorati_GetInfoResult', $result); - // content is validated in Zend_Service_Technorati_GetInfoResult tests - } - - public function testGetInfoThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestGetInfoError.xml')->getInfo(self::TEST_PARAM_GETINFO); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Username is a required field.", $e->getMessage()); - } - } - - public function testGetInfoThrowsExceptionWithInvalidUsername() - { - // username is mandatory --> validated by PHP interpreter - // username must not be empty - $this->_testThrowsExceptionWithInvalidMandatoryOption('getInfo', 'username'); - } - - public function testKeyInfo() - { - $result = $this->_setResponseFromFile('TestKeyInfoSuccess.xml')->keyInfo(); - - $this->assertType('Zend_Service_Technorati_KeyInfoResult', $result); - // content is validated in Zend_Service_Technorati_KeyInfoResult tests - } - - public function testKeyInfoThrowsExceptionWithError() - { - try { - $this->_setResponseFromFile('TestKeyInfoError.xml')->keyInfo(); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid key.", $e->getMessage()); - } - } - - public function testAllThrowsExceptionWithInvalidOptionFormat() - { - $invalidFormatOption = array('format' => 'rss'); - // format must be XML - $methods = array('cosmos' => self::TEST_PARAM_COSMOS, - 'search' => self::TEST_PARAM_SEARCH, - 'tag' => self::TEST_PARAM_TAG, - 'dailyCounts' => self::TEST_PARAM_DAILYCOUNT, - 'topTags' => null, - 'blogInfo' => self::TEST_PARAM_BLOGINFO, - 'blogPostTags' => self::TEST_PARAM_BLOGPOSTTAGS, - 'getInfo' => self::TEST_PARAM_GETINFO); - $technorati = $this->technorati; - - foreach ($methods as $method => $param) { - $options = array_merge((array) $param, array($invalidFormatOption)); - try { - call_user_func_array(array($technorati, $method), $options); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("'format'", $e->getMessage()); - } - } - } - - public function testAllThrowsExceptionWithUnknownOption() - { - $invalidOption = array('foo' => 'bar'); - $methods = array('cosmos' => self::TEST_PARAM_COSMOS, - 'search' => self::TEST_PARAM_SEARCH, - 'tag' => self::TEST_PARAM_TAG, - 'dailyCounts' => self::TEST_PARAM_DAILYCOUNT, - 'topTags' => null, - 'blogInfo' => self::TEST_PARAM_BLOGINFO, - 'blogPostTags' => self::TEST_PARAM_BLOGPOSTTAGS, - 'getInfo' => self::TEST_PARAM_GETINFO); - - $technorati = $this->technorati; - foreach ($methods as $method => $param) { - $options = array_merge((array) $param, array($invalidOption)); - try { - call_user_func_array(array($technorati, $method), $options); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("'foo'", $e->getMessage()); - } - } - } - - /** - * Tests whether $callbackMethod method throws an Exception - * with Invalid Url. - * - * @param string $callbackMethod - */ - private function _testThrowsExceptionWithInvalidMandatoryOption($callbackMethod, $name) - { - try { - $this->technorati->$callbackMethod(''); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("'$name'", $e->getMessage()); - } - } - - /** - * Tests whether for each $validOptions a method call is successful. - * - * @param array $validOptions - * @param string $xmlFile - * @param string $callbackMethod - * @param null|array $callbackRequiredOptions - */ - private function _testOption($validOptions, $xmlFile, $callbackMethod, $callbackRequiredOptions = null) - { - $technorati = $this->_setResponseFromFile($xmlFile); - foreach ($validOptions as $pair) { - list($option, $value) = each($pair); - $options = is_array($callbackRequiredOptions) ? - array_merge($callbackRequiredOptions, array($pair)) : - array($pair); - - try { - call_user_func_array(array($technorati, $callbackMethod), $options); - } catch (Zend_Service_Technorati_Exception $e) { - $this->fail("Exception " . $e->getMessage() . " thrown " . - "for option '$option' value '$value'"); - } - } - } - - /** - * Tests whether for each $validOptions a method call is successful. - * - * @param array $invalidOptions - * @param string $xmlFile - * @param string $callbackMethod - * @param null|array $callbackRequiredOptions - */ - private function _testThrowsExceptionWithInvalidOption($invalidOptions, $xmlFile, $callbackMethod, $callbackRequiredOptions = null) - { - $technorati = $this->_setResponseFromFile($xmlFile); - foreach ($invalidOptions as $pair) { - list($option, $value) = each($pair); - $options = is_array($callbackRequiredOptions) ? - array_merge($callbackRequiredOptions, array($pair)) : - array($pair); - - try { - call_user_func_array(array($technorati, $callbackMethod), $options); - $this->fail("Expected Zend_Service_Technorati_Exception not thrown " . - "for option '$option' value '$value'"); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains("'$option'", $e->getMessage()); - } - } - } - - /** - * Loads a response content from a test case file - * and sets the content to current Test Adapter. - * - * Returns current Zend_Service_Technorati instance - * to let developers use the powerful chain call. - * - * Do not execute any file validation. Please use this method carefully. - * - * @params string $file - * @return Zend_Service_Technorati - */ - private function _setResponseFromFile($file) - { - $response = "HTTP/1.0 200 OK\r\n" - . "Date: " . date(DATE_RFC1123) . "\r\n" - . "Server: Apache\r\n" - . "Cache-Control: max-age=60\r\n" - . "Content-Type: text/xml; charset=UTF-8\r\n" - . "X-Powered-By: PHP/5.2.1\r\n" - . "Connection: close\r\n" - . "\r\n" - . file_get_contents(dirname(__FILE__) . '/_files/' . $file) ; - - $this->adapter->setResponse($response); - return $this->technorati; // allow chain call - } -} diff --git a/tests/Zend/Service/Technorati/TestCase.php b/tests/Zend/Service/Technorati/TestCase.php deleted file mode 100644 index 98af1c9421a604b950fb32212ed95202c2c3dcb3..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/TestCase.php +++ /dev/null @@ -1,171 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: TestCase.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Patch for default timezone in PHP >= 5.1.0 - */ -if (!ini_get('date.timezone')) { - date_default_timezone_set(@date_default_timezone_get()); -} - -/** - * @see Zend_Service_Technorati - */ -require_once 'Zend/Service/Technorati.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_TestCase extends PHPUnit_Framework_TestCase -{ - protected function _testConstruct($className, $args) - { - $reflection = new ReflectionClass($className); - try { - $object = $reflection->newInstanceArgs($args); - $this->assertType($className, $object); - } catch (Zend_Service_Technorati_Exception $e) { - $this->fail("Exception " . $e->getMessage() . " thrown"); - } - } - - protected function _testConstructThrowsExceptionWithInvalidDom($className, $match) - { - if (self::skipInvalidArgumentTypeTests()) { - $this->markTestIncomplete('Failure to meet type hint results in fatal error in PHP < 5.2.0'); - return; - } - - $reflection = new ReflectionClass($className); - try { - $object = $reflection->newInstanceArgs(array('foo')); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Exception $e) { - $this->assertContains($match, $e->getMessage()); - } - } - - protected function _testResultSetItemsInstanceOfResult($resultSetClassName, $args, $resultClassName) - { - $reflection = new ReflectionClass($resultSetClassName); - $resultset = $reflection->newInstanceArgs($args); - foreach ($resultset as $result) { - $this->assertType($resultClassName, $result); - } - } - - protected function _testResultSetSerialization($resultSet) - { - $unobject = unserialize(serialize($resultSet)); - $unresult = null; - - $this->assertType(get_class($resultSet), $unobject); - - foreach ($resultSet as $index => $result) { - try { - $unobject->seek($index); - $unresult = $unobject->current(); - } catch(OutOfBoundsException $e) { - $this->fail("Missing result index $index"); - } - $this->assertEquals($result, $unresult); - } - } - - protected function _testResultSerialization($result) - { - /** - * Both Result and ResultSet objects includes variables - * that references special objects such as DomDocuments. - * - * Unlike ResultSet(s), Result instances uses Dom fragments - * only to construct the instance itself, then both Dom and Xpath objects - * are no longer required. - * - * It means serializing a Result is not a painful job. - * We don't need to implement any __wakeup or _sleep function - * because PHP is able to create a perfect serialized snapshot - * of current object status. - * - * Thought this situation makes our life easier, it's not safe - * to assume things will not change in the future. - * Testing each object now against a serialization request - * makes this library more secure in the future! - */ - $unresult = unserialize(serialize($result)); - - $this->assertType(get_class($result), $unresult); - $this->assertEquals($result, $unresult); - } - - public static function getTestFilePath($file) - { - return dirname(__FILE__) . '/_files/' . $file; - } - - public static function getTestFileContentAsDom($file) - { - $dom = new DOMDocument(); - $dom->load(self::getTestFilePath($file)); - return $dom; - } - - public static function getTestFileElementsAsDom($file, $exp = '//item') - { - $dom = self::getTestFileContentAsDom($file); - $xpath = new DOMXPath($dom); - return $xpath->query($exp); - } - - public static function getTestFileElementAsDom($file, $exp = '//item', $item = 0) - { - $dom = self::getTestFileContentAsDom($file); - $xpath = new DOMXPath($dom); - $domElements = $xpath->query($exp); - return $domElements->item($item); - } - - public static function skipInvalidArgumentTypeTests() - { - // PHP < 5.2.0 returns a fatal error - // instead of a catchable Exception (ZF-2334) - return version_compare(phpversion(), "5.2.0", "<"); - } - -} diff --git a/tests/Zend/Service/Technorati/UtilsTest.php b/tests/Zend/Service/Technorati/UtilsTest.php deleted file mode 100644 index 6817bbfa7efb6df8ed7b6f9331a90cd5454fdb8a..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/UtilsTest.php +++ /dev/null @@ -1,101 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: UtilsTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'TestCase.php'; - -/** - * @see Zend_Service_Technorati_Utils - */ -require_once "Zend/Service/Technorati/Utils.php"; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_UtilsTest extends Zend_Service_Technorati_TestCase -{ - /** - * @return void - */ - public function testSetUriHttpInputNullReturnsNull() - { - $this->assertNull(Zend_Service_Technorati_Utils::normalizeUriHttp(null)); - } - - /** - * @return void - */ - public function testSetUriHttpInputInvalidSchemeFtpThrowsException() - { - $scheme = 'ftp'; - $inputInvalidScheme = "$scheme://example.com"; - try { - Zend_Service_Technorati_Utils::normalizeUriHttp($inputInvalidScheme); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains($scheme, $e->getMessage()); - } - } - - /** - * @return void - */ - public function testSetDateInputNullReturnsNull() - { - $this->assertNull(Zend_Service_Technorati_Utils::normalizeDate(null)); - } - - /** - * @return void - */ - public function testSetDateInputDateInstanceReturnsInstance() - { - $date = new Zend_Date('2007-11-11 08:47:26 GMT'); - $result = Zend_Service_Technorati_Utils::normalizeDate($date); - - $this->assertType('Zend_Date', $result); - $this->assertEquals($date, $result); - } - - /** - * @return void - */ - public function testSetDateInputInvalidThrowsException() - { - $inputInvalid = "2007foo"; - try { - Zend_Service_Technorati_Utils::normalizeDate($inputInvalid); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch (Zend_Service_Technorati_Exception $e) { - $this->assertContains($inputInvalid, $e->getMessage()); - } - } -} diff --git a/tests/Zend/Service/Technorati/WeblogTest.php b/tests/Zend/Service/Technorati/WeblogTest.php deleted file mode 100644 index daa49dd8dabad7622febc63988f36af44c480a62..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/WeblogTest.php +++ /dev/null @@ -1,276 +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_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: WeblogTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR .'TestCase.php'; - -/** - * @see Zend_Service_Technorati_Weblog - */ -require_once 'Zend/Service/Technorati/Weblog.php'; - - -/** - * @category Zend - * @package Zend_Service_Technorati - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Technorati_WeblogTest extends Zend_Service_Technorati_TestCase -{ - public function setUp() - { - $this->domElement = self::getTestFileElementAsDom('TestWeblog.xml', '//weblog'); - } - - public function testConstruct() - { - $this->_testConstruct('Zend_Service_Technorati_Weblog', array($this->domElement)); - } - - public function testConstructThrowsExceptionWithInvalidDom() - { - $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_Weblog', 'DOMElement'); - } - - public function testWeblog() - { - $weblog = new Zend_Service_Technorati_Weblog($this->domElement); - - // check name - $this->assertEquals('Roby Web World Italia', $weblog->getName()); - // check URL - $this->assertEquals(Zend_Uri::factory('http://robyww.blogspot.com'), $weblog->getUrl()); - // check Atom Url - $this->assertEquals(Zend_Uri::factory('http://robyww.blogspot.com/feeds/posts/atom'), $weblog->getAtomUrl()); - // check RSS Url - $this->assertEquals(Zend_Uri::factory('http://robyww.blogspot.com/feeds/posts/rss'), $weblog->getRssUrl()); - // check inbound blogs - $this->assertEquals(71, $weblog->getInboundBlogs()); - // check inbound links - $this->assertEquals(103, $weblog->getInboundLinks()); - // check last update - $this->assertEquals(new Zend_Date('2007-11-11 08:47:26 GMT'), $weblog->getLastUpdate()); - // check rank - $this->assertEquals(93473, $weblog->getRank()); - // check authors - $var = $weblog->getAuthors(); - $this->assertType('array', $var); - $this->assertEquals(1, sizeof($var)); - // check photo - $this->assertEquals(false, $weblog->hasPhoto()); - // check lat and lon - $this->assertNull($weblog->getLat()); - $this->assertNull($weblog->getLon()); - } - - public function testWeblogWithTwoAuthors() - { - $domElement = self::getTestFileElementAsDom('TestWeblogTwoAuthors.xml', '//weblog'); - $weblog = new Zend_Service_Technorati_Weblog($domElement); - - $authors = $weblog->getAuthors(); - - // check whether $authors is an array with valid length - $this->assertType('array', $authors); - $this->assertEquals(2, sizeof($authors)); - - // check first author - $author = $authors[0]; - $this->assertType('Zend_Service_Technorati_Author', $author); - $this->assertEquals('rfilippini', $author->getUsername()); - - // check second author, be sure it's not the first one - $author = $authors[1]; - $this->assertType('Zend_Service_Technorati_Author', $author); - $this->assertEquals('Rinzi', $author->getUsername()); - } - - public function testSetGet() - { - $weblog = new Zend_Service_Technorati_Weblog($this->domElement); - - // check name - $set = 'foo'; - $get = $weblog->setName($set)->getName(); - $this->assertType('string', $get); - $this->assertEquals($set, $get); - - // check URL - - $set = Zend_Uri::factory('http://www.simonecarletti.com/'); - $get = $weblog->setUrl($set)->getUrl(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals($set, $get); - - $set = 'http://www.simonecarletti.com/'; - $get = $weblog->setUrl($set)->getUrl(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals(Zend_Uri::factory($set), $get); - - $set = 'http:::/foo'; - try { - $weblog->setUrl($set); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid URI", $e->getMessage()); - } - - // check Atom URL - - $set = Zend_Uri::factory('http://www.simonecarletti.com/'); - $get = $weblog->setAtomUrl($set)->getAtomUrl(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals($set, $get); - - $set = 'http://www.simonecarletti.com/'; - $get = $weblog->setAtomUrl($set)->getAtomUrl(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals(Zend_Uri::factory($set), $get); - - $set = 'http:::/foo'; - try { - $weblog->setAtomUrl($set); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid URI", $e->getMessage()); - } - - // check RSS Url - - $set = Zend_Uri::factory('http://www.simonecarletti.com/'); - $get = $weblog->setRssUrl($set)->getRssUrl(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals($set, $get); - - $set = 'http://www.simonecarletti.com/'; - $get = $weblog->setRssUrl($set)->getRssUrl(); - $this->assertType('Zend_Uri_Http', $get); - $this->assertEquals(Zend_Uri::factory($set), $get); - - $set = 'http:::/foo'; - try { - $weblog->setRssUrl($set); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Service_Technorati_Exception $e) { - $this->assertContains("Invalid URI", $e->getMessage()); - } - - // check inbound blogs - - $set = rand(); - $get = $weblog->setInboundBlogs($set)->getInboundBlogs(); - $this->assertType('integer', $get); - $this->assertEquals($set, $get); - - $set = (string) rand(); - $get = $weblog->setInboundBlogs($set)->getInboundBlogs(); - $this->assertType('integer', $get); - $this->assertEquals((int) $set, $get); - - // check inbound links - - $set = rand(); - $get = $weblog->setInboundLinks($set)->getInboundLinks(); - $this->assertType('integer', $get); - $this->assertEquals((int) $set, $get); - - $set = (string) rand(); - $get = $weblog->setInboundLinks($set)->getInboundLinks(); - $this->assertType('integer', $get); - $this->assertEquals((int) $set, $get); - - // last update - - $set = '2007-11-11 08:47:26 GMT'; - $get = $weblog->setLastUpdate($set)->getLastUpdate(); - $this->assertType('Zend_Date', $get); - $this->assertEquals(new Zend_Date($set), $get); - - /* not supported - $set = time(); - $get = $weblog->setLastUpdate($set)->getLastUpdate(); - $this->assertType('integer', $get); - $this->assertEquals($set, $get); */ - - $set = '200ty'; - try { - $weblog->setLastUpdate($set); - $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); - } catch(Zend_Service_Technorati_Exception $e) { - $this->assertContains("valid Date/Time", $e->getMessage()); - } - - // check rank - - $set = rand(); - $get = $weblog->setRank($set)->getRank(); - $this->assertType('integer', $get); - $this->assertEquals((int) $set, $get); - - $set = (string) rand(); - $get = $weblog->setRank($set)->getRank(); - $this->assertType('integer', $get); - $this->assertEquals((int) $set, $get); - - // check hasPhoto - - $set = false; - $get = $weblog->setHasPhoto($set)->hasPhoto(); - $this->assertType('boolean', $get); - $this->assertEquals($set, $get); - - $set = 0; - $get = $weblog->setHasPhoto($set)->hasPhoto(); - $this->assertType('boolean', $get); - $this->assertEquals((bool) $set, $get); - - // check lat - - $set = 1.3; - $get = $weblog->setLat($set)->getLat(); - $this->assertType('float', $get); - $this->assertEquals($set, $get); - - $set = '1.3'; - $get = $weblog->setLat($set)->getLat(); - $this->assertType('float', $get); - $this->assertEquals((float) $set, $get); - - // check lon - - $set = 1.3; - $get = $weblog->setLon($set)->getLon(); - $this->assertType('float', $get); - $this->assertEquals($set, $get); - - $set = '1.3'; - $get = $weblog->setLon($set)->getLon(); - $this->assertType('float', $get); - $this->assertEquals((float) $set, $get); - } -} diff --git a/tests/Zend/Service/Technorati/_files/MISSING b/tests/Zend/Service/Technorati/_files/MISSING deleted file mode 100644 index b114332bbd7b646f3e71aadd5d01c73c90892050..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/MISSING +++ /dev/null @@ -1,15 +0,0 @@ -= Missing Cases = - -Unable to find an output for the following cases. -Please, write me at weppos@weppos.net if you have one of the following XML responses. - -== Cosmos == - - * Highligh = 1 returned an highlighted result within <excerpt> tag - -== Search == - - * `Search` error response cannot be created because due to a Technorati bug - any bad `Search` request returns an HTML response - * Claim = 1 option doesn't work for the same (unknown) reason it failed - in `Cosmos` search \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestAuthor.xml b/tests/Zend/Service/Technorati/_files/TestAuthor.xml deleted file mode 100644 index a0f64248393f2667b84697b24ab80e90ca0c3e20..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestAuthor.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Author XML fragment. - ---> -<author> - <username>cesarehtml</username> - <firstname>Cesare</firstname> - <lastname>Lamanna</lastname> - <description>This is a description.</description> - <bio>This is a bio.</bio> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=117217</thumbnailpicture> -</author> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestAuthorNullFields.xml b/tests/Zend/Service/Technorati/_files/TestAuthorNullFields.xml deleted file mode 100644 index 2ae49497b97e88232869ba28daf72188b9e2bab2..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestAuthorNullFields.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Author XML fragment. - ---> -<author> - <username>cesarehtml</username> - <firstname>Cesare</firstname> - <lastname>Lamanna</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=117217</thumbnailpicture> -</author> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestBlogInfoError.xml b/tests/Zend/Service/Technorati/_files/TestBlogInfoError.xml deleted file mode 100644 index 25d4cb0ac8ed3d124c1b1e2f421fa33505b81509..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogInfoError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Bloginfo request - http://api.technorati.com/bloginfo?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /bloginfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Invalid request: url is required</error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogInfoErrorUrlNotWeblog.xml b/tests/Zend/Service/Technorati/_files/TestBlogInfoErrorUrlNotWeblog.xml deleted file mode 100644 index f94edd9618c81592f796b754733d71441230e8bc..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogInfoErrorUrlNotWeblog.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Bloginfo request - http://api.technorati.com/bloginfo?key=VALID_API_KEY&url=www.simonecarletti.com - - The request has the following properties: - * url is a site, not a claimed blog - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>www.simonecarletti.com</url> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogInfoResult.xml b/tests/Zend/Service/Technorati/_files/TestBlogInfoResult.xml deleted file mode 100644 index a3ae7b41ca950208150a5f6dac50c82a9942f0f6..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogInfoResult.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Bloginfo request - http://api.technorati.com/bloginfo?key=VALID_API_KEY&url=http://www.simonecarletti.com/blog - - The request has the following properties: - * url is a valid blog - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <rssurl/> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - <lastupdate>2007-11-14 21:06:36 GMT</lastupdate> - <rank>80591</rank> - </weblog> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogInfoResultUrlWithInvalidSchema.xml b/tests/Zend/Service/Technorati/_files/TestBlogInfoResultUrlWithInvalidSchema.xml deleted file mode 100644 index efdc20edd4d5680d0e7384a2f161279b6419f628..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogInfoResultUrlWithInvalidSchema.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Bloginfo request - http://api.technorati.com/bloginfo?key=VALID_API_KEY&url=www.simonecarletti.com/blog - - The request has the following properties: - * url is a valid blog - * url is missing a valid schema and might cause Zend_Uri_Http parser to fail - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <rssurl/> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - <lastupdate>2007-11-14 21:06:36 GMT</lastupdate> - <rank>80591</rank> - </weblog> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogInfoSuccess.xml b/tests/Zend/Service/Technorati/_files/TestBlogInfoSuccess.xml deleted file mode 100644 index 8d2c3598fc083d0888c2db4c7bd0933260915e2e..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogInfoSuccess.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Bloginfo request - http://api.technorati.com/bloginfo?key=VALID_API_KEY&url=www.simonecarletti.com/blog - - The request has the following properties: - * url is a valid blog - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <rssurl/> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - <lastupdate>2007-11-14 21:06:36 GMT</lastupdate> - <rank>80591</rank> - </weblog> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogPostTagsError.xml b/tests/Zend/Service/Technorati/_files/TestBlogPostTagsError.xml deleted file mode 100644 index 1b5dd95019cde323955bfe4cb948fdba7a08d2d9..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogPostTagsError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Blogposttags request - http://api.technorati.com/blogposttags?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /bloginfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Invalid request: url is required</error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogPostTagsErrorUrlNotWeblog.xml b/tests/Zend/Service/Technorati/_files/TestBlogPostTagsErrorUrlNotWeblog.xml deleted file mode 100644 index 03ab2e33212a671b336ba654d1989739837d7c1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogPostTagsErrorUrlNotWeblog.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Blogposttags request - http://api.technorati.com/blogposttags?key=VALID_API_KEY&url=www.simonecarletti.com - - The request has the following properties: - * url is a site, not a claimed blog - - Please note how this request is considered an error because `url` - is not a claimed blog. - The same request for `Bloginfo` simple returns the blog URL - and is not considered as an error. - ---> -<!-- generator="Technorati API version 1.0 " --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Your URL is not in our system </error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestBlogPostTagsSuccess.xml b/tests/Zend/Service/Technorati/_files/TestBlogPostTagsSuccess.xml deleted file mode 100644 index 77cab9e343f5636757d24dae9df6774c338b8cf4..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestBlogPostTagsSuccess.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Blogposttags request - http://api.technorati.com/blogposttags?key=VALID_API_KEY&url=www.simonecarletti.com/blog - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `item` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /blogposttags" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <querycount>20</querycount> - </result> - <item> - <tag>Google</tag> - <posts>102</posts> - </item> - <item> - <tag>software</tag> - <posts>50</posts> - </item> - <item> - <tag>Blogging</tag> - <posts>50</posts> - </item> - <item> - <tag>Blog</tag> - <posts>45</posts> - </item> - <item> - <tag>Internet</tag> - <posts>42</posts> - </item> - <item> - <tag>Motori di ricerca</tag> - <posts>41</posts> - </item> - <item> - <tag>SEO</tag> - <posts>39</posts> - </item> - <item> - <tag>software e strumenti</tag> - <posts>28</posts> - </item> - <item> - <tag>Microsoft</tag> - <posts>22</posts> - </item> - <item> - <tag>Syndication</tag> - <posts>21</posts> - </item> - <item> - <tag>feed</tag> - <posts>18</posts> - </item> - <item> - <tag>Strumenti</tag> - <posts>18</posts> - </item> - <item> - <tag>trucchi & segreti</tag> - <posts>17</posts> - </item> - <item> - <tag>About This Blog</tag> - <posts>17</posts> - </item> - <item> - <tag>Lettori di Feed</tag> - <posts>16</posts> - </item> - <item> - <tag>feedburner</tag> - <posts>15</posts> - </item> - <item> - <tag>Relax</tag> - <posts>14</posts> - </item> - <item> - <tag>eventi e segnalazioni</tag> - <posts>13</posts> - </item> - <item> - <tag>PHP</tag> - <posts>12</posts> - </item> - <item> - <tag>Articoli</tag> - <posts>12</posts> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosError.xml b/tests/Zend/Service/Technorati/_files/TestCosmosError.xml deleted file mode 100644 index e059f4f60fd79ab79e2b8581983586ef1d3c59d5..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /cosmos" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Invalid request: url is required</error> - </result> - </document> -</tapi> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSet.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSet.xml deleted file mode 100644 index b33a23e17d64fe77e52b14aa42b68840b3c09f4b..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSet.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com/blog - - This is the most simple Cosmos request. - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>82</inboundblogs> - <inboundlinks>111</inboundlinks> - <lastupdate>2007-12-19 16:11:13 GMT</lastupdate> - <rank>85297</rank> - </weblog> - <inboundlinks>278</inboundlinks> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name>Sentieri Didattici del Veneto </name> - <url>http://sentierididattici.scuoleinrete.net/wpmu</url> - <rssurl>http://sentierididattici.scuoleinrete.net/wpmu/feed/</rssurl> - <inboundblogs>4</inboundblogs> - <inboundlinks>4</inboundlinks> - <lastupdate>2007-09-20 11:42:39 GMT</lastupdate> - </weblog> - <excerpt>Che cos'è un blog Blog di Sergio Maistrello Il mestiere di scrivere ScuolaERSimone Carletti's BlogWikipedia</excerpt> - <linkcreated>2007-12-24 15:29:17 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2005/09/che_cose_un_blog.php</linkurl> - </item> - <item> - <weblog> - <name>Marco Cattaneo Weblog - Tecnologia e New Media; Innovazione, Informazione e Comunicazione Digitale </name> - <url>http://www.marcocattaneo.com</url> - <rssurl>http://www.marcocattaneo.com/feed/</rssurl> - <inboundblogs>39</inboundblogs> - <inboundlinks>73</inboundlinks> - <lastupdate>2007-12-22 10:00:14 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.marcocattaneo.com/2007/12/22/buon-natale-con-sentimento-e-spero-non-con-banalita/</nearestpermalink> - <excerpt>cultura, ricette, ricordi o piacevoli scorci di vita vissuta, regalo un link, che per me equivale ad un piccolo pensiero natalizio.Ringrazio quindi (in rigoroso ordine quasi sparso): Tevac, Mac Blog, Macity, Lele, Paolo Valdemarin, Luca Mascaro,Simone Carletti, Ludo, Dario Salvelli, Kurai, Roberto, Nicola Mattina Blog, Alberto Mucignat, Alberto Nardelli, Andrea Beggi, Luca Pandemia Conti, Marco Camisani Calzolari, Robin Good, Maestrini, Alberto, Tiziano Fogliata</excerpt> - <linkcreated>2007-12-22 10:00:14 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogLink.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogLink.xml deleted file mode 100644 index 3b0f2715e8a7ce914ad0a94f7271df9809d37d3c..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogLink.xml +++ /dev/null @@ -1,303 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com/blog&type=link - - The request has the following properties: - * url is blog - * type is weblog - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - <rank>81766</rank> - </weblog> - <inboundlinks>298</inboundlinks> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-11 20:07:11 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <excerpt>Scegli il mese PREFERITI [IMG] Seth Godin's Blog [IMG] John Battelle's Search Blog [IMG] Search Engine Land [IMG] SEM Blog (Marco Loguercio) [IMG]Simone Carletti's Blog</excerpt> - <linkcreated>2007-11-11 16:56:30 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-11 05:04:12 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <excerpt>( soprattutto Google ) a riconoscere il nostro dominio di competenza; tutto questo influirà sensibilmente sui risultati dell’intero progetto. I migliori SEO divulgano insegnamenti che sfortunatamente in pochi hanno l’accortezza di seguire;Simone Carlettiè sicuramente uno dei più autorevoli; vediamo insieme cosa egli scrive nella sua recente guida dedicata ai Google site links: Ci sono alcune attività che possono agevolare l’analisi e l’interpretazione del sito, migliorando l</excerpt> - <linkcreated>2007-11-10 09:01:12 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.progetto-seo.com/motori-di-ricerca/links-interni</nearestpermalink> - <excerpt>( soprattutto Google ) a riconoscere il nostro dominio di competenza; tutto questo influirà sensibilmente sui risultati dell’intero progetto. I migliori SEO divulgano insegnamenti che sfortunatamente in pochi hanno l’accortezza di seguire;Simone Carlettiè sicuramente uno dei più autorevoli; vediamo insieme cosa egli scrive nella sua recente guida dedicata ai Google site links: Ci sono alcune attività che possono agevolare l’analisi e l’interpretazione del sito, migliorando l</excerpt> - <linkcreated>2007-11-10 08:57:22 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name>FeedBurner Stats 2 Feed 1.1 - Build your own FeedBurner feeds stats feed</name> - <url>http://lab.rss-world.info/feedburner-feedstats</url> - <rssurl>http://lab.rss-world.info/feedburner-feedstats/stats2feed.php</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>4</inboundlinks> - <lastupdate>2007-11-07 17:54:16 GMT</lastupdate> - </weblog> - <nearestpermalink>http://lab.rss-world.info/feedburner-feedstats/#errors</nearestpermalink> - <excerpt>here</excerpt> - <linkcreated>2007-11-08 11:54:32 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2006/06/feedburner_stats_2_feed.php</linkurl> - </item> - <item> - <weblog> - <name>Se siamo fatti di pura energia,</name> - <url>http://sitaram.splinder.com</url> - <rssurl>http://syndication.splinder.com/sitaram/rss2.xml</rssurl> - <atomurl>http://syndication.splinder.com/sitaram/atom.xml</atomurl> - <inboundblogs>27</inboundblogs> - <inboundlinks>49</inboundlinks> - <lastupdate>2007-11-10 19:27:05 GMT</lastupdate> - </weblog> - <excerpt>Blog di Mercante di Sogni Blog di Morris Goodman Blog di Natalibera Blog di Nuovo Spazio Blog di Oltre l'infinito Blog di OsteMax Blog di Pachucha Blog di Paul Coelho Blog di Riccardo Blog di Ron Peer Blog di SilasBlog di Simone CarlettiBlog di Sofia Blog di Stazione Celeste Blog di Susan Hanshaw Blog di Visualizzazione Positiva Blog di Web Caffè Blog di Wolf Blog di Zio Hack Buddhismo della Via di Diamante Celestian Center Cellula Cancerosa</excerpt> - <linkcreated>2007-11-07 21:03:08 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>BLOG intarget.net</name> - <url>http://blog.intarget.net</url> - <rssurl>http://blog.intarget.net/feed</rssurl> - <atomurl>http://blog.intarget.net/feed/atom</atomurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-06 16:58:08 GMT</lastupdate> - </weblog> - <excerpt>- “tecniche segrete†del marketing Pandemia - ambiente, media, rete e tecnologia Search Advertising Blog - il Blog di Andrea Cappello Search Engine Marketing - il blog di Marco Loguercio SeoTalk - il Blog di Salvatore CarielloSimone Carletti's Blog- Un piccolo spazio nel web dedicato al web con approfondimenti su marketing, feed RSS / Atom e motori di ricerca Tagliaerbe Blog - seo blog</excerpt> - <linkcreated>2007-11-06 16:58:13 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>Soft Review </name> - <url>http://softrevi.com</url> - <rssurl>http://softrevi.com/feed/</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>2007-11-12 17:38:55 GMT</lastupdate> - </weblog> - <nearestpermalink>http://softrevi.com/2007/11/06/how-to-add-rmail-as-a-choice-in-firefox-20/</nearestpermalink> - <excerpt>read more</excerpt> - <linkcreated>2007-11-06 16:51:43 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2006/06/how_to_add_rmail_as_a_choice_i.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.progetto-seo.com/motori-di-ricerca/rel-nofollow-seo</nearestpermalink> - <excerpt>è presente, significa che la pagina d’origine non attribuirà alcun valore alla pagina di destinazione; Ask dichiara di non averlo mai supportato ufficialmente, potete trovare tutte le informazioni necessarie inquesto articolo, liberamente tradotto da Simone Carletti da un articolo di Loren Baker pubblicato sul Search Engine Journal. Technorati Tag: SEO, rel nofollow, motori di ricerca</excerpt> - <linkcreated>2007-11-06 14:03:18 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-05 12:47:43 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>DreamsWorld - www.dreamsworld.it - Errore Interno del Server</name> - <url>http://www.dreamsworld.it/emanuele</url> - <inboundblogs>112</inboundblogs> - <inboundlinks>354</inboundlinks> - <lastupdate>2007-11-12 18:42:17 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.dreamsworld.it/emanuele/2007-11-04/mac-onsigliatemi-11-domande-prima-di-passare-a-mac/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. A questo punto immagino che sia consigliabile avere almeno 2Gb di ram. Conviene spendere 132??? ed acquistare “l’upgrade</excerpt> - <linkcreated>2007-11-04 19:15:57 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name> …time is what you make of it…</name> - <url>http://emanuele.dreamsworld.it</url> - <rssurl>http://www.dreamsworld.it/emanuele/feed/</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-11-12 15:24:46 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.dreamsworld.it/emanuele/2007-11-04/mac-onsigliatemi-11-domande-prima-di-passare-a-mac/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. A questo punto immagino che sia consigliabile avere almeno 2Gb di ram. Conviene spendere 132€ ed acquistare “l’upgrade</excerpt> - <linkcreated>2007-11-04 19:15:57 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Stefano Gorgoni » Dovevo chiedervi scusa?</name> - <url>http://www.stefanogorgoni.com/384/dovevo-chiedervi-scusa</url> - <rssurl>http://www.stefanogorgoni.com/feed/</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-02 14:11:04 GMT</lastupdate> - </weblog> - <excerpt>inaritech kerouac3001 marketing routes mauro lupi mini marketing motoricerca.info motoricerca.net progetto seo ranklab seo search advertising blog semblog seo talk studiocelso webmarketing web marketingwepposYoYo Formazione rotolante</excerpt> - <linkcreated>2007-11-03 13:02:10 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>[•] - RSS/ATOM Feeds Aggregator </name> - <url>http://www.codicesorgente.it</url> - <rssurl>http://www.codicesorgente.it/feedsaggregator/rss.php</rssurl> - <inboundblogs>67</inboundblogs> - <inboundlinks>321</inboundlinks> - <lastupdate>2007-11-05 02:40:19 GMT</lastupdate> - </weblog> - <excerpt>ho sentita) che rappresentano, per il momento, una piccola minoranza, e non rientrano tra quelli considerati “utente medio†peccando di superbia, penso di aver fatto una bella analisi, ma mi piacerebbe avere il parere di alberto, tambu,simone, altre che naturalmente di tutti quelli che avranno voglia di lasciarmelo… [richiesta marchetta on] non contento della dose di link appena vomitata, aggiungo che se marco formento, lele dainesi e</excerpt> - <linkcreated>2007-11-03 08:03:16 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/default</atomurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - </weblog> - <excerpt>Seth's Blog David Naylor Reporter Diffuso Marco Loguercio Tiziano Fogliata Davide Pozzi SetFocus [dot] IT Mauro Lupi 980Km Lo Direi Così Lafra Napolux Senza Stile Titti Zingone Giorgio Tave Luca ContiSimone CarlettiLalui Felter Roberto Luca Togni Robin Good Albegor's Blog Nik's Blog [mini]marketing Blographik Luca DeBiase Cristian Castellari Massimo Mantellini Sacha Catalano Numero Venti Xipe Eugenio La Mesa Andrea Cappello</excerpt> - <linkcreated>2007-11-01 09:13:15 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <excerpt>Redazione: Ogni dipendente, ad esempio, può creare il proprio calendario aziendale e condividerlo in sola lettura con gli altri colleghi. Un calendario aziendale, condiviso in lettura e scrittura, permetterà di segnare gli appuntamenti comuni.</excerpt> - <linkcreated>2007-10-30 23:58:10 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/10/ottimizzare-costi-azienda-parte-2.php</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <nearestpermalink>http://italyfilm.net/Cinema-2007/10/31/come-ridurre-ed-ottimizzare-i-costi-tecnici-in-azienda-parte-2/</nearestpermalink> - <excerpt>Redazione: Ogni dipendente, ad esempio, può creare il proprio calendario aziendale e condividerlo in sola lettura con gli altri colleghi. Un calendario aziendale, condiviso in lettura e scrittura, permetterà di segnare gli appuntamenti comuni.</excerpt> - <linkcreated>2007-10-30 23:36:00 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/10/ottimizzare-costi-azienda-parte-2.php</linkurl> - </item> - <item> - <weblog> - <name>980km | Smart Web Marketing</name> - <url>http://www.980km.com</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>137</inboundblogs> - <inboundlinks>327</inboundlinks> - <lastupdate>2007-11-11 21:08:33 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.980km.com/web-marketing/980km-entra-nel-network-web-marketing-e-motori-di-ricerca.html</nearestpermalink> - <excerpt>Dopo 6 mesi di dura attività su 980km eccomi giunto ad uno dei traguardi che mi ero prefissato fin dall’inizio: entrare nel network “Web marketing e motori di ricerca†su Feedburner, Network gestito daSimone Carletti; è una grande soddisfazione per me! D’ora in poi i contenuti di 980km verrano distribuiti anche sul Network, oltre al Feed diretto dal blog. Per conoscere tutti i siti/blog che compongono il Network basta andare su</excerpt> - <linkcreated>2007-10-29 18:14:58 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name> Allora vendi PageRank! E Matt Cutts lo conferma su Search Engine Journal | 980km</name> - <url>http://www.980km.com/google/allora-vendi-pagerank-e-matt-cutts-lo-conferma-su-search-engine-journal.html</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-10-31 13:06:51 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.980km.com/web-marketing/980km-entra-nel-network-web-marketing-e-motori-di-ricerca.html</nearestpermalink> - <excerpt>Dopo 6 mesi di dura attività su 980km eccomi giunto ad uno dei traguardi che mi ero prefissato fin dall’inizio: entrare nel network “Web marketing e motori di ricerca†su Feedburner, Network gestito daSimone Carletti; è una grande soddisfazione per me! D’ora in poi i contenuti di 980km verrano distribuiti anche sul Network, oltre al Feed diretto dal blog. Per conoscere tutti i siti/blog che compongono il Network basta andare su</excerpt> - <linkcreated>2007-10-29 18:14:58 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogLinkClaim.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogLinkClaim.xml deleted file mode 100644 index ced4a309f1cada97005117e704d6780800b84097..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogLinkClaim.xml +++ /dev/null @@ -1,348 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com/blog&type=link&claim=1 - - The request has the following properties: - * url is blog - * type is link - * claim = 1 - - When claim is enabled Technorati returns details - about the author who claimed the blog, if any. - See - * http://sitaram.splinder.com - * http://www.dreamsworld.it/emanuele - * http://robyww.blogspot.com - and more below. - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - <rank>81766</rank> - </weblog> - <inboundlinks>298</inboundlinks> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - <author> - <username>gioxx</username> - <firstname>Gioxx</firstname> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=311288</thumbnailpicture> - </author> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-11 20:07:11 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <excerpt>Scegli il mese PREFERITI [IMG] Seth Godin's Blog [IMG] John Battelle's Search Blog [IMG] Search Engine Land [IMG] SEM Blog (Marco Loguercio) [IMG]Simone Carletti's Blog</excerpt> - <linkcreated>2007-11-11 16:56:30 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-11 05:04:12 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <excerpt>( soprattutto Google ) a riconoscere il nostro dominio di competenza; tutto questo influirà sensibilmente sui risultati dell’intero progetto. I migliori SEO divulgano insegnamenti che sfortunatamente in pochi hanno l’accortezza di seguire;Simone Carlettiè sicuramente uno dei più autorevoli; vediamo insieme cosa egli scrive nella sua recente guida dedicata ai Google site links: Ci sono alcune attività che possono agevolare l’analisi e l’interpretazione del sito, migliorando l</excerpt> - <linkcreated>2007-11-10 09:01:12 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.progetto-seo.com/motori-di-ricerca/links-interni</nearestpermalink> - <excerpt>( soprattutto Google ) a riconoscere il nostro dominio di competenza; tutto questo influirà sensibilmente sui risultati dell’intero progetto. I migliori SEO divulgano insegnamenti che sfortunatamente in pochi hanno l’accortezza di seguire;Simone Carlettiè sicuramente uno dei più autorevoli; vediamo insieme cosa egli scrive nella sua recente guida dedicata ai Google site links: Ci sono alcune attività che possono agevolare l’analisi e l’interpretazione del sito, migliorando l</excerpt> - <linkcreated>2007-11-10 08:57:22 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name>FeedBurner Stats 2 Feed 1.1 - Build your own FeedBurner feeds stats feed</name> - <url>http://lab.rss-world.info/feedburner-feedstats</url> - <rssurl>http://lab.rss-world.info/feedburner-feedstats/stats2feed.php</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>4</inboundlinks> - <lastupdate>2007-11-07 17:54:16 GMT</lastupdate> - </weblog> - <nearestpermalink>http://lab.rss-world.info/feedburner-feedstats/#errors</nearestpermalink> - <excerpt>here</excerpt> - <linkcreated>2007-11-08 11:54:32 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2006/06/feedburner_stats_2_feed.php</linkurl> - </item> - <item> - <weblog> - <name>Se siamo fatti di pura energia,</name> - <url>http://sitaram.splinder.com</url> - <rssurl>http://syndication.splinder.com/sitaram/rss2.xml</rssurl> - <atomurl>http://syndication.splinder.com/sitaram/atom.xml</atomurl> - <inboundblogs>27</inboundblogs> - <inboundlinks>49</inboundlinks> - <lastupdate>2007-11-10 19:27:05 GMT</lastupdate> - <author> - <username>SitaRam</username> - <firstname/> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=714617</thumbnailpicture> - </author> - </weblog> - <excerpt>Blog di Mercante di Sogni Blog di Morris Goodman Blog di Natalibera Blog di Nuovo Spazio Blog di Oltre l'infinito Blog di OsteMax Blog di Pachucha Blog di Paul Coelho Blog di Riccardo Blog di Ron Peer Blog di SilasBlog di Simone CarlettiBlog di Sofia Blog di Stazione Celeste Blog di Susan Hanshaw Blog di Visualizzazione Positiva Blog di Web Caffè Blog di Wolf Blog di Zio Hack Buddhismo della Via di Diamante Celestian Center Cellula Cancerosa</excerpt> - <linkcreated>2007-11-07 21:03:08 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>BLOG intarget.net</name> - <url>http://blog.intarget.net</url> - <rssurl>http://blog.intarget.net/feed</rssurl> - <atomurl>http://blog.intarget.net/feed/atom</atomurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-06 16:58:08 GMT</lastupdate> - </weblog> - <excerpt>- “tecniche segrete†del marketing Pandemia - ambiente, media, rete e tecnologia Search Advertising Blog - il Blog di Andrea Cappello Search Engine Marketing - il blog di Marco Loguercio SeoTalk - il Blog di Salvatore CarielloSimone Carletti's Blog- Un piccolo spazio nel web dedicato al web con approfondimenti su marketing, feed RSS / Atom e motori di ricerca Tagliaerbe Blog - seo blog</excerpt> - <linkcreated>2007-11-06 16:58:13 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>Soft Review </name> - <url>http://softrevi.com</url> - <rssurl>http://softrevi.com/feed/</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>2007-11-12 17:38:55 GMT</lastupdate> - </weblog> - <nearestpermalink>http://softrevi.com/2007/11/06/how-to-add-rmail-as-a-choice-in-firefox-20/</nearestpermalink> - <excerpt>read more</excerpt> - <linkcreated>2007-11-06 16:51:43 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2006/06/how_to_add_rmail_as_a_choice_i.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.progetto-seo.com/motori-di-ricerca/rel-nofollow-seo</nearestpermalink> - <excerpt>è presente, significa che la pagina d’origine non attribuirà alcun valore alla pagina di destinazione; Ask dichiara di non averlo mai supportato ufficialmente, potete trovare tutte le informazioni necessarie inquesto articolo, liberamente tradotto da Simone Carletti da un articolo di Loren Baker pubblicato sul Search Engine Journal. Technorati Tag: SEO, rel nofollow, motori di ricerca</excerpt> - <linkcreated>2007-11-06 14:03:18 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-05 12:47:43 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>DreamsWorld - www.dreamsworld.it - Errore Interno del Server</name> - <url>http://www.dreamsworld.it/emanuele</url> - <inboundblogs>112</inboundblogs> - <inboundlinks>354</inboundlinks> - <lastupdate>2007-11-12 18:42:17 GMT</lastupdate> - <author> - <username>pixel8383</username> - <firstname>Emanuele</firstname> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=143656</thumbnailpicture> - </author> - </weblog> - <nearestpermalink>http://www.dreamsworld.it/emanuele/2007-11-04/mac-onsigliatemi-11-domande-prima-di-passare-a-mac/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. A questo punto immagino che sia consigliabile avere almeno 2Gb di ram. Conviene spendere 132??? ed acquistare “l’upgrade</excerpt> - <linkcreated>2007-11-04 19:15:57 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name> …time is what you make of it…</name> - <url>http://emanuele.dreamsworld.it</url> - <rssurl>http://www.dreamsworld.it/emanuele/feed/</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-11-12 15:24:46 GMT</lastupdate> - <author> - <username>pixel8383</username> - <firstname>Emanuele</firstname> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=143656</thumbnailpicture> - </author> - </weblog> - <nearestpermalink>http://www.dreamsworld.it/emanuele/2007-11-04/mac-onsigliatemi-11-domande-prima-di-passare-a-mac/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. A questo punto immagino che sia consigliabile avere almeno 2Gb di ram. Conviene spendere 132€ ed acquistare “l’upgrade</excerpt> - <linkcreated>2007-11-04 19:15:57 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Stefano Gorgoni » Dovevo chiedervi scusa?</name> - <url>http://www.stefanogorgoni.com/384/dovevo-chiedervi-scusa</url> - <rssurl>http://www.stefanogorgoni.com/feed/</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-02 14:11:04 GMT</lastupdate> - </weblog> - <excerpt>inaritech kerouac3001 marketing routes mauro lupi mini marketing motoricerca.info motoricerca.net progetto seo ranklab seo search advertising blog semblog seo talk studiocelso webmarketing web marketingwepposYoYo Formazione rotolante</excerpt> - <linkcreated>2007-11-03 13:02:10 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>[•] - RSS/ATOM Feeds Aggregator </name> - <url>http://www.codicesorgente.it</url> - <rssurl>http://www.codicesorgente.it/feedsaggregator/rss.php</rssurl> - <inboundblogs>67</inboundblogs> - <inboundlinks>321</inboundlinks> - <lastupdate>2007-11-05 02:40:19 GMT</lastupdate> - </weblog> - <excerpt>ho sentita) che rappresentano, per il momento, una piccola minoranza, e non rientrano tra quelli considerati “utente medio†peccando di superbia, penso di aver fatto una bella analisi, ma mi piacerebbe avere il parere di alberto, tambu,simone, altre che naturalmente di tutti quelli che avranno voglia di lasciarmelo… [richiesta marchetta on] non contento della dose di link appena vomitata, aggiungo che se marco formento, lele dainesi e</excerpt> - <linkcreated>2007-11-03 08:03:16 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/default</atomurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - <author> - <username>rfilippini</username> - <firstname>Roberto</firstname> - <lastname>Filippini</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=290763</thumbnailpicture> - </author> - </weblog> - <excerpt>Seth's Blog David Naylor Reporter Diffuso Marco Loguercio Tiziano Fogliata Davide Pozzi SetFocus [dot] IT Mauro Lupi 980Km Lo Direi Così Lafra Napolux Senza Stile Titti Zingone Giorgio Tave Luca ContiSimone CarlettiLalui Felter Roberto Luca Togni Robin Good Albegor's Blog Nik's Blog [mini]marketing Blographik Luca DeBiase Cristian Castellari Massimo Mantellini Sacha Catalano Numero Venti Xipe Eugenio La Mesa Andrea Cappello</excerpt> - <linkcreated>2007-11-01 09:13:15 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <excerpt>Redazione: Ogni dipendente, ad esempio, può creare il proprio calendario aziendale e condividerlo in sola lettura con gli altri colleghi. Un calendario aziendale, condiviso in lettura e scrittura, permetterà di segnare gli appuntamenti comuni.</excerpt> - <linkcreated>2007-10-30 23:58:10 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/10/ottimizzare-costi-azienda-parte-2.php</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <nearestpermalink>http://italyfilm.net/Cinema-2007/10/31/come-ridurre-ed-ottimizzare-i-costi-tecnici-in-azienda-parte-2/</nearestpermalink> - <excerpt>Redazione: Ogni dipendente, ad esempio, può creare il proprio calendario aziendale e condividerlo in sola lettura con gli altri colleghi. Un calendario aziendale, condiviso in lettura e scrittura, permetterà di segnare gli appuntamenti comuni.</excerpt> - <linkcreated>2007-10-30 23:36:00 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/10/ottimizzare-costi-azienda-parte-2.php</linkurl> - </item> - <item> - <weblog> - <name>980km | Smart Web Marketing</name> - <url>http://www.980km.com</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>137</inboundblogs> - <inboundlinks>327</inboundlinks> - <lastupdate>2007-11-11 21:08:33 GMT</lastupdate> - <author> - <username>johnniemaneiro</username> - <firstname>Johnnie</firstname> - <lastname>Maneiro</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=396500</thumbnailpicture> - </author> - </weblog> - <nearestpermalink>http://www.980km.com/web-marketing/980km-entra-nel-network-web-marketing-e-motori-di-ricerca.html</nearestpermalink> - <excerpt>Dopo 6 mesi di dura attività su 980km eccomi giunto ad uno dei traguardi che mi ero prefissato fin dall’inizio: entrare nel network “Web marketing e motori di ricerca†su Feedburner, Network gestito daSimone Carletti; è una grande soddisfazione per me! D’ora in poi i contenuti di 980km verrano distribuiti anche sul Network, oltre al Feed diretto dal blog. Per conoscere tutti i siti/blog che compongono il Network basta andare su</excerpt> - <linkcreated>2007-10-29 18:14:58 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - <item> - <weblog> - <name> Allora vendi PageRank! E Matt Cutts lo conferma su Search Engine Journal | 980km</name> - <url>http://www.980km.com/google/allora-vendi-pagerank-e-matt-cutts-lo-conferma-su-search-engine-journal.html</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-10-31 13:06:51 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.980km.com/web-marketing/980km-entra-nel-network-web-marketing-e-motori-di-ricerca.html</nearestpermalink> - <excerpt>Dopo 6 mesi di dura attività su 980km eccomi giunto ad uno dei traguardi che mi ero prefissato fin dall’inizio: entrare nel network “Web marketing e motori di ricerca†su Feedburner, Network gestito daSimone Carletti; è una grande soddisfazione per me! D’ora in poi i contenuti di 980km verrano distribuiti anche sul Network, oltre al Feed diretto dal blog. Per conoscere tutti i siti/blog che compongono il Network basta andare su</excerpt> - <linkcreated>2007-10-29 18:14:58 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblog.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblog.xml deleted file mode 100644 index 9d2c9c369af27ed280801df4ead23702842a1b3f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblog.xml +++ /dev/null @@ -1,252 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com/blog&type=weblog - - The request has the following properties: - * url is blog - * type is weblog - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - <rank>81766</rank> - </weblog> - <inboundblogs>85</inboundblogs> - <inboundlinks/> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>FeedBurner Stats 2 Feed 1.1 - Build your own FeedBurner feeds stats feed</name> - <url>http://lab.rss-world.info/feedburner-feedstats</url> - <rssurl>http://lab.rss-world.info/feedburner-feedstats/stats2feed.php</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>4</inboundlinks> - <lastupdate>2007-11-07 17:54:16 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Se siamo fatti di pura energia,</name> - <url>http://sitaram.splinder.com</url> - <rssurl>http://syndication.splinder.com/sitaram/rss2.xml</rssurl> - <atomurl>http://syndication.splinder.com/sitaram/atom.xml</atomurl> - <inboundblogs>27</inboundblogs> - <inboundlinks>49</inboundlinks> - <lastupdate>2007-11-10 19:27:05 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>BLOG intarget.net</name> - <url>http://blog.intarget.net</url> - <rssurl>http://blog.intarget.net/feed</rssurl> - <atomurl>http://blog.intarget.net/feed/atom</atomurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-06 16:58:08 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Soft Review </name> - <url>http://softrevi.com</url> - <rssurl>http://softrevi.com/feed/</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>2007-11-12 17:38:55 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>DreamsWorld - www.dreamsworld.it - Errore Interno del Server</name> - <url>http://www.dreamsworld.it/emanuele</url> - <inboundblogs>112</inboundblogs> - <inboundlinks>354</inboundlinks> - <lastupdate>2007-11-12 18:42:17 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> …time is what you make of it…</name> - <url>http://emanuele.dreamsworld.it</url> - <rssurl>http://www.dreamsworld.it/emanuele/feed/</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-11-12 15:24:46 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Stefano Gorgoni » Dovevo chiedervi scusa?</name> - <url>http://www.stefanogorgoni.com/384/dovevo-chiedervi-scusa</url> - <rssurl>http://www.stefanogorgoni.com/feed/</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-02 14:11:04 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>[•] - RSS/ATOM Feeds Aggregator </name> - <url>http://www.codicesorgente.it</url> - <rssurl>http://www.codicesorgente.it/feedsaggregator/rss.php</rssurl> - <inboundblogs>67</inboundblogs> - <inboundlinks>321</inboundlinks> - <lastupdate>2007-11-05 02:40:19 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/default</atomurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>980km | Smart Web Marketing</name> - <url>http://www.980km.com</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>137</inboundblogs> - <inboundlinks>327</inboundlinks> - <lastupdate>2007-11-11 21:08:33 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Allora vendi PageRank! E Matt Cutts lo conferma su Search Engine Journal | 980km</name> - <url>http://www.980km.com/google/allora-vendi-pagerank-e-matt-cutts-lo-conferma-su-search-engine-journal.html</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-10-31 13:06:51 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblogClaim.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblogClaim.xml deleted file mode 100644 index 196218ddc5035033568c7a00053b3f84be4a0788..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblogClaim.xml +++ /dev/null @@ -1,266 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com/blog&type=weblog&claim=1 - - The request has the following properties: - * url is blog - * type is weblog - * claim = 1 - - When claim is enabled Technorati *returns* details - about the author who claimed the blog, if any. - - TECHNORATI BUG: for somewhat reason Technorati decided - this option doens't work when type is weblog. - Don't ask me why, that's the way it goes! - - See - * http://sitaram.splinder.com - * http://www.dreamsworld.it/emanuele - * http://robyww.blogspot.com - and more below compared with TestCosmosBlogWeblogClaim.xml - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - <rank>81766</rank> - </weblog> - <inboundblogs>85</inboundblogs> - <inboundlinks/> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>FeedBurner Stats 2 Feed 1.1 - Build your own FeedBurner feeds stats feed</name> - <url>http://lab.rss-world.info/feedburner-feedstats</url> - <rssurl>http://lab.rss-world.info/feedburner-feedstats/stats2feed.php</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>4</inboundlinks> - <lastupdate>2007-11-07 17:54:16 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Se siamo fatti di pura energia,</name> - <url>http://sitaram.splinder.com</url> - <rssurl>http://syndication.splinder.com/sitaram/rss2.xml</rssurl> - <atomurl>http://syndication.splinder.com/sitaram/atom.xml</atomurl> - <inboundblogs>27</inboundblogs> - <inboundlinks>49</inboundlinks> - <lastupdate>2007-11-10 19:27:05 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>BLOG intarget.net</name> - <url>http://blog.intarget.net</url> - <rssurl>http://blog.intarget.net/feed</rssurl> - <atomurl>http://blog.intarget.net/feed/atom</atomurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-06 16:58:08 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Soft Review </name> - <url>http://softrevi.com</url> - <rssurl>http://softrevi.com/feed/</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>2007-11-12 17:38:55 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>DreamsWorld - www.dreamsworld.it - Errore Interno del Server</name> - <url>http://www.dreamsworld.it/emanuele</url> - <inboundblogs>112</inboundblogs> - <inboundlinks>354</inboundlinks> - <lastupdate>2007-11-12 18:42:17 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> …time is what you make of it…</name> - <url>http://emanuele.dreamsworld.it</url> - <rssurl>http://www.dreamsworld.it/emanuele/feed/</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-11-12 15:24:46 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Stefano Gorgoni » Dovevo chiedervi scusa?</name> - <url>http://www.stefanogorgoni.com/384/dovevo-chiedervi-scusa</url> - <rssurl>http://www.stefanogorgoni.com/feed/</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-02 14:11:04 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>[•] - RSS/ATOM Feeds Aggregator </name> - <url>http://www.codicesorgente.it</url> - <rssurl>http://www.codicesorgente.it/feedsaggregator/rss.php</rssurl> - <inboundblogs>67</inboundblogs> - <inboundlinks>321</inboundlinks> - <lastupdate>2007-11-05 02:40:19 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/default</atomurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>980km | Smart Web Marketing</name> - <url>http://www.980km.com</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>137</inboundblogs> - <inboundlinks>327</inboundlinks> - <lastupdate>2007-11-11 21:08:33 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Allora vendi PageRank! E Matt Cutts lo conferma su Search Engine Journal | 980km</name> - <url>http://www.980km.com/google/allora-vendi-pagerank-e-matt-cutts-lo-conferma-su-search-engine-journal.html</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-10-31 13:06:51 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblogClaim2.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblogClaim2.xml deleted file mode 100644 index 6f3edc35967faf7d8fa677c48bbc7b2c7cf7c1de..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetBlogWeblogClaim2.xml +++ /dev/null @@ -1,293 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com/blog&type=weblog&claim=1 - - The request has the following properties: - * url is blog - * type is weblog - * claim = 1 - - This is the same as TestCosmosBlogWeblogClaim - but for somewhat else reason when I requested this file - claim option worked. - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>www.simonecarletti.com/blog</url> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - <rank>81766</rank> - </weblog> - <inboundblogs>85</inboundblogs> - <inboundlinks/> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - <author> - <username>gioxx</username> - <firstname>Gioxx</firstname> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=311288</thumbnailpicture> - </author> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>FeedBurner Stats 2 Feed 1.1 - Build your own FeedBurner feeds stats feed</name> - <url>http://lab.rss-world.info/feedburner-feedstats</url> - <rssurl>http://lab.rss-world.info/feedburner-feedstats/stats2feed.php</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>4</inboundlinks> - <lastupdate>2007-11-07 17:54:16 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Se siamo fatti di pura energia,</name> - <url>http://sitaram.splinder.com</url> - <rssurl>http://syndication.splinder.com/sitaram/rss2.xml</rssurl> - <atomurl>http://syndication.splinder.com/sitaram/atom.xml</atomurl> - <inboundblogs>27</inboundblogs> - <inboundlinks>49</inboundlinks> - <lastupdate>2007-11-10 19:27:05 GMT</lastupdate> - <author> - <username>SitaRam</username> - <firstname/> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=714617</thumbnailpicture> - </author> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>BLOG intarget.net</name> - <url>http://blog.intarget.net</url> - <rssurl>http://blog.intarget.net/feed</rssurl> - <atomurl>http://blog.intarget.net/feed/atom</atomurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-06 16:58:08 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Soft Review </name> - <url>http://softrevi.com</url> - <rssurl>http://softrevi.com/feed/</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>2007-11-12 17:38:55 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.wordpress.com</url> - <inboundblogs>7</inboundblogs> - <inboundlinks>8</inboundlinks> - <lastupdate>2007-11-12 21:35:14 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>DreamsWorld - www.dreamsworld.it - Errore Interno del Server</name> - <url>http://www.dreamsworld.it/emanuele</url> - <inboundblogs>112</inboundblogs> - <inboundlinks>354</inboundlinks> - <lastupdate>2007-11-12 18:42:17 GMT</lastupdate> - <author> - <username>pixel8383</username> - <firstname>Emanuele</firstname> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=143656</thumbnailpicture> - </author> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> …time is what you make of it…</name> - <url>http://emanuele.dreamsworld.it</url> - <rssurl>http://www.dreamsworld.it/emanuele/feed/</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-11-12 15:24:46 GMT</lastupdate> - <author> - <username>pixel8383</username> - <firstname>Emanuele</firstname> - <lastname/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=143656</thumbnailpicture> - </author> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Stefano Gorgoni » Dovevo chiedervi scusa?</name> - <url>http://www.stefanogorgoni.com/384/dovevo-chiedervi-scusa</url> - <rssurl>http://www.stefanogorgoni.com/feed/</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-02 14:11:04 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>[•] - RSS/ATOM Feeds Aggregator </name> - <url>http://www.codicesorgente.it</url> - <rssurl>http://www.codicesorgente.it/feedsaggregator/rss.php</rssurl> - <inboundblogs>67</inboundblogs> - <inboundlinks>321</inboundlinks> - <lastupdate>2007-11-05 02:40:19 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/default</atomurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - <author> - <username>rfilippini</username> - <firstname>Roberto</firstname> - <lastname>Filippini</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=290763</thumbnailpicture> - </author> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>ItalyFilm Blog</name> - <url>http://italyfilm.net</url> - <rssurl>http://italyfilm.net/feed/</rssurl> - <atomurl>http://italyfilm.net/feed/atom/</atomurl> - <inboundblogs>5</inboundblogs> - <inboundlinks>39</inboundlinks> - <lastupdate>2007-11-12 18:48:28 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name>980km | Smart Web Marketing</name> - <url>http://www.980km.com</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>137</inboundblogs> - <inboundlinks>327</inboundlinks> - <lastupdate>2007-11-11 21:08:33 GMT</lastupdate> - <author> - <username>johnniemaneiro</username> - <firstname>Johnnie</firstname> - <lastname>Maneiro</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=396500</thumbnailpicture> - </author> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - <item> - <weblog> - <name> Allora vendi PageRank! E Matt Cutts lo conferma su Search Engine Journal | 980km</name> - <url>http://www.980km.com/google/allora-vendi-pagerank-e-matt-cutts-lo-conferma-su-search-engine-journal.html</url> - <rssurl>http://feeds.980km.com/980kmSmartWebMarketing</rssurl> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-10-31 13:06:51 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com/blog</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteLink.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteLink.xml deleted file mode 100644 index e3b70335e997ce9a0d2d32b735a2bb8977032491..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteLink.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com&type=link - - The request has the following properties: - * url is site (not a blog) - * type is link - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com</url> - <inboundlinks>949</inboundlinks> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-11 20:07:11 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - <item> - <weblog> - <name>Progetto-Seo </name> - <url>http://www.progetto-seo.com</url> - <rssurl>http://www.progetto-seo.com/feed/</rssurl> - <inboundblogs>43</inboundblogs> - <inboundlinks>84</inboundlinks> - <lastupdate>2007-11-10 08:57:22 GMT</lastupdate> - </weblog> - <nearestpermalink>http://www.progetto-seo.com/motori-di-ricerca/links-interni</nearestpermalink> - <excerpt>( soprattutto Google ) a riconoscere il nostro dominio di competenza; tutto questo influirà sensibilmente sui risultati dell’intero progetto. I migliori SEO divulgano insegnamenti che sfortunatamente in pochi hanno l’accortezza di seguire;Simone Carlettiè sicuramente uno dei più autorevoli; vediamo insieme cosa egli scrive nella sua recente guida dedicata ai Google site links: Ci sono alcune attività che possono agevolare l’analisi e l’interpretazione del sito, migliorando l</excerpt> - <linkcreated>2007-11-10 08:57:22 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/google-yahoo-ask-nofollow.php</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <excerpt>Scegli il mese PREFERITI [IMG] Seth Godin's Blog [IMG] John Battelle's Search Blog [IMG] Search Engine Land [IMG] SEM Blog (Marco Loguercio) [IMG]Simone Carletti's Blog</excerpt> - <linkcreated>2007-11-11 16:56:30 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteUrlWithInvalidSchema.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteUrlWithInvalidSchema.xml deleted file mode 100644 index 561322fb53bff223a56529e40c2c4dd411e5d22b..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteUrlWithInvalidSchema.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com&type=weblog - - The request has the following properties: - * url is site (not a blog) - * type is weblog - * returned URL is missing a valid schema (http/s). - It happens when type=weblog and url is not a Technorati weblog. - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>www.simonecarletti.com</url> - <inboundlinks/> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteWeblog.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteWeblog.xml deleted file mode 100644 index ac040b1b2ac3a6c67bb252b50f159b7eb5d35f06..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteWeblog.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com&type=weblog - - The request has the following properties: - * url is site (not a blog) - * type is weblog - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com</url> - <inboundblogs>39</inboundblogs> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - </weblog> - <linkurl>http://www.simonecarletti.com</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <linkurl>http://www.simonecarletti.com</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <linkurl>http://www.simonecarletti.com</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteWeblogWithMissingInboundblogs.xml b/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteWeblogWithMissingInboundblogs.xml deleted file mode 100644 index 6cb67adc95285ea1b835413b58d3d3baf4a6009d..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosResultSetSiteWeblogWithMissingInboundblogs.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com&type=weblog - - The request has the following properties: - * url is site (not a blog) - * type is weblog - * result header is missing a valid value for inboundblogs - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com</url> - <inboundlinks/> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com</linkurl> - </item> - <item> - <weblog> - <name>Controrete - Search Marketing e dintorni</name> - <url>http://controrete.blog.excite.it</url> - <rssurl>http://feeds.feedburner.com/controrete/cFuo</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>1</inboundlinks> - <lastupdate>1970-01-01 00:00:00 GMT</lastupdate> - </weblog> - <linkurl>www.simonecarletti.com</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestCosmosSuccess.xml b/tests/Zend/Service/Technorati/_files/TestCosmosSuccess.xml deleted file mode 100644 index 1f079e9822da9690f4c499f0a0889b1f83bf972f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestCosmosSuccess.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Cosmos request - http://api.technorati.com/cosmos?key=VALID_API_KEY&url=www.simonecarletti.com - - The request has the following properties: - * url is site (not a blog) - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <url>http://www.simonecarletti.com</url> - <inboundlinks>949</inboundlinks> - <rankingstart>1</rankingstart> - </result> - <item> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>85</inboundblogs> - <inboundlinks>112</inboundlinks> - <lastupdate>2007-11-12 20:51:52 GMT</lastupdate> - </weblog> - <excerpt>Superata la diffidenza iniziale (a dire il vero durata meno di 30 minuti) di pagare in anticipo senza alcuna referenza un servizio online, ho ordinato il mio primo template. Tag: design (3) · html (3) · psd (1) Continua la lettura di "PSD to HTML: convertire PSD in (X)HTML " » Scritto da Simone Carletti alle 20:37 Permalink | Commenti (0) | TrackBack (0) Categorie servizi</excerpt> - <linkcreated>2007-11-12 20:53:13 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/mt4/mt-search.cgi?tag=html&blog_id=1</linkurl> - </item> - <item> - <weblog> - <name> Gioxx’s Wall</name> - <url>http://gioxx.org</url> - <inboundblogs>271</inboundblogs> - <inboundlinks>774</inboundlinks> - <lastupdate>2007-11-12 17:01:29 GMT</lastupdate> - </weblog> - <nearestpermalink>http://gioxx.org/2007/11/05/il-passaggio-a-mac-le-11-risposte/</nearestpermalink> - <excerpt>Ho intenzione di prendere il modello bianco “non base†(quello con il SuperDrive per intenderci)… quanta ram consigliate di mettergli? Escono di default con 1Gb, ma considerate che mi piacerebbe potersfruttare Parallelsper bene tenendo magari un OS secondario su uno degli “spaces†di Leopard. Su Mercury ho 1 GB di ram, Leopard installato ed una virtuale XP Professional che uso quando ne ho bisogno. I consumi della virtuale si aggirano attorno ai 512 MB di ram</excerpt> - <linkcreated>2007-11-11 20:07:11 GMT</linkcreated> - <linkurl>http://www.simonecarletti.com/blog/2007/04/parallels-desktop-overview.php</linkurl> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestDailyCountsError.xml b/tests/Zend/Service/Technorati/_files/TestDailyCountsError.xml deleted file mode 100644 index 3ed53a1549c5b51de38226a91df7b6f14b97da90..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestDailyCountsError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Dailycounts request - http://api.technorati.com/dailycounts?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /dailycounts" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Missing required parameter: q</error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestDailyCountsResultSet.xml b/tests/Zend/Service/Technorati/_files/TestDailyCountsResultSet.xml deleted file mode 100644 index 8180556c78cc8d2f42d4bea1ede7b9a3b7601dbe..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestDailyCountsResultSet.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Dailycounts request - http://api.technorati.com/dailycounts?key=VALID_API_KEY&q=google - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `item` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <queryterm>google</queryterm> - <days>5</days> - <searchurl>http://technorati.com/search/google</searchurl> - </result> - <items> - <item> - <date>2007-11-14</date> - <count>29067</count> - </item> - <item> - <date>2007-11-13</date> - <count>54414</count> - </item> - <item> - <date>2007-11-12</date> - <count>62171</count> - </item> - <item> - <date>2007-11-11</date> - <count>43494</count> - </item> - <item> - <date>2007-11-10</date> - <count>29390</count> - </item> - </items> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestDailyCountsSuccess.xml b/tests/Zend/Service/Technorati/_files/TestDailyCountsSuccess.xml deleted file mode 100644 index c32209dfa11e738de18b999f12808f578e6664a8..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestDailyCountsSuccess.xml +++ /dev/null @@ -1,747 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Dailycounts request - http://api.technorati.com/dailycounts?key=VALID_API_KEY&q=google - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `item` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <queryterm>google</queryterm> - <days>180</days> - <searchurl>http://technorati.com/search/google</searchurl> - </result> - <items> - <item> - <date>2007-11-14</date> - <count>29067</count> - </item> - <item> - <date>2007-11-13</date> - <count>54414</count> - </item> - <item> - <date>2007-11-12</date> - <count>62171</count> - </item> - <item> - <date>2007-11-11</date> - <count>43494</count> - </item> - <item> - <date>2007-11-10</date> - <count>29390</count> - </item> - <item> - <date>2007-11-09</date> - <count>35589</count> - </item> - <item> - <date>2007-11-08</date> - <count>37758</count> - </item> - <item> - <date>2007-11-07</date> - <count>40545</count> - </item> - <item> - <date>2007-11-06</date> - <count>45783</count> - </item> - <item> - <date>2007-11-05</date> - <count>46159</count> - </item> - <item> - <date>2007-11-04</date> - <count>35774</count> - </item> - <item> - <date>2007-11-03</date> - <count>30016</count> - </item> - <item> - <date>2007-11-02</date> - <count>24662</count> - </item> - <item> - <date>2007-11-01</date> - <count>16893</count> - </item> - <item> - <date>2007-10-31</date> - <count>30178</count> - </item> - <item> - <date>2007-10-30</date> - <count>30917</count> - </item> - <item> - <date>2007-10-29</date> - <count>29358</count> - </item> - <item> - <date>2007-10-28</date> - <count>23700</count> - </item> - <item> - <date>2007-10-27</date> - <count>25742</count> - </item> - <item> - <date>2007-10-26</date> - <count>29412</count> - </item> - <item> - <date>2007-10-25</date> - <count>30129</count> - </item> - <item> - <date>2007-10-24</date> - <count>27235</count> - </item> - <item> - <date>2007-10-23</date> - <count>26485</count> - </item> - <item> - <date>2007-10-22</date> - <count>23708</count> - </item> - <item> - <date>2007-10-21</date> - <count>18664</count> - </item> - <item> - <date>2007-10-20</date> - <count>12918</count> - </item> - <item> - <date>2007-10-19</date> - <count>12283</count> - </item> - <item> - <date>2007-10-18</date> - <count>18798</count> - </item> - <item> - <date>2007-10-17</date> - <count>17870</count> - </item> - <item> - <date>2007-10-16</date> - <count>27321</count> - </item> - <item> - <date>2007-10-15</date> - <count>20955</count> - </item> - <item> - <date>2007-10-14</date> - <count>17277</count> - </item> - <item> - <date>2007-10-13</date> - <count>15732</count> - </item> - <item> - <date>2007-10-12</date> - <count>22193</count> - </item> - <item> - <date>2007-10-11</date> - <count>23967</count> - </item> - <item> - <date>2007-10-10</date> - <count>24105</count> - </item> - <item> - <date>2007-10-09</date> - <count>25827</count> - </item> - <item> - <date>2007-10-08</date> - <count>22879</count> - </item> - <item> - <date>2007-10-07</date> - <count>16434</count> - </item> - <item> - <date>2007-10-06</date> - <count>14722</count> - </item> - <item> - <date>2007-10-05</date> - <count>20060</count> - </item> - <item> - <date>2007-10-04</date> - <count>22368</count> - </item> - <item> - <date>2007-10-03</date> - <count>22624</count> - </item> - <item> - <date>2007-10-02</date> - <count>22918</count> - </item> - <item> - <date>2007-10-01</date> - <count>23662</count> - </item> - <item> - <date>2007-09-30</date> - <count>18929</count> - </item> - <item> - <date>2007-09-29</date> - <count>17368</count> - </item> - <item> - <date>2007-09-28</date> - <count>22745</count> - </item> - <item> - <date>2007-09-27</date> - <count>25251</count> - </item> - <item> - <date>2007-09-26</date> - <count>25507</count> - </item> - <item> - <date>2007-09-25</date> - <count>25666</count> - </item> - <item> - <date>2007-09-24</date> - <count>27322</count> - </item> - <item> - <date>2007-09-23</date> - <count>22022</count> - </item> - <item> - <date>2007-09-22</date> - <count>20777</count> - </item> - <item> - <date>2007-09-21</date> - <count>23448</count> - </item> - <item> - <date>2007-09-20</date> - <count>23264</count> - </item> - <item> - <date>2007-09-19</date> - <count>25960</count> - </item> - <item> - <date>2007-09-18</date> - <count>27563</count> - </item> - <item> - <date>2007-09-17</date> - <count>26225</count> - </item> - <item> - <date>2007-09-16</date> - <count>22655</count> - </item> - <item> - <date>2007-09-15</date> - <count>21077</count> - </item> - <item> - <date>2007-09-14</date> - <count>26217</count> - </item> - <item> - <date>2007-09-13</date> - <count>26792</count> - </item> - <item> - <date>2007-09-12</date> - <count>23027</count> - </item> - <item> - <date>2007-09-11</date> - <count>23723</count> - </item> - <item> - <date>2007-09-10</date> - <count>24347</count> - </item> - <item> - <date>2007-09-09</date> - <count>19166</count> - </item> - <item> - <date>2007-09-08</date> - <count>17218</count> - </item> - <item> - <date>2007-09-07</date> - <count>22143</count> - </item> - <item> - <date>2007-09-06</date> - <count>24576</count> - </item> - <item> - <date>2007-09-05</date> - <count>24807</count> - </item> - <item> - <date>2007-09-04</date> - <count>24835</count> - </item> - <item> - <date>2007-09-03</date> - <count>24501</count> - </item> - <item> - <date>2007-09-02</date> - <count>24578</count> - </item> - <item> - <date>2007-09-01</date> - <count>22953</count> - </item> - <item> - <date>2007-08-31</date> - <count>26727</count> - </item> - <item> - <date>2007-08-30</date> - <count>25074</count> - </item> - <item> - <date>2007-08-29</date> - <count>24254</count> - </item> - <item> - <date>2007-08-28</date> - <count>26515</count> - </item> - <item> - <date>2007-08-27</date> - <count>26111</count> - </item> - <item> - <date>2007-08-26</date> - <count>20638</count> - </item> - <item> - <date>2007-08-25</date> - <count>18115</count> - </item> - <item> - <date>2007-08-24</date> - <count>22584</count> - </item> - <item> - <date>2007-08-23</date> - <count>25020</count> - </item> - <item> - <date>2007-08-22</date> - <count>27988</count> - </item> - <item> - <date>2007-08-21</date> - <count>25995</count> - </item> - <item> - <date>2007-08-20</date> - <count>24731</count> - </item> - <item> - <date>2007-08-19</date> - <count>18361</count> - </item> - <item> - <date>2007-08-18</date> - <count>16598</count> - </item> - <item> - <date>2007-08-17</date> - <count>20153</count> - </item> - <item> - <date>2007-08-16</date> - <count>21720</count> - </item> - <item> - <date>2007-08-15</date> - <count>21802</count> - </item> - <item> - <date>2007-08-14</date> - <count>22947</count> - </item> - <item> - <date>2007-08-13</date> - <count>21967</count> - </item> - <item> - <date>2007-08-12</date> - <count>16542</count> - </item> - <item> - <date>2007-08-11</date> - <count>14987</count> - </item> - <item> - <date>2007-08-10</date> - <count>19414</count> - </item> - <item> - <date>2007-08-09</date> - <count>18989</count> - </item> - <item> - <date>2007-08-08</date> - <count>21348</count> - </item> - <item> - <date>2007-08-07</date> - <count>22020</count> - </item> - <item> - <date>2007-08-06</date> - <count>22715</count> - </item> - <item> - <date>2007-08-05</date> - <count>17146</count> - </item> - <item> - <date>2007-08-04</date> - <count>15892</count> - </item> - <item> - <date>2007-08-03</date> - <count>21480</count> - </item> - <item> - <date>2007-08-02</date> - <count>22276</count> - </item> - <item> - <date>2007-08-01</date> - <count>21715</count> - </item> - <item> - <date>2007-07-31</date> - <count>21008</count> - </item> - <item> - <date>2007-07-30</date> - <count>21698</count> - </item> - <item> - <date>2007-07-29</date> - <count>15858</count> - </item> - <item> - <date>2007-07-28</date> - <count>13813</count> - </item> - <item> - <date>2007-07-27</date> - <count>18962</count> - </item> - <item> - <date>2007-07-26</date> - <count>17607</count> - </item> - <item> - <date>2007-07-25</date> - <count>17295</count> - </item> - <item> - <date>2007-07-24</date> - <count>17154</count> - </item> - <item> - <date>2007-07-23</date> - <count>21576</count> - </item> - <item> - <date>2007-07-22</date> - <count>15726</count> - </item> - <item> - <date>2007-07-21</date> - <count>13455</count> - </item> - <item> - <date>2007-07-20</date> - <count>19614</count> - </item> - <item> - <date>2007-07-19</date> - <count>20714</count> - </item> - <item> - <date>2007-07-18</date> - <count>20527</count> - </item> - <item> - <date>2007-07-17</date> - <count>22526</count> - </item> - <item> - <date>2007-07-16</date> - <count>22344</count> - </item> - <item> - <date>2007-07-15</date> - <count>16120</count> - </item> - <item> - <date>2007-07-14</date> - <count>14508</count> - </item> - <item> - <date>2007-07-13</date> - <count>18782</count> - </item> - <item> - <date>2007-07-12</date> - <count>22156</count> - </item> - <item> - <date>2007-07-11</date> - <count>22275</count> - </item> - <item> - <date>2007-07-10</date> - <count>21997</count> - </item> - <item> - <date>2007-07-09</date> - <count>22977</count> - </item> - <item> - <date>2007-07-08</date> - <count>15616</count> - </item> - <item> - <date>2007-07-07</date> - <count>13719</count> - </item> - <item> - <date>2007-07-06</date> - <count>18747</count> - </item> - <item> - <date>2007-07-05</date> - <count>19326</count> - </item> - <item> - <date>2007-07-04</date> - <count>17480</count> - </item> - <item> - <date>2007-07-03</date> - <count>21735</count> - </item> - <item> - <date>2007-07-02</date> - <count>21540</count> - </item> - <item> - <date>2007-07-01</date> - <count>20069</count> - </item> - <item> - <date>2007-06-30</date> - <count>17006</count> - </item> - <item> - <date>2007-06-29</date> - <count>19905</count> - </item> - <item> - <date>2007-06-28</date> - <count>21225</count> - </item> - <item> - <date>2007-06-27</date> - <count>21596</count> - </item> - <item> - <date>2007-06-26</date> - <count>22021</count> - </item> - <item> - <date>2007-06-25</date> - <count>21391</count> - </item> - <item> - <date>2007-06-24</date> - <count>15930</count> - </item> - <item> - <date>2007-06-23</date> - <count>13730</count> - </item> - <item> - <date>2007-06-22</date> - <count>18214</count> - </item> - <item> - <date>2007-06-21</date> - <count>20504</count> - </item> - <item> - <date>2007-06-20</date> - <count>22849</count> - </item> - <item> - <date>2007-06-19</date> - <count>23485</count> - </item> - <item> - <date>2007-06-18</date> - <count>21793</count> - </item> - <item> - <date>2007-06-17</date> - <count>16178</count> - </item> - <item> - <date>2007-06-16</date> - <count>16053</count> - </item> - <item> - <date>2007-06-15</date> - <count>20732</count> - </item> - <item> - <date>2007-06-14</date> - <count>21946</count> - </item> - <item> - <date>2007-06-13</date> - <count>22717</count> - </item> - <item> - <date>2007-06-12</date> - <count>23057</count> - </item> - <item> - <date>2007-06-11</date> - <count>23347</count> - </item> - <item> - <date>2007-06-10</date> - <count>17675</count> - </item> - <item> - <date>2007-06-09</date> - <count>14928</count> - </item> - <item> - <date>2007-06-08</date> - <count>19405</count> - </item> - <item> - <date>2007-06-07</date> - <count>21356</count> - </item> - <item> - <date>2007-06-06</date> - <count>21845</count> - </item> - <item> - <date>2007-06-05</date> - <count>21843</count> - </item> - <item> - <date>2007-06-04</date> - <count>23465</count> - </item> - <item> - <date>2007-06-03</date> - <count>18988</count> - </item> - <item> - <date>2007-06-02</date> - <count>17831</count> - </item> - <item> - <date>2007-06-01</date> - <count>21835</count> - </item> - <item> - <date>2007-05-31</date> - <count>25020</count> - </item> - <item> - <date>2007-05-30</date> - <count>24503</count> - </item> - <item> - <date>2007-05-29</date> - <count>24012</count> - </item> - <item> - <date>2007-05-28</date> - <count>21886</count> - </item> - <item> - <date>2007-05-27</date> - <count>16315</count> - </item> - <item> - <date>2007-05-26</date> - <count>15197</count> - </item> - <item> - <date>2007-05-25</date> - <count>19829</count> - </item> - <item> - <date>2007-05-24</date> - <count>22112</count> - </item> - <item> - <date>2007-05-23</date> - <count>23377</count> - </item> - <item> - <date>2007-05-22</date> - <count>22755</count> - </item> - <item> - <date>2007-05-21</date> - <count>22927</count> - </item> - <item> - <date>2007-05-20</date> - <count>17978</count> - </item> - <item> - <date>2007-05-19</date> - <count>15233</count> - </item> - </items> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestError.xml b/tests/Zend/Service/Technorati/_files/TestError.xml deleted file mode 100644 index 721513b9c07b2b5e0aebd415799c298fffdf6b2a..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestError.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a generic request - ---> -<!-- generator="Technorati API version 1.0 /keyinfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Something weird happens!</error> - </result> - </document> -</tapi> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestGetInfoError.xml b/tests/Zend/Service/Technorati/_files/TestGetInfoError.xml deleted file mode 100644 index af020fa21d038acd921abae793eba467a5fd0e33..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestGetInfoError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a GetInfo request - http://api.technorati.com/getinfo?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /getinfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Username is a required field.</error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestGetInfoResult.xml b/tests/Zend/Service/Technorati/_files/TestGetInfoResult.xml deleted file mode 100644 index 4947c215f4cc8ac81642ad7f1be2235685c0f16d..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestGetInfoResult.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a GetInfo request - http://api.technorati.com/getinfo?key=VALID_API_KEY&username=weppos - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `weblog` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /getinfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <username>weppos</username> - <firstname>Simone</firstname> - <lastname>Carletti</lastname> - </result> - <item> - <weblog> - <name> coComment -</name> - <url>http://www.cocomment.com/comments/weppos</url> - <rssurl>http://cocomment.com/myrss2/weppos.rss</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-09-18 07:58:43 GMT</lastupdate> - <rank>2929077</rank> - <lat>0.0</lat> - <lon>0.0</lon> - </weblog> - </item> - <item> - <weblog> - <name>RSS World - Un mondo dedicato al formato RSS, Atom e Blog</name> - <url>http://www.rss-world.info</url> - <description>Dedicato ai formati RSS e Atom propone informazioni, articoli e risorse sul linguaggio con approfondimenti su blog e podcast.</description> - <rssurl>http://www.rss-world.info/feed/risorse.xml</rssurl> - <atomurl>http://www.rss-world.info/feed/news.xml</atomurl> - <inboundblogs>121</inboundblogs> - <inboundlinks>285</inboundlinks> - <lastupdate>2006-11-03 14:08:11 GMT</lastupdate> - <rank>64696</rank> - <lat>0.0</lat> - <lon>0.0</lon> - <lang>26230</lang> - </weblog> - </item> - </document> -</tapi> - diff --git a/tests/Zend/Service/Technorati/_files/TestGetInfoSuccess.xml b/tests/Zend/Service/Technorati/_files/TestGetInfoSuccess.xml deleted file mode 100644 index eb76023f79c0ad5e3d1d4c3826027038ddddf9f7..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestGetInfoSuccess.xml +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a GetInfo request - http://api.technorati.com/getinfo?key=VALID_API_KEY&username=weppos - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `weblog` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /getinfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <username>weppos</username> - <firstname>Simone</firstname> - <lastname>Carletti</lastname> - </result> - <item> - <weblog> - <name> coComment -</name> - <url>http://www.cocomment.com/comments/weppos</url> - <rssurl>http://cocomment.com/myrss2/weppos.rss</rssurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-09-18 07:58:43 GMT</lastupdate> - <rank>2929077</rank> - <lat>0.0</lat> - <lon>0.0</lon> - </weblog> - </item> - <item> - <weblog> - <name>RSS World - Un mondo dedicato al formato RSS, Atom e Blog</name> - <url>http://www.rss-world.info</url> - <description>Dedicato ai formati RSS e Atom propone informazioni, articoli e risorse sul linguaggio con approfondimenti su blog e podcast.</description> - <rssurl>http://www.rss-world.info/feed/risorse.xml</rssurl> - <atomurl>http://www.rss-world.info/feed/news.xml</atomurl> - <inboundblogs>121</inboundblogs> - <inboundlinks>285</inboundlinks> - <lastupdate>2006-11-03 14:08:11 GMT</lastupdate> - <rank>64696</rank> - <lat>0.0</lat> - <lon>0.0</lon> - <lang>26230</lang> - </weblog> - </item> - <item> - <weblog> - <name>Vino e Salute: Il potere curativo del vino</name> - <url>http://www.vino-salute.com</url> - <description>Un viaggio alla scoperta dei poteri terapeutici, degli effetti benefici e curativi del vino sul nostro organismo.</description> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-10-19 04:42:34 GMT</lastupdate> - <rank>2929077</rank> - <lat>0.0</lat> - <lon>0.0</lon> - <lang>26230</lang> - </weblog> - </item> - <item> - <weblog> - <name>ASP Stats Generator Blog</name> - <url>http://blog.asp-stats.com</url> - <rssurl>http://blog.asp-stats.com/index.php/feed/</rssurl> - <inboundblogs>1</inboundblogs> - <inboundlinks>7</inboundlinks> - <lastupdate>2006-06-22 12:03:49 GMT</lastupdate> - <rank>2929077</rank> - <lat>0.0</lat> - <lon>0.0</lon> - <lang>26110</lang> - </weblog> - </item> - <item> - <weblog> - <name>Simone Carletti's Blog</name> - <url>http://www.simonecarletti.com/blog</url> - <description>Un piccolo spazio nel web dedicato a marketing, feed e motori di ricerca.</description> - <atomurl>http://www.simonecarletti.com/blog/index.xml</atomurl> - <inboundblogs>86</inboundblogs> - <inboundlinks>114</inboundlinks> - <lastupdate>2007-11-14 19:45:06 GMT</lastupdate> - <rank>96928</rank> - <lat>41.706</lat> - <lon>12.69</lon> - <lang>26230</lang> - </weblog> - </item> - <item> - <weblog> - <name>Daily Feed: Directory di blog e feed Rss/Atom</name> - <url>http://dailyfeed.rss-world.info</url> - <description>Directory multitematica di siti che propongono feed Atom ed RSS.</description> - <rssurl>http://dailyfeed.rss-world.info/index.xml</rssurl> - <atomurl>http://www.rss-world.info/feed/news.xml</atomurl> - <inboundblogs>2</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-08-13 09:59:20 GMT</lastupdate> - <rank>2929077</rank> - <lat>0.0</lat> - <lon>0.0</lon> - <lang>26230</lang> - </weblog> - </item> - </document> -</tapi> - diff --git a/tests/Zend/Service/Technorati/_files/TestKeyInfoError.xml b/tests/Zend/Service/Technorati/_files/TestKeyInfoError.xml deleted file mode 100644 index 3e96cafdf7e7e0098b078f9ddcd55b155826b9a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestKeyInfoError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a KeyInfo request - http://api.technorati.com/keyinfo?key=foo - ---> -<!-- generator="Technorati API version 1.0 /keyinfo" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Invalid key. Please visit http://technorati.com/developers/apikey.html to obtain a valid key.</error> - </result> - </document> -</tapi> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestKeyInfoResult.xml b/tests/Zend/Service/Technorati/_files/TestKeyInfoResult.xml deleted file mode 100644 index 704304d610c4e96e41a1f4452a66fe6eac7911c1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestKeyInfoResult.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a KeyInfo request - http://api.technorati.com/keyinfo?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /keyinfo" --> -<tapi version="1.0"> - <document> - <result> - <apiqueries>27</apiqueries> - <maxqueries>1500</maxqueries> - </result> - </document> -</tapi> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestKeyInfoSuccess.xml b/tests/Zend/Service/Technorati/_files/TestKeyInfoSuccess.xml deleted file mode 100644 index b1e59dfcda179031f9d91fe571be7d7b22d82a1f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestKeyInfoSuccess.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a KeyInfo request - http://api.technorati.com/keyinfo?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /keyinfo" --> -<tapi version="1.0"> - <document> - <result> - <apiqueries>0</apiqueries> - <maxqueries>500</maxqueries> - </result> - </document> -</tapi> \ No newline at end of file diff --git a/tests/Zend/Service/Technorati/_files/TestSearchResultSet.xml b/tests/Zend/Service/Technorati/_files/TestSearchResultSet.xml deleted file mode 100644 index fa52e9c423cb5961aa5a6d0e6e94adba6e8d61ee..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestSearchResultSet.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Search request - http://api.technorati.com/search?key=VALID_API_KEY&query=google - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `author` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /search" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <query>google</query> - <querycount>4298362</querycount> - <rankingstart/> - </result> - <item> - <weblog> - <name>Mi otro blog… </name> - <url>http://blogs.eurielec.etsit.upm.es/miotroblog</url> - <rssurl>http://blogs.eurielec.etsit.upm.es/miotroblog/?feed=rss2</rssurl> - <atomurl/> - <inboundblogs>12</inboundblogs> - <inboundlinks>20</inboundlinks> - <lastupdate>2007-11-14 22:18:04 GMT</lastupdate> - </weblog> - <title>El SDK de Android ya está disponible</title> - <excerpt> [ Android]Este pasado lunes se publicó el SDK (Software Development Kit) de Android, el paquete de software para móviles presentado por <strong class="keyword">Google</strong> y la Open Handset Alliance ... que cualquier desarrollador pueda construir aplicaciones para Android, se puede descargar de <strong class="keyword">Google</strong> Code, dónde</excerpt> - <created>2007-11-14 22:18:04 GMT</created> - <permalink>http://blogs.eurielec.etsit.upm.es/miotroblog/?p=271</permalink> - </item> - <item> - <weblog> - <name>インフォトップã§ãƒã‚¯ãƒã‚¯ç¨¼ã</name> - <url>http://infotop60-02.269g.net</url> - <rssurl>http://infotop60-02.269g.net/index.rdf</rssurl> - <atomurl/> - <inboundblogs>0</inboundblogs> - <inboundlinks>0</inboundlinks> - <lastupdate>2007-11-14 22:11:46 GMT</lastupdate> - </weblog> - <title>質ã®è¶…濃ã„èªè€…ã‚’ã©ã‹ã‚“ã¨5000件集ã‚ã¾ã™ã€”インフォトップ アフィリエイト〕</title> - <excerpt>出ç¾ãƒ‘ターンã—ã‹ãªã‹ã£ãŸï¼ï¼Ÿè² ã‘ã‚‹ç†ç”±ãŒè¦‹ã¤ã‹ã‚‰ãªã„・徹底ã—ãŸãƒªã‚¹ã‚¯ç®¡ç†ã§ã€å¥³æ€§ã‚„åˆã‚ã¦ã®æ–¹ã§ã‚‚安心ã—ã¦å–り組ã‚ã¾ã™ã‚¤ãƒ³ãƒ•ォトップ全商æå¯¾å¿œï¼ï¼å®Œå…¨è‡ªå‹•ブãƒã‚°æ›´æ–°ãƒ„ールï¼ï¼ ãã£ã¨ã‚ãªãŸã®ã‚¢ãƒ•ィリエイト生活・・ 楽ã—ããªã„ã§ã—ょやã£ã¨ アフィリエイト 㧠稼ã ã“ã¨ãŒå‡ºæ¥ã‚‹ã“ã¨ã‚’ã€ç¢ºä¿¡ã€‘ã—ãŸã‹ã‚‰ã§ã™ ç§ãŒä»Šã¾ã§ã€ アフィリエイト ã‚’ã™ã‚‹æ™‚ã«ã¯ã€ インフォトップ 〠インフォカート ã€ä»–ã«ã‚‚色々 ASP を使ã£ã¦ãã¾ã—ãŸãŒâ€¦ ã“ã“ã¾ã§å¥½æ¡ä»¶ã® ï¼¡ï¼³ï¼°è¶…ç°¡å˜ æ¯Žæ—¥ seesaa ブãƒã‚°ã‚¢ãƒ•ィリエイト aaa 記事 <strong class="keyword">GooGle</strong> å†è²© é¡§å®¢å¿ƒç† sexi RSS 主婦 æ ª オークション ライティング ã›ã©ã‚Š sns fc2 メール 万 ãƒãƒƒãƒˆ 稼ã åˆå¿ƒè€… 億万長者 知æµè”µ モãƒ</excerpt> - <created>2007-11-14 22:11:46 GMT</created> - <permalink>http://infotop60-02.269g.net/article/6594548.html</permalink> - </item> - <item> - <weblog> - <name>Tecno Wappy </name> - <url>http://tecno.wappy.ws</url> - <rssurl>http://feeds.feedburner.com/tecno-wappy</rssurl> - <atomurl/> - <inboundblogs>19</inboundblogs> - <inboundlinks>795</inboundlinks> - <lastupdate>2007-11-14 22:16:55 GMT</lastupdate> - </weblog> - <title>AdSense: Cambios en las zonas de los clics</title> - <excerpt>AdSense: Cambios en las zonas de los clics Por Nicolás — sin comentarios » Por medio del Blog de Dirson y una entrada en sus foros, nos enteramos que <strong class="keyword">Google</strong> AdSense esta llevando a cabo ciertas modificaciones en el comportamiento ... desde hace unas cuantas semanas atrás, por lo técnicos de <strong class="keyword">Google</strong>. El ajuste que ha hecho <strong class="keyword">Google</strong> es</excerpt> - <created>2007-11-14 22:16:55 GMT</created> - <permalink>http://tecno.wappy.ws/2007/11/15/adsense-cambios-en-las-zonas-de-los-clics.html</permalink> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestSearchSuccess.xml b/tests/Zend/Service/Technorati/_files/TestSearchSuccess.xml deleted file mode 100644 index 080bc2a11c659250a681d0677e97c783b9c6d9a5..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestSearchSuccess.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Search request - http://api.technorati.com/search?key=VALID_API_KEY&query=google - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `author` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /search" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <query>google</query> - <querycount>4298362</querycount> - <rankingstart/> - </result> - <item> - <weblog> - <name>Mi otro blog… </name> - <url>http://blogs.eurielec.etsit.upm.es/miotroblog</url> - <rssurl>http://blogs.eurielec.etsit.upm.es/miotroblog/?feed=rss2</rssurl> - <atomurl/> - <inboundblogs>12</inboundblogs> - <inboundlinks>20</inboundlinks> - <lastupdate>2007-11-14 22:18:04 GMT</lastupdate> - </weblog> - <title>El SDK de Android ya está disponible</title> - <excerpt> [ Android]Este pasado lunes se publicó el SDK (Software Development Kit) de Android, el paquete de software para móviles presentado por <strong class="keyword">Google</strong> y la Open Handset Alliance ... que cualquier desarrollador pueda construir aplicaciones para Android, se puede descargar de <strong class="keyword">Google</strong> Code, dónde</excerpt> - <created>2007-11-14 22:18:04 GMT</created> - <permalink>http://blogs.eurielec.etsit.upm.es/miotroblog/?p=271</permalink> - </item> - <item> - <weblog> - <name>Quick Aid For Everyone</name> - <url>http://quickaid4me.com</url> - <rssurl/> - <atomurl/> - <inboundblogs>1</inboundblogs> - <inboundlinks>2</inboundlinks> - <lastupdate>2007-11-14 22:17:28 GMT</lastupdate> - </weblog> - <title>KitchenAid Stand Mixer Owners Manual</title> - <excerpt>KitchenAid Stand Mixer Owners Manual by Kitchen aid stand mixer Converting Your Recipe for the Mixer The mixing instructions for recipes in this ... Mixer Owners Manual at <strong class="keyword">Google</strong> Blog Search: kitchen aid stand mixer Tag: Kitchen aid stand mixer </excerpt> - <created>2007-11-14 22:17:28 GMT</created> - <permalink>http://quickaid4me.com/category/kitchen-aid-stand-mixer/224/kitchenaid-stand-mixer-owners-manual/</permalink> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestTagError.xml b/tests/Zend/Service/Technorati/_files/TestTagError.xml deleted file mode 100644 index f856f41c775e4f6dea7bb682c745df69436c3896..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestTagError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Tag request - http://api.technorati.com/tag?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /tag" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Invalid request.</error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestTagResultSet.xml b/tests/Zend/Service/Technorati/_files/TestTagResultSet.xml deleted file mode 100644 index ed024815d451565b6396ac7efc4a9ad4ce010f58..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestTagResultSet.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Tag request - http://api.technorati.com/tag?key=VALID_API_KEY&tag=google - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `author` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <query>google</query> - <postsmatched>268877</postsmatched> - <blogsmatched>1812</blogsmatched> - <start>1</start> - <limit>3</limit> - <querytime>2.109</querytime> - </result> - <item> - <weblog> - <name>Apple Rocker Report</name> - <url>http://apple.rockerreport.com</url> - <rssurl>http://apple.rockerreport.com/blog/1/feed</rssurl> - <atomurl/> - <inboundlinks>197</inboundlinks> - <inboundblogs>17</inboundblogs> - <lastupdate>2007-11-14 22:01:43</lastupdate> - <hasphoto/> - </weblog> - <title>Apple number one when you type "store"</title> - <excerpt> Type "store" in Google and no you do not get Google store as the number one result, but in fact the Apple store comes up, wow!</excerpt> - <created>2007-11-14 22:01:43</created> - <postupdate>2007-11-14 22:02:11</postupdate> - <permalink>http://apple.rockerreport.com/apple_number_one_when_you_type_store</permalink> - </item> - <item> - <weblog> - <name> ScienceRoll</name> - <url>http://scienceroll.com</url> - <rssurl/> - <atomurl/> - <inboundlinks>1341</inboundlinks> - <inboundblogs>357</inboundblogs> - <lastupdate>2007-11-14 21:52:11</lastupdate> - <hasphoto/> - <author> - <firstname>Bertalan</firstname> - <lastname>Meskó</lastname> - <username>NCurse</username> - <description>A journey inside medicine and genetics. I try to make medicine, genetics more readable even for those who don't like these too much. And I also write about pop-medicine.</description> - <bio/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=419980</thumbnailpicture> - </author> - </weblog> - <title>Permalink for : VerveEarth: Locate Your Blog!</title> - <excerpt>VerveEarth: Locate Your Blog! Posted by Bertalan Meskó in Community Site, Google, RSS, Web 2.0. </excerpt> - <created>2007-11-14 21:52:11</created> - <postupdate>2007-11-14 21:57:59</postupdate> - <permalink>http://scienceroll.com/2007/11/14/verveearth-locate-your-blog/</permalink> - </item> - <item> - <weblog> - <name>Linux, Open Source, Mandriva :: thecamels.org :: ArtykuÅ‚y, Newsy, Download</name> - <url>http://thecamels.org</url> - <rssurl>http://thecamels.org/feed/</rssurl> - <atomurl>http://thecamels.org/feed/atom/</atomurl> - <inboundlinks>28</inboundlinks> - <inboundblogs>11</inboundblogs> - <lastupdate>2007-11-14 21:29:39</lastupdate> - <hasphoto/> - </weblog> - <title>Luka w Firefoksie obejmuje użytkowników Gmail</title> - <excerpt>Odkryta dziura w przeglÄ…darce Firefox zwiÄ…zana z protokoÅ‚em JAR pozwala na wykorzystanie jej w celu </excerpt> - <created>2007-11-14 21:47:54</created> - <postupdate>2007-11-14 21:51:46</postupdate> - <permalink>http://thecamels.org/2007/11/14/luka-w-firefoksie-obejmuje-uzytkownikow-gmail/</permalink> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestTagSuccess.xml b/tests/Zend/Service/Technorati/_files/TestTagSuccess.xml deleted file mode 100644 index c117feae3976dd0d797b98a8b69e0b129a57b95e..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestTagSuccess.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Tag request - http://api.technorati.com/tag?key=VALID_API_KEY&tag=google - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `author` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <query>google</query> - <postsmatched>268877</postsmatched> - <blogsmatched/> - <start>1</start> - <limit>2</limit> - <querytime>2.109</querytime> - </result> - <item> - <weblog> - <name>Apple Rocker Report</name> - <url>http://apple.rockerreport.com</url> - <rssurl>http://apple.rockerreport.com/blog/1/feed</rssurl> - <atomurl/> - <inboundlinks>197</inboundlinks> - <inboundblogs>17</inboundblogs> - <lastupdate>2007-11-14 22:01:43</lastupdate> - <hasphoto/> - </weblog> - <title>Apple number one when you type "store"</title> - <excerpt> Type "store" in Google and no you do not get Google store as the number one result, but in fact the Apple store comes up, wow!</excerpt> - <created>2007-11-14 22:01:43</created> - <postupdate>2007-11-14 22:02:11</postupdate> - <permalink>http://apple.rockerreport.com/apple_number_one_when_you_type_store</permalink> - </item> - <item> - <weblog> - <name>Chismes Calientes</name> - <url>http://chismescalientitos.blogspot.com</url> - <rssurl/> - <atomurl>http://chismescalientitos.blogspot.com/feeds/posts/default</atomurl> - <inboundlinks>4</inboundlinks> - <inboundblogs>3</inboundblogs> - <lastupdate>2007-11-14 21:57:31</lastupdate> - <hasphoto/> - <author> - <firstname/> - <lastname/> - <username>jmiguelus</username> - <description>Chismes atrevidos y escándalos de la farándula mundial.</description> - <bio/> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=794083</thumbnailpicture> - </author> - </weblog> - <title>Fotos hot de Beyoncé escandaliza a vecinos</title> - <excerpt>[IMG ] Un poster en el que figura Beyonce Knowles ha sido etiquetado como obsceno por indignados res</excerpt> - <created>2007-11-14 21:57:31</created> - <postupdate>2007-11-14 22:01:06</postupdate> - <permalink>http://chismescalientitos.blogspot.com/2007/11/fotos-hot-de-beyonc-escandaliza-vecinos.html</permalink> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestTagsResultSet.xml b/tests/Zend/Service/Technorati/_files/TestTagsResultSet.xml deleted file mode 100644 index 09200925d2a21f2abf991f910cb1a45868353b46..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestTagsResultSet.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Dailycounts request - http://api.technorati.com/toptags?key=VALID_API_KEY - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `result` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /topptags" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <limit>3</limit> - </result> - <item> - <tag>練習用</tag> - <posts>19655999</posts> - </item> - <item> - <tag>未分類</tag> - <posts>9095407</posts> - </item> - <item> - <tag>Weblog</tag> - <posts>8336350</posts> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestTopTagsError.xml b/tests/Zend/Service/Technorati/_files/TestTopTagsError.xml deleted file mode 100644 index 111a369d3b1be73c2dc2e3abb95e971523fc86d1..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestTopTagsError.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Error response returned for a Toptags request - http://api.technorati.com/toptags?key=VALID_API_KEY - ---> -<!-- generator="Technorati API version 1.0 /toptags" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <error>Invalid key. Please visit http://technorati.com/developers/apikey.html to obtain a valid key.</error> - </result> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestTopTagsSuccess.xml b/tests/Zend/Service/Technorati/_files/TestTopTagsSuccess.xml deleted file mode 100644 index 454ca74d85ee97837fafb38ad4f799968932e73f..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestTopTagsSuccess.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Successful response returned for a Dailycounts request - http://api.technorati.com/toptags?key=VALID_API_KEY - - Be aware that some test cases underlined how sometimes Technorati - doesn't take care of its DTD. - For instance, in the following response `result` node is invalid - according to current DTD declaration. - - See http://framework.zend.com/issues/browse/ZF-2203 - ---> -<!-- generator="Technorati API version 1.0 /topptags" --> -<!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml"> -<tapi version="1.0"> - <document> - <result> - <limit>20</limit> - </result> - <item> - <tag>練習用</tag> - <posts>19655999</posts> - </item> - <item> - <tag>未分類</tag> - <posts>9095407</posts> - </item> - <item> - <tag>Weblog</tag> - <posts>8336350</posts> - </item> - <item> - <tag>Life</tag> - <posts>6870173</posts> - </item> - <item> - <tag>Music</tag> - <posts>3693811</posts> - </item> - <item> - <tag>News</tag> - <posts>2740259</posts> - </item> - <item> - <tag>Blogging</tag> - <posts>1876351</posts> - </item> - <item> - <tag>Writing and poetry</tag> - <posts>1782247</posts> - </item> - <item> - <tag>日常</tag> - <posts>1653909</posts> - </item> - <item> - <tag>雑記</tag> - <posts>1581913</posts> - </item> - <item> - <tag>Romance and Relationships</tag> - <posts>1551242</posts> - </item> - <item> - <tag>Friends</tag> - <posts>1296840</posts> - </item> - <item> - <tag>Diary</tag> - <posts>1173377</posts> - </item> - <item> - <tag>общие</tag> - <posts>1157059</posts> - </item> - <item> - <tag>ãã®ä»–</tag> - <posts>1071083</posts> - </item> - <item> - <tag>Blog</tag> - <posts>1015232</posts> - </item> - <item> - <tag>ゲーム</tag> - <posts>996613</posts> - </item> - <item> - <tag>音楽</tag> - <posts>969464</posts> - </item> - <item> - <tag>Politics</tag> - <posts>967007</posts> - </item> - <item> - <tag>心情</tag> - <posts>944025</posts> - </item> - </document> -</tapi> diff --git a/tests/Zend/Service/Technorati/_files/TestWeblog.xml b/tests/Zend/Service/Technorati/_files/TestWeblog.xml deleted file mode 100644 index 2c9ec485a25509c995d13b819cabb594458c21b3..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestWeblog.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Weblog XML fragment. - ---> -<weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/atom</atomurl> - <rssurl>http://robyww.blogspot.com/feeds/posts/rss</rssurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - <rank>93473</rank> - <!-- available only in Cosmos <result> tag --> - <rankingstart>1</rankingstart> - <author> - <username>rfilippini</username> - <firstname>Roberto</firstname> - <lastname>Filippini</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=290763</thumbnailpicture> - </author> -</weblog> - diff --git a/tests/Zend/Service/Technorati/_files/TestWeblogTwoAuthors.xml b/tests/Zend/Service/Technorati/_files/TestWeblogTwoAuthors.xml deleted file mode 100644 index 3cce87259920c768ef1534479cb9c0bcf83fb5fb..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Technorati/_files/TestWeblogTwoAuthors.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - Weblog XML fragment. - ---> -<weblog> - <name>Roby Web World Italia</name> - <url>http://robyww.blogspot.com</url> - <atomurl>http://robyww.blogspot.com/feeds/posts/atom</atomurl> - <rssurl>http://robyww.blogspot.com/feeds/posts/rss</rssurl> - <inboundblogs>71</inboundblogs> - <inboundlinks>103</inboundlinks> - <lastupdate>2007-11-11 08:47:26 GMT</lastupdate> - <rank>93473</rank> - <author> - <username>rfilippini</username> - <firstname>Roberto</firstname> - <lastname>Filippini</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=290763</thumbnailpicture> - </author> - <author> - <username>Rinzi</username> - <firstname>Simone</firstname> - <lastname>Rinzivillo</lastname> - <thumbnailpicture>http://static.technorati.com/progimages/photo.jpg?uid=377409</thumbnailpicture> - </author> -</weblog> - diff --git a/tests/Zend/Service/Yahoo/AllTests.php b/tests/Zend/Service/Yahoo/AllTests.php deleted file mode 100644 index 3edcbf4f16eacedee9f7a6d23a38c5125bd404c5..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Yahoo/AllTests.php +++ /dev/null @@ -1,93 +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_Service_Yahoo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Service_Yahoo_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * Exclude from code coverage report - */ -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @see Zend_Service_Yahoo_OfflineTest - */ -require_once 'Zend/Service/Yahoo/OfflineTest.php'; - -/** - * @see Zend_Service_Yahoo_OnlineTest - */ -require_once 'Zend/Service/Yahoo/OnlineTest.php'; - - -/** - * @category Zend - * @package Zend_Service_Yahoo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Yahoo_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Service_Yahoo'); - - $suite->addTestSuite('Zend_Service_Yahoo_OfflineTest'); - - if (defined('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED') && - constant('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED') !== false) { - $suite->addTestSuite('Zend_Service_Yahoo_OnlineTest'); - } else { - $suite->addTestSuite('Zend_Service_Yahoo_OnlineTest_Skip'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Service_Yahoo_AllTests::main') { - Zend_Service_Yahoo_AllTests::main(); -} diff --git a/tests/Zend/Service/Yahoo/OfflineTest.php b/tests/Zend/Service/Yahoo/OfflineTest.php deleted file mode 100644 index 340f8e24e2c2657b09ef3a7a8e19d1ed5494f241..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Yahoo/OfflineTest.php +++ /dev/null @@ -1,540 +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_Service_Yahoo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OfflineTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Yahoo - */ -require_once 'Zend/Service/Yahoo.php'; - -/** - * @see Zend_Service_Yahoo_ResultSet - */ -require_once 'Zend/Service/Yahoo/ResultSet.php'; - -/** - * @see Zend_Http_Client_Adapter_Socket - */ -require_once 'Zend/Http/Client/Adapter/Socket.php'; - -/** - * @see Zend_Http_Client_Adapter_Test - */ -require_once 'Zend/Http/Client/Adapter/Test.php'; - - -/** - * @category Zend - * @package Zend_Service_Yahoo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Yahoo_OfflineTest extends PHPUnit_Framework_TestCase -{ - /** - * Reference to Yahoo service consumer object - * - * @var Zend_Service_Yahoo - */ - protected $_yahoo; - - /** - * Socket based HTTP client adapter - * - * @var Zend_Http_Client_Adapter_Socket - */ - protected $_httpClientAdapterSocket; - - /** - * HTTP client adapter for testing - * - * @var Zend_Http_Client_Adapter_Test - */ - protected $_httpClientAdapterTest; - - /** - * Sets up this test case - * - * @return void - */ - public function setUp() - { - $this->_yahoo = new Zend_Service_Yahoo(constant('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID')); - - $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket(); - - $this->_httpClientAdapterTest = new Zend_Http_Client_Adapter_Test(); - } - - /** - * Ensures that Zend_Service_Yahoo_ResultSet::current() throws an exception - * - * @return void - */ - public function testResultSetCurrentException() - { - $domDocument = new DOMDocument(); - $domDocument->appendChild($domDocument->createElement('ResultSet')); - - $resultSet = new Zend_Service_Yahoo_OfflineTest_ResultSet($domDocument); - - try { - $resultSet->current(); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('implemented by child', $e->getMessage()); - } - } - - /** - * Ensures that inlinkDataSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testInlinkDataSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->inlinkDataSearch('http://framework.zend.com/', array('results' => 101)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that inlinkDataSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testInlinkDataSearchExceptionStartInvalid() - { - try { - $this->_yahoo->inlinkDataSearch('http://framework.zend.com/', array('start' => 1001)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that inlinkDataSearch() throws an exception when the omit_inlinks option is invalid - * - * @return void - */ - public function testInlinkDataSearchExceptionOmitLinksInvalid() - { - try { - $this->_yahoo->inlinkDataSearch('http://framework.zend.com/', array('omit_inlinks' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'omit_inlinks'", $e->getMessage()); - } - } - - /** - * Ensures that imageSearch() throws an exception when the type option is invalid - * - * @return void - */ - public function testImageSearchExceptionTypeInvalid() - { - try { - $this->_yahoo->imageSearch('php', array('type' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'type'", $e->getMessage()); - } - } - - /** - * Ensures that imageSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testImageSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->imageSearch('php', array('results' => 500)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that imageSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testImageSearchExceptionStartInvalid() - { - try { - $this->_yahoo->imageSearch('php', array('start' => 1001)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that imageSearch() throws an exception when the format option is invalid - * - * @return void - */ - public function testImageSearchExceptionFormatInvalid() - { - try { - $this->_yahoo->imageSearch('php', array('format' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'format'", $e->getMessage()); - } - } - - /** - * Ensures that imageSearch() throws an exception when the coloration option is invalid - * - * @return void - */ - public function testImageSearchExceptionColorationInvalid() - { - try { - $this->_yahoo->imageSearch('php', array('coloration' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'coloration'", $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testLocalSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->localSearch('php', array('results' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testLocalSearchExceptionStartInvalid() - { - try { - $this->_yahoo->localSearch('php', array('start' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when the longitude option is invalid - * - * @return void - */ - public function testLocalSearchExceptionLongitudeInvalid() - { - try { - $this->_yahoo->localSearch('php', array('longitude' => -91)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'longitude'", $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when the latitude option is invalid - * - * @return void - */ - public function testLocalSearchExceptionLatitudeInvalid() - { - try { - $this->_yahoo->localSearch('php', array('latitude' => -181)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'latitude'", $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when the zip option is invalid - * - * @return void - */ - public function testLocalSearchExceptionZipInvalid() - { - try { - $this->_yahoo->localSearch('php', array('zip' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'zip'", $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when location data are missing - * - * @return void - */ - public function testLocalSearchExceptionLocationMissing() - { - try { - $this->_yahoo->localSearch('php'); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('Location data', $e->getMessage()); - } - } - - /** - * Ensures that localSearch() throws an exception when the sort option is invalid - * - * @return void - */ - public function testLocalSearchExceptionSortInvalid() - { - try { - $this->_yahoo->localSearch('php', array('location' => '95014', 'sort' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'sort'", $e->getMessage()); - } - } - - /** - * Ensures that newsSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testNewsSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->newsSearch('php', array('results' => 51)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that newsSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testNewsSearchExceptionStartInvalid() - { - try { - $this->_yahoo->newsSearch('php', array('start' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that newsSearch() throws an exception when the language option is invalid - * - * @return void - */ - public function testNewsSearchExceptionLanguageInvalid() - { - try { - $this->_yahoo->newsSearch('php', array('language' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('selected language', $e->getMessage()); - } - } - - /** - * Ensures that pageDataSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testPageDataSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->pageDataSearch('http://framework.zend.com/', array('results' => 101)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that pageDataSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testPageDataSearchExceptionStartInvalid() - { - try { - $this->_yahoo->pageDataSearch('http://framework.zend.com/', array('start' => 1001)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that videoSearch() throws an exception when the type option is invalid - * - * @return void - */ - public function testVideoSearchExceptionTypeInvalid() - { - try { - $this->_yahoo->videoSearch('php', array('type' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'type'", $e->getMessage()); - } - } - - /** - * Ensures that videoSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testVideoSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->videoSearch('php', array('results' => 500)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that videoSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testVideoSearchExceptionStartInvalid() - { - try { - $this->_yahoo->videoSearch('php', array('start' => 1001)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that videoSearch() throws an exception when the format option is invalid - * - * @return void - */ - public function testVideoSearchExceptionFormatInvalid() - { - try { - $this->_yahoo->videoSearch('php', array('format' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'format'", $e->getMessage()); - } - } - - /** - * Ensures that webSearch() throws an exception when the results option is invalid - * - * @return void - */ - public function testWebSearchExceptionResultsInvalid() - { - try { - $this->_yahoo->webSearch('php', array('results' => 101)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'results'", $e->getMessage()); - } - } - - /** - * Ensures that webSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testWebSearchExceptionStartInvalid() - { - try { - $this->_yahoo->webSearch('php', array('start' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'start'", $e->getMessage()); - } - } - - /** - * Ensures that webSearch() throws an exception when the start option is invalid - * - * @return void - */ - public function testWebSearchExceptionOptionInvalid() - { - try { - $this->_yahoo->webSearch('php', array('oops' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('parameters are invalid', $e->getMessage()); - } - } - - /** - * Ensures that webSearch() throws an exception when the type option is invalid - * - * @return void - */ - public function testWebSearchExceptionTypeInvalid() - { - try { - $this->_yahoo->webSearch('php', array('type' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains("option 'type'", $e->getMessage()); - } - } -} - - -class Zend_Service_Yahoo_OfflineTest_ResultSet extends Zend_Service_Yahoo_ResultSet -{ - protected $_namespace = ''; -} diff --git a/tests/Zend/Service/Yahoo/OnlineTest.php b/tests/Zend/Service/Yahoo/OnlineTest.php deleted file mode 100644 index f73af90d4ec4959a84b92856c36068b65b79cbf9..0000000000000000000000000000000000000000 --- a/tests/Zend/Service/Yahoo/OnlineTest.php +++ /dev/null @@ -1,343 +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_Service_Yahoo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: OnlineTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Service_Yahoo - */ -require_once 'Zend/Service/Yahoo.php'; - -/** - * @see Zend_Http_Client_Adapter_Socket - */ -require_once 'Zend/Http/Client/Adapter/Socket.php'; - - -/** - * @category Zend - * @package Zend_Service_Yahoo - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Service_Yahoo_OnlineTest extends PHPUnit_Framework_TestCase -{ - /** - * Reference to Yahoo service consumer object - * - * @var Zend_Service_Yahoo - */ - protected $_yahoo; - - /** - * Socket based HTTP client adapter - * - * @var Zend_Http_Client_Adapter_Socket - */ - protected $_httpClientAdapterSocket; - - /** - * Sets up this test case - * - * @return void - */ - public function setUp() - { - $this->_yahoo = new Zend_Service_Yahoo(constant('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID')); - - $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket(); - - $this->_yahoo->getRestClient() - ->getHttpClient() - ->setAdapter($this->_httpClientAdapterSocket); - } - - /** - * Ensures that inlinkDataSearch() works as expected given 'http://framework.zend.com/' as a query - * - * @return void - */ - public function testInlinkDataSearchPhp() - { - $inlinkDataResultSet = $this->_yahoo->inlinkDataSearch('http://framework.zend.com/'); - - $this->assertTrue($inlinkDataResultSet instanceof Zend_Service_Yahoo_InlinkDataResultSet); - $this->assertTrue($inlinkDataResultSet->totalResultsAvailable > 10); - $this->assertEquals(50, $inlinkDataResultSet->totalResultsReturned); - $this->assertEquals(50, $inlinkDataResultSet->totalResults()); - $this->assertEquals(1, $inlinkDataResultSet->firstResultPosition); - $this->assertEquals(0, $inlinkDataResultSet->key()); - - try { - $inlinkDataResultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - foreach ($inlinkDataResultSet as $inlinkDataResult) { - $this->assertTrue($inlinkDataResult instanceof Zend_Service_Yahoo_InlinkDataResult); - } - - $this->assertEquals(50, $inlinkDataResultSet->key()); - $inlinkDataResultSet->seek(0); - $this->assertEquals(0, $inlinkDataResultSet->key()); - } - - /** - * Ensures that imageSearch() works as expected given 'php' as a query - * - * @return void - */ - public function testImageSearchPhp() - { - $imageResultSet = $this->_yahoo->imageSearch('php'); - - $this->assertTrue($imageResultSet instanceof Zend_Service_Yahoo_ImageResultSet); - $this->assertTrue($imageResultSet->totalResultsAvailable > 10); - $this->assertEquals(10, $imageResultSet->totalResultsReturned); - $this->assertEquals(10, $imageResultSet->totalResults()); - $this->assertEquals(1, $imageResultSet->firstResultPosition); - $this->assertEquals(0, $imageResultSet->key()); - - try { - $imageResultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - foreach ($imageResultSet as $imageResult) { - $this->assertTrue($imageResult instanceof Zend_Service_Yahoo_ImageResult); - } - - $this->assertEquals(10, $imageResultSet->key()); - $imageResultSet->seek(0); - $this->assertEquals(0, $imageResultSet->key()); - } - - /** - * Ensures that imageSearch() throws an exception when the adult_ok option is invalid - * - * @return void - */ - public function testImageSearchExceptionAdultOkInvalid() - { - try { - $this->_yahoo->imageSearch('php', array('adult_ok' => -1)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('error occurred sending request', $e->getMessage()); - } - } - - /** - * Ensures that localSearch() works as expected when searching for restaurants in ZIP 95014 - * - * @return void - */ - public function testLocalSearchRestaurants() - { - $localResultSet = $this->_yahoo->localSearch('restaurants', array('zip' => '95014')); - - $this->assertTrue($localResultSet instanceof Zend_Service_Yahoo_LocalResultSet); - - $this->assertTrue($localResultSet->totalResultsAvailable > 10); - $this->assertEquals(10, $localResultSet->totalResultsReturned); - $this->assertEquals(10, $localResultSet->totalResults()); - $this->assertEquals(1, $localResultSet->firstResultPosition); - - foreach ($localResultSet as $localResult) { - $this->assertTrue($localResult instanceof Zend_Service_Yahoo_LocalResult); - } - } - - /** - * Ensures that localSearch() throws an exception when the radius option is invalid - * - * @return void - */ - public function testLocalSearchExceptionRadiusInvalid() - { - try { - $this->_yahoo->localSearch('php', array('zip' => '95014', 'radius' => -1)); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('error occurred sending request', $e->getMessage()); - } - } - - /** - * Ensures that newsSearch() works as expected when searching for 'php' - * - * @return void - */ - public function testNewsSearchPhp() - { - $newsResultSet = $this->_yahoo->newsSearch('php'); - - $this->assertTrue($newsResultSet instanceof Zend_Service_Yahoo_NewsResultSet); - - $this->assertTrue($newsResultSet->totalResultsAvailable > 10); - $this->assertEquals(10, $newsResultSet->totalResultsReturned); - $this->assertEquals(10, $newsResultSet->totalResults()); - $this->assertEquals(1, $newsResultSet->firstResultPosition); - - foreach ($newsResultSet as $newsResult) { - $this->assertTrue($newsResult instanceof Zend_Service_Yahoo_NewsResult); - } - } - - /** - * Ensures that pageDataSearch() works as expected given 'http://framework.zend.com/' as a query - * - * @return void - */ - public function testPageDataSearchPhp() - { - $pageDataResultSet = $this->_yahoo->pageDataSearch('http://framework.zend.com/'); - - $this->assertTrue($pageDataResultSet instanceof Zend_Service_Yahoo_PageDataResultSet); - $this->assertTrue($pageDataResultSet->totalResultsAvailable > 10); - $this->assertEquals(50, $pageDataResultSet->totalResultsReturned); - $this->assertEquals(50, $pageDataResultSet->totalResults()); - $this->assertEquals(1, $pageDataResultSet->firstResultPosition); - $this->assertEquals(0, $pageDataResultSet->key()); - - try { - $pageDataResultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - foreach ($pageDataResultSet as $pageDataResult) { - $this->assertTrue($pageDataResult instanceof Zend_Service_Yahoo_PageDataResult); - } - - $this->assertEquals(50, $pageDataResultSet->key()); - $pageDataResultSet->seek(0); - $this->assertEquals(0, $pageDataResultSet->key()); - } - - /** - * Ensures that videoSearch() works as expected given 'php' as a query - * - * @return void - */ - public function testVideoSearchPhp() - { - $videoResultSet = $this->_yahoo->videoSearch('php'); - - $this->assertTrue($videoResultSet instanceof Zend_Service_Yahoo_VideoResultSet); - $this->assertTrue($videoResultSet->totalResultsAvailable > 10); - $this->assertEquals(10, $videoResultSet->totalResultsReturned); - $this->assertEquals(10, $videoResultSet->totalResults()); - $this->assertEquals(1, $videoResultSet->firstResultPosition); - $this->assertEquals(0, $videoResultSet->key()); - - try { - $videoResultSet->seek(-1); - $this->fail('Expected OutOfBoundsException not thrown'); - } catch (OutOfBoundsException $e) { - $this->assertContains('Illegal index', $e->getMessage()); - } - - foreach ($videoResultSet as $videoResult) { - $this->assertTrue($videoResult instanceof Zend_Service_Yahoo_VideoResult); - } - - $this->assertEquals(10, $videoResultSet->key()); - $videoResultSet->seek(0); - $this->assertEquals(0, $videoResultSet->key()); - } - - /** - * Ensures that webSearch() works as expected when searching for 'php' - * - * @return void - */ - public function testWebSearchPhp() - { - $webResultSet = $this->_yahoo->webSearch('php'); - - $this->assertTrue($webResultSet instanceof Zend_Service_Yahoo_WebResultSet); - - $this->assertTrue($webResultSet->totalResultsAvailable > 10); - $this->assertEquals(10, $webResultSet->totalResultsReturned); - $this->assertEquals(10, $webResultSet->totalResults()); - $this->assertEquals(1, $webResultSet->firstResultPosition); - - foreach ($webResultSet as $webResult) { - $this->assertTrue($webResult instanceof Zend_Service_Yahoo_WebResult); - } - } - - /** - * Ensures that webSearch() throws an exception when the adult_ok option is invalid - * - * @return void - */ - public function testWebSearchExceptionAdultOkInvalid() - { - try { - $this->_yahoo->webSearch('php', array('adult_ok' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('error occurred sending request', $e->getMessage()); - } - } - - /** - * Ensures that webSearch() throws an exception when the similar_ok option is invalid - * - * @return void - */ - public function testWebSearchExceptionSimilarOkInvalid() - { - try { - $this->_yahoo->webSearch('php', array('similar_ok' => 'oops')); - $this->fail('Expected Zend_Service_Exception not thrown'); - } catch (Zend_Service_Exception $e) { - $this->assertContains('error occurred sending request', $e->getMessage()); - } - } -} - - -class Zend_Service_Yahoo_OnlineTest_Skip extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->markTestSkipped('Zend_Service_Yahoo online tests not enabled with an APPID in TestConfiguration.php'); - } - - public function testNothing() - { - } -} \ No newline at end of file diff --git a/tests/Zend/Session/AllTests.php b/tests/Zend/Session/AllTests.php deleted file mode 100644 index fbc05cf32557fb8b4c9dea6d9b2fbda1fad8f6fa..0000000000000000000000000000000000000000 --- a/tests/Zend/Session/AllTests.php +++ /dev/null @@ -1,96 +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_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10116 2008-07-16 02:34:10Z matthew $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Session_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - - -/** - * Zend_Session tests need to be output buffered because they depend on headers_sent() === false - * - * @see http://framework.zend.com/issues/browse/ZF-700 - */ -ob_start(); - -require_once 'SessionTest.php'; - -/** Zend_Session_SaveHandler_AllTests */ -require_once 'Zend/Session/SaveHandler/AllTests.php'; - -/** - * @category Zend - * @package Zend_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Session_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - /** - * PHPUnit_TextUI_TestRunner - */ - // require_once 'PHPUnit/TextUI/TestRunner.php'; - - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - /** - * PHPUnit_Framework_TestSuite - */ - // require_once 'PHPUnit/Framework/TestSuite.php'; - - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Session'); - - - $suite->addTestSuite('Zend_SessionTest'); - $suite->addTest(Zend_Session_SaveHandler_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Session_AllTests::main') { - Zend_Session_AllTests::main(); -} diff --git a/tests/Zend/Session/README.txt b/tests/Zend/Session/README.txt deleted file mode 100644 index 60700d02b8f50a0575d748fe756c6f4034b615af..0000000000000000000000000000000000000000 --- a/tests/Zend/Session/README.txt +++ /dev/null @@ -1,19 +0,0 @@ -The most recently published version of Zend_Session documentation: -http://framework.zend.com/wiki/x/iVc - -Comments may be added by readers to each wiki page, by first registering -for a wiki/issue tracker account, and then emailing your username to -cla@zend.com with a request to enable posting privileges. - -To run the unit tests for Zend_Session*, use a CLI version of PHP: - -$ cd /path/to/zend_framework/tests/Zend/Session -$ php AllTests.php - -Simulation of multiple, sequential requests required the use of exec() using the -CLI version of PHP. Additionally, issues discussed on the headers_sent() manual -page also pose issues when trying to combine multiple test suites and avoid -problems associated with output buffering, and headers "already sent". - -If you would like to help implement a solution, please start here: -http://framework.zend.com/issues/browse/ZF-700 diff --git a/tests/Zend/Session/SaveHandler/AllTests.php b/tests/Zend/Session/SaveHandler/AllTests.php deleted file mode 100644 index c5c3ac21014abdf49d952213eea19419fb220b35..0000000000000000000000000000000000000000 --- a/tests/Zend/Session/SaveHandler/AllTests.php +++ /dev/null @@ -1,79 +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_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10116 2008-07-16 02:34:10Z matthew $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Session_SaveHandler_AllTests::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * @category Zend - * @package Zend_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Session_SaveHandler_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Session_SaveHandler'); - - /** - * @see Zend_Session_SaveHandler_DbTableTest - */ - require_once 'Zend/Session/SaveHandler/DbTableTest.php'; - - if (!extension_loaded('pdo_sqlite')) { - $suite->addTestSuite('Zend_Session_SaveHandler_DbTableTestSkip'); - } else { - $suite->addTestSuite('Zend_Session_SaveHandler_DbTableTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Session_SaveHandler_AllTests::main') { - Zend_Session_SaveHandler_AllTests::main(); -} diff --git a/tests/Zend/Session/SaveHandler/DbTableTest.php b/tests/Zend/Session/SaveHandler/DbTableTest.php deleted file mode 100644 index a7109532c65223ad01639de0c48e5074bd4cb536..0000000000000000000000000000000000000000 --- a/tests/Zend/Session/SaveHandler/DbTableTest.php +++ /dev/null @@ -1,537 +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_Session_SaveHandler - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DbTableTest.php 10116 2008-07-16 02:34:10Z matthew $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Session_SaveHandler_DbTable - */ -require_once 'Zend/Session/SaveHandler/DbTable.php'; - -/** - * Unit testing for Zend_Session_SaveHandler_DbTable include all tests for regular session handling - * - * @category Zend - * @package Zend_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @see http://en.wikipedia.org/wiki/Black_box_testing - */ -class Zend_Session_SaveHandler_DbTableTest extends PHPUnit_Framework_TestCase -{ - /** - * @var array - */ - protected $_saveHandlerTableConfig = array( - 'name' => 'sessions', - 'primary' => array( - 'id', - 'save_path', - 'name', - ), - Zend_Session_SaveHandler_DbTable::MODIFIED_COLUMN => 'modified', - Zend_Session_SaveHandler_DbTable::LIFETIME_COLUMN => 'lifetime', - Zend_Session_SaveHandler_DbTable::DATA_COLUMN => 'data', - Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT => array( - Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT_SESSION_ID, - Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT_SESSION_SAVE_PATH, - Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT_SESSION_NAME, - ), - ); - - /** - * @var Zend_Db_Adapter_Abstract - */ - protected $_db; - - /** - * Setup performed prior to each test method - * - * @return void - */ - public function setUp() - { - $this->_setupDb($this->_saveHandlerTableConfig['primary']); - } - - /** - * Tear-down operations performed after each test method - * - * @return void - */ - public function tearDown() - { - $this->_dropTable(); - } - - public function testConfigPrimaryAssignmentFullConfig() - { - $saveHandler = new Zend_Session_SaveHandler_DbTable($this->_saveHandlerTableConfig); - /** - * @todo Test something other than that an exception is not thrown - */ - } - - public function testConstructorThrowsExceptionGivenConfigAsNull() - { - try { - $saveHandler = new Zend_Session_SaveHandler_DbTable(null); - $this->fail('Expected Zend_Session_SaveHandler_Exception not thrown'); - } catch (Zend_Session_SaveHandler_Exception $e) { - $this->assertContains('$config must be', $e->getMessage()); - } - } - - public function testTableNameSchema() - { - //this is thrown AFTER what we want to test... - $this->setExpectedException('Zend_Db_Statement_Exception'); - $config = $this->_saveHandlerTableConfig; - $config['name'] = 'schema.session'; - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - } - - public function testTableEmptyNamePullFromSavePath() - { - $config = $this->_saveHandlerTableConfig; - unset($config['name']); - try { - $savePath = ini_get('session.save_path'); - ini_set('session.save_path', dirname(__FILE__)); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->fail(); - } catch (Zend_Session_SaveHandler_Exception $e) { - ini_set('session.save_path', $savePath); - /** - * @todo Test something other than that an exception is thrown - */ - } - } - - public function testPrimaryAssignmentIdNotSet() - { - $this->setExpectedException('Zend_Session_SaveHandler_Exception'); - $config = $this->_saveHandlerTableConfig; - $config['primary'] = array('id'); - $config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT] - = Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT_SESSION_SAVE_PATH; - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - /** - * @todo Test something other than that an exception is thrown - */ - } - - public function testPrimaryAssignmentNotArray() - { - $config = $this->_saveHandlerTableConfig; - $config['primary'] = array('id'); - $config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT] - = Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT_SESSION_ID; - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - /** - * @todo Test something other than that an exception is not thrown - */ - } - - public function testModifiedColumnNotSet() - { - $this->setExpectedException('Zend_Session_SaveHandler_Exception'); - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::MODIFIED_COLUMN]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - /** - * @todo Test something other than that an exception is thrown - */ - } - - public function testLifetimeColumnNotSet() - { - $this->setExpectedException('Zend_Session_SaveHandler_Exception'); - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::LIFETIME_COLUMN]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - /** - * @todo Test something other than that an exception is thrown - */ - } - - public function testDataColumnNotSet() - { - $this->setExpectedException('Zend_Session_SaveHandler_Exception'); - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::DATA_COLUMN]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - /** - * @todo Test something other than that an exception is thrown - */ - } - - public function testDifferentArraySize() - { - //different number of args between primary and primaryAssignment - try { - $config = $this->_saveHandlerTableConfig; - array_pop($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->fail(); - } catch (Zend_Session_SaveHandler_Exception $e) { - /** - * @todo Test something other than that an exception is thrown - */ - } - } - - public function testEmptyPrimaryAssignment() - { - //test the default - no primaryAssignment - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = $config['primary'][0]; - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - /** - * @todo Test something other than that an exception is not thrown - */ - } - - public function testSessionIdPresent() - { - //test that the session Id must be in the primary assignment config - try { - $config = $this->_saveHandlerTableConfig; - $config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT] = array( - Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT_SESSION_NAME, - ); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->fail(); - } catch (Zend_Session_SaveHandler_Exception $e) { - /** - * @todo Test something other than that an exception is thrown - */ - } - } - - public function testModifiedColumnDefined() - { - //test the default - no primaryAssignment - try { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - unset($config[Zend_Session_SaveHandler_DbTable::MODIFIED_COLUMN]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->fail(); - } catch (Zend_Session_SaveHandler_Exception $e) { - /** - * @todo Test something other than that an exception is thrown - */ - } - } - - public function testLifetimeColumnDefined() - { - //test the default - no primaryAssignment - try { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - unset($config[Zend_Session_SaveHandler_DbTable::LIFETIME_COLUMN]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->fail(); - } catch (Zend_Session_SaveHandler_Exception $e) { - /** - * @todo Test something other than that an exception is thrown - */ - } - } - - public function testDataColumnDefined() - { - //test the default - no primaryAssignment - try { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - unset($config[Zend_Session_SaveHandler_DbTable::DATA_COLUMN]); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->fail(); - } catch (Zend_Session_SaveHandler_Exception $e) { - /** - * @todo Test something other than that an exception is thrown - */ - } - } - - public function testLifetime() - { - $config = $this->_saveHandlerTableConfig; - unset($config['lifetime']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->assertSame($saveHandler->getLifetime(), (int) ini_get('session.gc_maxlifetime'), - 'lifetime must default to session.gc_maxlifetime' - ); - - $config = $this->_saveHandlerTableConfig; - $lifetime = $config['lifetime'] = 1242; - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->assertSame($lifetime, $saveHandler->getLifetime()); - } - - public function testOverrideLifetime() - { - try { - $config = $this->_saveHandlerTableConfig; - $config['overrideLifetime'] = true; - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - } catch (Zend_Session_SaveHandler_Exception $e) { - /** - * @todo Test something other than that an exception is thrown - */ - } - - $this->assertTrue($saveHandler->getOverrideLifetime(), ''); - } - - public function testSessionSaving() - { - $this->_dropTable(); - - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = array($config['primary'][0]); - - $this->_setupDb($config['primary']); - - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - Zend_Session::setSaveHandler($saveHandler); - Zend_Session::start(); - - /** - * @see Zend_Session_Namespace - */ - require_once 'Zend/Session/Namespace.php'; - - $session = new Zend_Session_Namespace('SaveHandler'); - $session->testArray = $this->_saveHandlerTableConfig; - - $tmp = array('SaveHandler' => serialize(array('testArray' => $this->_saveHandlerTableConfig))); - $testAgainst = ''; - foreach ($tmp as $key => $val) { - $testAgainst .= $key . "|" . $val; - } - - session_write_close(); - - foreach ($this->_db->query('SELECT * FROM Sessions')->fetchAll() as $row) { - $this->assertSame($row[$config[Zend_Session_SaveHandler_DbTable::DATA_COLUMN]], - $testAgainst, 'Data was not saved properly' - ); - } - } - - public function testReadWrite() - { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = array($config['primary'][0]); - $this->_setupDb($config['primary']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - - $id = '242'; - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - } - - public function testReadWriteComplex() - { - $config = $this->_saveHandlerTableConfig; - $this->_setupDb($config['primary']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $saveHandler->open('savepath', 'sessionname'); - - $id = '242'; - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - } - - public function testReadWriteTwice() - { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = array($config['primary'][0]); - $this->_setupDb($config['primary']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - - $id = '242'; - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - } - - public function testReadWriteTwiceAndExpire() - { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = array($config['primary'][0]); - $config['lifetime'] = 1; - - $this->_setupDb($config['primary']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - - $id = '242'; - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - sleep(2); - - $this->assertSame(false, unserialize($saveHandler->read($id))); - } - - public function testReadWriteThreeTimesAndGc() - { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = array($config['primary'][0]); - $config['lifetime'] = 1; - - $this->_setupDb($config['primary']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - - $id = 242; - - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - - $id++; - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - - $id++; - $this->assertTrue($saveHandler->write($id, serialize($config))); - - $this->assertSame($config, unserialize($saveHandler->read($id))); - - foreach ($this->_db->query('SELECT * FROM Sessions')->fetchAll() as $row) { - $this->assertSame($config, unserialize($row['data'])); - } - - sleep(2); - - $saveHandler->gc(false); - - foreach ($this->_db->query('SELECT * FROM Sessions')->fetchAll() as $row) { - //should be empty! - $this->fail(); - } - } - - public function testSetLifetime() - { - $config = $this->_saveHandlerTableConfig; - unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); - $config['primary'] = array($config['primary'][0]); - $config['lifetime'] = 1; - - $this->_setupDb($config['primary']); - $saveHandler = new Zend_Session_SaveHandler_DbTable($config); - $this->assertSame(1, $saveHandler->getLifetime()); - - $saveHandler->setLifetime(27); - - $this->assertSame(27, $saveHandler->getLifetime()); - } - - public function testZendConfig() - { - $saveHandler = new Zend_Session_SaveHandler_DbTable(new Zend_Config($this->_saveHandlerTableConfig)); - /** - * @todo Test something other than that an exception is not thrown - */ - } - - /** - * Sets up the database connection and creates the table for session data - * - * @param array $primary - * @return void - */ - protected function _setupDb(array $primary) - { - if (!extension_loaded('pdo_sqlite')) { - $this->markTestSkipped('The pdo_sqlite extension must be available and enabled for this test'); - } - - $this->_db = Zend_Db::factory('Pdo_Sqlite', array('dbname' => ':memory:')); - Zend_Db_Table_Abstract::setDefaultAdapter($this->_db); - $query = array(); - $query[] = 'CREATE TABLE `Sessions` ( '; - $query[] = '`id` varchar(32) NOT NULL, '; - if (in_array('save_path', $primary)) { - $query[] = '`save_path` varchar(32) NOT NULL, '; - } - if (in_array('name', $primary)) { - $query[] = '`name` varchar(32) NOT NULL, '; - } - $query[] = '`modified` int(11) default NULL, '; - $query[] = '`lifetime` int(11) default NULL, '; - $query[] = '`data` text, '; - $query[] = 'PRIMARY KEY (' . implode(', ', $primary) . ') '; - $query[] = ');'; - $this->_db->query(implode("\n", $query)); - } - - /** - * Drops the database table for session data - * - * @return void - */ - protected function _dropTable() - { - $this->_db->query('DROP TABLE Sessions'); - } -} - -/** - * This class is used by Zend_Session_SaveHandler_AllTests to produce one skip message when pdo_sqlite is unavailable - */ -class Zend_Session_SaveHandler_DbTableTestSkip extends PHPUnit_Framework_TestCase -{ - public function testNothing() - { - $this->markTestSkipped('The pdo_sqlite extension must be available and enabled for this test'); - } -} \ No newline at end of file diff --git a/tests/Zend/Session/SessionTest.php b/tests/Zend/Session/SessionTest.php deleted file mode 100644 index f1af18fee16af078e748a20ff86d4179284cc39b..0000000000000000000000000000000000000000 --- a/tests/Zend/Session/SessionTest.php +++ /dev/null @@ -1,978 +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_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SessionTest.php 10802 2008-08-08 12:14:42Z alexander $ - */ - - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @see Zend_Session - */ -require_once 'Zend/Session.php'; - - -/** - * Black box testing for Zend_Session - * - * @category Zend - * @package Zend_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @see http://en.wikipedia.org/wiki/Black_box_testing - */ -class Zend_SessionTest extends PHPUnit_Framework_TestCase -{ - /** - * Helper script invoked via exec() - * - * @var string - */ - protected $_script = null; - - /** - * Storage for session.save_path, so that unit tests may change the value without side effect - * - * @var string - */ - protected $_savePath; - - /** - * Initializes instance data - * - * @return void - */ - public function __construct() - { - $this->_script = 'php -c ' . php_ini_loaded_file() . ' ' - . escapeshellarg(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SessionTestHelper.php'); - - $this->_savePath = ini_get('session.save_path'); - } - - /** - * Set up tests environment - */ - function setUp() - { - // _unitTestEnabled is utilised by other tests to handle session data processing - // Zend_Session tests should pass with _unitTestEnabled turned off - Zend_Session::$_unitTestEnabled = false; - } - - /** - * Cleanup operations after each test method is run - * - * @return void - */ - public function tearDown() - { - ini_set('session.save_path', $this->_savePath); - - $this->assertSame( - E_ALL | E_STRICT, - error_reporting( E_ALL | E_STRICT ), - 'A test altered error_reporting to something other than E_ALL | E_STRICT' - ); - - Zend_Session_Namespace::unlockAll(); - - // unset all namespaces - foreach (Zend_Session::getIterator() as $space) { - try { - Zend_Session::namespaceUnset($space); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/read.only/i', $e->getMessage()); - return; - } - } - } - - /** - * Sorts the compound result returned by SessionTestHelper, so that the - * order of iteration over namespace items do not impact analysis of test results. - * - * @param array $result output of exec()'ing SessionTestHelper - * @return string sorted alphabetically - */ - public function sortResult(array $result) - { - $results = explode(';', array_pop($result)); - sort($results); - return implode(';', $results); - } - - /** - * test session id manipulations; expect isRegenerated flag == true - * - * @return void - */ - public function testRegenerateId() - { - // Check if session hasn't already been started by another test - if (!Zend_Session::isStarted()) { - Zend_Session::setId('myid123'); - Zend_Session::regenerateId(); - - $this->assertFalse(Zend_Session::isRegenerated()); - $id = Zend_Session::getId(); - $this->assertTrue($id === 'myid123', - 'getId() reported something different than set via setId("myid123")'); - - Zend_Session::start(); - } else { - // Start session if it's not actually started - // That may happen if Zend_Session::$_unitTestEnabled is turned on while some other - // Unit tests utilize Zend_Session functionality - if (!defined('SID')) { - session_start(); - } - - // only regenerate session id if session has already been started - Zend_Session::regenerateId(); - } - - $this->assertTrue(Zend_Session::isRegenerated()); - - try { - Zend_Session::setId('someo-therid-123'); - $this->fail('No exception was returned when trying to set the session id, after session_start()'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/already.*started/i', $e->getMessage()); - } - } - - /** - * Ensures that setOptions() behaves as expected - * - * @return void - */ - public function testSetOptions() - { - try { - Zend_Session::setOptions(array('foo' => 'break me')); - $this->fail('Expected Zend_Session_Exception not thrown when trying to set an invalid option'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/unknown.option/i', $e->getMessage()); - } - - Zend_Session::setOptions(array('save_path' => '1;777;/tmp')); - - Zend_Session::setOptions(array('save_path' => '2;/tmp')); - - Zend_Session::setOptions(array('save_path' => '/tmp')); - } - - /** - * test for initialisation without parameter; expect instance - * - * @return void - */ - public function testInit() - { - $s = new Zend_Session_Namespace(); - $this->assertTrue($s instanceof Zend_Session_Namespace,'Zend_Session Object not returned'); - } - - /** - * test for initialisation with empty string; expect failure - * - * @return void - */ - public function testInitEmpty() - { - try { - $s = new Zend_Session_Namespace(''); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/non.empty.string/i', $e->getMessage()); - return; - } - $this->fail('No exception was returned when trying to create a namespace having the empty string as ' - . 'its name; expected Zend_Session_Exception'); - } - - /** - * test for initialisation with Session parameter; expect instance - * - * @return void - */ - public function testInitSession() - { - $s = new Zend_Session_Namespace('namespace'); - $this->assertTrue($s instanceof Zend_Session_Namespace, 'Zend_Session_Namespace object not returned'); - } - - /** - * test for initialisation with single instance; expected instance - * - * @return void - */ - public function testInitSingleInstance() - { - $s = new Zend_Session_Namespace('single', true); - try { - $s = new Zend_Session_Namespace('single', true); - } catch (Zend_Session_Exception $e) { - // session namespace 'single' already exists and is set to be the only instance of this namespace - $this->assertRegexp('/already.*exist/i', $e->getMessage()); - return; - } - $this->fail('No exception was returned when creating a duplicate session for the same namespace, ' - . 'even though "single instance" was specified; expected Zend_Session_Exception'); - } - - /** - * test for retrieval of non-existent keys in a valid namespace; expected null value - * returned by getter for an unset key - * - * @return void - */ - public function testNamespaceGetNull() - { - try { - $s = new Zend_Session_Namespace(); - $s->tree = 'fig'; - $dog = $s->dog; - $this->assertTrue($dog === null, "getting value of non-existent key failed to return null ($dog)"); - } catch (Zend_Session_Exception $e) { - $this->fail('Unexpected exception returned when attempting to fetch the value of non-existent key'); - } - } - - /** - * test for existence of namespace; expected true - * - * @return void - */ - public function testNamespaceIsset() - { - try { - $this->assertFalse(Zend_Session::namespaceIsset('trees'), - 'namespaceIsset() should have returned false for a namespace with no keys set'); - $s = new Zend_Session_Namespace('trees'); - $this->assertFalse(Zend_Session::namespaceIsset('trees'), - 'namespaceIsset() should have returned false for a namespace with no keys set'); - $s->cherry = 'bing'; - $this->assertTrue(Zend_Session::namespaceIsset('trees'), - 'namespaceIsset() should have returned true for a namespace with keys set'); - } catch (Zend_Session_Exception $e) { - $this->fail('Unexpected exception returned when attempting to fetch the value of non-existent key'); - } - } - - /** - * test magic methods with improper variable interpolation; expect no exceptions - * - * @return void - */ - public function testMagicMethodsEmpty() - { - $s = new Zend_Session_Namespace(); - $name = 'fruit'; - $s->$name = 'apples'; - $this->assertTrue(isset($s->fruit), 'isset() failed - returned false, but should have been true'); - - try { - $name = ''; // simulate a common bug, where user refers to an unset/empty variable - $s->$name = 'pear'; - $this->fail('No exception was returned when trying to __set() a key named ""; expected ' - . 'Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/non.empty.string/i', $e->getMessage()); - } - - try { - $name = ''; // simulate a common bug, where user refers to an unset/empty variable - $nothing = $s->$name; - $this->fail('No exception was returned when trying to __set() a key named ""; expected ' - . 'Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/non.empty.string/i', $e->getMessage()); - } - - try { - $name = ''; // simulate a common bug, where user refers to an unset/empty variable - if (isset($s->$name)) { true; } - $this->fail('No exception was returned when trying to __set() a key named ""; expected ' - . 'Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/non.empty.string/i', $e->getMessage()); - } - - try { - $name = ''; // simulate a common bug, where user refers to an unset/empty variable - unset($s->$name); - $this->fail('No exception was returned when trying to __set() a key named ""; expected ' - . 'Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/non.empty.string/i', $e->getMessage()); - } - } - - /** - * test for proper separation of namespace "spaces"; expect variables in different namespaces are - * different variables (i.e., not shared values) - * - * @return void - */ - public function testInitNamespaces() - { - $s1 = new Zend_Session_Namespace('namespace1'); - $s1b = new Zend_Session_Namespace('namespace1'); - $s2 = new Zend_Session_Namespace('namespace2'); - $s2b = new Zend_Session_Namespace('namespace2'); - $s3 = new Zend_Session_Namespace(); - $s3b = new Zend_Session_Namespace(); - $s1->a = 'apple'; - $s2->a = 'pear'; - $s3->a = 'orange'; - $this->assertTrue(($s1->a != $s2->a && $s1->a != $s3->a && $s2->a != $s3->a), - 'Zend_Session improperly shared namespaces'); - $this->assertTrue(($s1->a === $s1b->a),'Zend_Session namespace error'); - $this->assertTrue(($s2->a === $s2b->a),'Zend_Session namespace error'); - $this->assertTrue(($s3->a === $s3b->a),'Zend_Session namespace error'); - } - - /** - * test for detection of illegal namespace names; expect exception complaining about name beginning - * with an underscore - * - * @return void - */ - public function testInitNamespaceUnderscore() - { - try { - $s = new Zend_Session_Namespace('_namespace'); - $this->fail('No exception was returned when requesting a namespace having a name beginning with ' - . 'an underscore'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/underscore/i', $e->getMessage()); - } - } - - /** - * test iteration; expect native PHP foreach statement is able to properly iterate all items in a session namespace - * - * @return void - */ - public function testGetIterator() - { - $s = new Zend_Session_Namespace(); - $s->a = 'apple'; - $s->p = 'pear'; - $s->o = 'orange'; - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue($result === 'a === apple;p === pear;o === orange;', - 'iteration over default Zend_Session namespace failed: result="' . $result . '"'); - $s = new Zend_Session_Namespace('namespace'); - $s->g = 'guava'; - $s->p = 'peach'; - $s->p = 'plum'; - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue($result === 'g === guava;p === plum;', - 'iteration over named Zend_Session namespace failed'); - } - - /** - * test locking of the Default namespace (i.e. make namespace readonly); expect exceptions when trying to write to - * locked namespace - * - * @return void - */ - public function testLock() - { - $s = new Zend_Session_Namespace(); - $s->a = 'apple'; - $s->p = 'pear'; - $s->lock(); - try { - $s->o = 'orange'; - $this->fail('No exception was returned when setting a variable in the "Default" namespace, ' - . 'after marking the namespace as read-only; expected Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - // session namespace 'single' already exists and is set to be the only instance of this namespace - $this->assertRegexp('/read.only/i', $e->getMessage()); - } - $s->unlock(); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - $s->lock(); - try { - $s->o = 'orange'; - $this->fail('No exception was returned when setting a variable in the "Default" namespace, ' - . 'after marking the namespace as read-only; expected Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - // session namespace 'single' already exists and is set to be the only instance of this namespace - $this->assertRegexp('/read.only/i', $e->getMessage()); - } - } - - /** - * test locking of named namespaces (i.e. make namespace readonly); expect exceptions when trying to write - * to locked namespace - * - * @return void - */ - public function testLockNamespace() - { - $s = new Zend_Session_Namespace('somenamespace'); - $s->a = 'apple'; - $s->p = 'pear'; - $s->lock(); - try { - $s->o = 'orange'; - $this->fail('No exception was returned when setting a variable in the "Default" namespace, ' - . 'after marking the namespace as read-only; expected Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - // session namespace 'single' already exists and is set to be the only instance of this namespace - $this->assertRegexp('/read.only/i', $e->getMessage()); - } - $s = new Zend_Session_Namespace('somenamespace'); - $s2 = new Zend_Session_Namespace('mayday'); - $s2->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - $s = new Zend_Session_Namespace('somenamespace'); - $s->lock(); - $s2->unlock(); - try { - $s->o = 'orange'; - $this->fail('No exception was returned when setting a variable in the "Default" namespace, ' - . 'after marking the namespace as read-only; expected Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/read.only/i', $e->getMessage()); - } - } - - /** - * test unlocking of the Default namespace (i.e. make namespace readonly); expected no exceptions - * - * @return void - */ - public function testUnlock() - { - $s = new Zend_Session_Namespace(); - try { - $s->a = 'apple'; - $s->p = 'pear'; - $s->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'prune'; - $s->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - } catch (Zend_Session_Exception $e) { - $this->fail('Unexpected exception when writing to namespaces after unlocking it.'); - } - } - - /** - * test combinations of locking and unlocking of the Default namespace (i.e. make namespace readonly) - * expected no exceptions - * - * @return void - */ - public function testUnLockAll() - { - $sessions = array('one', 'two', 'default', 'three'); - foreach ($sessions as $namespace) { - $s = new Zend_Session_Namespace($namespace); - $s->a = 'apple'; - $s->p = 'pear'; - $s->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'prune'; - $s->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - $s->lock(); - $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (not locked)'); - try { - $s->p = 'prune'; - $s->f = 'fig'; - $this->fail('No exception was returned when setting a variable in the "Default" namespace, ' - . 'after marking the namespace as read-only; expected Zend_Session_Exception'); - } catch (Zend_Session_Exception $e) { - $this->assertRegexp('/read.only/i', $e->getMessage()); - } - } - $s->unlockAll(); - foreach ($sessions as $namespace) { - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->p = 'pear'; - $s->f = 'fig'; - $s->l = 'lime'; - } - } - - /** - * test isLocked() unary comparison operator under various situations; expect lock status remains synchronized - * with last call to unlock() or lock(); expect no exceptions - * - * @return void - */ - public function testIsLocked() - { - try { - $s = new Zend_Session_Namespace(); - $s->a = 'apple'; - $s->p = 'pear'; - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->lock(); - $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (unlocked)'); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'prune'; - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->lock(); - $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (unlocked)'); - $s->unlock(); - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - } catch (Zend_Session_Exception $e) { - $this->fail('Unexpected exception when writing to named namespaces after unlocking them.'); - } - } - - /** - * test unlocking of named namespaces (i.e., make namespace readonly); expect no exceptions - * - * @return void - */ - public function testUnLockNamespace() - { - $s = new Zend_Session_Namespace('somenamespace'); - try { - $s->a = 'apple'; - $s->p = 'pear'; - $s->lock(); - $s2 = new Zend_Session_Namespace('mayday'); - $s2->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'prune'; - $s->lock(); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - } catch (Zend_Session_Exception $e) { - $this->fail('Unexpected exception when writing to named namespaces after unlocking them.'); - } - } - - /** - * test isLocked() unary comparison operator under various situations; expect lock status remains synchronized with - * last call to unlock() or lock(); expect no exceptions - * - * @return void - */ - public function testIsLockedNamespace() - { - try { - $s = new Zend_Session_Namespace('somenamespace'); - $s->a = 'apple'; - $s->p = 'pear'; - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->lock(); - $s2 = new Zend_Session_Namespace('mayday'); - $s2->lock(); - $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (unlocked)'); - $s->unlock(); - $s->o = 'orange'; - $s->p = 'prune'; - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->lock(); - $s2->unlock(); - $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (unlocked)'); - $s->unlock(); - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - $s->o = 'orange'; - $s->p = 'papaya'; - $s->c = 'cherry'; - $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)'); - } catch (Zend_Session_Exception $e) { - $this->fail('Unexpected exception when writing to named namespaces after unlocking them.'); - } - } - - /** - * test unsetAll keys in default namespace; expect namespace contains only keys not unset() - * - * @return void - */ - public function testUnsetAll() - { - $s = new Zend_Session_Namespace(); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "tearDown failure, found keys in default namespace: '$result'"); - $s->a = 'apple'; - $s->lock(); - $s->unlock(); - $s->p = 'papaya'; - $s->c = 'cherry'; - $s = new Zend_Session_Namespace(); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue($result === 'a === apple;p === papaya;c === cherry;', - "unsetAll() setup for test failed: '$result'"); - $s->unsetAll(); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "unsetAll() did not remove keys from namespace: '$result'"); - } - - /** - * test unset() keys in default namespace; expect namespace contains only keys not unset() - * - * @return void - */ - public function testUnset() - { - $s = new Zend_Session_Namespace(); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "tearDown failure, found keys in default namespace: '$result'"); - $s->a = 'apple'; - $s->lock(); - $s->unlock(); - $s->p = 'papaya'; - $s->c = 'cherry'; - $s = new Zend_Session_Namespace(); - foreach ($s->getIterator() as $key => $val) { - unset($s->$key); - } - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "unsetAll() did not remove keys from namespace: '$result'"); - } - - - /** - * test unset() keys in non-default namespace; expect namespace contains only keys not unset() - * - * @return void - */ - public function testUnsetNamespace() - { - $s = new Zend_Session_Namespace('foobar'); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "tearDown failure, found keys in default namespace: '$result'"); - $s->a = 'apple'; - $s->lock(); - $s->unlock(); - $s->p = 'papaya'; - $s->c = 'cherry'; - $s = new Zend_Session_Namespace('foobar'); - foreach ($s->getIterator() as $key => $val) { - unset($s->$key); - } - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "unsetAll() did not remove keys from namespace: '$result'"); - } - - /** - * test unsetAll keys in default namespace; expect namespace will contain no keys - * - * @return void - */ - public function testUnsetAllNamespace() - { - $s = new Zend_Session_Namespace('somenamespace'); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "tearDown failure, found keys in 'somenamespace' namespace: '$result'"); - $s->a = 'apple'; - $s->lock(); - $s->unlock(); - $s->p = 'papaya'; - $s->c = 'cherry'; - $s = new Zend_Session_Namespace('somenamespace'); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue($result === 'a === apple;p === papaya;c === cherry;', - "unsetAll() setup for test failed: '$result'"); - $s->unsetAll(); - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - $this->assertTrue(empty($result), "unsetAll() did not remove keys from namespace: '$result'"); - } - - /** - * test expiration of namespaces and namespace variables by seconds; expect expiration of specified keys/namespace - * - * @return void - */ - public function testSetExpirationSeconds() - { - // Calculate common script execution time - $startTime = time(); - exec($this->_script, $result, $returnValue); - $execTime = time() - $startTime; - - $s = new Zend_Session_Namespace('expireAll'); - $s->a = 'apple'; - $s->p = 'pear'; - $s->o = 'orange'; - $s->setExpirationSeconds($execTime*2 + 5); - - Zend_Session::regenerateId(); - $id = Zend_Session::getId(); - - sleep(4); // not long enough for things to expire - - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id expireAll", $result, $returnValue); - session_start(); // resume artificially suspended session - - $result = $this->sortResult($result); - $expect = ';a === apple;o === orange;p === pear'; - $this->assertTrue($result === $expect, - "iteration over default Zend_Session namespace failed; expecting result === '$expect', but got '$result'"); - - sleep($execTime*2 + 2); // long enough for things to expire (total of $execTime*2 + 6 seconds waiting, but expires in $execTime*2 + 5) - - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id expireAll", $result, $returnValue); - session_start(); // resume artificially suspended session - - $this->assertNull(array_pop($result)); - - // We could split this into a separate test, but actually, if anything leftover from above - // contaminates the tests below, that is also a bug that we want to know about. - $s = new Zend_Session_Namespace('expireGuava'); - $s->setExpirationSeconds(5, 'g'); // now try to expire only 1 of the keys in the namespace - $s->g = 'guava'; - $s->p = 'peach'; - $s->p = 'plum'; - - sleep(6); // not long enough for things to expire - - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id expireGuava", $result, $returnValue); - session_start(); // resume artificially suspended session - - $result = $this->sortResult($result); - $this->assertTrue($result === ';p === plum', - "iteration over named Zend_Session namespace failed (result=$result)"); - } - - /** - * test expiration of namespaces by hops; expect expiration of specified namespace in the proper number of hops - * - * @return void - */ - public function testSetExpireSessionHops() - { - $s = new Zend_Session_Namespace('expireAll'); - $s->a = 'apple'; - $s->p = 'pear'; - $s->o = 'orange'; - $expireBeforeHop = 3; - $s->setExpirationHops($expireBeforeHop); - - $id = session_id(); - - for ($i = 1; $i <= ($expireBeforeHop + 2); $i++) { - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id expireAll", $result, $returnValue); - session_start(); // resume artificially suspended session - - $result = $this->sortResult($result); - if ($i > $expireBeforeHop) { - $this->assertTrue($result === '', - "iteration over default Zend_Session namespace failed (result='$result'; hop #$i)"); - } else { - $this->assertTrue($result === ';a === apple;o === orange;p === pear', - "iteration over default Zend_Session namespace failed (result='$result'; hop #$i)"); - } - } - } - - /** - * test expiration of namespace variables by hops; expect expiration of specified keys in the proper number of hops - * - * @return void - */ - public function testSetExpireSessionVarsByHops1() - { - $this->setExpireSessionVarsByHops(); - } - - /** - * sanity check .. we should be able to repeat this test without problems - * - * @return void - */ - public function testSetExpireSessionVarsByHops2() - { - $this->setExpireSessionVarsByHops(); - } - - /** - * test expiration of namespace variables by hops; expect expiration of specified keys in the proper number of hops - * - * @return void - */ - public function setExpireSessionVarsByHops() - { - $s = new Zend_Session_Namespace('expireGuava'); - $expireBeforeHop = 4; - $s->setExpirationHops($expireBeforeHop, 'g'); - $s->g = 'guava'; - $s->p = 'peach'; - $s->p = 'plum'; - - $id = session_id(); - - for ($i = 1; $i <= ($expireBeforeHop + 2); $i++) { - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id expireGuava", $result); - session_start(); // resume artificially suspended session - - $result = $this->sortResult($result); - if ($i > $expireBeforeHop) { - $this->assertTrue($result === ';p === plum', - "iteration over named Zend_Session namespace failed (result='$result'; hop #$i)"); - } else { - $this->assertTrue($result === ';g === guava;p === plum', - "iteration over named Zend_Session namespace failed (result='$result'; hop #$i)"); - } - } - } - - /** - * @todo PHP 5.2.1 is required (fixes a bug with magic __get() returning by reference) - * @see http://framework.zend.com/issues/browse/ZF-800 - */ - public function testArrays() - { - $this->markTestIncomplete(); - $s = new Zend_Session_Namespace('aspace'); - $id = Zend_Session::getId(); - $this->assertSame($id, session_id()); - $s->top = 'begin'; - - session_write_close(); // release session so process below can use it - exec("$this->_script setArray $id aspace 1 2 3 4 5", $result); - exec("$this->_script getArray $id aspace", $result); - session_start(); // resume artificially suspended session - - $result = array_pop($result); - $expect = 'top === begin;astring === happy;someArray === Array;(;[0]=>aspace;[1]=>1;[2]=>2;[3]=>3;[4]=>4;[5]=>5;[bee]=>honey;[ant]=>sugar;[dog]=>cat;);;serializedArray === a:8:{i:0;s:6:"aspace";i:1;s:1:"1";i:2;s:1:"2";i:3;s:1:"3";i:4;s:1:"4";i:5;s:1:"5";s:3:"ant";s:5:"sugar";s:3:"dog";s:3:"cat";};'; - $this->assertTrue($result === $expect, - "iteration over default Zend_Session namespace failed; expecting result ===\n$expect\n, but got\n$result\n)"); - } - - /** - * test expiration of namespace variables by hops; expect expiration of specified keys in the proper number of hops - * - * @return void - */ - public function testSetExpireSessionVarsByHopsOnUse() - { - $s = new Zend_Session_Namespace('expireGuava'); - $expireBeforeHop = 2; - $s->setExpirationHops($expireBeforeHop, 'g', true); // only count a hop, when namespace is used - $s->g = 'guava'; - $s->p = 'peach'; - $s->p = 'plum'; - - $id = session_id(); - - // we are not accessing (using) the "expireGuava" namespace, so these hops should have no effect - for ($i = 1; $i <= ($expireBeforeHop + 2); $i++) { - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id notused", $result); - session_start(); // resume artificially suspended session - - $result = $this->sortResult($result); - $this->assertTrue($result === '', - "iteration over named Zend_Session namespace failed (result='$result'; hop #$i)"); - } - - for ($i = 1; $i <= ($expireBeforeHop + 2); $i++) { - session_write_close(); // release session so process below can use it - exec("$this->_script expireAll $id expireGuava", $result); - session_start(); // resume artificially suspended session - - $result = $this->sortResult($result); - if ($i > $expireBeforeHop) { - $expect = ';p === plum'; - $this->assertTrue($result === $expect, - "unexpected results iterating over named Zend_Session namespace (result='$result'; expected '$expect'; hop #$i)"); - } else { - $expect = ';g === guava;p === plum'; - $this->assertTrue($result === $expect, - "unexpected results iterating over named Zend_Session namespace (result='$result'; expected '$expect'; hop #$i)"); - } - } - - // Do not destroy session since it still may be used by other tests - // Zend_Session::destroy(); - } -} diff --git a/tests/Zend/Session/SessionTestHelper.php b/tests/Zend/Session/SessionTestHelper.php deleted file mode 100644 index 30d7aafcfe17645aa08086ac5c2e7a8cd6362700..0000000000000000000000000000000000000000 --- a/tests/Zend/Session/SessionTestHelper.php +++ /dev/null @@ -1,164 +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_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SessionTestHelper.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - - -/** - * @see Zend_Session - */ -require_once 'Zend/Session.php'; - - -/** - * White box testing for Zend_Session - * - * @category Zend - * @package Zend_Session - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @see http://en.wikipedia.org/wiki/White_box_testing - */ -class Zend_Session_TestHelper -{ - /** - * Runs the test method specified via command line arguments. - * - * @param array $argv - * @return integer - */ - public function run(array $argv) - { - if (!isset($argv[0]) || !isset($argv[1])) { - echo "Usage: {$argv[0]} <test name>\n"; - return 1; - } - - $testMethod = 'do' . ucfirst($argv[1]); - - if (!method_exists($this, $testMethod)) { - echo "Invalid test: '{$argv[1]}'\n"; - return 2; - } - - array_shift($argv); - array_shift($argv); - - return $this->$testMethod($argv); - } - - /** - * @param array $args - * @return integer Always returns zero. - */ - public function doExpireAll(array $args) - { - Zend_Session::setOptions(array('remember_me_seconds' => 15, 'gc_probability' => 2)); - session_id($args[0]); - if (isset($args[1]) && !empty($args[1])) { - $s = new Zend_Session_Namespace($args[1]); - } - else { - $s = new Zend_Session_Namespace(); - } - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === $val;"; - } - Zend_Session::expireSessionCookie(); - Zend_Session::writeClose(); - echo $result; - - return 0; - } - - /** - * @param array $args - * @return integer Always returns zero. - */ - public function doSetArray(array $args) - { - $GLOBALS['fpc'] = 'set'; - session_id($args[0]); - $s = new Zend_Session_Namespace($args[1]); - array_shift($args); - $s->astring = 'happy'; - - // works, even for broken versions of PHP - // $s->someArray = array( & $args ) ; - // $args['OOOOOOOOOOOOOOOO'] = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYY'; - - $s->someArray = $args; - $s->someArray['bee'] = 'honey'; // Repeating this line twice "solves" the problem for some versions of PHP, - $s->someArray['bee'] = 'honey'; // but PHP 5.2.1 has the real fix for ZF-800. - $s->someArray['ant'] = 'sugar'; - $s->someArray['dog'] = 'cat'; - // file_put_contents('out.sessiontest.set', (str_replace(array("\n", ' '),array(';',''), print_r($_SESSION, true))) ); - $s->serializedArray = serialize($args); - - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === ". (print_r($val,true)) .';'; - } - - Zend_Session::writeClose(); - - return 0; - } - - /** - * @param array $args - * @return integer Always returns zero. - */ - public function doGetArray(array $args) - { - $GLOBALS['fpc'] = 'get'; - session_id($args[0]); - if (isset($args[1]) && !empty($args[1])) { - $s = new Zend_Session_Namespace($args[1]); - } - else { - $s = new Zend_Session_Namespace(); - } - $result = ''; - foreach ($s->getIterator() as $key => $val) { - $result .= "$key === ". (str_replace(array("\n", ' '),array(';',''), print_r($val, true))) .';'; - } - // file_put_contents('out.sesstiontest.get', print_r($s->someArray, true)); - Zend_Session::writeClose(); - echo $result; - - return 0; - } -} - - -$testHelper = new Zend_Session_TestHelper(); - -exit($testHelper->run($argv)); - diff --git a/tests/Zend/Soap/AllTests.php b/tests/Zend/Soap/AllTests.php deleted file mode 100644 index 7ae84996f68109e93eb46b83dfce98986be09d26..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/AllTests.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Soap_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Soap/AutoDiscoverTest.php'; -require_once 'Zend/Soap/ClientTest.php'; -require_once 'Zend/Soap/ServerTest.php'; -require_once 'Zend/Soap/WsdlTest.php'; - -class Zend_Soap_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Soap'); - - $suite->addTestSuite('Zend_Soap_AutoDiscoverTest'); - $suite->addTestSuite('Zend_Soap_ClientTest'); - $suite->addTestSuite('Zend_Soap_ServerTest'); - $suite->addTestSuite('Zend_Soap_WsdlTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Soap_AllTests::main') { - Zend_Soap_AllTests::main(); -} diff --git a/tests/Zend/Soap/AutoDiscoverTest.php b/tests/Zend/Soap/AutoDiscoverTest.php deleted file mode 100644 index e8604cd2d1e3a2fb94a084c1c15e44bc90c14dba..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/AutoDiscoverTest.php +++ /dev/null @@ -1,321 +0,0 @@ -<?php -/** - * @package Zend_Soap - * @subpackage UnitTests - */ - -/** PHPUnit Test Case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Soap_AutoDiscover */ -require_once 'Zend/Soap/AutoDiscover.php'; - - -/** - * Test cases for Zend_Soap_AutoDiscover - * - * @package Zend_Soap - * @subpackage UnitTests - */ -class Zend_Soap_AutoDiscoverTest extends PHPUnit_Framework_TestCase -{ - function testSetClass() - { - if (!isset($_SERVER['HTTP_HOST'])) { - $_SERVER['HTTP_HOST'] = 'localhost'; - } - if (!isset($_SERVER['SCRIPT_NAME'])) { - $_SERVER['SCRIPT_NAME'] = '/my_script.php'; - } - $scriptUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; - - - $server = new Zend_Soap_AutoDiscover(); - $server->setClass('Zend_Soap_AutoDiscover_Test'); - $dom = new DOMDocument(); - ob_start(); - $server->handle(); - $dom->loadXML(ob_get_clean()); - $wsdl = '<?xml version="1.0"?>' . PHP_EOL - . '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="' . $scriptUri . '" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="Zend_Soap_AutoDiscover_Test" ' - . 'targetNamespace="' . $scriptUri . '">' - . '<portType name="Zend_Soap_AutoDiscover_TestPort">' - . '<operation name="testFunc1">' - . '<input message="tns:testFunc1Request"/>' - . '<output message="tns:testFunc1Response"/>' - . '</operation>' - . '<operation name="testFunc2">' - . '<input message="tns:testFunc2Request"/>' - . '<output message="tns:testFunc2Response"/>' - . '</operation>' - . '<operation name="testFunc3">' - . '<input message="tns:testFunc3Request"/>' - . '<output message="tns:testFunc3Response"/>' - . '</operation><operation name="testFunc4">' - . '<input message="tns:testFunc4Request"/>' - . '<output message="tns:testFunc4Response"/>' - . '</operation>' - . '</portType>' - . '<binding name="Zend_Soap_AutoDiscover_TestBinding" type="tns:Zend_Soap_AutoDiscover_TestPort">' - . '<soap:operation soapAction="' . $scriptUri . '#testFunc4"/>' - . '<soap:operation soapAction="' . $scriptUri . '#testFunc3"/>' - . '<soap:operation soapAction="' . $scriptUri . '#testFunc2"/>' - . '<soap:operation soapAction="' . $scriptUri . '#testFunc1"/>' - . '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>' - . '<operation name="testFunc1">' - . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>' - . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>' - . '</operation>' - . '<operation name="testFunc2">' - . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>' - . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>' - . '</operation>' - . '<operation name="testFunc3">' - . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>' - . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>' - . '</operation>' - . '<operation name="testFunc4">' - . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>' - . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>' - . '</operation>' - . '</binding>' - . '<service name="Zend_Soap_AutoDiscover_TestService">' - . '<port name="Zend_Soap_AutoDiscover_TestPort" binding="tns:Zend_Soap_AutoDiscover_TestBinding">' - . '<soap:address location="' . $scriptUri . '"/>' - . '</port>' - . '</service>' - . '<message name="testFunc1Request"/>' - . '<message name="testFunc1Response"><part name="testFunc1Return" type="xsd:string"/></message>' - . '<message name="testFunc2Request"><part name="who" type="xsd:string"/></message>' - . '<message name="testFunc2Response"><part name="testFunc2Return" type="xsd:string"/></message>' - . '<message name="testFunc3Request"><part name="who" type="xsd:string"/><part name="when" type="xsd:int"/></message>' - . '<message name="testFunc3Response"><part name="testFunc3Return" type="xsd:string"/></message>' - . '<message name="testFunc4Request"/>' - . '<message name="testFunc4Response"><part name="testFunc4Return" type="xsd:string"/></message>' - . '</definitions>' . PHP_EOL; - - $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertEquals($wsdl, $dom->saveXML()); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(dirname(__FILE__).'/_files/setclass.wsdl'); - } - - function testAddFunctionSimple() - { - if (!isset($_SERVER['HTTP_HOST'])) { - $_SERVER['HTTP_HOST'] = 'localhost'; - } - if (!isset($_SERVER['SCRIPT_NAME'])) { - $_SERVER['SCRIPT_NAME'] = '/my_script.php'; - } - $scriptUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; - - $server = new Zend_Soap_AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $dom = new DOMDocument(); - ob_start(); - $server->handle(); - $dom->loadXML(ob_get_contents()); - $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); - - ob_end_clean(); - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; - - $wsdl = '<?xml version="1.0"?> -<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" name="' .$name. '" targetNamespace="' . $scriptUri . '"><portType name="' .$name. 'Port"><operation name="Zend_Soap_AutoDiscover_TestFunc"><input message="tns:Zend_Soap_AutoDiscover_TestFuncRequest"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncResponse"/></operation></portType><binding name="' .$name. 'Binding" type="tns:' .$name. 'Port"><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="Zend_Soap_AutoDiscover_TestFunc"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation></binding><service name="' .$name. 'Service"><port name="' .$name. 'Port" binding="tns:' .$name. 'Binding"><soap:address location="' . $scriptUri . '"/></port></service><message name="Zend_Soap_AutoDiscover_TestFuncRequest"><part name="who" type="xsd:string"/></message><message name="Zend_Soap_AutoDiscover_TestFuncResponse"><part name="Zend_Soap_AutoDiscover_TestFuncReturn" type="xsd:string"/></message></definitions> -'; - $this->assertEquals($wsdl, $dom->saveXML(), "Bad WSDL generated"); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); - } - - function testAddFunctionMultiple() - { - if (!isset($_SERVER['HTTP_HOST'])) { - $_SERVER['HTTP_HOST'] = 'localhost'; - } - if (!isset($_SERVER['SCRIPT_NAME'])) { - $_SERVER['SCRIPT_NAME'] = '/my_script.php'; - } - $scriptUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; - - $server = new Zend_Soap_AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc2'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc3'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc4'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc5'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc6'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc7'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc9'); - - $dom = new DOMDocument(); - ob_start(); - $server->handle(); - $dom->loadXML(ob_get_contents()); - $dom->save(dirname(__FILE__).'/_files/addfunction2.wsdl'); - - ob_end_clean(); - - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; - - $wsdl = '<?xml version="1.0"?> -<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" name="' .$name. '" targetNamespace="' . $scriptUri . '"><portType name="' .$name. 'Port"><operation name="Zend_Soap_AutoDiscover_TestFunc"><input message="tns:Zend_Soap_AutoDiscover_TestFuncRequest"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncResponse"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc2"><input message="tns:Zend_Soap_AutoDiscover_TestFunc2Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc2Response"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc3"><input message="tns:Zend_Soap_AutoDiscover_TestFunc3Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc3Response"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc4"><input message="tns:Zend_Soap_AutoDiscover_TestFunc4Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc4Response"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc5"><input message="tns:Zend_Soap_AutoDiscover_TestFunc5Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc5Response"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc6"><input message="tns:Zend_Soap_AutoDiscover_TestFunc6Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc6Response"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc7"><input message="tns:Zend_Soap_AutoDiscover_TestFunc7Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc7Response"/></operation><operation name="Zend_Soap_AutoDiscover_TestFunc9"><input message="tns:Zend_Soap_AutoDiscover_TestFunc9Request"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc9Response"/></operation></portType><binding name="' .$name. 'Binding" type="tns:' .$name. 'Port"><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc9"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc7"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc6"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc5"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc4"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc3"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc2"/><soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="Zend_Soap_AutoDiscover_TestFunc"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc2"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc3"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc4"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc5"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc6"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc7"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="Zend_Soap_AutoDiscover_TestFunc9"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation></binding><service name="' .$name. 'Service"><port name="' .$name. 'Port" binding="tns:' .$name. 'Binding"><soap:address location="' . $scriptUri . '"/></port></service><message name="Zend_Soap_AutoDiscover_TestFuncRequest"><part name="who" type="xsd:string"/></message><message name="Zend_Soap_AutoDiscover_TestFuncResponse"><part name="Zend_Soap_AutoDiscover_TestFuncReturn" type="xsd:string"/></message><message name="Zend_Soap_AutoDiscover_TestFunc2Request"/><message name="Zend_Soap_AutoDiscover_TestFunc3Request"/><message name="Zend_Soap_AutoDiscover_TestFunc3Response"><part name="Zend_Soap_AutoDiscover_TestFunc3Return" type="xsd:boolean"/></message><message name="Zend_Soap_AutoDiscover_TestFunc4Request"/><message name="Zend_Soap_AutoDiscover_TestFunc4Response"><part name="Zend_Soap_AutoDiscover_TestFunc4Return" type="xsd:boolean"/></message><message name="Zend_Soap_AutoDiscover_TestFunc5Request"/><message name="Zend_Soap_AutoDiscover_TestFunc5Response"><part name="Zend_Soap_AutoDiscover_TestFunc5Return" type="xsd:int"/></message><message name="Zend_Soap_AutoDiscover_TestFunc6Request"/><message name="Zend_Soap_AutoDiscover_TestFunc6Response"><part name="Zend_Soap_AutoDiscover_TestFunc6Return" type="xsd:string"/></message><message name="Zend_Soap_AutoDiscover_TestFunc7Request"/><message name="Zend_Soap_AutoDiscover_TestFunc7Response"><part name="Zend_Soap_AutoDiscover_TestFunc7Return" type="soap-enc:Array"/></message><message name="Zend_Soap_AutoDiscover_TestFunc9Request"><part name="foo" type="xsd:string"/><part name="bar" type="xsd:string"/></message><message name="Zend_Soap_AutoDiscover_TestFunc9Response"><part name="Zend_Soap_AutoDiscover_TestFunc9Return" type="xsd:string"/></message></definitions> -'; - $this->assertEquals($wsdl, $dom->saveXML(), "Bad WSDL generated"); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(dirname(__FILE__).'/_files/addfunction2.wsdl'); - } -} - -/* Test Functions */ - -/** - * Test Function - * - * @param string $arg - * @return string - */ -function Zend_Soap_AutoDiscover_TestFunc($who) -{ - return "Hello $who"; -} - -/** - * Test Function 2 - */ -function Zend_Soap_AutoDiscover_TestFunc2() -{ - return "Hello World"; -} - -/** - * Return false - * - * @return bool - */ -function Zend_Soap_AutoDiscover_TestFunc3() -{ - return false; -} - -/** - * Return true - * - * @return bool - */ -function Zend_Soap_AutoDiscover_TestFunc4() -{ - return true; -} - -/** - * Return integer - * - * @return int - */ -function Zend_Soap_AutoDiscover_TestFunc5() -{ - return 123; -} - -/** - * Return string - * - * @return string - */ -function Zend_Soap_AutoDiscover_TestFunc6() -{ - return "string"; -} - -/** - * Return array - * - * @return array - */ -function Zend_Soap_AutoDiscover_TestFunc7() -{ - return array('foo' => 'bar', 'baz' => true, 1 => false, 'bat' => 123); -} - -/** - * Return Object - * - * @return StdClass - */ -function Zend_Soap_AutoDiscover_TestFunc8() -{ - $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false); - return $return; -} - -/** - * Multiple Args - * - * @param string $foo - * @param string $bar - * @return string - */ -function Zend_Soap_AutoDiscover_TestFunc9($foo, $bar) -{ - return "$foo $bar"; -} - -/** - * Test Class - */ -class Zend_Soap_AutoDiscover_Test { - /** - * Test Function 1 - * - * @return string - */ - function testFunc1() - { - return "Hello World"; - } - - /** - * Test Function 2 - * - * @param string $who Some Arg - * @return string - */ - function testFunc2($who) - { - return "Hello $who!"; - } - - /** - * Test Function 3 - * - * @param string $who Some Arg - * @param int $when Some - * @return string - */ - function testFunc3($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 4 - * - * @return string - */ - static function testFunc4() - { - return "I'm Static!"; - } -} diff --git a/tests/Zend/Soap/ClientTest.php b/tests/Zend/Soap/ClientTest.php deleted file mode 100644 index 94dcfbb9758cb9d37ff6741f84328dd6d6cdc5bf..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/ClientTest.php +++ /dev/null @@ -1,390 +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 UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** PHPUnit Test Case */ -// // // require_once "PHPUnit/Framework/TestCase.php"; - -/** Zend_Soap_Server */ -require_once 'Zend/Soap/Server.php'; - -/** Zend_Soap_Client */ -require_once 'Zend/Soap/Client.php'; - -/** - * Zend_Soap_Client - * - * @category Zend - * @package UnitTests - * @version $Id: ServerTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ -class Zend_Soap_ClientTest extends PHPUnit_Framework_TestCase -{ - public function testSetOptions() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - /************************************************************* - * ------ Test WSDL mode options ----------------------------- - *************************************************************/ - $client = new Zend_Soap_Client(); - - $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); - - $nonWsdlOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), - 'encoding' => 'ISO-8859-1', - 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'use' => SOAP_ENCODED, - 'style' => SOAP_RPC, - - 'login' => 'http_login', - 'password' => 'http_password', - - 'proxy_host' => 'proxy.somehost.com', - 'proxy_port' => 8080, - 'proxy_login' => 'proxy_login', - 'proxy_password' => 'proxy_password', - - 'local_cert' => dirname(__FILE__).'/_files/cert_file', - 'passphrase' => 'some pass phrase', - - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); - - $client->setOptions($nonWsdlOptions); - $this->assertTrue($client->getOptions() == $nonWsdlOptions); - - - /************************************************************* - * ------ Test non-WSDL mode options ----------------------------- - *************************************************************/ - $client1 = new Zend_Soap_Client(); - - $this->assertTrue($client1->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); - - $wsdlOptions = array('soap_version' => SOAP_1_1, - 'wsdl' => dirname(__FILE__).'/_files/wsdl_example.wsdl', - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), - 'encoding' => 'ISO-8859-1', - - 'login' => 'http_login', - 'password' => 'http_password', - - 'proxy_host' => 'proxy.somehost.com', - 'proxy_port' => 8080, - 'proxy_login' => 'proxy_login', - 'proxy_password' => 'proxy_password', - - 'local_cert' => dirname(__FILE__).'/_files/cert_file', - 'passphrase' => 'some pass phrase', - - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); - - $client1->setOptions($wsdlOptions); - $this->assertTrue($client1->getOptions() == $wsdlOptions); - } - - public function testGetOptions() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $client = new Zend_Soap_Client(); - - $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); - - $options = array('soap_version' => SOAP_1_1, - 'wsdl' => dirname(__FILE__).'/_files/wsdl_example.wsdl', - - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), - 'encoding' => 'ISO-8859-1', - 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'use' => SOAP_ENCODED, - 'style' => SOAP_RPC, - - 'login' => 'http_login', - 'password' => 'http_password', - - 'proxy_host' => 'proxy.somehost.com', - 'proxy_port' => 8080, - 'proxy_login' => 'proxy_login', - 'proxy_password' => 'proxy_password', - - 'local_cert' => dirname(__FILE__).'/_files/cert_file', - 'passphrase' => 'some pass phrase', - - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); - - $client->setOptions($options); - $this->assertTrue($client->getOptions() == $options); - } - - public function testGetFunctions() - { - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); - - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - - $this->assertTrue($client->getFunctions() == array('string testFunc1()', - 'string testFunc2(string $who)', - 'string testFunc3(string $who, int $when)', - 'string testFunc4()')); - } - - /** - * @todo Implement testGetTypes(). - */ - public function testGetTypes() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - // Remove the following line when you implement this test. - $this->markTestIncomplete( - "This test has not been implemented yet." - ); - } - - public function testGetLastRequest() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); - - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - - // Perform request - $client->testFunc2('World'); - - $expectedRequest = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:enc="http://www.w3.org/2003/05/soap-encoding">' - . '<env:Body>' - . '<env:testFunc2 env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">' - . '<who xsi:type="xsd:string">World</who>' - . '</env:testFunc2>' - . '</env:Body>' - . '</env:Envelope>' . PHP_EOL; - - $this->assertEquals($client->getLastRequest(), $expectedRequest); - } - - public function testGetLastResponse() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); - - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - - // Perform request - $client->testFunc2('World'); - - $expectedResponse = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:enc="http://www.w3.org/2003/05/soap-encoding">' - . '<env:Body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc">' - . '<env:testFunc2Response env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">' - . '<rpc:result>testFunc2Return</rpc:result>' - . '<testFunc2Return xsi:type="xsd:string">Hello World!</testFunc2Return>' - . '</env:testFunc2Response>' - . '</env:Body>' - . '</env:Envelope>' . PHP_EOL; - - $this->assertEquals($client->getLastResponse(), $expectedResponse); - } - - public function testCallInvoke() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); - - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - - $this->assertEquals($client->testFunc2('World'), 'Hello World!'); - } -} - - -/** Test Class */ -class Zend_Soap_Client_TestClass { - /** - * Test Function 1 - * - * @return string - */ - function testFunc1() - { - return "Hello World"; - } - - /** - * Test Function 2 - * - * @param string $who Some Arg - * @return string - */ - function testFunc2($who) - { - return "Hello $who!"; - } - - /** - * Test Function 3 - * - * @param string $who Some Arg - * @param int $when Some - * @return string - */ - function testFunc3($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 4 - * - * @return string - */ - static function testFunc4() - { - return "I'm Static!"; - } -} - -/** Test class 2 */ -class Zend_Soap_Client_TestData1 { - /** - * Property1 - * - * @var string - */ - public $property1; - - /** - * Property2 - * - * @var float - */ - public $property2; -} - -/** Test class 2 */ -class Zend_Soap_Client_TestData2 { - /** - * Property1 - * - * @var integer - */ - public $property1; - - /** - * Property1 - * - * @var float - */ - public $property2; -} - - -/* Test Functions */ - -/** - * Test Function - * - * @param string $arg - * @return string - */ -function Zend_Soap_Client_TestFunc1($who) -{ - return "Hello $who"; -} - -/** - * Test Function 2 - */ -function Zend_Soap_Client_TestFunc2() -{ - return "Hello World"; -} - -/** - * Return false - * - * @return bool - */ -function Zend_Soap_Client_TestFunc3() -{ - return false; -} - -/** - * Return true - * - * @return bool - */ -function Zend_Soap_Client_TestFunc4() -{ - return true; -} - -/** - * Return integer - * - * @return int - */ -function Zend_Soap_Client_TestFunc5() -{ - return 123; -} - -/** - * Return string - * - * @return string - */ -function Zend_Soap_Client_TestFunc6() -{ - return "string"; -} - diff --git a/tests/Zend/Soap/ServerTest.php b/tests/Zend/Soap/ServerTest.php deleted file mode 100644 index d001c4691c27484deb5d07b4e6ea14e0f5e99af0..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/ServerTest.php +++ /dev/null @@ -1,851 +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 UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** PHPUnit Test Case */ -// // // require_once "PHPUnit/Framework/TestCase.php"; - -/** Zend_Soap_Server */ -require_once 'Zend/Soap/Server.php'; - -/** - * Zend_Soap_Server - * - * @category Zend - * @package UnitTests - * @uses Zend_Server_Interface - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ServerTest.php 10034 2008-07-10 16:51:08Z alexander $ - */ -class Zend_Soap_ServerTest extends PHPUnit_Framework_TestCase -{ - public function testSetOptions() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); - - $options = array('soap_version' => SOAP_1_1, - 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2',), - 'encoding' => 'ISO-8859-1', - 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' - ); - $server->setOptions($options); - - $this->assertTrue($server->getOptions() == $options); - } - - public function testGetOptions() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); - - $options = array('soap_version' => SOAP_1_1, - 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' - ); - $server->setOptions($options); - - $this->assertTrue($server->getOptions() == $options); - } - - public function testEncoding() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getEncoding()); - $server->setEncoding('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $server->getEncoding()); - - try { - $server->setEncoding(array('UTF-8')); - $this->fail('Non-string encoding values should fail'); - } catch (Exception $e) { - // success - } - } - - public function testSoapVersion() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertEquals(SOAP_1_2, $server->getSoapVersion()); - $server->setSoapVersion(SOAP_1_1); - $this->assertEquals(SOAP_1_1, $server->getSoapVersion()); - try { - $server->setSoapVersion('bogus'); - $this->fail('Invalid soap versions should fail'); - } catch (Exception $e) { - // success - } - } - - public function testValidateUrn() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - try { - $server->validateUrn('bogosity'); - $this->fail('URNs without schemes should fail'); - } catch (Exception $e) { - // success - } - - $this->assertTrue($server->validateUrn('http://framework.zend.com/')); - $this->assertTrue($server->validateUrn('urn:soapHandler/GetOpt')); - } - - public function testSetActor() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getActor()); - $server->setActor('http://framework.zend.com/'); - $this->assertEquals('http://framework.zend.com/', $server->getActor()); - try { - $server->setActor('bogus'); - $this->fail('Invalid actor should fail'); - } catch (Exception $e) { - // success - } - } - - public function testGetActor() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getActor()); - $server->setActor('http://framework.zend.com/'); - $this->assertEquals('http://framework.zend.com/', $server->getActor()); - } - - public function testSetUri() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getUri()); - $server->setUri('http://framework.zend.com/'); - $this->assertEquals('http://framework.zend.com/', $server->getUri()); - try { - $server->setUri('bogus'); - $this->fail('Invalid URI should fail'); - } catch (Exception $e) { - // success - } - } - - public function testGetUri() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getUri()); - $server->setUri('http://framework.zend.com/'); - $this->assertEquals('http://framework.zend.com/', $server->getUri()); - } - - public function testSetClassmap() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2'); - - $this->assertNull($server->getClassmap()); - $server->setClassmap($classmap); - $this->assertTrue($classmap == $server->getClassmap()); - try { - $server->setClassmap('bogus'); - $this->fail('Classmap which is not an array should fail'); - } catch (Exception $e) { - // success - } - try { - $server->setClassmap(array('soapTypeName', 'bogusClassName')); - $this->fail('Invalid class within classmap should fail'); - } catch (Exception $e) { - // success - } - } - - public function testGetClassmap() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2'); - - $this->assertNull($server->getClassmap()); - $server->setClassmap($classmap); - $this->assertTrue($classmap == $server->getClassmap()); - } - - public function testSetWsdl() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getWsdl()); - $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); - $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl()); - try { - $server->setWsdl(dirname(__FILE__).'/_files/bogus.wsdl'); - $this->fail('Invalid WSDL URI or PATH should fail'); - } catch (Exception $e) { - // success - } - } - - public function testGetWsdl() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getWsdl()); - $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); - $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl()); - } - - public function testAddFunction() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - try { - $server->addFunction('bogus_function'); - $this->fail('Invalid function should fail'); - } catch (Exception $e) { - // success - } - - // Correct function should pass - $server->addFunction('Zend_Soap_Server_TestFunc1'); - - // Array of correct functions should pass - $functions = array('Zend_Soap_Server_TestFunc2', - 'Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc4'); - $server->addFunction($functions); - - try { - $functions1 = array('Zend_Soap_Server_TestFunc5', - 'bogus_function', - 'Zend_Soap_Server_TestFunc6'); - $server->addFunction('bogus_function'); - $this->fail('Invalid function within a set of functions should fail'); - } catch (Exception $e) { - // success - } - - try { - $server->addFunction(126); - $this->fail('Invalid value should fail'); - } catch (Exception $e) { - // success - } - - // SOAP_FUNCTIONS_ALL as a value should pass - $server->addFunction(SOAP_FUNCTIONS_ALL); - } - - public function testSetClass() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - try { - $server->setClass(465); - $this->fail('Non-string value should fail'); - } catch (Exception $e) { - // success - } - try { - $server->setClass('Zend_Soap_Server_Test_BogusClass'); - $this->fail('Invalid class should fail'); - } catch (Exception $e) { - // success - } - - // Correct class name should pass - $server->setClass('Zend_Soap_Server_TestClass'); - - try { - $server->setClass('Zend_Soap_Server_TestClass'); - $this->fail('setClass() should pass only once'); - } catch (Exception $e) { - // success - } - } - - public function testGetFunctions() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $server->addFunction('Zend_Soap_Server_TestFunc1'); - - $functions = array('Zend_Soap_Server_TestFunc2', - 'Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc4'); - $server->addFunction($functions); - - $functions = array('Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc5', - 'Zend_Soap_Server_TestFunc6'); - $server->addFunction($functions); - - $this->assertTrue($server->getFunctions() == array('Zend_Soap_Server_TestFunc1', - 'Zend_Soap_Server_TestFunc2', - 'Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc4', - 'Zend_Soap_Server_TestFunc5', - 'Zend_Soap_Server_TestFunc6')); - } - - public function testSetPersistence() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getPersistence()); - $server->setPersistence(SOAP_PERSISTENCE_SESSION); - $this->assertEquals(SOAP_PERSISTENCE_SESSION, $server->getPersistence()); - try { - $server->setSoapVersion('bogus'); - $this->fail('Invalid soap versions should fail'); - } catch (Exception $e) { - // success - } - - $server->setPersistence(SOAP_PERSISTENCE_REQUEST); - $this->assertEquals(SOAP_PERSISTENCE_REQUEST, $server->getPersistence()); - } - - public function testGetPersistence() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertNull($server->getPersistence()); - $server->setPersistence(SOAP_PERSISTENCE_SESSION); - $this->assertEquals(SOAP_PERSISTENCE_SESSION, $server->getPersistence()); - } - - public function testGetLastRequest() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - $server->setReturnResponse(true); - - $server->setClass('Zend_Soap_Server_TestClass'); - - $request = - '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' - . 'xmlns:ns1="http://framework.zend.com" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' - . '<SOAP-ENV:Body>' - . '<ns1:testFunc2>' - . '<param0 xsi:type="xsd:string">World</param0>' - . '</ns1:testFunc2>' - . '</SOAP-ENV:Body>' - . '</SOAP-ENV:Envelope>' . PHP_EOL; - - $response = $server->handle($request); - - $this->assertEquals($request, $server->getLastRequest()); - } - - public function testSetReturnResponse() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertFalse($server->getReturnResponse()); - - $server->setReturnResponse(true); - $this->assertTrue($server->getReturnResponse()); - - $server->setReturnResponse(false); - $this->assertFalse($server->getReturnResponse()); - } - - public function testGetReturnResponse() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - $this->assertFalse($server->getReturnResponse()); - - $server->setReturnResponse(true); - $this->assertTrue($server->getReturnResponse()); - } - - public function testGetLastResponse() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - $server->setReturnResponse(true); - - $server->setClass('Zend_Soap_Server_TestClass'); - - $request = - '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' - . 'xmlns:ns1="http://framework.zend.com" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' - . '<SOAP-ENV:Body>' - . '<ns1:testFunc2>' - . '<param0 xsi:type="xsd:string">World</param0>' - . '</ns1:testFunc2>' - . '</SOAP-ENV:Body>' - . '</SOAP-ENV:Envelope>' . PHP_EOL; - - $expectedResponse = - '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' - . 'xmlns:ns1="http://framework.zend.com" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' - . '<SOAP-ENV:Body>' - . '<ns1:testFunc2Response>' - . '<return xsi:type="xsd:string">Hello World!</return>' - . '</ns1:testFunc2Response>' - . '</SOAP-ENV:Body>' - . '</SOAP-ENV:Envelope>' . PHP_EOL; - - $server->handle($request); - - $this->assertEquals($expectedResponse, $server->getLastResponse()); - } - - public function testHandle() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - - $server->setClass('Zend_Soap_Server_TestClass'); - - $localClient = new Zend_Soap_Server_TestLocalSoapClient($server, - null, - array('location'=>'test://', - 'uri'=>'http://framework.zend.com')); - - // Local SOAP client call automatically invokes handle method of the provided SOAP server - $this->assertEquals('Hello World!', $localClient->testFunc2('World')); - - - $request = - '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' - . 'xmlns:ns1="http://framework.zend.com" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' - . '<SOAP-ENV:Body>' - . '<ns1:testFunc2>' - . '<param0 xsi:type="xsd:string">World</param0>' - . '</ns1:testFunc2>' - . '</SOAP-ENV:Body>' - . '</SOAP-ENV:Envelope>' . PHP_EOL; - - $expectedResponse = - '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL - . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' - . 'xmlns:ns1="http://framework.zend.com" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' - . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' - . '<SOAP-ENV:Body>' - . '<ns1:testFunc2Response>' - . '<return xsi:type="xsd:string">Hello World!</return>' - . '</ns1:testFunc2Response>' - . '</SOAP-ENV:Body>' - . '</SOAP-ENV:Envelope>' . PHP_EOL; - - $server1 = new Zend_Soap_Server(); - $server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - - $server1->setClass('Zend_Soap_Server_TestClass'); - $server1->setReturnResponse(true); - - $this->assertEquals($expectedResponse, $server1->handle($request)); - } - - /** - * @todo Implement testRegisterFaultException(). - */ - public function testRegisterFaultException() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - // Remove the following line when you implement this test. - $this->markTestIncomplete( - "This test has not been implemented yet." - ); - } - - /** - * @todo Implement testDeregisterFaultException(). - */ - public function testDeregisterFaultException() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - // Remove the following line when you implement this test. - $this->markTestIncomplete( - "This test has not been implemented yet." - ); - } - - /** - * @todo Implement testGetFaultExceptions(). - */ - public function testGetFaultExceptions() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - // Remove the following line when you implement this test. - $this->markTestIncomplete( - "This test has not been implemented yet." - ); - } - - /** - * @todo Implement testFault(). - */ - public function testFault() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - // Remove the following line when you implement this test. - $this->markTestIncomplete( - "This test has not been implemented yet." - ); - } - - /** - * @todo Implement testHandlePhpErrors(). - */ - public function testHandlePhpErrors() - { - if (!extension_loaded('soap')) { - $this->markTestSkipped('SOAP Extension is not loaded'); - } - - $server = new Zend_Soap_Server(); - - // Remove the following line when you implement this test. - $this->markTestIncomplete( - "This test has not been implemented yet." - ); - } -} - - -if (extension_loaded('soap')) { - -/** Local SOAP client */ -class Zend_Soap_Server_TestLocalSoapClient extends SoapClient { - /** - * Server object - * - * @var Zend_Soap_Server - */ - public $server; - - /** - * Local client constructor - * - * @param Zend_Soap_Server $server - * @param string $wsdl - * @param array $options - */ - function __construct(Zend_Soap_Server $server, $wsdl, $options) { - $this->server = $server; - parent::__construct($wsdl, $options); - } - - function __doRequest($request, $location, $action, $version) { - ob_start(); - $this->server->handle($request); - $response = ob_get_contents(); - ob_end_clean(); - - return $response; - } -} - -} - - -/** Test Class */ -class Zend_Soap_Server_TestClass { - /** - * Test Function 1 - * - * @return string - */ - function testFunc1() - { - return "Hello World"; - } - - /** - * Test Function 2 - * - * @param string $who Some Arg - * @return string - */ - function testFunc2($who) - { - return "Hello $who!"; - } - - /** - * Test Function 3 - * - * @param string $who Some Arg - * @param int $when Some - * @return string - */ - function testFunc3($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 4 - * - * @return string - */ - static function testFunc4() - { - return "I'm Static!"; - } -} - - -/** Test class 2 */ -class Zend_Soap_Server_TestData1 { - /** - * Property1 - * - * @var string - */ - public $property1; - - /** - * Property2 - * - * @var float - */ - public $property2; -} - -/** Test class 2 */ -class Zend_Soap_Server_TestData2 { - /** - * Property1 - * - * @var integer - */ - public $property1; - - /** - * Property1 - * - * @var float - */ - public $property2; -} - - -/* Test Functions */ - -/** - * Test Function - * - * @param string $arg - * @return string - */ -function Zend_Soap_Server_TestFunc1($who) -{ - return "Hello $who"; -} - -/** - * Test Function 2 - */ -function Zend_Soap_Server_TestFunc2() -{ - return "Hello World"; -} - -/** - * Return false - * - * @return bool - */ -function Zend_Soap_Server_TestFunc3() -{ - return false; -} - -/** - * Return true - * - * @return bool - */ -function Zend_Soap_Server_TestFunc4() -{ - return true; -} - -/** - * Return integer - * - * @return int - */ -function Zend_Soap_Server_TestFunc5() -{ - return 123; -} - -/** - * Return string - * - * @return string - */ -function Zend_Soap_Server_TestFunc6() -{ - return "string"; -} - diff --git a/tests/Zend/Soap/WsdlTest.php b/tests/Zend/Soap/WsdlTest.php deleted file mode 100644 index cb900dc8c400e47e761da54f6b539df7f0765586..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/WsdlTest.php +++ /dev/null @@ -1,489 +0,0 @@ -<?php -/** - * @package Zend_Soap - * @subpackage UnitTests - */ - -/** PHPUnit Test Case */ -// require_once 'PHPUnit/Framework/TestCase.php'; - -/** Zend_Soap_Wsdl */ -require_once 'Zend/Soap/Wsdl.php'; - - -/** - * Test cases for Zend_Soap_Wsdl - * - * @package Zend_Soap - * @subpackage UnitTests - */ -class Zend_Soap_WsdlTest extends PHPUnit_Framework_TestCase -{ - function testConstructor() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' . PHP_EOL); - } - - function testAddMessage() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $messageParts = array(); - $messageParts['parameter1'] = $wsdl->getType('int'); - $messageParts['parameter2'] = $wsdl->getType('string'); - $messageParts['parameter3'] = $wsdl->getType('mixed'); - - $wsdl->addMessage('myMessage', $messageParts); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<message name="myMessage">' - . '<part name="parameter1" type="xsd:int"/>' - . '<part name="parameter2" type="xsd:string"/>' - . '<part name="parameter3" type="xsd:anyType"/>' - . '</message>' - . '</definitions>' . PHP_EOL); - } - - function testAddPortType() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addPortType('myPortType'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '</definitions>' . PHP_EOL); - } - - function testAddPortOperation() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $portType = $wsdl->addPortType('myPortType'); - - $wsdl->addPortOperation($portType, 'operation1'); - $wsdl->addPortOperation($portType, 'operation2', 'tns:operation2Request', 'tns:operation2Response'); - $wsdl->addPortOperation($portType, 'operation3', 'tns:operation3Request', 'tns:operation3Response', 'tns:operation3Fault'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType">' - . '<operation name="operation1"/>' - . '<operation name="operation2">' - . '<input message="tns:operation2Request"/>' - . '<output message="tns:operation2Response"/>' - . '</operation>' - . '<operation name="operation3">' - . '<input message="tns:operation3Request"/>' - . '<output message="tns:operation3Response"/>' - . '<fault message="tns:operation3Fault"/>' - . '</operation>' - . '</portType>' - . '</definitions>' . PHP_EOL); - } - - function testAddBinding() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addPortType('myPortType'); - $wsdl->addBinding('MyServiceBinding', 'myPortType'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '<binding name="MyServiceBinding" type="myPortType"/>' - . '</definitions>' . PHP_EOL); - } - - function testAddBindingOperation() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addPortType('myPortType'); - $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); - - $wsdl->addBindingOperation($binding, 'operation1'); - $wsdl->addBindingOperation($binding, - 'operation2', - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") - ); - $wsdl->addBindingOperation($binding, - 'operation3', - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") - ); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '<binding name="MyServiceBinding" type="myPortType">' - . '<operation name="operation1"/>' - . '<operation name="operation2">' - . '<input>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</input>' - . '<output>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</output>' - . '</operation>' - . '<operation name="operation3">' - . '<input>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</input>' - . '<output>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</output>' - . '<fault>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</fault>' - . '</operation>' - . '</binding>' - . '</definitions>' . PHP_EOL); - } - - function testAddSoapBinding() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addPortType('myPortType'); - $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); - - $wsdl->addSoapBinding($binding); - - $wsdl->addBindingOperation($binding, 'operation1'); - $wsdl->addBindingOperation($binding, - 'operation2', - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") - ); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '<binding name="MyServiceBinding" type="myPortType">' - . '<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>' - . '<operation name="operation1"/>' - . '<operation name="operation2">' - . '<input>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</input>' - . '<output>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</output>' - . '</operation>' - . '</binding>' - . '</definitions>' . PHP_EOL); - - $wsdl1 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl1->addPortType('myPortType'); - $binding = $wsdl1->addBinding('MyServiceBinding', 'myPortType'); - - $wsdl1->addSoapBinding($binding, 'rpc'); - - $wsdl1->addBindingOperation($binding, 'operation1'); - $wsdl1->addBindingOperation($binding, - 'operation2', - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") - ); - - $this->assertEquals($wsdl1->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '<binding name="MyServiceBinding" type="myPortType">' - . '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>' - . '<operation name="operation1"/>' - . '<operation name="operation2">' - . '<input>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</input>' - . '<output>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</output>' - . '</operation>' - . '</binding>' - . '</definitions>' . PHP_EOL); - } - - - function testAddSoapOperation() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addPortType('myPortType'); - $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); - - $wsdl->addSoapOperation($binding, 'http://localhost/MyService.php#myOperation'); - - $wsdl->addBindingOperation($binding, 'operation1'); - $wsdl->addBindingOperation($binding, - 'operation2', - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") - ); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '<binding name="MyServiceBinding" type="myPortType">' - . '<soap:operation soapAction="http://localhost/MyService.php#myOperation"/>' - . '<operation name="operation1"/>' - . '<operation name="operation2">' - . '<input>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</input>' - . '<output>' - . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' - . '</output>' - . '</operation>' - . '</binding>' - . '</definitions>' . PHP_EOL); - } - - function testAddService() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addPortType('myPortType'); - $wsdl->addBinding('MyServiceBinding', 'myPortType'); - - $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType"/>' - . '<binding name="MyServiceBinding" type="myPortType"/>' - . '<service name="Service1">' - . '<port name="myPortType" binding="MyServiceBinding">' - . '<soap:address location="http://localhost/MyService.php"/>' - . '</port>' - . '</service>' - . '</definitions>' . PHP_EOL); - } - - function testAddDocumentation() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $portType = $wsdl->addPortType('myPortType'); - - $wsdl->addDocumentation($portType, 'This is a description for Port Type node.'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<portType name="myPortType">' - . '<documentation>This is a description for Port Type node.</documentation>' - . '</portType>' - . '</definitions>' . PHP_EOL); - } - - function testToXml() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' . PHP_EOL); - } - - function testToDomDocument() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - $dom = $wsdl->toDomDocument(); - - $this->assertTrue($dom instanceOf DOMDocument); - - $this->assertEquals($dom->saveXML(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' . PHP_EOL); - } - - function testDump() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - ob_start(); - $wsdl->dump(); - $wsdlDump = ob_get_contents(); - ob_end_clean(); - - $this->assertEquals($wsdlDump, - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' . PHP_EOL); - - $wsdl->dump(dirname(__FILE__) . '/_files/dumped.wsdl'); - $dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl'); - - $this->assertEquals($dumpedContent, - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' . PHP_EOL); - - unlink(dirname(__FILE__) . '/_files/dumped.wsdl'); - } - - function testGetType() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $this->assertEquals($wsdl->getType('string'), 'xsd:string'); - $this->assertEquals($wsdl->getType('str'), 'xsd:string'); - $this->assertEquals($wsdl->getType('int'), 'xsd:int'); - $this->assertEquals($wsdl->getType('integer'), 'xsd:int'); - $this->assertEquals($wsdl->getType('float'), 'xsd:float'); - $this->assertEquals($wsdl->getType('double'), 'xsd:float'); - $this->assertEquals($wsdl->getType('boolean'), 'xsd:boolean'); - $this->assertEquals($wsdl->getType('bool'), 'xsd:boolean'); - $this->assertEquals($wsdl->getType('array'), 'soap-enc:Array'); - $this->assertEquals($wsdl->getType('object'), 'xsd:struct'); - $this->assertEquals($wsdl->getType('mixed'), 'xsd:anyType'); - $this->assertEquals($wsdl->getType('void'), ''); - - $this->assertEquals($wsdl->getType('Zend_Soap_Wsdl_Test'), - 'tns:Zend_Soap_Wsdl_Test'); - - $wsdl1 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', false); - - $this->assertEquals($wsdl1->getType('Zend_Soap_Wsdl_Test'), 'xsd:anyType'); - - } - - function testAddComplexType() - { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - - $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); - - $this->assertEquals($wsdl->toXml(), - '<?xml version="1.0"?>' . PHP_EOL . - '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' - . 'xmlns:tns="http://localhost/MyService.php" ' - . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' - . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' - . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' - . 'name="MyService" targetNamespace="http://localhost/MyService.php">' - . '<types>' - . '<xsd:schema targetNamespace="">' - . '<xsd:complexType name="Zend_Soap_Wsdl_Test">' - . '<xsd:all>' - . '<xsd:element name="var1" type="xsd:int"/>' - . '<xsd:element name="var2" type="xsd:string"/>' - . '</xsd:all>' - . '</xsd:complexType>' - . '</xsd:schema>' - . '</types>' - . '</definitions>' . PHP_EOL); - } -} - - - -/** - * Test Class - */ -class Zend_Soap_Wsdl_Test { - /** - * @var integer - */ - public $var1; - - /** - * @var string - */ - public $var2; -} - diff --git a/tests/Zend/Soap/_files/cert_file b/tests/Zend/Soap/_files/cert_file deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/Zend/Soap/_files/wsdl_example.wsdl b/tests/Zend/Soap/_files/wsdl_example.wsdl deleted file mode 100644 index 4eaa87610b52c58a3a51f410048e8a49ce17b09d..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/_files/wsdl_example.wsdl +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0"?> -<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://framework.zend.com/my_script.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" name="Zend_Soap_Server_TestClass" targetNamespace="http://framework.zend.com/my_script.php"><portType name="Zend_Soap_Server_TestClassPort"><operation name="testFunc1"><input message="tns:testFunc1Request"/><output message="tns:testFunc1Response"/></operation><operation name="testFunc2"><input message="tns:testFunc2Request"/><output message="tns:testFunc2Response"/></operation><operation name="testFunc3"><input message="tns:testFunc3Request"/><output message="tns:testFunc3Response"/></operation><operation name="testFunc4"><input message="tns:testFunc4Request"/><output message="tns:testFunc4Response"/></operation></portType><binding name="Zend_Soap_Server_TestClassBinding" type="tns:Zend_Soap_Server_TestClassPort"><soap:operation soapAction="http://framework.zend.com/my_script.php#testFunc4"/><soap:operation soapAction="http://framework.zend.com/my_script.php#testFunc3"/><soap:operation soapAction="http://framework.zend.com/my_script.php#testFunc2"/><soap:operation soapAction="http://framework.zend.com/my_script.php#testFunc1"/><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="testFunc1"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="testFunc2"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="testFunc3"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="testFunc4"><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation></binding><service name="Zend_Soap_Server_TestClassService"><port name="Zend_Soap_Server_TestClassPort" binding="tns:Zend_Soap_Server_TestClassBinding"><soap:address location="http://framework.zend.com/my_script.php"/></port></service><message name="testFunc1Request"/><message name="testFunc1Response"><part name="testFunc1Return" type="xsd:string"/></message><message name="testFunc2Request"><part name="who" type="xsd:string"/></message><message name="testFunc2Response"><part name="testFunc2Return" type="xsd:string"/></message><message name="testFunc3Request"><part name="who" type="xsd:string"/><part name="when" type="xsd:int"/></message><message name="testFunc3Response"><part name="testFunc3Return" type="xsd:string"/></message><message name="testFunc4Request"/><message name="testFunc4Response"><part name="testFunc4Return" type="xsd:string"/></message></definitions> diff --git a/tests/Zend/Soap/schemas/wsdl.xsd b/tests/Zend/Soap/schemas/wsdl.xsd deleted file mode 100644 index 14b5bef302e6dee4833b2abe419f99a1f8d30048..0000000000000000000000000000000000000000 --- a/tests/Zend/Soap/schemas/wsdl.xsd +++ /dev/null @@ -1,310 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - -Copyright 2001 - 2005, International Business Machines Corporation and Microsoft Corporation -All Rights Reserved - -License for WSDL Schema Files - -The Authors grant permission to copy and distribute the WSDL Schema -Files in any medium without fee or royalty as long as this notice and -license are distributed with them. The originals of these files can -be located at: - -http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd - -THESE SCHEMA FILES ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS -OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THESE FILES, INCLUDING, BUT NOT -LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, -INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR -RELATING TO ANY USE OR DISTRIBUTION OF THESE FILES. - -The name and trademarks of the Authors may NOT be used in any manner, -including advertising or publicity pertaining to these files or any program -or service that uses these files, written prior permission. Title to copyright -in these files will at all times remain with the Authors. - -No other rights are granted by implication, estoppel or otherwise. - - ---> -<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" - targetNamespace="http://schemas.xmlsoap.org/wsdl/" - elementFormDefault="qualified" > - - <xs:complexType mixed="true" name="tDocumentation" > - <xs:sequence> - <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" /> - </xs:sequence> - </xs:complexType> - - <xs:complexType name="tDocumented" > - <xs:annotation> - <xs:documentation> - This type is extended by component types to allow them to be documented - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:element name="documentation" type="wsdl:tDocumentation" minOccurs="0" /> - </xs:sequence> - </xs:complexType> - - <xs:complexType name="tExtensibleAttributesDocumented" abstract="true" > - <xs:complexContent> - <xs:extension base="wsdl:tDocumented" > - <xs:annotation> - <xs:documentation> - This type is extended by component types to allow attributes from other namespaces to be added. - </xs:documentation> - </xs:annotation> - <xs:anyAttribute namespace="##other" processContents="lax" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tExtensibleDocumented" abstract="true" > - <xs:complexContent> - <xs:extension base="wsdl:tDocumented" > - <xs:annotation> - <xs:documentation> - This type is extended by component types to allow elements from other namespaces to be added. - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> - </xs:sequence> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:element name="definitions" type="wsdl:tDefinitions" > - <xs:key name="message" > - <xs:selector xpath="wsdl:message" /> - <xs:field xpath="@name" /> - </xs:key> - <xs:key name="portType" > - <xs:selector xpath="wsdl:portType" /> - <xs:field xpath="@name" /> - </xs:key> - <xs:key name="binding" > - <xs:selector xpath="wsdl:binding" /> - <xs:field xpath="@name" /> - </xs:key> - <xs:key name="service" > - <xs:selector xpath="wsdl:service" /> - <xs:field xpath="@name" /> - </xs:key> - <xs:key name="import" > - <xs:selector xpath="wsdl:import" /> - <xs:field xpath="@namespace" /> - </xs:key> - </xs:element> - - <xs:group name="anyTopLevelOptionalElement" > - <xs:annotation> - <xs:documentation> - Any top level optional element allowed to appear more then once - any child of definitions element except wsdl:types. Any extensibility element is allowed in any place. - </xs:documentation> - </xs:annotation> - <xs:choice> - <xs:element name="import" type="wsdl:tImport" /> - <xs:element name="types" type="wsdl:tTypes" /> - <xs:element name="message" type="wsdl:tMessage" > - <xs:unique name="part" > - <xs:selector xpath="wsdl:part" /> - <xs:field xpath="@name" /> - </xs:unique> - </xs:element> - <xs:element name="portType" type="wsdl:tPortType" /> - <xs:element name="binding" type="wsdl:tBinding" /> - <xs:element name="service" type="wsdl:tService" > - <xs:unique name="port" > - <xs:selector xpath="wsdl:port" /> - <xs:field xpath="@name" /> - </xs:unique> - </xs:element> - </xs:choice> - </xs:group> - - <xs:complexType name="tDefinitions" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:sequence> - <xs:group ref="wsdl:anyTopLevelOptionalElement" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - <xs:attribute name="targetNamespace" type="xs:anyURI" use="optional" /> - <xs:attribute name="name" type="xs:NCName" use="optional" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tImport" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleAttributesDocumented" > - <xs:attribute name="namespace" type="xs:anyURI" use="required" /> - <xs:attribute name="location" type="xs:anyURI" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tTypes" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" /> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tMessage" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:sequence> - <xs:element name="part" type="wsdl:tPart" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - <xs:attribute name="name" type="xs:NCName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tPart" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleAttributesDocumented" > - <xs:attribute name="name" type="xs:NCName" use="required" /> - <xs:attribute name="element" type="xs:QName" use="optional" /> - <xs:attribute name="type" type="xs:QName" use="optional" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tPortType" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleAttributesDocumented" > - <xs:sequence> - <xs:element name="operation" type="wsdl:tOperation" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - <xs:attribute name="name" type="xs:NCName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tOperation" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:sequence> - <xs:choice> - <xs:group ref="wsdl:request-response-or-one-way-operation" /> - <xs:group ref="wsdl:solicit-response-or-notification-operation" /> - </xs:choice> - </xs:sequence> - <xs:attribute name="name" type="xs:NCName" use="required" /> - <xs:attribute name="parameterOrder" type="xs:NMTOKENS" use="optional" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:group name="request-response-or-one-way-operation" > - <xs:sequence> - <xs:element name="input" type="wsdl:tParam" /> - <xs:sequence minOccurs='0' > - <xs:element name="output" type="wsdl:tParam" /> - <xs:element name="fault" type="wsdl:tFault" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:sequence> - </xs:group> - - <xs:group name="solicit-response-or-notification-operation" > - <xs:sequence> - <xs:element name="output" type="wsdl:tParam" /> - <xs:sequence minOccurs='0' > - <xs:element name="input" type="wsdl:tParam" /> - <xs:element name="fault" type="wsdl:tFault" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:sequence> - </xs:group> - - <xs:complexType name="tParam" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleAttributesDocumented" > - <xs:attribute name="name" type="xs:NCName" use="optional" /> - <xs:attribute name="message" type="xs:QName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tFault" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleAttributesDocumented" > - <xs:attribute name="name" type="xs:NCName" use="required" /> - <xs:attribute name="message" type="xs:QName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tBinding" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:sequence> - <xs:element name="operation" type="wsdl:tBindingOperation" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - <xs:attribute name="name" type="xs:NCName" use="required" /> - <xs:attribute name="type" type="xs:QName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tBindingOperationMessage" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:attribute name="name" type="xs:NCName" use="optional" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tBindingOperationFault" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:attribute name="name" type="xs:NCName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tBindingOperation" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:sequence> - <xs:element name="input" type="wsdl:tBindingOperationMessage" minOccurs="0" /> - <xs:element name="output" type="wsdl:tBindingOperationMessage" minOccurs="0" /> - <xs:element name="fault" type="wsdl:tBindingOperationFault" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - <xs:attribute name="name" type="xs:NCName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tService" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:sequence> - <xs:element name="port" type="wsdl:tPort" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - <xs:attribute name="name" type="xs:NCName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:complexType name="tPort" > - <xs:complexContent> - <xs:extension base="wsdl:tExtensibleDocumented" > - <xs:attribute name="name" type="xs:NCName" use="required" /> - <xs:attribute name="binding" type="xs:QName" use="required" /> - </xs:extension> - </xs:complexContent> - </xs:complexType> - - <xs:attribute name="arrayType" type="xs:string" /> - <xs:attribute name="required" type="xs:boolean" /> - <xs:complexType name="tExtensibilityElement" abstract="true" > - <xs:attribute ref="wsdl:required" use="optional" /> - </xs:complexType> - -</xs:schema> \ No newline at end of file diff --git a/tests/Zend/Test/AllTests.php b/tests/Zend/Test/AllTests.php deleted file mode 100644 index 2891d768aae101ff5244fd79319d450b677ba056..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/AllTests.php +++ /dev/null @@ -1,60 +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_Test - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 9799 2008-06-27 01:54:36Z dasprid $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Test_AllTests::main'); -} - -require_once 'Zend/Test/PHPUnit/AllTests.php'; - -/** - * @category Zend - * @package Zend_Test - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Test_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Test'); - - $suite->addTest(Zend_Test_PHPUnit_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Test_AllTests::main') { - Zend_Test_AllTests::main(); -} diff --git a/tests/Zend/Test/PHPUnit/AllTests.php b/tests/Zend/Test/PHPUnit/AllTests.php deleted file mode 100644 index c4e42d0366ef65aab0a49e689ab22c77cb12fcfa..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/AllTests.php +++ /dev/null @@ -1,60 +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_Test - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 9799 2008-06-27 01:54:36Z dasprid $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Test_PHPUnit_AllTests::main'); -} - -require_once 'Zend/Test/PHPUnit/ControllerTestCaseTest.php'; - -/** - * @category Zend - * @package Zend_Test - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Test_PHPUnit_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Test- Zend_Test_PHPUnit'); - - $suite->addTestSuite('Zend_Test_PHPUnit_ControllerTestCaseTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Test_PHPUnit_AllTests::main') { - Zend_Test_PHPUnit_AllTests::main(); -} diff --git a/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php b/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php deleted file mode 100644 index 62fed68d00926304a6deab1ee49406c187f76fe1..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php +++ /dev/null @@ -1,679 +0,0 @@ -<?php -// Call Zend_Test_PHPUnit_ControllerTestCaseTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Test_PHPUnit_ControllerTestCaseTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_Test_PHPUnit_ControllerTestCase */ -require_once 'Zend/Test/PHPUnit/ControllerTestCase.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Session */ -require_once 'Zend/Session.php'; - -/** Zend_Controller_Action */ -require_once 'Zend/Controller/Action.php'; - -/** - * Test class for Zend_Test_PHPUnit_ControllerTestCase. - */ -class Zend_Test_PHPUnit_ControllerTestCaseTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Test_PHPUnit_ControllerTestCaseTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $_SESSION = array(); - $this->setExpectedException(null); - $this->testCase = new Zend_Test_PHPUnit_ControllerTestCaseTest_Concrete(); - $this->testCase->reset(); - $this->testCase->bootstrap = array($this, 'bootstrap'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - $registry = Zend_Registry::getInstance(); - if (isset($registry['router'])) { - unset($registry['router']); - } - if (isset($registry['dispatcher'])) { - unset($registry['dispatcher']); - } - if (isset($registry['plugin'])) { - unset($registry['plugin']); - } - if (isset($registry['viewRenderer'])) { - unset($registry['viewRenderer']); - } - Zend_Session::$_unitTestEnabled = false; - session_id(uniqid()); - } - - public function bootstrap() - { - } - - public function testGetFrontControllerShouldReturnFrontController() - { - $controller = $this->testCase->getFrontController(); - $this->assertTrue($controller instanceof Zend_Controller_Front); - } - - public function testGetFrontControllerShouldReturnSameFrontControllerObjectOnRepeatedCalls() - { - $controller = $this->testCase->getFrontController(); - $this->assertTrue($controller instanceof Zend_Controller_Front); - $test = $this->testCase->getFrontController(); - $this->assertSame($controller, $test); - } - - public function testGetRequestShouldReturnRequestTestCase() - { - $request = $this->testCase->getRequest(); - $this->assertTrue($request instanceof Zend_Controller_Request_HttpTestCase); - } - - public function testGetRequestShouldReturnSameRequestObjectOnRepeatedCalls() - { - $request = $this->testCase->getRequest(); - $this->assertTrue($request instanceof Zend_Controller_Request_HttpTestCase); - $test = $this->testCase->getRequest(); - $this->assertSame($request, $test); - } - - public function testGetResponseShouldReturnResponseTestCase() - { - $response = $this->testCase->getResponse(); - $this->assertTrue($response instanceof Zend_Controller_Response_HttpTestCase); - } - - public function testGetResponseShouldReturnSameResponseObjectOnRepeatedCalls() - { - $response = $this->testCase->getResponse(); - $this->assertTrue($response instanceof Zend_Controller_Response_HttpTestCase); - $test = $this->testCase->getResponse(); - $this->assertSame($response, $test); - } - - public function testGetQueryShouldReturnQueryTestCase() - { - $query = $this->testCase->getQuery(); - $this->assertTrue($query instanceof Zend_Dom_Query); - } - - public function testGetQueryShouldReturnSameQueryObjectOnRepeatedCalls() - { - $query = $this->testCase->getQuery(); - $this->assertTrue($query instanceof Zend_Dom_Query); - $test = $this->testCase->getQuery(); - $this->assertSame($query, $test); - } - - public function testOverloadingShouldReturnRequestResponseAndFrontControllerObjects() - { - $request = $this->testCase->getRequest(); - $response = $this->testCase->getResponse(); - $frontController = $this->testCase->getFrontController(); - $this->assertSame($request, $this->testCase->request); - $this->assertSame($response, $this->testCase->response); - $this->assertSame($frontController, $this->testCase->frontController); - } - - public function testOverloadingShouldPreventSettingRequestResponseAndFrontControllerObjects() - { - try { - $this->testCase->request = new Zend_Controller_Request_Http(); - $this->fail('Setting request object as public property should raise exception'); - } catch (Exception $e) { - $this->assertContains('not allow', $e->getMessage()); - } - - try { - $this->testCase->response = new Zend_Controller_Response_Http(); - $this->fail('Setting response object as public property should raise exception'); - } catch (Exception $e) { - $this->assertContains('not allow', $e->getMessage()); - } - - try { - $this->testCase->frontController = Zend_Controller_Front::getInstance(); - $this->fail('Setting front controller as public property should raise exception'); - } catch (Exception $e) { - $this->assertContains('not allow', $e->getMessage()); - } - } - - public function testResetShouldResetMvcState() - { - require_once 'Zend/Controller/Action/HelperBroker.php'; - require_once 'Zend/Controller/Dispatcher/Standard.php'; - require_once 'Zend/Controller/Plugin/ErrorHandler.php'; - require_once 'Zend/Controller/Router/Rewrite.php'; - $request = $this->testCase->getRequest(); - $response = $this->testCase->getResponse(); - $router = new Zend_Controller_Router_Rewrite(); - $dispatcher = new Zend_Controller_Dispatcher_Standard(); - $plugin = new Zend_Controller_Plugin_ErrorHandler(); - $controller = $this->testCase->getFrontController(); - $controller->setParam('foo', 'bar') - ->registerPlugin($plugin) - ->setRouter($router) - ->setDispatcher($dispatcher); - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); - $this->testCase->reset(); - $test = $controller->getRouter(); - $this->assertNotSame($router, $test); - $test = $controller->getDispatcher(); - $this->assertNotSame($dispatcher, $test); - $this->assertFalse($controller->getPlugin('Zend_Controller_Plugin_ErrorHandler')); - $test = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); - $this->assertNotSame($viewRenderer, $test); - $this->assertNull($controller->getRequest()); - $this->assertNull($controller->getResponse()); - $this->assertNotSame($request, $this->testCase->getRequest()); - $this->assertNotSame($response, $this->testCase->getResponse()); - } - - public function testBootstrapShouldSetRequestAndResponseTestCaseObjects() - { - $this->testCase->bootstrap(); - $controller = $this->testCase->getFrontController(); - $request = $controller->getRequest(); - $response = $controller->getResponse(); - $this->assertSame($this->testCase->getRequest(), $request); - $this->assertSame($this->testCase->getResponse(), $response); - } - - public function testBootstrapShouldIncludeBootstrapFileSpecifiedInPublicBootstrapProperty() - { - $this->testCase->bootstrap = dirname(__FILE__) . '/_files/bootstrap.php'; - $this->testCase->bootstrap(); - $controller = $this->testCase->getFrontController(); - $this->assertSame(Zend_Registry::get('router'), $controller->getRouter()); - $this->assertSame(Zend_Registry::get('dispatcher'), $controller->getDispatcher()); - $this->assertSame(Zend_Registry::get('plugin'), $controller->getPlugin('Zend_Controller_Plugin_ErrorHandler')); - $this->assertSame(Zend_Registry::get('viewRenderer'), Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')); - } - - public function testBootstrapShouldInvokeCallbackSpecifiedInPublicBootstrapProperty() - { - $this->testCase->bootstrap = array($this, 'bootstrapCallback'); - $this->testCase->bootstrap(); - $controller = $this->testCase->getFrontController(); - $this->assertSame(Zend_Registry::get('router'), $controller->getRouter()); - $this->assertSame(Zend_Registry::get('dispatcher'), $controller->getDispatcher()); - $this->assertSame(Zend_Registry::get('plugin'), $controller->getPlugin('Zend_Controller_Plugin_ErrorHandler')); - $this->assertSame(Zend_Registry::get('viewRenderer'), Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')); - } - - public function bootstrapCallback() - { - require_once 'Zend/Controller/Action/HelperBroker.php'; - require_once 'Zend/Controller/Dispatcher/Standard.php'; - require_once 'Zend/Controller/Front.php'; - require_once 'Zend/Controller/Plugin/ErrorHandler.php'; - require_once 'Zend/Controller/Router/Rewrite.php'; - require_once 'Zend/Registry.php'; - $router = new Zend_Controller_Router_Rewrite(); - $dispatcher = new Zend_Controller_Dispatcher_Standard(); - $plugin = new Zend_Controller_Plugin_ErrorHandler(); - $controller = Zend_Controller_Front::getInstance(); - $controller->setParam('foo', 'bar') - ->registerPlugin($plugin) - ->setRouter($router) - ->setDispatcher($dispatcher); - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); - Zend_Registry::set('router', $router); - Zend_Registry::set('dispatcher', $dispatcher); - Zend_Registry::set('plugin', $plugin); - Zend_Registry::set('viewRenderer', $viewRenderer); - } - - public function testDispatchShouldDispatchSpecifiedUrl() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/bar'); - $request = $this->testCase->getRequest(); - $response = $this->testCase->getResponse(); - $content = $response->getBody(); - $this->assertEquals('zend-test-php-unit-foo', $request->getControllerName(), $content); - $this->assertEquals('bar', $request->getActionName()); - $this->assertContains('FooController::barAction', $content, $content); - } - - public function testAssertQueryShouldDoNothingForValidResponseContent() - { - $this->testCase->getFrontController()->setControllerDirectory(realpath(dirname(__FILE__)) . '/_files/application/controllers', 'default'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $body = $this->testCase->getResponse()->getBody(); - $this->testCase->assertQuery('div#foo legend.bar', $body); - $this->testCase->assertQuery('div#foo legend.baz', $body); - $this->testCase->assertQuery('div#foo legend.bat', $body); - $this->testCase->assertNotQuery('div#foo legend.bogus', $body); - $this->testCase->assertQueryContentContains('legend.bat', 'La di da', $body); - $this->testCase->assertNotQueryContentContains('legend.bat', 'La do da', $body); - $this->testCase->assertQueryContentRegex('legend.bat', '/d[a|i]/i', $body); - $this->testCase->assertNotQueryContentRegex('legend.bat', '/d[o|e]/i', $body); - $this->testCase->assertQueryCountMin('div#foo legend.bar', 2, $body); - $this->testCase->assertQueryCount('div#foo legend.bar', 2, $body); - $this->testCase->assertQueryCountMin('div#foo legend.bar', 2, $body); - $this->testCase->assertQueryCountMax('div#foo legend.bar', 2, $body); - } - - public function testAssertQueryShouldThrowExceptionsForInValidResponseContent() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - try { - $this->testCase->assertNotQuery('div#foo legend.bar'); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQuery('div#foo legend.bogus'); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertNotQueryContentContains('legend.bat', 'La di da'); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQueryContentContains('legend.bat', 'La do da'); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertNotQueryContentRegex('legend.bat', '/d[a|i]/i'); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQueryContentRegex('legend.bat', '/d[o|e]/i'); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQueryCountMin('div#foo legend.bar', 3); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQueryCount('div#foo legend.bar', 1); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQueryCountMin('div#foo legend.bar', 3); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertQueryCountMax('div#foo legend.bar', 1); - $this->fail('Invalid assertions should throw exceptions'); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - } - - public function testAssertXpathShouldDoNothingForValidResponseContent() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->testCase->assertXpath("//div[@id='foo']//legend[contains(@class, ' bar ')]"); - $this->testCase->assertXpath("//div[@id='foo']//legend[contains(@class, ' baz ')]"); - $this->testCase->assertXpath("//div[@id='foo']//legend[contains(@class, ' bat ')]"); - $this->testCase->assertNotXpath("//div[@id='foo']//legend[contains(@class, ' bogus ')]"); - $this->testCase->assertXpathContentContains("//legend[contains(@class, ' bat ')]", "La di da"); - $this->testCase->assertNotXpathContentContains("//legend[contains(@class, ' bat ')]", "La do da"); - $this->testCase->assertXpathContentRegex("//legend[contains(@class, ' bat ')]", "/d[a'i]/i"); - $this->testCase->assertNotXpathContentRegex("//legend[contains(@class, ' bat ')]", "/d[o'e]/i"); - $this->testCase->assertXpathCountMin("//div[@id='foo']//legend[contains(@class, ' bar ')]", 2); - $this->testCase->assertXpathCount("//div[@id='foo']//legend[contains(@class, ' bar ')]", 2); - $this->testCase->assertXpathCountMin("//div[@id='foo']//legend[contains(@class, ' bar ')]", 2); - $this->testCase->assertXpathCountMax("//div[@id='foo']//legend[contains(@class, ' bar ')]", 2); - } - - public function testAssertXpathShouldThrowExceptionsForInValidResponseContent() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - try { - $this->testCase->assertNotXpath("//div[@id='foo']//legend[contains(@class, ' bar ')]"); - $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, ' bar ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpath("//div[@id='foo']//legend[contains(@class, ' bogus ')]"); - $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, ' bogus ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertNotXpathContentContains("//legend[contains(@class, ' bat ')]", "La di da"); - $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, ' bat ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpathContentContains("//legend[contains(@class, ' bat ')]", 'La do da'); - $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, ' bat ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertNotXpathContentRegex("//legend[contains(@class, ' bat ')]", '/d[a|i]/i'); - $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, ' bat ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpathContentRegex("//legend[contains(@class, ' bat ')]", '/d[o|e]/i'); - $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, ' bat ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpathCountMin("//div[@id='foo']//legend[contains(@class, ' bar ')]", 3); - $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, ' bar ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpathCount("//div[@id='foo']//legend[contains(@class, ' bar ')]", 1); - $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, ' bar ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpathCountMin("//div[@id='foo']//legend[contains(@class, ' bar ')]", 3); - $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, ' bar ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - try { - $this->testCase->assertXpathCountMax("//div[@id='foo']//legend[contains(@class, ' bar ')]", 1); - $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, ' bar ')] failed"); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - } - } - - public function testRedirectAssertionsShouldDoNothingForValidAssertions() - { - $this->testCase->getResponse()->setRedirect('/foo'); - $this->testCase->assertRedirect(); - $this->testCase->assertRedirectTo('/foo', var_export($this->testCase->getResponse()->sendHeaders(), 1)); - $this->testCase->assertRedirectRegex('/FOO$/i'); - - $this->testCase->reset(); - $this->testCase->assertNotRedirect(); - $this->testCase->assertNotRedirectTo('/foo'); - $this->testCase->assertNotRedirectRegex('/FOO$/i'); - $this->testCase->getResponse()->setRedirect('/foo'); - $this->testCase->assertNotRedirectTo('/bar'); - $this->testCase->assertNotRedirectRegex('/bar/i'); - } - - public function testHeaderAssertionShouldDoNothingForValidComparison() - { - $this->testCase->getResponse()->setHeader('Content-Type', 'x-application/my-foo'); - $this->testCase->assertResponseCode(200); - $this->testCase->assertNotResponseCode(500); - $this->testCase->assertHeader('Content-Type'); - $this->testCase->assertNotHeader('X-Bogus'); - $this->testCase->assertHeaderContains('Content-Type', 'my-foo'); - $this->testCase->assertNotHeaderContains('Content-Type', 'my-bar'); - $this->testCase->assertHeaderRegex('Content-Type', '#^[a-z-]+/[a-z-]+$#i'); - $this->testCase->assertNotHeaderRegex('Content-Type', '#^\d+#i'); - } - - public function testHeaderAssertionShouldThrowExceptionForInvalidComparison() - { - $this->testCase->getResponse()->setHeader('Content-Type', 'x-application/my-foo'); - try { - $this->testCase->assertResponseCode(500); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertNotResponseCode(200); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertNotHeader('Content-Type'); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertHeader('X-Bogus'); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertNotHeaderContains('Content-Type', 'my-foo'); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertHeaderContains('Content-Type', 'my-bar'); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertNotHeaderRegex('Content-Type', '#^[a-z-]+/[a-z-]+$#i'); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - try { - $this->testCase->assertHeaderRegex('Content-Type', '#^\d+#i'); - $this->fail(); - } catch (Zend_Test_PHPUnit_Constraint_Exception $e) { - $this->assertContains('Failed', $e->getMessage()); - } - } - - public function testModuleAssertionShouldDoNothingForValidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->testCase->assertModule('default'); - $this->testCase->assertNotModule('zend-test-php-unit-foo'); - } - - public function testModuleAssertionShouldThrowExceptionForInvalidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->setExpectedException('PHPUnit_Framework_AssertionFailedError'); - $this->testCase->assertModule('zend-test-php-unit-foo'); - $this->testCase->assertNotModule('default'); - } - - public function testControllerAssertionShouldDoNothingForValidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->testCase->assertController('zend-test-php-unit-foo'); - $this->testCase->assertNotController('baz'); - } - - public function testControllerAssertionShouldThrowExceptionForInvalidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->setExpectedException('PHPUnit_Framework_AssertionFailedError'); - $this->testCase->assertController('baz'); - $this->testCase->assertNotController('zend-test-php-unit-foo'); - } - - public function testActionAssertionShouldDoNothingForValidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->testCase->assertAction('baz'); - $this->testCase->assertNotAction('zend-test-php-unit-foo'); - } - - public function testActionAssertionShouldThrowExceptionForInvalidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/foo/baz'); - $this->setExpectedException('PHPUnit_Framework_AssertionFailedError'); - $this->testCase->assertAction('foo'); - $this->testCase->assertNotAction('baz'); - } - - public function testRouteAssertionShouldDoNothingForValidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $this->testCase->assertRoute('default'); - $this->testCase->assertNotRoute('zend-test-php-unit-foo'); - } - - public function testRouteAssertionShouldThrowExceptionForInvalidComparison() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/foo/baz'); - $this->setExpectedException('PHPUnit_Framework_AssertionFailedError'); - $this->testCase->assertRoute('foo'); - $this->testCase->assertNotRoute('default'); - } - - public function testResetShouldResetSessionArray() - { - $this->assertTrue(empty($_SESSION)); - $_SESSION = array('foo' => 'bar', 'bar' => 'baz'); - $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $_SESSION, var_export($_SESSION, 1)); - $this->testCase->reset(); - $this->assertTrue(empty($_SESSION)); - } - - public function testResetShouldUnitTestEnableZendSession() - { - $this->testCase->reset(); - $this->assertTrue(Zend_Session::$_unitTestEnabled); - } - - public function testResetResponseShouldClearResponseObject() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $response = $this->testCase->getResponse(); - $this->testCase->resetResponse(); - $test = $this->testCase->getResponse(); - $this->assertNotSame($response, $test); - } - - public function testResetResponseShouldClearAllViewPlaceholders() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - $viewRenderer->initView(); - $view = $viewRenderer->view; - $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper'); - $view->dojo()->setCdnVersion('1.1.0') - ->requireModule('dojo.parser') - ->enable(); - $view->headTitle('Foo'); - $this->testCase->dispatch('/zend-test-php-unit-foo/baz'); - $response = $this->testCase->getResponse(); - $this->testCase->resetResponse(); - - $view = new Zend_View(); - $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper'); - $this->assertFalse($view->dojo()->isEnabled(), 'Dojo is enabled? ', $view->dojo()); - $this->assertNotContains('Foo', $view->headTitle()->__toString(), 'Head title persisted?'); - } - - /** - * @group ZF-4070 - */ - public function testQueryParametersShouldPersistFollowingDispatch() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $request = $this->testCase->request; - $request->setQuery('mr', 'proper') - ->setQuery('james', 'bond'); - - $this->assertEquals('proper', $request->getQuery('mr'), '(pre) Failed retrieving mr parameter: ' . var_export($request->getQuery(), 1)); - $this->assertEquals('bond', $request->getQuery('james'), '(pre) Failed retrieving james parameter: ' . var_export($request->getQuery(), 1)); - - $this->testCase->dispatch('/'); - - $this->assertEquals('proper', $request->getQuery('mr'), '(post) Failed retrieving mr parameter: ' . var_export($request->getQuery(), 1)); - $this->assertEquals('bond', $request->getQuery('james'), '(post) Failed retrieving james parameter: ' . var_export($request->getQuery(), 1)); - } - - /** - * @group ZF-4070 - */ - public function testQueryStringShouldNotOverwritePreviouslySetQueryParameters() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $request = $this->testCase->request; - $request->setQuery('mr', 'proper') - ->setQuery('james', 'bond'); - - $this->assertEquals('proper', $request->getQuery('mr'), '(pre) Failed retrieving mr parameter: ' . var_export($request->getQuery(), 1)); - $this->assertEquals('bond', $request->getQuery('james'), '(pre) Failed retrieving james parameter: ' . var_export($request->getQuery(), 1)); - - $this->testCase->dispatch('/?spy=super'); - - $this->assertEquals('super', $request->getQuery('spy'), '(post) Failed retrieving spy parameter: ' . var_export($request->getQuery(), 1)); - $this->assertEquals('proper', $request->getQuery('mr'), '(post) Failed retrieving mr parameter: ' . var_export($request->getQuery(), 1)); - $this->assertEquals('bond', $request->getQuery('james'), '(post) Failed retrieving james parameter: ' . var_export($request->getQuery(), 1)); - } - - /** - * @group ZF-3979 - */ - public function testSuperGlobalArraysShouldBeClearedDuringSetUp() - { - $this->testCase->getFrontController()->setControllerDirectory(dirname(__FILE__) . '/_files/application/controllers'); - $request = $this->testCase->request; - $request->setQuery('mr', 'proper') - ->setPost('foo', 'bar') - ->setCookie('bar', 'baz'); - - $this->testCase->setUp(); - $this->assertNull($request->getQuery('mr'), 'Retrieved mr get parameter: ' . var_export($request->getQuery(), 1)); - $this->assertNull($request->getPost('foo'), 'Retrieved foo post parameter: ' . var_export($request->getPost(), 1)); - $this->assertNull($request->getCookie('bar'), 'Retrieved bar cookie parameter: ' . var_export($request->getCookie(), 1)); - } -} - -// Concrete test case class for testing purposes -class Zend_Test_PHPUnit_ControllerTestCaseTest_Concrete extends Zend_Test_PHPUnit_ControllerTestCase -{ -} - -// Call Zend_Test_PHPUnit_ControllerTestCaseTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Test_PHPUnit_ControllerTestCaseTest::main") { - Zend_Test_PHPUnit_ControllerTestCaseTest::main(); -} diff --git a/tests/Zend/Test/PHPUnit/_files/application/controllers/ErrorController.php b/tests/Zend/Test/PHPUnit/_files/application/controllers/ErrorController.php deleted file mode 100644 index 76af70e477b44aafdd10c816b3921e64084782cb..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/application/controllers/ErrorController.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -require_once 'Zend/Controller/Action.php'; - -class ErrorController extends Zend_Controller_Action -{ - public function errorAction() - { - $errors = $this->_getParam('error_handler'); - - switch ($errors->type) { - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: - // 404 error -- controller or action not found - $this->getResponse()->setHttpResponseCode(404); - $this->view->message = 'Page not found'; - $this->view->request = $errors->request; - $this->view->info = $errors->exception; - break; - default: - // application error - $this->getResponse()->setHttpResponseCode(500); - $this->view->message = 'Application error'; - $this->view->request = $errors->request; - $this->view->info = $errors->exception; - break; - } - } -} diff --git a/tests/Zend/Test/PHPUnit/_files/application/controllers/IndexController.php b/tests/Zend/Test/PHPUnit/_files/application/controllers/IndexController.php deleted file mode 100644 index 63055bfc7ead5ea573c0ae5cd39709ff81b21f32..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/application/controllers/IndexController.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -require_once 'Zend/Controller/Action.php'; - -class IndexController extends Zend_Controller_Action -{ - public function indexAction() - { - } -} diff --git a/tests/Zend/Test/PHPUnit/_files/application/controllers/ZendTestPhpUnitFooController.php b/tests/Zend/Test/PHPUnit/_files/application/controllers/ZendTestPhpUnitFooController.php deleted file mode 100644 index 8ed838e42e137e180787b9606158905f139c8b4b..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/application/controllers/ZendTestPhpUnitFooController.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -class ZendTestPhpUnitFooController extends Zend_Controller_Action -{ - public function barAction() - { - } - - public function bazAction() - { - } - - public function sessionAction() - { - $this->_helper->viewRenderer->setNoRender(true); - $_SESSION = array('foo' => 'bar', 'bar' => 'baz'); - } -} diff --git a/tests/Zend/Test/PHPUnit/_files/application/views/scripts/error/error.phtml b/tests/Zend/Test/PHPUnit/_files/application/views/scripts/error/error.phtml deleted file mode 100644 index 99fc904ef6ffbf5ce1bd5ca20478cc03160657da..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/application/views/scripts/error/error.phtml +++ /dev/null @@ -1,7 +0,0 @@ -Error occurred while performing action: <?php echo $this->info->getMessage() ?> - -Original request parameters: -<?php echo var_export($this->request->getParams(), 1) ?> - -BackTrace: -<?php echo $this->info->getTraceAsString() ?> diff --git a/tests/Zend/Test/PHPUnit/_files/application/views/scripts/zend-test-php-unit-foo/bar.phtml b/tests/Zend/Test/PHPUnit/_files/application/views/scripts/zend-test-php-unit-foo/bar.phtml deleted file mode 100644 index 6b93c92d7b82d6fa21fade3c8358044628c22796..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/application/views/scripts/zend-test-php-unit-foo/bar.phtml +++ /dev/null @@ -1 +0,0 @@ -FooController::barAction() diff --git a/tests/Zend/Test/PHPUnit/_files/application/views/scripts/zend-test-php-unit-foo/baz.phtml b/tests/Zend/Test/PHPUnit/_files/application/views/scripts/zend-test-php-unit-foo/baz.phtml deleted file mode 100644 index 938c07d470c2ef49637e18e8e2bd40e6e3c08425..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/application/views/scripts/zend-test-php-unit-foo/baz.phtml +++ /dev/null @@ -1,17 +0,0 @@ -<html> -<body> -<div id="foo"> - <fieldset> - <legend class="bar">Some Legend</legend> - </fieldset> - - <fieldset> - <legend class="bar baz">Something else</legend> - </fieldset> - - <fieldset> - <legend class="bat">La di da</legend> - </fieldset> -</div> -</body> -</html> diff --git a/tests/Zend/Test/PHPUnit/_files/bootstrap.php b/tests/Zend/Test/PHPUnit/_files/bootstrap.php deleted file mode 100644 index 63b53ff2c7f5040cfec6ce871b86d9b1165566f0..0000000000000000000000000000000000000000 --- a/tests/Zend/Test/PHPUnit/_files/bootstrap.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -require_once 'Zend/Controller/Action/HelperBroker.php'; -require_once 'Zend/Controller/Dispatcher/Standard.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Plugin/ErrorHandler.php'; -require_once 'Zend/Controller/Router/Rewrite.php'; -require_once 'Zend/Registry.php'; -$router = new Zend_Controller_Router_Rewrite(); -$dispatcher = new Zend_Controller_Dispatcher_Standard(); -$plugin = new Zend_Controller_Plugin_ErrorHandler(); -$controller = Zend_Controller_Front::getInstance(); -$controller->setParam('foo', 'bar') - ->registerPlugin($plugin) - ->setRouter($router) - ->setDispatcher($dispatcher); -$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); -Zend_Registry::set('router', $router); -Zend_Registry::set('dispatcher', $dispatcher); -Zend_Registry::set('plugin', $plugin); -Zend_Registry::set('viewRenderer', $viewRenderer); - diff --git a/tests/Zend/Text/AllTests.php b/tests/Zend/Text/AllTests.php deleted file mode 100644 index 3ac5c44e2bcca4329024a74f6208b53667c3fd70..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/AllTests.php +++ /dev/null @@ -1,60 +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_Text - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 6593 2007-10-05 16:43:02Z darby $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Text_AllTests::main'); -} - -require_once 'Zend/Text/FigletTest.php'; - -/** - * @category Zend - * @package Zend_Text - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Text_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Text'); - - $suite->addTestSuite('Zend_Text_FigletTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Text_AllTests::main') { - Zend_Text_AllTests::main(); -} diff --git a/tests/Zend/Text/Figlet/CharWrapLeftToRight.figlet b/tests/Zend/Text/Figlet/CharWrapLeftToRight.figlet deleted file mode 100644 index 4588a18a4c9b326ce4f2422a2876c39c2aa4d9b7..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/CharWrapLeftToRight.figlet +++ /dev/null @@ -1,14 +0,0 @@ - _____ _ _ _ _ _ _ __ __ _____ _ _ -| __ \\ | || | || | \ / || | \ / || \ \\/ // | __ \\ | || | || -| | \ || | || | || | \/ || | \/ || \ ` // | | \ || | || | || -| |__/ || | \\_/ || | . . || | . . || | || | |__/ || | \\_/ || -|_____// \____// |_|\/|_|| |_|\/|_|| |_|| |_____// \____// - -----` `---` `-` `-` `-` `-` `-`' -----` `---` - - _ _ _____ _ _ _ _ _ _ __ __ -| \ / || | __ \\ | || | || | \ / || | \ / || \ \\/ // -| \/ || | | \ || | || | || | \/ || | \/ || \ ` // -| . . || | |__/ || | \\_/ || | . . || | . . || | || -|_|\/|_|| |_____// \____// |_|\/|_|| |_|\/|_|| |_|| -`-` `-` -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/CharWrapRightToLeft.figlet b/tests/Zend/Text/Figlet/CharWrapRightToLeft.figlet deleted file mode 100644 index 9f52fb5d1fe97cbc0dd0b4a0e8177e86ffc58628..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/CharWrapRightToLeft.figlet +++ /dev/null @@ -1,14 +0,0 @@ - _ _ _____ __ __ _ _ _ _ _ _ _____ - | || | || | __ \\ \ \\/ // | \ / || | \ / || | || | || | __ \\ - | || | || | | \ || \ ` // | \/ || | \/ || | || | || | | \ || - | \\_/ || | |__/ || | || | . . || | . . || | \\_/ || | |__/ || - \____// |_____// |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `---` -----` `-`' `-` `-` `-` `-` `---` -----` - - __ __ _ _ _ _ _ _ _____ _ _ - \ \\/ // | \ / || | \ / || | || | || | __ \\ | \ / || - \ ` // | \/ || | \/ || | || | || | | \ || | \/ || - | || | . . || | . . || | \\_/ || | |__/ || | . . || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// |_|\/|_|| - `-`' `-` `-` `-` `-` `---` -----` `-` `-` - diff --git a/tests/Zend/Text/Figlet/CorrectEncoding.figlet b/tests/Zend/Text/Figlet/CorrectEncoding.figlet deleted file mode 100644 index b53422046d2c197533cdf777083872f9aec3891f..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/CorrectEncoding.figlet +++ /dev/null @@ -1,7 +0,0 @@ - []|_[]| _ _ __ []|_[]| []| []| ______ - / _ \\ | \ / || | || / _ \\ | || | || /_ _// - | / \ || | \/ || | || / //\ \\ | || | || `-| |,- - | \_/ || | . . || | ||__ | ___ ||| \\_/ || | || - \___// |_|\/|_|| |____// |_|| |_|| \____// |_|| - ---` `-` `-` `----` `-` `-` `---` `-`' - diff --git a/tests/Zend/Text/Figlet/GenerateDummies.sh b/tests/Zend/Text/Figlet/GenerateDummies.sh deleted file mode 100755 index a366c50f4d50f8220378ff4ea92840c1da20ad50..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/GenerateDummies.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# This file will generate all dummies which are required for the unit testing. -# The figlet program needs to be installed. -# -# Author: Ben 'DASPRiD' Scholzen -# Date: 2008/6/27 13:05 - -# Font used for unit testing, should be the default font -UTFLF="../../../../library/Zend/Text/Figlet/zend-framework.flf" - -# GZIP font for .gz test -rm -f GzippedFont.gz -cp $UTFLF GzippedFont -gzip GzippedFont - -# Create an invalid font file -rm -f InvalidFont.flf -touch InvalidFont.flf - -# Create dummies -figlet -f $UTFLF Dummy > StandardAlignLeft.figlet -figlet -f $UTFLF -c Dummy > StandardAlignCenter.figlet -figlet -f $UTFLF -r Dummy > StandardAlignRight.figlet -figlet -f $UTFLF -R Dummy > StandardRightToLeftAlignRight.figlet -figlet -f $UTFLF -Rc Dummy > StandardRightToLeftAlignCenter.figlet -figlet -f $UTFLF -Rl Dummy > StandardRightToLeftAlignLeft.figlet -figlet -f $UTFLF -w50 -r Dummy > OutputWidth50AlignRight.figlet -figlet -f $UTFLF -m-1 Dummy > NoSmush.figlet -figlet -f $UTFLF -m-1 -R Dummy > NoSmushRightToLeft.figlet -figlet -f $UTFLF -m0 Dummy > SmushDefault.figlet -figlet -f $UTFLF -m5 Dummy > SmushForced.figlet -echo 'Ömläüt' | iconv -f UTF-8 -t ISO-8859-15 | figlet -f $UTFLF > CorrectEncoding.figlet -figlet -f $UTFLF Dummy Dummy Dummy > WordWrapLeftToRight.figlet -figlet -f $UTFLF -R Dummy Dummy Dummy > WordWrapRightToLeft.figlet -figlet -f $UTFLF DummyDumDummy > CharWrapLeftToRight.figlet -figlet -f $UTFLF -R DummyDumDummy > CharWrapRightToLeft.figlet -echo -e "Dum\nDum\n\nDum" | figlet -f $UTFLF -p > ParagraphOn.figlet -echo -e "Dum\nDum\n\nDum" | figlet -f $UTFLF > ParagraphOff.figlet diff --git a/tests/Zend/Text/Figlet/GzippedFont.gz b/tests/Zend/Text/Figlet/GzippedFont.gz deleted file mode 100644 index dd5c5e1b931ed4ffca2b537c6200fcbc8d794717..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Text/Figlet/GzippedFont.gz and /dev/null differ diff --git a/tests/Zend/Text/Figlet/InvalidFont.flf b/tests/Zend/Text/Figlet/InvalidFont.flf deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/Zend/Text/Figlet/NoSmush.figlet b/tests/Zend/Text/Figlet/NoSmush.figlet deleted file mode 100644 index e6de424d8173f09f2a6c6e608dd138b1e34506b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/NoSmush.figlet +++ /dev/null @@ -1,7 +0,0 @@ - _____ _ _ _ _ _ _ __ __ -| __ \\ | || | || | \ / || | \ / || \ \\/ // -| | \ || | || | || | \/ || | \/ || \ ` // -| |__/ || | \\_/ || | . . || | . . || | || -|_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/NoSmushRightToLeft.figlet b/tests/Zend/Text/Figlet/NoSmushRightToLeft.figlet deleted file mode 100644 index 537166a3cb5e4b4dab4e5e1dee1a362852c46d8b..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/NoSmushRightToLeft.figlet +++ /dev/null @@ -1,7 +0,0 @@ - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - diff --git a/tests/Zend/Text/Figlet/OutputWidth50AlignRight.figlet b/tests/Zend/Text/Figlet/OutputWidth50AlignRight.figlet deleted file mode 100644 index 71bab44283399693c3c33e0d8c87dc431414f2e9..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/OutputWidth50AlignRight.figlet +++ /dev/null @@ -1,14 +0,0 @@ - _____ _ _ _ _ _ _ - | __ \\ | || | || | \ / || | \ / || - | | \ || | || | || | \/ || | \/ || - | |__/ || | \\_/ || | . . || | . . || - |_____// \____// |_|\/|_|| |_|\/|_|| - -----` `---` `-` `-` `-` `-` - - __ __ - \ \\/ // - \ ` // - | || - |_|| - `-`' - diff --git a/tests/Zend/Text/Figlet/ParagraphOff.figlet b/tests/Zend/Text/Figlet/ParagraphOff.figlet deleted file mode 100644 index 8666333b02babfbbb42609f89aaa0a99c069d5e1..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/ParagraphOff.figlet +++ /dev/null @@ -1,28 +0,0 @@ - _____ _ _ _ _ -| __ \\ | || | || | \ / || -| | \ || | || | || | \/ || -| |__/ || | \\_/ || | . . || -|_____// \____// |_|\/|_|| - -----` `---` `-` `-` - - _____ _ _ _ _ -| __ \\ | || | || | \ / || -| | \ || | || | || | \/ || -| |__/ || | \\_/ || | . . || -|_____// \____// |_|\/|_|| - -----` `---` `-` `-` - - - - - - - - - _____ _ _ _ _ -| __ \\ | || | || | \ / || -| | \ || | || | || | \/ || -| |__/ || | \\_/ || | . . || -|_____// \____// |_|\/|_|| - -----` `---` `-` `-` - diff --git a/tests/Zend/Text/Figlet/ParagraphOn.figlet b/tests/Zend/Text/Figlet/ParagraphOn.figlet deleted file mode 100644 index 92fe94d2730dd316e4126d5b400656ca67625873..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/ParagraphOn.figlet +++ /dev/null @@ -1,21 +0,0 @@ - _____ _ _ _ _ _____ _ _ _ _ -| __ \\ | || | || | \ / || | __ \\ | || | || | \ / || -| | \ || | || | || | \/ || | | \ || | || | || | \/ || -| |__/ || | \\_/ || | . . || | |__/ || | \\_/ || | . . || -|_____// \____// |_|\/|_|| |_____// \____// |_|\/|_|| - -----` `---` `-` `-` -----` `---` `-` `-` - - - - - - - - - _____ _ _ _ _ -| __ \\ | || | || | \ / || -| | \ || | || | || | \/ || -| |__/ || | \\_/ || | . . || -|_____// \____// |_|\/|_|| - -----` `---` `-` `-` - diff --git a/tests/Zend/Text/Figlet/SmushDefault.figlet b/tests/Zend/Text/Figlet/SmushDefault.figlet deleted file mode 100644 index 421dd669616e8effcebf363de9586423b75ca80e..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/SmushDefault.figlet +++ /dev/null @@ -1,7 +0,0 @@ - _____ _ _ _ _ _ _ __ __ -| __ \\ | || | ||| \ / ||| \ / ||\ \\/ // -| | \ ||| || | ||| \/ ||| \/ || \ ` // -| |__/ ||| \\_/ ||| . . ||| . . || | || -|_____// \____// |_|\/|_|||_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/SmushForced.figlet b/tests/Zend/Text/Figlet/SmushForced.figlet deleted file mode 100644 index cae05d66f7ee2e7b74409618f84faf6a78b1ac57..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/SmushForced.figlet +++ /dev/null @@ -1,7 +0,0 @@ - _____ _ _ _ _ _ _ __ __ -| __ \\| || | || \ / || \ / |\ \\/ // -| | \ || || | || \/ || \/ ||\ ` // -| |__/ || \\_/ || . . || . . || | || -|_____// \____//|_|\/|_||_|\/|_|| |_|| - -----` `---` `-` `-``-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/StandardAlignCenter.figlet b/tests/Zend/Text/Figlet/StandardAlignCenter.figlet deleted file mode 100644 index 1f4956c5d463f5dd2dc74129a7ebe49bb8897275..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/StandardAlignCenter.figlet +++ /dev/null @@ -1,7 +0,0 @@ - _____ _ _ _ _ _ _ __ __ - | __ \\ | || | || | \ / || | \ / || \ \\/ // - | | \ || | || | || | \/ || | \/ || \ ` // - | |__/ || | \\_/ || | . . || | . . || | || - |_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/StandardAlignLeft.figlet b/tests/Zend/Text/Figlet/StandardAlignLeft.figlet deleted file mode 100644 index e6de424d8173f09f2a6c6e608dd138b1e34506b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/StandardAlignLeft.figlet +++ /dev/null @@ -1,7 +0,0 @@ - _____ _ _ _ _ _ _ __ __ -| __ \\ | || | || | \ / || | \ / || \ \\/ // -| | \ || | || | || | \/ || | \/ || \ ` // -| |__/ || | \\_/ || | . . || | . . || | || -|_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/StandardAlignRight.figlet b/tests/Zend/Text/Figlet/StandardAlignRight.figlet deleted file mode 100644 index bfdf6181c66b4f5c41c4695c7ed949a27e26a2d3..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/StandardAlignRight.figlet +++ /dev/null @@ -1,7 +0,0 @@ - _____ _ _ _ _ _ _ __ __ - | __ \\ | || | || | \ / || | \ / || \ \\/ // - | | \ || | || | || | \/ || | \/ || \ ` // - | |__/ || | \\_/ || | . . || | . . || | || - |_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/StandardRightToLeftAlignCenter.figlet b/tests/Zend/Text/Figlet/StandardRightToLeftAlignCenter.figlet deleted file mode 100644 index b6ee4a2cc1e38f3f332b3c35044471afefba7622..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/StandardRightToLeftAlignCenter.figlet +++ /dev/null @@ -1,7 +0,0 @@ - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - diff --git a/tests/Zend/Text/Figlet/StandardRightToLeftAlignLeft.figlet b/tests/Zend/Text/Figlet/StandardRightToLeftAlignLeft.figlet deleted file mode 100644 index 87d80a70ee839211acda98e37ae51ddd2550b76a..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/StandardRightToLeftAlignLeft.figlet +++ /dev/null @@ -1,7 +0,0 @@ - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - diff --git a/tests/Zend/Text/Figlet/StandardRightToLeftAlignRight.figlet b/tests/Zend/Text/Figlet/StandardRightToLeftAlignRight.figlet deleted file mode 100644 index 537166a3cb5e4b4dab4e5e1dee1a362852c46d8b..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/StandardRightToLeftAlignRight.figlet +++ /dev/null @@ -1,7 +0,0 @@ - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - diff --git a/tests/Zend/Text/Figlet/WordWrapLeftToRight.figlet b/tests/Zend/Text/Figlet/WordWrapLeftToRight.figlet deleted file mode 100644 index 4660246a556e2eede26a0a87846595e93fa4be8b..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/WordWrapLeftToRight.figlet +++ /dev/null @@ -1,21 +0,0 @@ - _____ _ _ _ _ _ _ __ __ -| __ \\ | || | || | \ / || | \ / || \ \\/ // -| | \ || | || | || | \/ || | \/ || \ ` // -| |__/ || | \\_/ || | . . || | . . || | || -|_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - - _____ _ _ _ _ _ _ __ __ -| __ \\ | || | || | \ / || | \ / || \ \\/ // -| | \ || | || | || | \/ || | \/ || \ ` // -| |__/ || | \\_/ || | . . || | . . || | || -|_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - - _____ _ _ _ _ _ _ __ __ -| __ \\ | || | || | \ / || | \ / || \ \\/ // -| | \ || | || | || | \/ || | \/ || \ ` // -| |__/ || | \\_/ || | . . || | . . || | || -|_____// \____// |_|\/|_|| |_|\/|_|| |_|| - -----` `---` `-` `-` `-` `-` `-`' - diff --git a/tests/Zend/Text/Figlet/WordWrapRightToLeft.figlet b/tests/Zend/Text/Figlet/WordWrapRightToLeft.figlet deleted file mode 100644 index 4bc178ac441fddcd4ee8f47ac56e5f2119d59f77..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/Figlet/WordWrapRightToLeft.figlet +++ /dev/null @@ -1,21 +0,0 @@ - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - - __ __ _ _ _ _ _ _ _____ - \ \\/ // | \ / || | \ / || | || | || | __ \\ - \ ` // | \/ || | \/ || | || | || | | \ || - | || | . . || | . . || | \\_/ || | |__/ || - |_|| |_|\/|_|| |_|\/|_|| \____// |_____// - `-`' `-` `-` `-` `-` `---` -----` - diff --git a/tests/Zend/Text/FigletTest.php b/tests/Zend/Text/FigletTest.php deleted file mode 100644 index 024c94411c4a825d800d72f5013bd0413225ea96..0000000000000000000000000000000000000000 --- a/tests/Zend/Text/FigletTest.php +++ /dev/null @@ -1,290 +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_Text - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: XmlTest.php 9670 2008-06-11 08:51:21Z dasprid $ - */ - -// Call Zend_Text_FigletTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Text_FigletTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * Zend_Text_Figlet - */ -require_once 'Zend/Text/Figlet.php'; - -/** - * Zend_Config - */ -require_once 'Zend/Config.php'; - -/** - * @category Zend - * @package Zend_Text - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Text_FigletTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Text_FigletTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testStandardAlignLeft() - { - $figlet = new Zend_Text_Figlet(); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignLeft.figlet'); - } - - public function testStandardAlignCenter() - { - $figlet = new Zend_Text_Figlet(array('justification' => Zend_Text_Figlet::JUSTIFICATION_CENTER)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignCenter.figlet'); - } - - public function testStandardAlignRight() - { - $figlet = new Zend_Text_Figlet(array('justification' => Zend_Text_Figlet::JUSTIFICATION_RIGHT)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignRight.figlet'); - } - - public function testStandardRightToLeftAlignLeft() - { - $figlet = new Zend_Text_Figlet(array('justification' => Zend_Text_Figlet::JUSTIFICATION_LEFT, - 'rightToLeft' => Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardRightToLeftAlignLeft.figlet'); - } - - public function testStandardRightToLeftAlignCenter() - { - $figlet = new Zend_Text_Figlet(array('justification' => Zend_Text_Figlet::JUSTIFICATION_CENTER, - 'rightToLeft' => Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardRightToLeftAlignCenter.figlet'); - } - - public function testStandardRightToLeftAlignRight() - { - $figlet = new Zend_Text_Figlet(array('rightToLeft' => Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardRightToLeftAlignRight.figlet'); - } - - public function testWrongParameter() - { - $figlet = new Zend_Text_Figlet(); - - try { - $figlet->render(1); - $this->fail('An expected InvalidArgumentException has not been raised'); - } catch (InvalidArgumentException $expected) { - $this->assertContains('$text must be a string', $expected->getMessage()); - } - } - - public function testCorrectEncodingUTF8() - { - $figlet = new Zend_Text_Figlet(); - - $this->_equalAgainstFile($figlet->render('Ömläüt'), 'CorrectEncoding.figlet'); - } - - public function testCorrectEncodingISO885915() - { - $figlet = new Zend_Text_Figlet(); - - $isoText = iconv('UTF-8', 'ISO-8859-15', 'Ömläüt'); - $this->_equalAgainstFile($figlet->render($isoText, 'ISO-8859-15'), 'CorrectEncoding.figlet'); - } - - /** - * @expectedException Zend_Text_Figlet_Exception - */ - public function testIncorrectEncoding() - { - $this->markTestSkipped('Test case not reproducible on all setups'); - $figlet = new Zend_Text_Figlet(); - $isoText = iconv('UTF-8', 'ISO-8859-15', 'Ömläüt'); - $figlet->render($isoText); - } - - public function testNonExistentFont() - { - try { - $figlet = new Zend_Text_Figlet(array('font' => dirname(__FILE__) . '/Figlet/NonExistentFont.flf')); - $this->fail('An expected Zend_Text_Figlet_Exception has not been raised'); - } catch (Zend_Text_Figlet_Exception $expected) { - $this->assertContains('Font file not found', $expected->getMessage()); - } - } - - public function testInvalidFont() - { - try { - $figlet = new Zend_Text_Figlet(array('font' => dirname(__FILE__) . '/Figlet/InvalidFont.flf')); - $this->fail('An expected Zend_Text_Figlet_Exception has not been raised'); - } catch (Zend_Text_Figlet_Exception $expected) { - $this->assertContains('Not a FIGlet 2 font file', $expected->getMessage()); - } - } - - public function testGzippedFont() - { - $figlet = new Zend_Text_Figlet(array('font' => dirname(__FILE__) . '/Figlet/GzippedFont.gz')); - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignLeft.figlet'); - } - - public function testConfig() - { - $config = new Zend_Config(array('justification' => Zend_Text_Figlet::JUSTIFICATION_RIGHT)); - $figlet = new Zend_Text_Figlet($config); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignRight.figlet'); - } - - public function testOutputWidth() - { - $figlet = new Zend_Text_Figlet(array('outputWidth' => 50, - 'justification' => Zend_Text_Figlet::JUSTIFICATION_RIGHT)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'OutputWidth50AlignRight.figlet'); - } - - public function testSmushModeRemoved() - { - $figlet = new Zend_Text_Figlet(array('smushMode' => -1)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'NoSmush.figlet'); - } - - public function testSmushModeRemovedRightToLeft() - { - $figlet = new Zend_Text_Figlet(array('smushMode' => -1, - 'rightToLeft' => Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'NoSmushRightToLeft.figlet'); - } - - public function testSmushModeInvalid() - { - $figlet = new Zend_Text_Figlet(array('smushMode' => -5)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignLeft.figlet'); - } - - public function testSmushModeTooSmall() - { - $figlet = new Zend_Text_Figlet(array('smushMode' => -2)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'StandardAlignLeft.figlet'); - } - - public function testSmushModeDefault() - { - $figlet = new Zend_Text_Figlet(array('smushMode' => 0)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'SmushDefault.figlet'); - } - - public function testSmushModeForced() - { - $figlet = new Zend_Text_Figlet(array('smushMode' => 5)); - - $this->_equalAgainstFile($figlet->render('Dummy'), 'SmushForced.figlet'); - } - - public function testWordWrapLeftToRight() - { - $figlet = new Zend_Text_Figlet(); - - $this->_equalAgainstFile($figlet->render('Dummy Dummy Dummy'), 'WordWrapLeftToRight.figlet'); - } - - public function testWordWrapRightToLeft() - { - $figlet = new Zend_Text_Figlet(array('rightToLeft' => Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT)); - - $this->_equalAgainstFile($figlet->render('Dummy Dummy Dummy'), 'WordWrapRightToLeft.figlet'); - } - - public function testCharWrapLeftToRight() - { - $figlet = new Zend_Text_Figlet(); - - $this->_equalAgainstFile($figlet->render('DummyDumDummy'), 'CharWrapLeftToRight.figlet'); - } - - public function testCharWrapRightToLeft() - { - $figlet = new Zend_Text_Figlet(array('rightToLeft' => Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT)); - - $this->_equalAgainstFile($figlet->render('DummyDumDummy'), 'CharWrapRightToLeft.figlet'); - } - - public function testParagraphOff() - { - $figlet = new Zend_Text_Figlet(); - - $this->_equalAgainstFile($figlet->render("Dum\nDum\n\nDum\n"), 'ParagraphOff.figlet'); - } - - public function testParagraphOn() - { - $figlet = new Zend_Text_Figlet(array('handleParagraphs' => true)); - - $this->_equalAgainstFile($figlet->render("Dum\nDum\n\nDum\n"), 'ParagraphOn.figlet'); - } - - public function testEmptyString() - { - $figlet = new Zend_Text_Figlet(); - - $this->assertEquals('', $figlet->render('')); - } - - protected function _equalAgainstFile($output, $file) - { - $compareString = file_get_contents(dirname(__FILE__) . '/Figlet/' . $file); - - $this->assertEquals($compareString, $output); - } -} - -// Call Zend_Text_FigletTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Text_FigletTest::main") { - Zend_Text_FigletTest::main(); -} diff --git a/tests/Zend/TimeSyncTest.php b/tests/Zend/TimeSyncTest.php deleted file mode 100644 index e4c9ae129d396d38efcf1b986b87051353cf7dda..0000000000000000000000000000000000000000 --- a/tests/Zend/TimeSyncTest.php +++ /dev/null @@ -1,333 +0,0 @@ -<?php - -/** - * @package Zend_TimeSync - * @subpackage UnitTests - */ - -/** - * Zend_timeSync - */ -require_once 'Zend/TimeSync.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @package Zend_TimeSync - * @subpackage UnitTests - */ -class Zend_TimeSyncTest extends PHPUnit_Framework_TestCase -{ - public $timeservers = array( - // invalid servers - 'server_a' => 'ntp://be.foo.bar.org', - 'server_b' => 'sntp://be.foo.bar.org', - 'server_c' => 'sntp://foo:bar@be.foo.bar.org:123', - - // valid servers - 'server_d' => 'ntp://be.pool.ntp.org', - 'server_e' => 'ntp://time.windows.com', - 'server_f' => 'sntp://time-C.timefreq.bldrdoc.gov' - ); - - /** - * Test for object initialisation - * - * @return void - */ - public function testInitTimeserver() - { - $server = new Zend_TimeSync(); - - $this->assertTrue($server instanceof Zend_TimeSync); - } - - /** - * Test for object initialisation with multiple timeservers - * - * @return void - */ - public function testInitTimeservers() - { - $server = new Zend_TimeSync($this->timeservers); - $result = $server->getServer('server_f'); - - $this->assertTrue($result instanceof Zend_TimeSync_Protocol); - } - - /** - * Test for object initialisation with a single timeserver that will - * default to the default scheme (ntp), because no scheme is supplied - * - * @return void - */ - public function testInitDefaultScheme() - { - $server = new Zend_TimeSync('time.windows.com', 'windows_time'); - $server->setServer('windows_time'); - $result = $server->getServer(); - - $this->assertTrue($result instanceof Zend_TimeSync_Ntp); - } - - /** - * Test for object initialisation with a single NTP timeserver - * - * @return void - */ - public function testInitNtpScheme() - { - $server = new Zend_TimeSync('ntp://time.windows.com', 'windows_time'); - $server->setServer('windows_time'); - $result = $server->getServer(); - - $this->assertTrue($result instanceof Zend_TimeSync_Ntp); - } - - - /** - * Test for object initialisation with a single SNTP timeserver - * - * @return void - */ - public function testInitSntpScheme() - { - $server = new Zend_TimeSync('sntp://time.zend.com', 'windows_time'); - $server->setServer('windows_time'); - $result = $server->getServer(); - - $this->assertTrue($result instanceof Zend_TimeSync_Sntp); - } - - - /** - * Test for object initialisation with an unsupported scheme. This will - * cause the default scheme to be used (ntp) - * - * @return void - */ - public function testInitUnknownScheme() - { - try { - $server = new Zend_TimeSync('http://time.windows.com', 'windows_time'); - $this->fail('Exception expected because we supplied an invalid protocol'); - } catch (Zend_TimeSync_Exception $e) { - // success - } - } - - /** - * Test setting a single option - * - * @return void - */ - public function tesSetOption() - { - $timeout = 5; - - $server = new Zend_TimeSync(); - $server->setOptions(array('timeout' => $timeout)); - - $this->assertEquals($timeout, $server->getOptions('timeout')); - } - - /** - * Test setting an array of options - * - * @return void - */ - public function testSetOptions() - { - $options = array( - 'timeout' => 5, - 'foo' => 'bar' - ); - - $server = new Zend_TimeSync(); - $server->setOptions($options); - - $this->assertEquals($options['timeout'], $server->getOptions('timeout')); - $this->assertEquals($options['foo'], $server->getOptions('foo')); - } - - /** - * Test getting an option that is not set - * - * @return void - */ - public function testGetInvalidOptionKey() - { - $server = new Zend_TimeSync(); - - try { - $result = $server->getOptions('foobar'); - $this->fail('Exception expected because we supplied an invalid option key'); - } catch (Zend_TimeSync_Exception $e) { - // success - } - } - - /** - * Test marking a none existing timeserver as current - * - * @return void - */ - public function testSetUnknownCurrent() - { - $server = new Zend_TimeSync(); - - try { - $server->setServer('unkown_alias'); - $this->fail('Exception expected because there is no timeserver which we can mark as current'); - } catch (Zend_TimeSync_Exception $e) { - // success - } - } - - /** - * Test getting the current timeserver when none is set - * - * @return void - */ - public function testGetUnknownCurrent() - { - $server = new Zend_TimeSync(); - - try { - $result = $server->getServer(); - $this->fail('Exception expected because there is no current timeserver set'); - } catch (Zend_TimeSync_Exception $e) { - // success - } - } - - /** - * Test getting a none existing timeserver - * - * @return void - */ - public function testGetUnknownServer() - { - $server = new Zend_TimeSync(); - - try { - $result = $server->getServer('none_existing_server_alias'); - $this->fail('Exception expected, because the requested timeserver does not exist'); - } catch (Zend_TimeSync_Exception $e) { - // success - } - } - - /** - * Test getting a date using the fallback mechanism, will try to - * return the date from the first server that returns a valid result - * - * @return void - */ - public function testGetDate() - { - $server = new Zend_TimeSync($this->timeservers); - - try { - $result = $server->getDate(); - $this->assertTrue($result instanceof Zend_Date); - } catch (Zend_TimeSync_Exception $e) { - $this->assertContains('all timeservers are bogus', $e->getMessage()); - } - } - - /** - * Test getting a date from an ntp timeserver - * - * @return void - */ - public function testGetNtpDate() - { - $server = new Zend_TimeSync('ntp://time.windows.com', 'time_windows'); - - try { - $result = $server->getDate(); - $this->assertTrue($result instanceof Zend_Date); - } catch (Zend_TimeSync_Exception $e) { - $this->assertContains('all timeservers are bogus', $e->getMessage()); - } - } - - /** - * Test getting a date from an sntp timeserver - * - * @return void - */ - public function testGetSntpDate() - { - $server = new Zend_TimeSync('sntp://time-C.timefreq.bldrdoc.gov'); - - try { - $result = $server->getDate(); - $this->assertTrue($result instanceof Zend_Date); - } catch (Zend_TimeSync_Exception $e) { - $this->assertContains('all timeservers are bogus', $e->getMessage()); - } - } - - /** - * Test getting a date from an invalid timeserver - * - * @return void - */ - public function testGetInvalidDate() - { - $servers = array( - 'server_a' => 'dummy-ntp-timeserver.com', - 'server_b' => 'another-dummy-ntp-timeserver.com' - ); - - $server = new Zend_TimeSync($servers); - - try { - $result = $server->getDate(); - } catch (Zend_TimeSync_Exception $e) { - $exceptions = $e->get(); - - foreach($exceptions as $key => $exception) { - $this->assertTrue($exception instanceof Zend_TimeSync_Exception); - } - } - } - - /** - * Test walking through the server list - * - * @return void - */ - public function testWalkServers() - { - $servers = new Zend_TimeSync($this->timeservers); - - foreach ($servers as $key => $server) { - $this->assertTrue($server instanceof Zend_TimeSync_Protocol); - } - } - - /** - * Test getting info returned from the server - * - * @return void - */ - public function testGetInfo() - { - $server = new Zend_TimeSync('time.windows.com'); - try { - $date = $server->getDate(); - $result = $server->getInfo(); - - $this->assertTrue(count($result) > 0); - } catch (Zend_TimeSync_Exception $e) { - // nothing - } - } -} diff --git a/tests/Zend/Translate/AllTests.php b/tests/Zend/Translate/AllTests.php deleted file mode 100644 index ffc2f66cf5d9a2b73dbaba1297815a1a974fa536..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/AllTests.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Translate_AllTests::main'); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/Translate/ArrayTest.php'; -require_once 'Zend/Translate/CsvTest.php'; -require_once 'Zend/Translate/GettextTest.php'; -require_once 'Zend/Translate/IniTest.php'; -require_once 'Zend/Translate/QtTest.php'; -require_once 'Zend/Translate/TbxTest.php'; -require_once 'Zend/Translate/TmxTest.php'; -require_once 'Zend/Translate/XliffTest.php'; -require_once 'Zend/Translate/XmlTmTest.php'; - -class Zend_Translate_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Translate'); - - $suite->addTestSuite('Zend_Translate_ArrayTest'); - $suite->addTestSuite('Zend_Translate_CsvTest'); - $suite->addTestSuite('Zend_Translate_GettextTest'); - $suite->addTestSuite('Zend_Translate_IniTest'); - $suite->addTestSuite('Zend_Translate_QtTest'); - $suite->addTestSuite('Zend_Translate_TbxTest'); - $suite->addTestSuite('Zend_Translate_TmxTest'); - $suite->addTestSuite('Zend_Translate_XliffTest'); - $suite->addTestSuite('Zend_Translate_XmlTmTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Translate_AllTests::main') { - Zend_Translate_AllTests::main(); -} diff --git a/tests/Zend/Translate/ArrayTest.php b/tests/Zend/Translate/ArrayTest.php deleted file mode 100644 index a23cbd656b94d2953b94cc43d94f032352539d7b..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/ArrayTest.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - - -/** - * Zend_Translate_Adapter_Array - */ -require_once 'Zend/Translate/Adapter/Array.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Config - * @subpackage UnitTests - */ -class Zend_Translate_ArrayTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - )); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array); - - try { - $adapter = new Zend_Translate_Adapter_Array('hastofail'); - $this->fail(); - } catch (Zend_Translate_Exception $e) { - // success - } - - $adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/array.php'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array); - - try { - $adapter = new Zend_Translate_Adapter_Array(dirname(__FILE__) . '/_files/translation_en.csv'); - $this->fail(); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - )); - $this->assertEquals('Array', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - )); - $this->assertEquals('Message 1 (en)', $adapter->translate('msg1')); - $this->assertEquals('msg4', $adapter->translate('msg4')); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - )); - $this->assertTrue( $adapter->isTranslated('msg1')); - $this->assertFalse($adapter->isTranslated('msg4')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - ), - 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('msg1')); - $this->assertEquals('Message 1 (en)', $adapter->_('msg1' )); - $this->assertEquals('msg4', $adapter->translate('msg4')); - - $adapter->addTranslation(array('msg4' => 'Message 4 (en)', - 'msg5' => 'Message 5 (en)', - 'msg6' => 'Message 6 (en)' - ),'en'); - $this->assertEquals('Message 5 (en)', $adapter->translate('msg5')); - - $adapter->addTranslation(array('msg1' => 'Message 1 (ru)', - 'msg2' => 'Message 2 (ru)', - 'msg3' => 'Message 3 (ru)' - ), 'ru'); - $this->assertEquals('Message 1 (ru)', $adapter->translate('msg1', 'ru')); - - $adapter->addTranslation(array('msg4' => 'Message 4 (ru)', - 'msg5' => 'Message 5 (ru)', - 'msg6' => 'Message 6 (ru)' - ), 'ru', - array('clear' => true)); - $this->assertEquals('msg2', $adapter->translate('msg2', 'ru')); - $this->assertEquals('Message 4 (ru)', $adapter->translate('msg4', 'ru')); - $this->assertEquals('msg1', $adapter->translate('msg1', 'xx')); - $this->assertEquals('Message 4 (ru)', $adapter->translate('msg4', 'ru_RU')); - - try { - $adapter->addTranslation(array('msg1' => 'Message 1 (ru)', - 'msg2' => 'Message 2 (ru)', - 'msg3' => 'Message 3 (ru)' - ), 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - ), 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - ), 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('de'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Array(array('msg1' => 'Message 1 (en)', - 'msg2' => 'Message 2 (en)', - 'msg3' => 'Message 3 (en)' - ), 'en'); - $this->assertEquals(array('en' => 'en'), $adapter->getList()); - $adapter->addTranslation(array('msg1'), 'de'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - $this->assertTrue($adapter->isAvailable('de')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } -} diff --git a/tests/Zend/Translate/CsvTest.php b/tests/Zend/Translate/CsvTest.php deleted file mode 100644 index 1bcbbf3c9b349fe712adda36c34c78f95ae901a0..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/CsvTest.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - - -/** - * Zend_Translate_Adapter_Csv - */ -require_once 'Zend/Translate/Adapter/Csv.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_CsvTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Csv); - - try { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/nofile.csv', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv'); - $this->assertEquals('Csv', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1')); - $this->assertEquals('Message 1 (en)', $adapter->_( 'Message 1')); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5')); - - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en2.csv', 'en', array('delimiter' => ',')); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 4 (en)', $adapter->translate('Message 4,')); - $this->assertEquals('Message 5, (en)', $adapter->translate('Message 5' )); - $this->assertEquals('Message 6,addon (en)', $adapter->translate('Message 6,addon,' )); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv', 'en_US'); - $this->assertTrue( $adapter->isTranslated('Message 1' )); - $this->assertFalse($adapter->isTranslated('Message 8' )); - $this->assertTrue( $adapter->isTranslated('Message 1', true )); - $this->assertFalse($adapter->isTranslated('Message 1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message 1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5' )); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'xx' )); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1', 'en_US')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.csv', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv', 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('delimiter' => ';', 'testoption' => 'testkey', 'clear' => false, - 'scan' => null, 'locale' => 'en', 'length' => 0, 'enclosure' => '"'), - $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('de'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Csv(dirname(__FILE__) . '/_files/translation_en.csv', 'en'); - $this->assertEquals(array('en' => 'en'), $adapter->getList()); - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.csv', 'de'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - - $this->assertTrue( $adapter->isAvailable('de')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } -} diff --git a/tests/Zend/Translate/GettextTest.php b/tests/Zend/Translate/GettextTest.php deleted file mode 100644 index 639889e9ec96cd9b9033788b2d1f6e4a8219cdc4..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/GettextTest.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - - -/** - * Zend_Translate_Adapter_Gettext - */ -require_once 'Zend/Translate/Adapter/Gettext.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Config - * @subpackage UnitTests - */ -class Zend_Translate_GettextTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Gettext); - - try { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/nofile.mo', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/test_fileerror.mo', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo'); - $this->assertEquals('Gettext', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1')); - $this->assertEquals('Message 1 (en)', $adapter->_('Message 1' )); - $this->assertEquals('Message 5', $adapter->translate('Message 5')); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo'); - $this->assertTrue( $adapter->isTranslated('Message 1' )); - $this->assertFalse($adapter->isTranslated('Message 6' )); - $this->assertTrue( $adapter->isTranslated('Message 1', true )); - $this->assertFalse($adapter->isTranslated('Message 1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message 1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 5', $adapter->translate('Message 5' )); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru')); - - $adapter->addTranslation(dirname(__FILE__) . '/_files/testmsg_ru(koi8-r).mo', 'ru'); - // Original message is in KOI8-R.. as unit tests are done in UTF8 we have to convert - // the returned KOI8-R string into UTF-8 - $translation = iconv("KOI8-R", "UTF-8", $adapter->translate('Message 2', 'ru' )); - $this->assertEquals('Сообщение 2 (ru)', $translation ); - $this->assertEquals('Message 5', $adapter->translate('Message 5' )); - $this->assertEquals('Message 5', $adapter->translate('Message 5', 'ru_RU')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/testmsg_ru(koi8-r).mo', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo', 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('de'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/testmsg_en.mo', 'en'); - $this->assertEquals(array('en' => 'en'), $adapter->getList()); - $adapter->addTranslation(dirname(__FILE__) . '/_files/testmsg_en.mo', 'de'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - $this->assertTrue($adapter->isAvailable('de')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } - - public function testBigEndian() - { - $adapter = new Zend_Translate_Adapter_Gettext(dirname(__FILE__) . '/_files/translate_bigendian.mo', 'sr'); - $this->assertEquals('Informacje', $adapter->translate('Informacje')); - } -} diff --git a/tests/Zend/Translate/IniTest.php b/tests/Zend/Translate/IniTest.php deleted file mode 100644 index 51329276d22a263a799f151b62c37567df1724fb..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/IniTest.php +++ /dev/null @@ -1,153 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - -/** - * Zend_Translate_Adapter_Ini - */ -require_once 'Zend/Translate/Adapter/Ini.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_IniTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Translate_IniTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Ini); - - try { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/nofile.ini', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini'); - $this->assertEquals('Ini', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en'); - $this->assertEquals('Nachricht 1 (de)', $adapter->translate('Message_1')); - $this->assertEquals('Nachricht 1 (de)', $adapter->_( 'Message_1')); - $this->assertEquals('Nachricht 2 (de)', $adapter->translate('Message_2')); - - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en', array('separator' => ',')); - $this->assertEquals('Nachricht 1 (de)', $adapter->translate('Message_1' )); - $this->assertEquals('Nachricht 2 (de)', $adapter->translate('Message_2' )); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en_US'); - $this->assertTrue( $adapter->isTranslated('Message_1' )); - $this->assertFalse($adapter->isTranslated('Message_6' )); - $this->assertTrue( $adapter->isTranslated('Message_1', true )); - $this->assertFalse($adapter->isTranslated('Message_1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message_1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en'); - $this->assertEquals('Nachricht 1 (de)', $adapter->translate('Message_1' )); - $this->assertEquals('Message_5', $adapter->translate('Message_5' )); - $this->assertEquals('Message_2', $adapter->translate('Message_2', 'ru' )); - $this->assertEquals('Message_1', $adapter->translate('Message_1', 'xx' )); - $this->assertEquals('Nachricht 1 (de)', $adapter->translate('Message_1', 'en_US')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation.ini', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testClearing() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en'); - $this->assertEquals('Nachricht 1 (de)', $adapter->translate('Message_1' )); - $this->assertEquals('Message_5', $adapter->translate('Message_5' )); - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation2.ini', 'en', array('clear' => true)); - $this->assertEquals('Message_1', $adapter->translate('Message_1')); - $this->assertEquals('Nachricht 5 (de)', $adapter->translate('Message_5')); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('de'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/_files/translation.ini', 'en'); - $this->assertEquals(array('en' => 'en'), $adapter->getList()); - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation.ini', 'de'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - - $this->assertTrue( $adapter->isAvailable('de')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } -} - -// Call Zend_Translate_IniTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Translate_IniTest::main") { - Zend_Translate_IniTest::main(); -} diff --git a/tests/Zend/Translate/QtTest.php b/tests/Zend/Translate/QtTest.php deleted file mode 100644 index b4f63cb571bc57a3c64e7e76c0c0f6b727305dfd..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/QtTest.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - - -/** - * Zend_Translate_Adapter_Qt - */ -require_once 'Zend/Translate/Adapter/Qt.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_QtTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Qt); - - try { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/nofile.ts', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts'); - $this->assertEquals('Qt', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts', 'de'); - $this->assertEquals('Nachricht 1', $adapter->translate('Message 1')); - $this->assertEquals('Nachricht 1', $adapter->_( 'Message 1')); - $this->assertEquals('Message 5', $adapter->translate('Message 5')); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts', 'de_AT'); - $this->assertTrue( $adapter->isTranslated('Message 1' )); - $this->assertFalse($adapter->isTranslated('Message 6' )); - $this->assertTrue( $adapter->isTranslated('Message 1', true )); - $this->assertFalse($adapter->isTranslated('Message 1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message 1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts', 'de'); - $this->assertEquals('Nachricht 1', $adapter->translate('Message 1' )); - $this->assertEquals('Message 5', $adapter->translate('Message 5' )); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru')); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'xx')); - $this->assertEquals('Nachricht 1', $adapter->translate('Message 1', 'de')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_de.ts', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts', 'de'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'de'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts', 'de'); - $this->assertEquals('de', $adapter->getLocale()); - $locale = new Zend_Locale('de'); - $adapter->setLocale($locale); - $this->assertEquals('de', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de.ts', 'de'); - $this->assertEquals(array('de' => 'de'), $adapter->getList()); - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_de.ts', 'en'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - $this->assertTrue($adapter->isAvailable('en')); - $locale = new Zend_Locale('de'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } - - public function testIsoEncoding() - { - $adapter = new Zend_Translate_Adapter_Qt(dirname(__FILE__) . '/_files/translation_de2.ts', 'de'); - $this->assertEquals('Nachricht 1', $adapter->translate('Message 1' )); - $this->assertEquals('Nachricht 1', $adapter->_('Message 1' )); - $this->assertEquals(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel (en)'), $adapter->translate('Cooking Furniture')); - $this->assertEquals('Cooking Furniture (en)', $adapter->translate(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel'))); - } -} diff --git a/tests/Zend/Translate/TbxTest.php b/tests/Zend/Translate/TbxTest.php deleted file mode 100644 index 6c680b66b8d152898984036f9ef11b3461444dae..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/TbxTest.php +++ /dev/null @@ -1,141 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - -/** - * Zend_Translate_Adapter_Tbx - */ -require_once 'Zend/Translate/Adapter/Tbx.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_TbxTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Tbx); - - try { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/nofile.tbx', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/failed.tbx', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx'); - $this->assertEquals('Tbx', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en'); - $this->assertEquals('Message 1', $adapter->translate('Message 1' )); - $this->assertEquals('Message 1', $adapter->_('Message 1' )); - $this->assertEquals('Message 1 (fr)', $adapter->translate('Message 1', 'fr')); - $this->assertEquals('Message 5', $adapter->translate('Message 5' )); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en'); - $this->assertTrue( $adapter->isTranslated('Message 1' )); - $this->assertFalse($adapter->isTranslated('Message 6' )); - $this->assertTrue( $adapter->isTranslated('Message 1', true )); - $this->assertTrue( $adapter->isTranslated('Message 1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message 1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en'); - - $this->assertEquals('Message 1', $adapter->translate('Message 1' )); - $this->assertEquals('Message 5', $adapter->translate('Message 5' )); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'xx' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'en_US')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.tbx', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en2.tbx', 'de', array('clear' => true)); - $this->assertEquals('Message 1', $adapter->translate('Message 1')); - $this->assertEquals('Message 8', $adapter->translate('Message 8')); - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('ar'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en.tbx', 'en'); - $this->assertEquals(array('en' => 'en', 'fr' => 'fr'), $adapter->getList()); - $this->assertTrue($adapter->isAvailable('fr')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } - - public function testIsoEncoding() - { - $adapter = new Zend_Translate_Adapter_Tbx(dirname(__FILE__) . '/_files/translation_en3.tbx', 'fr'); - $this->assertEquals('Message 1 (fr)', $adapter->translate('Nachricht 1' )); - $this->assertEquals('Message 1 (fr)', $adapter->_('Nachricht 1' )); - $this->assertEquals(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel (en)'), $adapter->translate('Cooking Furniture')); - $this->assertEquals('Cooking Furniture (en)', $adapter->translate(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel'))); - } -} diff --git a/tests/Zend/Translate/TmxTest.php b/tests/Zend/Translate/TmxTest.php deleted file mode 100644 index c95a6d7e0553779029793ea96fd18bc8bee0b6da..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/TmxTest.php +++ /dev/null @@ -1,141 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - - -/** - * Zend_Translate_Adapter_Tmx - */ -require_once 'Zend/Translate/Adapter/Tmx.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_TmxTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Tmx); - - try { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/nofile.tmx', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/failed.tmx', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx'); - $this->assertEquals('Tmx', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 1 (en)', $adapter->_('Message 1' )); - $this->assertEquals('Message 1 (it)', $adapter->translate('Message 1', 'it' )); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5' )); - $this->assertEquals('Küchen Möbel (en)', $adapter->translate('Cooking furniture')); - $this->assertEquals('Cooking furniture (en)', $adapter->translate('Küchen Möbel' )); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en'); - $this->assertTrue( $adapter->isTranslated('Message 1' )); - $this->assertFalse($adapter->isTranslated('Message 6' )); - $this->assertTrue( $adapter->isTranslated('Message 1', true )); - $this->assertTrue( $adapter->isTranslated('Message 1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message 1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5' )); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'xx' )); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1', 'en_US')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.tmx', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('fr'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en.tmx', 'en'); - $this->assertEquals(array('en' => 'en', 'de' => 'de', 'it' => 'it'), $adapter->getList()); - $this->assertTrue($adapter->isAvailable('de')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } - - public function testIsoEncoding() - { - $adapter = new Zend_Translate_Adapter_Tmx(dirname(__FILE__) . '/_files/translation_en3.tmx', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 1 (en)', $adapter->_('Message 1' )); - $this->assertEquals('Message 1 (it)', $adapter->translate('Message 1', 'it' )); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5' )); - $this->assertEquals(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel (en)'), $adapter->translate('Cooking furniture')); - $this->assertEquals('Cooking furniture (en)', $adapter->translate(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel'))); - } -} diff --git a/tests/Zend/Translate/XliffTest.php b/tests/Zend/Translate/XliffTest.php deleted file mode 100644 index 3302ca212fe7a7d7b00f6f7422d4c7526d5e92b6..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/XliffTest.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - -/** - * Zend_Translate_Adapter_Xliff - */ -require_once 'Zend/Translate/Adapter/Xliff.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_XliffTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Xliff); - - try { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/nofile.xliff', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/failed.xliff', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff'); - $this->assertEquals('Xliff', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 1 (en)', $adapter->_('Message 1' )); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5' )); - $this->assertEquals('Küchen Möbel (en)', $adapter->translate('Cooking furniture')); - $this->assertEquals('Cooking furniture (en)', $adapter->translate('Küchen Möbel' )); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en'); - $this->assertTrue( $adapter->isTranslated('Message 1' )); - $this->assertFalse($adapter->isTranslated('Message 6' )); - $this->assertTrue( $adapter->isTranslated('Message 1', true )); - $this->assertTrue( $adapter->isTranslated('Message 1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Message 1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 5 (en)', $adapter->translate('Message 5' )); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'xx' )); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1', 'en_US')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.xliff', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en'); - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('fr'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en.xliff', 'en'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.xliff', 'de'); - $this->assertEquals(array('en' => 'en', 'de' => 'de'), $adapter->getList()); - $this->assertTrue($adapter->isAvailable('de')); - $locale = new Zend_Locale('en'); - $this->assertTrue( $adapter->isAvailable($locale)); - $this->assertFalse($adapter->isAvailable('sr' )); - } - - public function testIsoEncoding() - { - $adapter = new Zend_Translate_Adapter_Xliff(dirname(__FILE__) . '/_files/translation_en3.xliff', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Message 1' )); - $this->assertEquals('Message 1 (en)', $adapter->_('Message 1' )); - $this->assertEquals('Küchen Möbel (en)', $adapter->translate('Cooking Furniture')); - $this->assertEquals('Cooking Furniture (en)', $adapter->translate('Küchen Möbel')); - } -} diff --git a/tests/Zend/Translate/XmlTmTest.php b/tests/Zend/Translate/XmlTmTest.php deleted file mode 100644 index d269a07a3a7a94d89b3aa6e12e99f169a4ae6265..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/XmlTmTest.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ - -/** - * Zend_Translate_Adapter_XmlTm - */ -require_once 'Zend/Translate/Adapter/XmlTm.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - */ -class Zend_Translate_XmlTmTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml'); - $this->assertTrue($adapter instanceof Zend_Translate_Adapter_XmlTm); - - try { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/nofile.xml', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - - try { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/failed.xml', 'en'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testToString() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml'); - $this->assertEquals('XmlTm', $adapter->toString()); - } - - public function testTranslate() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'en'); - $this->assertEquals('Message 1', $adapter->translate('Message 1')); - $this->assertEquals('Message 1', $adapter->_('Message 1')); - $this->assertEquals('Message 5', $adapter->translate('Message 5')); - } - - public function testIsTranslated() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'en'); - $this->assertTrue( $adapter->isTranslated('Mess1')); - $this->assertFalse($adapter->isTranslated('Mess6')); - $this->assertTrue( $adapter->isTranslated('Mess1', true)); - $this->assertTrue( $adapter->isTranslated('Mess1', true, 'en')); - $this->assertFalse($adapter->isTranslated('Mess1', false, 'es')); - } - - public function testLoadTranslationData() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'en'); - $this->assertEquals('Message 1', $adapter->translate('Message 1')); - $this->assertEquals('Message 5', $adapter->translate('Message 5')); - $this->assertEquals('Message 2', $adapter->translate('Message 2', 'ru' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'xx' )); - $this->assertEquals('Message 1', $adapter->translate('Message 1', 'en_US')); - - try { - $adapter->addTranslation(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'xx'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - - $adapter->addTranslation(dirname(__FILE__) . '/_files/XmlTm_test_de.xml', 'de', array('clear' => true)); - $this->assertEquals('Message 1', $adapter->translate('Message 1')); - $this->assertEquals('Message 8', $adapter->translate('Message 8')); - } - - public function testOptions() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'en'); - - $adapter->setOptions(array('testoption' => 'testkey')); - $this->assertEquals(array('testoption' => 'testkey', 'clear' => false, 'scan' => null, 'locale' => 'en'), $adapter->getOptions()); - $this->assertEquals('testkey', $adapter->getOptions('testoption')); - $this->assertTrue(is_null($adapter->getOptions('nooption'))); - } - - public function testLocale() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'en'); - $this->assertEquals('en', $adapter->getLocale()); - $locale = new Zend_Locale('en'); - $adapter->setLocale($locale); - $this->assertEquals('en', $adapter->getLocale()); - - try { - $adapter->setLocale('nolocale'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - try { - $adapter->setLocale('ar'); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testList() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en.xml', 'en'); - $this->assertEquals(array('en' => 'en'), $adapter->getList()); - $this->assertFalse($adapter->isAvailable('fr')); - $locale = new Zend_Locale('en'); - $this->assertTrue($adapter->isAvailable($locale)); - } - - public function testIsoEncoding() - { - $adapter = new Zend_Translate_Adapter_XmlTm(dirname(__FILE__) . '/_files/XmlTm_test_en2.xml', 'en'); - $this->assertEquals('Message 1 (en)', $adapter->translate('Mess1' )); - $this->assertEquals('Message 1 (en)', $adapter->_('Mess1' )); - $this->assertEquals(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel (en)'), $adapter->translate('Cooking Furniture')); - $this->assertEquals('Cooking Furniture (en)', $adapter->translate(iconv('UTF-8', 'ISO-8859-1', 'Küchen Möbel'))); - } -} diff --git a/tests/Zend/Translate/_files/XmlTm_test_de.xml b/tests/Zend/Translate/_files/XmlTm_test_de.xml deleted file mode 100644 index 1640627316796c2fdd7e9c319129783b9b2ab594..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/XmlTm_test_de.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<office:document-content -xmlns:text="http://openoffice.org/2000/text" -xmlns:tm="urn:xmlintl-tm-tags" xmlns:xlink="http://www.w3.org/1999/xlink"> -<tm:tm> -<text:p text:style-name="Text body"> - <tm:te id="e1" tuval="2"> - <tm:tu id="Mess1">Message 1 (en)</tm:tu> - <tm:tu id="Mess2">Message 2 (en)</tm:tu> - </tm:te> -</text:p> -<text:ordered-list text:continue-numbering="false" text:style-name="L1"> -<text:p text:style-name="Text body"> - <tm:te id="e2"> - <tm:tu id="Mess3">Message 3 (en)</tm:tu> - <tm:tu id="Mess4">Message 4 (en)</tm:tu> - </tm:te> -</text:p> -<text:list-item> - <text:p text:style-name="P3"> - <tm:te id="e4"> - <tm:tu id="Mess5">Message 5 (en)</tm:tu> - </tm:te> - </text:p> -</text:list-item> \ No newline at end of file diff --git a/tests/Zend/Translate/_files/XmlTm_test_en.xml b/tests/Zend/Translate/_files/XmlTm_test_en.xml deleted file mode 100644 index 1640627316796c2fdd7e9c319129783b9b2ab594..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/XmlTm_test_en.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<office:document-content -xmlns:text="http://openoffice.org/2000/text" -xmlns:tm="urn:xmlintl-tm-tags" xmlns:xlink="http://www.w3.org/1999/xlink"> -<tm:tm> -<text:p text:style-name="Text body"> - <tm:te id="e1" tuval="2"> - <tm:tu id="Mess1">Message 1 (en)</tm:tu> - <tm:tu id="Mess2">Message 2 (en)</tm:tu> - </tm:te> -</text:p> -<text:ordered-list text:continue-numbering="false" text:style-name="L1"> -<text:p text:style-name="Text body"> - <tm:te id="e2"> - <tm:tu id="Mess3">Message 3 (en)</tm:tu> - <tm:tu id="Mess4">Message 4 (en)</tm:tu> - </tm:te> -</text:p> -<text:list-item> - <text:p text:style-name="P3"> - <tm:te id="e4"> - <tm:tu id="Mess5">Message 5 (en)</tm:tu> - </tm:te> - </text:p> -</text:list-item> \ No newline at end of file diff --git a/tests/Zend/Translate/_files/XmlTm_test_en2.xml b/tests/Zend/Translate/_files/XmlTm_test_en2.xml deleted file mode 100644 index ddda6709790f95105b5a39beced68d667c98fc19..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/XmlTm_test_en2.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<office:document-content -xmlns:text="http://openoffice.org/2000/text" -xmlns:tm="urn:xmlintl-tm-tags" xmlns:xlink="http://www.w3.org/1999/xlink"> -<tm:tm> -<text:p text:style-name="Text body"> - <tm:te id="e1" tuval="2"> - <tm:tu id="Mess1">Message 1 (en)</tm:tu> - <tm:tu id="Mess2">Message 2 (en)</tm:tu> - </tm:te> -</text:p> -<text:ordered-list text:continue-numbering="false" text:style-name="L1"> -<text:p text:style-name="Text body"> - <tm:te id="e2"> - <tm:tu id="Mess3">Message 3 (en)</tm:tu> - <tm:tu id="Mess4">Message 4 (en)</tm:tu> - </tm:te> -</text:p> -<text:list-item> - <text:p text:style-name="P3"> - <tm:te id="e4"> - <tm:tu id="Mess5">Message 5 (en)</tm:tu> - </tm:te> - </text:p> -</text:list-item> -<text:p text:style-name="Text body"> - <tm:te id="e2"> - <tm:tu id="Cooking Furniture">Küchen Möbel (en)</tm:tu> - <tm:tu id="Küchen Möbel">Cooking Furniture (en)</tm:tu> - </tm:te> -</text:p> - \ No newline at end of file diff --git a/tests/Zend/Translate/_files/array.php b/tests/Zend/Translate/_files/array.php deleted file mode 100644 index c7f8c89c8fe094b69c1758f6bd0aef25d9a24937..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/array.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php -return array( - 'test' => 'answer', - 'orig' => 'value' -); \ No newline at end of file diff --git a/tests/Zend/Translate/_files/failed.tmx b/tests/Zend/Translate/_files/failed.tmx deleted file mode 100644 index cb82b480111df4963f904642c8922abd511519c5..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/failed.tmx +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" ?> -<!DOCTYPE tmx SYSTEM "tmx14.dtd"> -<tmx version="1.4"> - <header creationtoolversion="1.0.0" datatype="winres" segtype="sentence" adminlang="en-us" srclang="de-at" o-tmf="abc" creationtool="XYZTool" > - </header> - <body> - <tu tuid='Message 1' /> - <tuv xml:lang="de"><seg>Message 1</seg></tuv> - <tuv xml:lang="en"><seg>Message 1 (en)</seg></tuv> - </tu> - <tu tuid='Message 2'> - <tuv xml:lang="de"><seg>Message 2</seg></tuv> - <tuv xml:lang="en"><seg>Message 2 (en)</seg></tuv> - </tu> - <tu tuid='Message 3'> - <tuv xml:lang="de"><seg>Message 3</seg></tuv> - <tuv xml:lang="en"><seg>Message 3 (en)</seg></tuv> - </tu> - <tu tuid='Message 4'> - <tuv xml:lang="de"><seg>Message 4</seg></tuv> - <tuv xml:lang="en"><seg>Message 4 (en)</seg></tuv> - </tu> - <tu tuid='Message 5'> - <tuv xml:lang="de"><seg>Message 5</seg></tuv> - <tuv xml:lang="en"><seg>Message 5 (en)</seg></tuv> - </tu> - </body> -</tmx> diff --git a/tests/Zend/Translate/_files/failed.xliff b/tests/Zend/Translate/_files/failed.xliff deleted file mode 100644 index 7346f8a4578a6562ccfd87282a9c7209d47e797d..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/failed.xliff +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" ?> -<xliff version='1.1' xmlns='urn:oasis:names:tc:xliff:document:1.1'> - <file original='hello.txt' source-language='de' target-language='en' datatype='plaintext'> - <body> - <trans-unit id='1' /> - <source>Message 1</source> - <target>Message 1 (en)</target> - </trans-unit> - <trans-unit id='2'> - <source>Message 2</source> - <target>Message 2 (en)</target> - </trans-unit> - <trans-unit id='3'> - <source>Message 3</source> - <target>Message 3 (en)</target> - </trans-unit> - <trans-unit id='4'> - <source>Message 4</source> - <target>Message 4 (en)</target> - </trans-unit> - <trans-unit id='5'> - <source>Message 5</source> - <target>Message 5 (en)</target> - </trans-unit> - </body> - </file> -</xliff> diff --git a/tests/Zend/Translate/_files/test/de_AT/LC_TEST/translation.csv b/tests/Zend/Translate/_files/test/de_AT/LC_TEST/translation.csv deleted file mode 100644 index 3feb7d2449ce773eec3b90aeed1390cd368039a6..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/test/de_AT/LC_TEST/translation.csv +++ /dev/null @@ -1,9 +0,0 @@ -# Comment -# A csv files contains all informations for one language -# MessageID;Translation -Message 1;Message 1 (de) -Message 2;Message 2 (de) -Message 3;Message 3 (de) -Message 4;Message 4 (de) -# Comment -Message 5;Message 5 (de) \ No newline at end of file diff --git a/tests/Zend/Translate/_files/test/en_GB/LC_OTHER/translation.csv b/tests/Zend/Translate/_files/test/en_GB/LC_OTHER/translation.csv deleted file mode 100644 index 760341d7e7b328327692bd53c4a20fb23c6064be..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/test/en_GB/LC_OTHER/translation.csv +++ /dev/null @@ -1,9 +0,0 @@ -# Comment -# A csv files contains all informations for one language -# MessageID;Translation -Message 1;Message 1 (en) -Message 2;Message 2 (en) -Message 3;Message 3 (en) -Message 4;Message 4 (en) -# Comment -Message 5;Message 5 (en) \ No newline at end of file diff --git a/tests/Zend/Translate/_files/test2/translation-de_AT.csv b/tests/Zend/Translate/_files/test2/translation-de_AT.csv deleted file mode 100644 index 760341d7e7b328327692bd53c4a20fb23c6064be..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/test2/translation-de_AT.csv +++ /dev/null @@ -1,9 +0,0 @@ -# Comment -# A csv files contains all informations for one language -# MessageID;Translation -Message 1;Message 1 (en) -Message 2;Message 2 (en) -Message 3;Message 3 (en) -Message 4;Message 4 (en) -# Comment -Message 5;Message 5 (en) \ No newline at end of file diff --git a/tests/Zend/Translate/_files/test2/translation-de_DE.csv b/tests/Zend/Translate/_files/test2/translation-de_DE.csv deleted file mode 100644 index 760341d7e7b328327692bd53c4a20fb23c6064be..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/test2/translation-de_DE.csv +++ /dev/null @@ -1,9 +0,0 @@ -# Comment -# A csv files contains all informations for one language -# MessageID;Translation -Message 1;Message 1 (en) -Message 2;Message 2 (en) -Message 3;Message 3 (en) -Message 4;Message 4 (en) -# Comment -Message 5;Message 5 (en) \ No newline at end of file diff --git a/tests/Zend/Translate/_files/test_fileerror.mo b/tests/Zend/Translate/_files/test_fileerror.mo deleted file mode 100644 index e057750ff2869c7922d9fab869c15a4841c4a1a1..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Translate/_files/test_fileerror.mo and /dev/null differ diff --git a/tests/Zend/Translate/_files/testmsg_en.mo b/tests/Zend/Translate/_files/testmsg_en.mo deleted file mode 100644 index 3ced007d49ca8ac1015fabaeff0e4556a6a79eba..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Translate/_files/testmsg_en.mo and /dev/null differ diff --git a/tests/Zend/Translate/_files/testmsg_en.po b/tests/Zend/Translate/_files/testmsg_en.po deleted file mode 100644 index 10fd8296e390d0765da2f2122c0daee9c11281b2..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/testmsg_en.po +++ /dev/null @@ -1,39 +0,0 @@ -# translation of testmsg_en.po into English -# $Id: testmsg_en.po,v 1.0 2007/01/16 12:05:55 tokul Exp $ -# -msgid "" -msgstr "" -"Project-Id-Version: testmsg_en\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-01-17 13:22-0400\n" -"PO-Revision-Date: 2008-02-10 14:14+0100\n" -"Last-Translator: Thomas Weidner <thomas.weidner@voxtronic.com>\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-1\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -"Language-Team: \n" - -#: test.php:0 -msgid "Message 1" -msgstr "Message 1 (en)" - -#: test.php:0 -msgid "Message 2" -msgstr "Message 2 (en)" - -#: test.php:0 -msgid "Message 3" -msgstr "Message 3 (en)" - -#: test.php:0 -msgid "Message 4" -msgstr "Message (en)" - -#: test.php:0 -msgid "Message 5" -msgid_plural "Message 5 Plural" -msgstr[0] "Message 5 (en) Plural 0" -msgstr[1] "Message 5 (en) Plural 1" -msgstr[2] "Message 5 (en) Plural 2" - diff --git a/tests/Zend/Translate/_files/testmsg_ru(koi8-r).mo b/tests/Zend/Translate/_files/testmsg_ru(koi8-r).mo deleted file mode 100644 index d81ad0f5aba29848de6fac87769958bedf902e3a..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Translate/_files/testmsg_ru(koi8-r).mo and /dev/null differ diff --git a/tests/Zend/Translate/_files/testmsg_ru(koi8-r).po b/tests/Zend/Translate/_files/testmsg_ru(koi8-r).po deleted file mode 100644 index 190d5a53ca3ae16a1c92b2129e9b54efb6de55d0..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/testmsg_ru(koi8-r).po +++ /dev/null @@ -1,31 +0,0 @@ -# translation of testmsg_en.po into English -# $Id: testmsg_en.po,v 1.0 2007/01/16 12:05:55 tokul Exp $ -# -msgid "" -msgstr "" -"Project-Id-Version: testmsg_en\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2007-01-17 13:22-0400\n" -"PO-Revision-Date: 2007-01-17 13:22-0400\n" -"Last-Translator: Alexander Veremyev <alexander.v@zend.com>\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=KOI8-R\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" -"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" - -#: test.php:0 -msgid "Message 1" -msgstr "óÏÏÂÝÅÎÉÅ 1 (ru)" - -#: test.php:0 -msgid "Message 2" -msgstr "óÏÏÂÝÅÎÉÅ 2 (ru)" - -#: test.php:0 -msgid "Message 3" -msgstr "óÏÏÂÝÅÎÉÅ 3 (ru)" - -#: test.php:0 -msgid "Message 4" -msgstr "óÏÏÂÝÅÎÉÅ 4 (ru)" diff --git a/tests/Zend/Translate/_files/translate_bigendian.mo b/tests/Zend/Translate/_files/translate_bigendian.mo deleted file mode 100644 index 53c830a5905d1831073266016e6b396eb0c62162..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Translate/_files/translate_bigendian.mo and /dev/null differ diff --git a/tests/Zend/Translate/_files/translation.ini b/tests/Zend/Translate/_files/translation.ini deleted file mode 100644 index 3528c29bd6f235217c0aa2da598f134820f11070..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Test] -;TestPage Comment -Message_1="Nachricht 1 (de)" -Message_2="Nachricht 2 (de)" -Message_3="Nachricht :3 (de)" diff --git a/tests/Zend/Translate/_files/translation2.ini b/tests/Zend/Translate/_files/translation2.ini deleted file mode 100644 index 6896203dce2566738282678e99a78fe870f14afe..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation2.ini +++ /dev/null @@ -1,3 +0,0 @@ -[Test] -;TestPage Comment -Message_5="Nachricht 5 (de)" diff --git a/tests/Zend/Translate/_files/translation_de.ts b/tests/Zend/Translate/_files/translation_de.ts deleted file mode 100644 index 7f54f22b180a93f09d9d672f9117a8b8232375e9..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_de.ts +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE TS> -<TS> -<context> - <name>Test</name> - <message> - <source>Message 1</source> - <translation>Nachricht 1</translation> - </message> - <message> - <source>Message 2</source> - <translation>Nachricht 2</translation> - </message> -</context> -</TS> diff --git a/tests/Zend/Translate/_files/translation_de2.ts b/tests/Zend/Translate/_files/translation_de2.ts deleted file mode 100644 index 67f68ae8a1fc6cc5f6389240c856d01f6262da71..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_de2.ts +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE TS> -<TS> -<context> - <name>Test</name> - <message> - <source>Message 1</source> - <translation>Nachricht 1</translation> - </message> - <message> - <source>Message 2</source> - <translation>Nachricht 2</translation> - </message> - <message> - <source>Küchen Möbel</source> - <translation>Cooking Furniture (en)</translation> - </message> - <message> - <source>Cooking Furniture</source> - <translation>Küchen Möbel (en)</translation> - </message> -</context> -</TS> diff --git a/tests/Zend/Translate/_files/translation_en.csv b/tests/Zend/Translate/_files/translation_en.csv deleted file mode 100644 index 657a2d3757167493a4c06883becafe48e4fe7680..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en.csv +++ /dev/null @@ -1,11 +0,0 @@ -# Comment -# A csv files contains all informations for one language -# MessageID;Translation -Message 1;Message 1 (en) -Message 2;Message 2 (en) -Message 3;Message 3 (en) -Message 4;Message 4 (en) -# Comment -Message 5;Message 5 (en) -"Message 6";"Message 6;"" (en)" -"Message ;"" 7";"Message 7 (en)" \ No newline at end of file diff --git a/tests/Zend/Translate/_files/translation_en.tbx b/tests/Zend/Translate/_files/translation_en.tbx deleted file mode 100644 index 14090c175b42f34424594526f5a5b1fe0edd3444..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en.tbx +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE martif PUBLIC "ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN" "TBXcdv04.dtd"> - -<martif type="TBX" xml:lang="en"> - <martifHeader> - <fileDesc> - <titleStmt> - <title>TBX Example</title> - </titleStmt> - <sourceDesc> - <p>for translation tests</p> - </sourceDesc> - </fileDesc> - <encodingDesc> - <p type="DCSName">No encoding</p> - </encodingDesc> - </martifHeader> - <text> - <body> - <termEntry id="c1"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Message 1</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 1 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c2"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Message 2</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 2 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c3"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Message 3</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 3 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c4"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Message 4</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 4 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - </body> - </text> -</martif> diff --git a/tests/Zend/Translate/_files/translation_en.tmx b/tests/Zend/Translate/_files/translation_en.tmx deleted file mode 100644 index bd5e196816a34165d742f28cca4dd9a27e07c175..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en.tmx +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" ?> -<!DOCTYPE tmx SYSTEM "tmx14.dtd"> -<tmx version="1.4"> - <header creationtoolversion="1.0.0" datatype="winres" segtype="sentence" adminlang="en-us" srclang="de-at" o-tmf="abc" creationtool="XYZTool" > - </header> - <body> - <tu tuid='Message 1'> - <tuv xml:lang="de"><seg>Message 1</seg></tuv> - <tuv xml:lang="en"><seg>Message 1 (en)</seg></tuv> - <tuv xml:lang="it"><seg>Message 1 (it)</seg></tuv> - </tu> - <tu tuid='Message 2'> - <tuv xml:lang="de"><seg>Message 2</seg></tuv> - <tuv xml:lang="en"><seg>Message 2 (en)</seg></tuv> - </tu> - <tu tuid='Message 3'> - <tuv xml:lang="de"><seg>Message 3</seg></tuv> - <tuv xml:lang="en"><seg>Message 3 (en)</seg></tuv> - </tu> - <tu tuid='Message 4'> - <tuv xml:lang="de"><seg>Message 4</seg></tuv> - <tuv xml:lang="en"><seg>Message 4 (en)</seg></tuv> - </tu> - <tu tuid='Message 5'> - <tuv xml:lang="de"><seg>Message 5</seg></tuv> - <tuv xml:lang="en"><seg>Message 5 (en)</seg></tuv> - </tu> - <tu tuid='Cooking furniture'> - <tuv xml:lang="de"><seg>Küchen Möbel</seg></tuv> - <tuv xml:lang="en"><seg>Küchen Möbel (en)</seg></tuv> - </tu> - <tu tuid='Küchen Möbel'> - <tuv xml:lang="de"><seg>Cooking furniture</seg></tuv> - <tuv xml:lang="en"><seg>Cooking furniture (en)</seg></tuv> - </tu> - </body> -</tmx> diff --git a/tests/Zend/Translate/_files/translation_en.xliff b/tests/Zend/Translate/_files/translation_en.xliff deleted file mode 100644 index 9aed9c4447c37a7e557ae65c0504077281358ced..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en.xliff +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" ?> -<xliff version='1.1' xmlns='urn:oasis:names:tc:xliff:document:1.1'> - <file original='hello.txt' source-language='de' target-language='en' datatype='plaintext'> - <body> - <trans-unit id='1'> - <source>Message 1</source> - <target>Message 1 (en)</target> - </trans-unit> - <trans-unit id='2'> - <source>Message 2</source> - <target>Message 2 (en)</target> - </trans-unit> - <trans-unit id='3'> - <source>Message 3</source> - <target>Message 3 (en)</target> - </trans-unit> - <trans-unit id='4'> - <source>Message 4</source> - <target>Message 4 (en)</target> - </trans-unit> - <trans-unit id='5'> - <source>Message 5</source> - <target>Message 5 (en)</target> - </trans-unit> - <trans-unit id='6'> - <source>Küchen Möbel</source> - <target>Cooking furniture (en)</target> - </trans-unit> - <trans-unit id='7'> - <source>Cooking furniture</source> - <target>Küchen Möbel (en)</target> - </trans-unit> - </body> - </file> -</xliff> diff --git a/tests/Zend/Translate/_files/translation_en2.csv b/tests/Zend/Translate/_files/translation_en2.csv deleted file mode 100644 index c16fce01c88dbada38b571cb764d0d2a2d504396..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en2.csv +++ /dev/null @@ -1,10 +0,0 @@ -# Comment -# A csv files contains all informations for one language -# MessageID;Translation -Message 1,Message 1 (en) -Message 2,Message 2 (en) -Message 3,Message 3 (en) -"Message 4,",Message 4 (en) -# Comment -Message 5,"Message 5, (en)" -"Message 6,addon,","Message 6,addon (en)" diff --git a/tests/Zend/Translate/_files/translation_en2.tbx b/tests/Zend/Translate/_files/translation_en2.tbx deleted file mode 100644 index eb511b65ecd1eaeac6cbdad7b04809f5567a69c9..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en2.tbx +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE martif PUBLIC "ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN" "TBXcdv04.dtd"> - -<martif type="TBX" xml:lang="en"> - <martifHeader> - <fileDesc> - <titleStmt> - <title>TBX Example</title> - </titleStmt> - <sourceDesc> - <p>for translation tests</p> - </sourceDesc> - </fileDesc> - <encodingDesc> - <p type="DCSName">No encoding</p> - </encodingDesc> - </martifHeader> - <text> - <body> - <termEntry id="c1"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Nachricht 1</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 1 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c4"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Message 4</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 4 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - </body> - </text> -</martif> diff --git a/tests/Zend/Translate/_files/translation_en2.tmx b/tests/Zend/Translate/_files/translation_en2.tmx deleted file mode 100644 index fe21c444c81b7d7e91819f782c4c3de3bc0d9343..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en2.tmx +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" ?> -<!DOCTYPE tmx SYSTEM "tmx14.dtd"> -<tmx version="1.4"> - <header creationtoolversion="1.0.0" datatype="winres" segtype="sentence" adminlang="en-us" srclang="de-at" o-tmf="abc" creationtool="XYZTool" > - </header> - <body> - <tu tuid='Message 1'> - <tuv xml:lang="de"><seg>Message 1</seg></tuv> - <tuv xml:lang="en"><seg>Message 1 (en)</seg></tuv> - </tu> - <tu tuid='Message 2'> - <tuv xml:lang="de"><seg>Message 2</seg></tuv> - <tuv xml:lang="en"><seg>Message 2 (en)</seg></tuv> - </tu> - <tu tuid='Message 3'> - <tuv xml:lang="de"><seg>Message 3</seg></tuv> - <tuv xml:lang="en"><seg>Message 3 (en)</seg></tuv> - </tu> - </body> -</tmx> diff --git a/tests/Zend/Translate/_files/translation_en2.xliff b/tests/Zend/Translate/_files/translation_en2.xliff deleted file mode 100644 index dbebbcd8ab3816ca3443ae84a6909b59df0ff653..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en2.xliff +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" ?> -<xliff version='1.1' xmlns='urn:oasis:names:tc:xliff:document:1.1'> - <file original='hello.txt' source-language='de' target-language='en' datatype='plaintext'> - <body> - <trans-unit id='1'> - <source>Message 1</source> - <target>Message 1 (en)</target> - </trans-unit> - <trans-unit id='2'> - <source>Message 2</source> - <target>Message 2 (en)</target> - </trans-unit> - <trans-unit id='3'> - <source>Message 3</source> - <target>Message 3 (en)</target> - </trans-unit> - </body> - </file> -</xliff> diff --git a/tests/Zend/Translate/_files/translation_en3.tbx b/tests/Zend/Translate/_files/translation_en3.tbx deleted file mode 100644 index cb153e459c59760357bc3ee0a7cd08ec833919cd..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en3.tbx +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE martif PUBLIC "ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN" "TBXcdv04.dtd"> - -<martif type="TBX" xml:lang="en"> - <martifHeader> - <fileDesc> - <titleStmt> - <title>TBX Example</title> - </titleStmt> - <sourceDesc> - <p>for translation tests</p> - </sourceDesc> - </fileDesc> - <encodingDesc> - <p type="DCSName">No encoding</p> - </encodingDesc> - </martifHeader> - <text> - <body> - <termEntry id="c1"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Nachricht 1</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 1 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c4"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Message 4</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Message 4 (fr)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c5"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Küchen Möbel</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Cooking Furniture (en)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - <termEntry id="c6"> - <langSet xml:lang="en"> - <ntig> - <termGrp> - <term>Cooking Furniture</term> - </termGrp> - </ntig> - </langSet> - <langSet xml:lang="fr"> - <ntig> - <termGrp> - <term>Küchen Möbel (en)</term> - </termGrp> - </ntig> - </langSet> - </termEntry> - </body> - </text> -</martif> diff --git a/tests/Zend/Translate/_files/translation_en3.tmx b/tests/Zend/Translate/_files/translation_en3.tmx deleted file mode 100644 index fa54673f76122e9e4a724e05205baf4b7b28c676..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en3.tmx +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE tmx SYSTEM "tmx14.dtd"> -<tmx version="1.4"> - <header creationtoolversion="1.0.0" datatype="winres" segtype="sentence" adminlang="en-us" srclang="de-at" o-tmf="abc" creationtool="XYZTool" > - </header> - <body> - <tu tuid='Message 1'> - <tuv xml:lang="de"><seg>Message 1</seg></tuv> - <tuv xml:lang="en"><seg>Message 1 (en)</seg></tuv> - <tuv xml:lang="it"><seg>Message 1 (it)</seg></tuv> - </tu> - <tu tuid='Message 2'> - <tuv xml:lang="de"><seg>Message 2</seg></tuv> - <tuv xml:lang="en"><seg>Message 2 (en)</seg></tuv> - </tu> - <tu tuid='Message 3'> - <tuv xml:lang="de"><seg>Message 3</seg></tuv> - <tuv xml:lang="en"><seg>Message 3 (en)</seg></tuv> - </tu> - <tu tuid='Message 4'> - <tuv xml:lang="de"><seg>Message 4</seg></tuv> - <tuv xml:lang="en"><seg>Message 4 (en)</seg></tuv> - </tu> - <tu tuid='Message 5'> - <tuv xml:lang="de"><seg>Message 5</seg></tuv> - <tuv xml:lang="en"><seg>Message 5 (en)</seg></tuv> - </tu> - <tu tuid='Cooking furniture'> - <tuv xml:lang="de"><seg>Küchen Möbel</seg></tuv> - <tuv xml:lang="en"><seg>Küchen Möbel (en)</seg></tuv> - </tu> - <tu tuid='Küchen Möbel'> - <tuv xml:lang="de"><seg>Cooking furniture</seg></tuv> - <tuv xml:lang="en"><seg>Cooking furniture (en)</seg></tuv> - </tu> - </body> -</tmx> diff --git a/tests/Zend/Translate/_files/translation_en3.xliff b/tests/Zend/Translate/_files/translation_en3.xliff deleted file mode 100644 index 39dd4df7cc2c38f9e87be9b93f72d1c37699e277..0000000000000000000000000000000000000000 --- a/tests/Zend/Translate/_files/translation_en3.xliff +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<xliff version='1.1' xmlns='urn:oasis:names:tc:xliff:document:1.1'> - <file original='hello.txt' source-language='de' target-language='en' datatype='plaintext'> - <body> - <trans-unit id='1'> - <source>Message 1</source> - <target>Message 1 (en)</target> - </trans-unit> - <trans-unit id='2'> - <source>Message 2</source> - <target>Message 2 (en)</target> - </trans-unit> - <trans-unit id='3'> - <source>Message 3</source> - <target>Message 3 (en)</target> - </trans-unit> - <trans-unit id='4'> - <source>Küchen Möbel</source> - <target>Cooking Furniture (en)</target> - </trans-unit> - <trans-unit id='5'> - <source>Cooking Furniture</source> - <target>Küchen Möbel (en)</target> - </trans-unit> - </body> - </file> -</xliff> diff --git a/tests/Zend/TranslateTest.php b/tests/Zend/TranslateTest.php deleted file mode 100644 index d09aec5d5e473281fd82897741f9846a9ccd4749..0000000000000000000000000000000000000000 --- a/tests/Zend/TranslateTest.php +++ /dev/null @@ -1,213 +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_Translate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -/** - * Test helper - */ -require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * Zend_Translate - */ -require_once 'Zend/Translate.php'; - -/** - * @category Zend - * @package Zend_Translate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_TranslateTest extends PHPUnit_Framework_TestCase -{ - public function testCreate() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array()); - $this->assertTrue($lang instanceof Zend_Translate); - } - - public function testLocaleInitialization() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'message1'), 'en'); - $this->assertEquals('en', $lang->getLocale()); - } - - public function testDefaultLocale() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'message1')); - $defaultLocale = new Zend_Locale(); - $this->assertEquals($defaultLocale->toString(), $lang->getLocale()); - } - - public function testGetAdapter() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY , array(), 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Array); - - $lang = new Zend_Translate(Zend_Translate::AN_GETTEXT , dirname(__FILE__) . '/Translate/_files/testmsg_en.mo', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Gettext); - - $lang = new Zend_Translate(Zend_Translate::AN_TMX , dirname(__FILE__) . '/Translate/_files/translation_en.tmx', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Tmx); - - $lang = new Zend_Translate(Zend_Translate::AN_CSV , dirname(__FILE__) . '/Translate/_files/translation_en.csv', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Csv); - - $lang = new Zend_Translate(Zend_Translate::AN_XLIFF , dirname(__FILE__) . '/Translate/_files/translation_en.xliff', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Xliff); - - $lang = new Zend_Translate('qt' , dirname(__FILE__) . '/Translate/_files/translation_de.ts', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Qt); - - $lang = new Zend_Translate('xmltm' , dirname(__FILE__) . '/Translate/_files/XmlTm_test_en.xml', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_XmlTm); - - $lang = new Zend_Translate('tbx' , dirname(__FILE__) . '/Translate/_files/translation_en.tbx', 'en'); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Tbx); - } - - public function testSetAdapter() - { - $lang = new Zend_Translate(Zend_Translate::AN_GETTEXT , dirname(__FILE__) . '/Translate/_files/testmsg_en.mo', 'en'); - $lang->setAdapter(Zend_Translate::AN_ARRAY, array()); - $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Array); - - try { - $lang->xxxFunction(); - $this->fail("exception expected"); - } catch (Zend_Translate_Exception $e) { - // success - } - } - - public function testAddTranslation() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en'); - - $this->assertEquals('msg2', $lang->_('msg2')); - - $lang->addTranslation(array('msg2' => 'Message 2'), 'en'); - $this->assertEquals('Message 2', $lang->_('msg2')); - $this->assertEquals('msg3', $lang->_('msg3')); - - $lang->addTranslation(array('msg3' => 'Message 3'), 'en', array('clear' => true)); - $this->assertEquals('msg2', $lang->_('msg2')); - $this->assertEquals('Message 3', $lang->_('msg3')); - } - - public function testGetLocale() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en'); - $this->assertEquals('en', $lang->getLocale()); - } - - public function testSetLocale() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en'); - $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru'); - $this->assertEquals('ru', $lang->getLocale()); - - $lang->setLocale('en'); - $this->assertEquals('en', $lang->getLocale()); - - $lang->setLocale('ru'); - $this->assertEquals('ru', $lang->getLocale()); - - $lang->setLocale('ru_RU'); - $this->assertEquals('ru', $lang->getLocale()); - } - - public function testSetLanguage() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en'); - $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru'); - $this->assertEquals('ru', $lang->getLocale()); - - $lang->setLocale('en'); - $this->assertEquals('en', $lang->getLocale()); - } - - public function testGetLanguageList() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en'); - $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru'); - $this->assertEquals(2, count($lang->getList())); - $this->assertTrue(in_array('en', $lang->getList())); - $this->assertTrue(in_array('ru', $lang->getList())); - } - - public function testIsAvailable() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en'); - $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru'); - $this->assertTrue( $lang->isAvailable('en')); - $this->assertTrue( $lang->isAvailable('ru')); - $this->assertFalse($lang->isAvailable('fr')); - } - - public function testTranslate() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1 (en)'), 'en'); - $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru'); - $this->assertEquals('Message 1 (en)', $lang->_('msg1', 'en' )); - $this->assertEquals('Message 1 (ru)', $lang->_('msg1' )); - $this->assertEquals('msg2', $lang->_('msg2', 'en' )); - $this->assertEquals('msg2', $lang->_('msg2' )); - $this->assertEquals('Message 1 (en)', $lang->translate('msg1', 'en')); - $this->assertEquals('Message 1 (ru)', $lang->translate('msg1' )); - $this->assertEquals('msg2', $lang->translate('msg2', 'en')); - $this->assertEquals('msg2', $lang->translate('msg2' )); - } - - public function testIsTranslated() - { - $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1 (en)'), 'en_US'); - $this->assertTrue( $lang->isTranslated('msg1' )); - $this->assertFalse($lang->isTranslated('msg2' )); - $this->assertFalse($lang->isTranslated('msg1', false, 'en')); - $this->assertFalse($lang->isTranslated('msg1', true, 'en')); - $this->assertFalse($lang->isTranslated('msg1', false, 'ru')); - } - - public function testWithOption() - { - $lang = new Zend_Translate(Zend_Translate::AN_CSV , dirname(__FILE__) . '/Translate/_files/translation_en2.csv', 'en', array('delimiter' => ',')); - $this->assertEquals('Message 1 (en)', $lang->translate('Message 1' )); - $this->assertEquals('Message 4 (en)', $lang->translate('Message 4,')); - $this->assertEquals('Message 5, (en)', $lang->translate('Message 5' )); - } - - public function testDirectorySearch() - { - $lang = new Zend_Translate(Zend_Translate::AN_CSV, dirname(__FILE__) . '/Translate/_files/test', null, array('scan' => Zend_Translate::LOCALE_DIRECTORY)); - $this->assertEquals(2, count($lang->getList())); - $this->assertTrue(in_array('de_AT', $lang->getList())); - $this->assertTrue(in_array('en_GB', $lang->getList())); - } - - public function testFileSearch() - { - $lang = new Zend_Translate(Zend_Translate::AN_CSV, dirname(__FILE__) . '/Translate/_files/test2', null, array('scan' => Zend_Translate::LOCALE_FILENAME)); - $this->assertEquals(2, count($lang->getList())); - $this->assertTrue(in_array('de_AT', $lang->getList())); - $this->assertTrue(in_array('de_DE', $lang->getList())); - } -} diff --git a/tests/Zend/Uri/AllTests.php b/tests/Zend/Uri/AllTests.php deleted file mode 100644 index e08f705fdc10ed578c4ba8d9aa94633697b29785..0000000000000000000000000000000000000000 --- a/tests/Zend/Uri/AllTests.php +++ /dev/null @@ -1,90 +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_Uri - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Uri_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - - -/** - * PHPUnit_Framework_TestSuite - */ -// require_once 'PHPUnit/Framework/TestSuite.php'; - - -/** - * PHPUnit_TextUI_TestRunner - */ -// require_once 'PHPUnit/TextUI/TestRunner.php'; - - -/** - * @see Zend_Uri_HttpTest - */ -require_once 'Zend/Uri/HttpTest.php'; - - -/** - * @category Zend - * @package Zend_Uri - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Uri_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Uri'); - - $suite->addTestSuite('Zend_Uri_HttpTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Uri_AllTests::main') { - Zend_Uri_AllTests::main(); -} diff --git a/tests/Zend/Uri/HttpTest.php b/tests/Zend/Uri/HttpTest.php deleted file mode 100644 index aabf4e60a9165825a2ee403189754364ebec1de8..0000000000000000000000000000000000000000 --- a/tests/Zend/Uri/HttpTest.php +++ /dev/null @@ -1,232 +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_Uri - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HttpTest.php 11890 2008-10-12 10:09:13Z alexander $ - */ - -/** - * Test helper - */ -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** - * @see Zend_Uri - */ -require_once 'Zend/Uri.php'; - -/** - * PHPUnit test case - */ -// require_once 'PHPUnit/Framework/TestCase.php'; - - -/** - * @category Zend - * @package Zend_Uri - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Uri_HttpTest extends PHPUnit_Framework_TestCase -{ - /** - * Tests for proper URI decomposition - */ - public function testSimple() - { - $this->_testValidUri('http://www.zend.com'); - } - - /** - * Test that fromString() works proprerly for simple valid URLs - * - */ - public function testSimpleFromString() - { - $tests = array( - 'http://www.zend.com', - 'https://www.zend.com', - 'http://www.zend.com/path', - 'http://www.zend.com/path?query=value' - ); - - foreach ($tests as $uri) { - $obj = Zend_Uri_Http::fromString($uri); - $this->assertEquals($uri, $obj->getUri(), - "getUri() returned value that differs from input for $uri"); - } - } - - /** - * Make sure an exception is thrown when trying to use fromString() with a - * non-HTTP scheme - * - * @see http://framework.zend.com/issues/browse/ZF-4395 - * - * @expectedException Zend_Uri_Exception - */ - public function testFromStringInvalidScheme() - { - Zend_Uri_Http::fromString('ftp://example.com/file'); - } - - public function testAllParts() - { - $this->_testValidUri('http://andi:password@www.zend.com:8080/path/to/file?a=1&b=2#top'); - } - - public function testUsernamePortPathQueryFragment() - { - $this->_testValidUri('http://andi@www.zend.com:8080/path/to/file?a=1&b=2#top'); - } - - public function testPortPathQueryFragment() - { - $this->_testValidUri('http://www.zend.com:8080/path/to/file?a=1&b=2#top'); - } - - public function testPathQueryFragment() - { - $this->_testValidUri('http://www.zend.com/path/to/file?a=1&b=2#top'); - } - - public function testQueryFragment() - { - $this->_testValidUri('http://www.zend.com/?a=1&b=2#top'); - } - - public function testFragment() - { - $this->_testValidUri('http://www.zend.com/#top'); - } - - public function testUsernamePassword() - { - $this->_testValidUri('http://andi:password@www.zend.com'); - } - - public function testUsernamePasswordColon() - { - $this->_testValidUri('http://an:di:password@www.zend.com'); - } - - public function testUsernamePasswordValidCharacters() - { - $this->_testValidUri('http://a_.!~*\'(-)n0123Di%25%26:pass;:&=+$,word@www.zend.com'); - } - - public function testUsernameInvalidCharacter() - { - $this->_testInvalidUri('http://an`di:password@www.zend.com'); - } - - public function testNoUsernamePassword() - { - $this->_testInvalidUri('http://:password@www.zend.com'); - } - - public function testPasswordInvalidCharacter() - { - $this->_testInvalidUri('http://andi:pass%word@www.zend.com'); - } - - public function testHostAsIP() - { - $this->_testValidUri('http://127.0.0.1'); - } - - public function testLocalhost() - { - $this->_testValidUri('http://localhost'); - } - - public function testLocalhostLocaldomain() - { - $this->_testValidUri('http://localhost.localdomain'); - } - - public function testSquareBrackets() - { - $this->_testValidUri('https://example.com/foo/?var[]=1&var[]=2&some[thing]=3'); - } - - /** - * Ensures that successive slashes are considered valid - * - * @return void - */ - public function testSuccessiveSlashes() - { - $this->_testValidUri('http://example.com//'); - $this->_testValidUri('http://example.com///'); - $this->_testValidUri('http://example.com/foo//'); - $this->_testValidUri('http://example.com/foo///'); - $this->_testValidUri('http://example.com/foo//bar'); - $this->_testValidUri('http://example.com/foo///bar'); - $this->_testValidUri('http://example.com/foo//bar/baz//fob/'); - } - - /** - * Test that setQuery() can handle unencoded query parameters (as other - * browsers do), ZF-1934 - * - * @return void - */ - public function testUnencodedQueryParameters() - { - $uri = Zend_Uri::factory('http://foo.com/bar'); - - // First, make sure no exceptions are thrown - try { - $uri->setQuery('id=123&url=http://example.com/?bar=foo baz'); - } catch (Exception $e) { - $this->fail('setQuery() was expected to handle unencoded parameters, but failed'); - } - - // Second, make sure the query string was properly encoded - $parts = parse_url($uri->getUri()); - $this->assertEquals('id=123&url=http%3A%2F%2Fexample.com%2F%3Fbar%3Dfoo+baz', $parts['query']); - } - - /** - * Test a known valid URI - * - * @param string $uri - */ - protected function _testValidUri($uri) - { - $obj = Zend_Uri::factory($uri); - $this->assertEquals($uri, $obj->getUri(), 'getUri() returned value that differs from input'); - } - - /** - * Test a known invalid URI - * - * @param string $uri - */ - protected function _testInvalidUri($uri) - { - try { - $obj = Zend_Uri::factory($uri); - $this->fail('Zend_Uri_Exception was expected but not thrown'); - } catch (Zend_Uri_Exception $e) { - } - } -} diff --git a/tests/Zend/UriTest.php b/tests/Zend/UriTest.php deleted file mode 100644 index 694b4a6990e84b2e120c6378e2c903b300dcfb18..0000000000000000000000000000000000000000 --- a/tests/Zend/UriTest.php +++ /dev/null @@ -1,132 +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_Uri - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_UriTest::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * Zend_Uri - */ -require_once 'Zend/Uri.php'; - -/** - * @category Zend - * @package Zend_Uri - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_UriTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_UriTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->notices = array(); - $this->errorReporting = error_reporting(); - $this->displayErrors = ini_get('display_errors'); - } - - public function tearDown() - { - error_reporting($this->errorReporting); - ini_set('display_errors', $this->displayErrors); - } - - public function testSchemeEmpty() - { - $this->_testInvalidUri('', '/empty/i'); - $this->_testInvalidUri('://www.zend.com', '/empty/i'); - } - - public function testSchemeUnsupported() - { - $this->_testInvalidUri('unsupported', '/unsupported/i'); - $this->_testInvalidUri('unsupported://zend.com', '/unsupported/i'); - } - - public function testSchemeIllegal() - { - $this->_testInvalidUri('!@#$%^&*()', '/illegal/i'); - } - - public function testSchemeHttp() - { - $this->_testValidUri('http'); - } - - public function testSchemeHttps() - { - $this->_testValidUri('https'); - } - - public function testSchemeMailto() - { - $this->markTestIncomplete('Zend_Uri_Mailto is not implemented yet'); - $this->_testValidUri('mailto'); - } - - /** - * Tests that an invalid $uri throws an exception and that the - * message of that exception matches $regex. - * - * @param string $uri - * @param string $regex - */ - protected function _testInvalidUri($uri, $regex) - { - $e = null; - try { - $uri = Zend_Uri::factory($uri); - } catch (Zend_Uri_Exception $e) { - $this->assertRegExp($regex, $e->getMessage()); - return; - } - $this->fail('Zend_Uri_Exception was expected but not thrown'); - } - - /** - * Tests that a valid $uri returns a Zend_Uri object. - * - * @param string $uri - */ - protected function _testValidUri($uri) - { - $uri = Zend_Uri::factory($uri); - $this->assertTrue($uri instanceof Zend_Uri, 'Zend_Uri object not returned.'); - } - -} - -// Call Zend_UriTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_UriTest::main") { - Zend_UriTest::main(); -} diff --git a/tests/Zend/Validate/AbstractTest.php b/tests/Zend/Validate/AbstractTest.php deleted file mode 100644 index ae6968eb96d1de53e90c01e5666e9251489b6f7c..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/AbstractTest.php +++ /dev/null @@ -1,213 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AbstractTest.php 10649 2008-08-04 20:58:45Z matthew $ - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Validate_AbstractTest::main'); -} - -/** Test helper */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Validate_Abstract */ -require_once 'Zend/Validate/Abstract.php'; - -/** Zend_Translate */ -require_once 'Zend/Translate.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_AbstractTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite('Zend_Validate_AbstractTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function clearRegistry() - { - if (Zend_Registry::isRegistered('Zend_Translate')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_Translate']); - } - } - - /** - * Creates a new validation object for each test method - * - * @return void - */ - public function setUp() - { - $this->clearRegistry(); - Zend_Validate_Abstract::setDefaultTranslator(null); - $this->validator = new Zend_Validate_AbstractTest_Concrete(); - } - - public function tearDown() - { - $this->clearRegistry(); - Zend_Validate_Abstract::setDefaultTranslator(null); - } - - public function testTranslatorNullByDefault() - { - $this->assertNull($this->validator->getTranslator()); - } - - public function testCanSetTranslator() - { - $this->testTranslatorNullByDefault(); - $translator = new Zend_Translate('array', array(), 'en'); - $this->validator->setTranslator($translator); - $this->assertSame($translator->getAdapter(), $this->validator->getTranslator()); - } - - public function testCanSetTranslatorToNull() - { - $this->testCanSetTranslator(); - $this->validator->setTranslator(null); - $this->assertNull($this->validator->getTranslator()); - } - - public function testGlobalDefaultTranslatorNullByDefault() - { - $this->assertNull(Zend_Validate_Abstract::getDefaultTranslator()); - } - - public function testCanSetGlobalDefaultTranslator() - { - $this->testGlobalDefaultTranslatorNullByDefault(); - $translator = new Zend_Translate('array', array(), 'en'); - Zend_Validate_Abstract::setDefaultTranslator($translator); - $this->assertSame($translator->getAdapter(), Zend_Validate_Abstract::getDefaultTranslator()); - } - - public function testGlobalDefaultTranslatorUsedWhenNoLocalTranslatorSet() - { - $this->testCanSetGlobalDefaultTranslator(); - $this->assertSame(Zend_Validate_Abstract::getDefaultTranslator(), $this->validator->getTranslator()); - } - - public function testGlobalTranslatorFromRegistryUsedWhenNoLocalTranslatorSet() - { - $translate = new Zend_Translate('array', array()); - Zend_Registry::set('Zend_Translate', $translate); - $this->assertSame($translate->getAdapter(), $this->validator->getTranslator()); - } - - public function testLocalTranslatorPreferredOverGlobalTranslator() - { - $this->testCanSetGlobalDefaultTranslator(); - $translator = new Zend_Translate('array', array(), 'en'); - $this->validator->setTranslator($translator); - $this->assertNotSame(Zend_Validate_Abstract::getDefaultTranslator(), $this->validator->getTranslator()); - } - - public function testErrorMessagesAreTranslatedWhenTranslatorPresent() - { - $translator = new Zend_Translate( - 'array', - array('fooMessage' => 'This is the translated message for %value%'), - 'en' - ); - $this->validator->setTranslator($translator); - $this->assertFalse($this->validator->isValid('bar')); - $messages = $this->validator->getMessages(); - $this->assertTrue(array_key_exists('fooMessage', $messages)); - $this->assertContains('bar', $messages['fooMessage']); - $this->assertContains('This is the translated message for ', $messages['fooMessage']); - } - - public function testCanTranslateMessagesInsteadOfKeys() - { - $translator = new Zend_Translate( - 'array', - array('%value% was passed' => 'This is the translated message for %value%'), - 'en' - ); - $this->validator->setTranslator($translator); - $this->assertFalse($this->validator->isValid('bar')); - $messages = $this->validator->getMessages(); - $this->assertTrue(array_key_exists('fooMessage', $messages)); - $this->assertContains('bar', $messages['fooMessage']); - $this->assertContains('This is the translated message for ', $messages['fooMessage']); - } - - public function testObscureValueFlagFalseByDefault() - { - $this->assertFalse($this->validator->getObscureValue()); - } - - public function testCanSetObscureValueFlag() - { - $this->testObscureValueFlagFalseByDefault(); - $this->validator->setObscureValue(true); - $this->assertTrue($this->validator->getObscureValue()); - $this->validator->setObscureValue(false); - $this->assertFalse($this->validator->getObscureValue()); - } - - public function testValueIsObfuscatedWheObscureValueFlagIsTrue() - { - $this->validator->setObscureValue(true); - $this->assertFalse($this->validator->isValid('foobar')); - $messages = $this->validator->getMessages(); - $this->assertTrue(isset($messages['fooMessage'])); - $message = $messages['fooMessage']; - $this->assertNotContains('foobar', $message); - $this->assertContains('******', $message); - } -} - -class Zend_Validate_AbstractTest_Concrete extends Zend_Validate_Abstract -{ - const FOO_MESSAGE = 'fooMessage'; - - protected $_messageTemplates = array( - 'fooMessage' => '%value% was passed', - ); - - public function isValid($value) - { - $this->_setValue($value); - $this->_error(self::FOO_MESSAGE); - return false; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Validate_AbstractTest::main') { - Zend_Validate_AbstractTest::main(); -} diff --git a/tests/Zend/Validate/AllTests.php b/tests/Zend/Validate/AllTests.php deleted file mode 100644 index e676b25193186dbdef19b4862501ec2e6fa75d4e..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/AllTests.php +++ /dev/null @@ -1,209 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 10656 2008-08-05 02:16:02Z matthew $ - */ - - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Validate_AllTests::main'); -} - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_AbstractTest - */ -require_once 'Zend/Validate/AbstractTest.php'; - -/** - * @see Zend_Validate_AlnumTest - */ -require_once 'Zend/Validate/AlnumTest.php'; - -/** - * @see Zend_Validate_AlphaTest - */ -require_once 'Zend/Validate/AlphaTest.php'; - -/** - * @see Zend_Validate_BarcodeTest - */ -require_once 'Zend/Validate/BarcodeTest.php'; - -/** - * @see Zend_Validate_BetweenTest - */ -require_once 'Zend/Validate/BetweenTest.php'; - -/** - * @see Zend_Validate_CcnumTest - */ -require_once 'Zend/Validate/CcnumTest.php'; - -/** - * @see Zend_Validate_DateTest - */ -require_once 'Zend/Validate/DateTest.php'; - -/** - * @see Zend_Validate_DigitsTest - */ -require_once 'Zend/Validate/DigitsTest.php'; - -/** - * @see Zend_Validate_EmailAddressTest - */ -require_once 'Zend/Validate/EmailAddressTest.php'; - -/** - * @see Zend_Validate_File_AllTests - */ -require_once 'Zend/Validate/File/AllTests.php'; - -/** - * @see Zend_Validate_FloatTest - */ -require_once 'Zend/Validate/FloatTest.php'; - -/** - * @see Zend_Validate_GreaterThanTest - */ -require_once 'Zend/Validate/GreaterThanTest.php'; - -/** - * @see Zend_Validate_HexTest - */ -require_once 'Zend/Validate/HexTest.php'; - -/** - * @see Zend_Validate_HostnameTest - */ -require_once 'Zend/Validate/HostnameTest.php'; - -/** - * @see Zend_Validate_IdenticalTest - */ -require_once 'Zend/Validate/IdenticalTest.php'; - -/** - * @see Zend_Validate_InArrayTest - */ -require_once 'Zend/Validate/InArrayTest.php'; - -/** - * @see Zend_Validate_IntTest - */ -require_once 'Zend/Validate/IntTest.php'; - -/** - * @see Zend_Validate_IpTest - */ -require_once 'Zend/Validate/IpTest.php'; - -/** - * @see Zend_Validate_LessThanTest - */ -require_once 'Zend/Validate/LessThanTest.php'; - -/** - * @see Zend_Validate_MessageTest - */ -require_once 'Zend/Validate/MessageTest.php'; - -/** - * @see Zend_Validate_NotEmptyTest - */ -require_once 'Zend/Validate/NotEmptyTest.php'; - -/** - * @see Zend_Validate_RegexTest - */ -require_once 'Zend/Validate/RegexTest.php'; - -/** - * @see Zend_Validate_StringLengthTest - */ -require_once 'Zend/Validate/StringLengthTest.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_AllTests -{ - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * Creates and returns this test suite - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Validate'); - - $suite->addTestSuite('Zend_Validate_AbstractTest'); - $suite->addTestSuite('Zend_Validate_AlnumTest'); - $suite->addTestSuite('Zend_Validate_AlphaTest'); - $suite->addTestSuite('Zend_Validate_BarcodeTest'); - $suite->addTestSuite('Zend_Validate_BetweenTest'); - $suite->addTestSuite('Zend_Validate_CcnumTest'); - $suite->addTestSuite('Zend_Validate_DateTest'); - $suite->addTestSuite('Zend_Validate_DigitsTest'); - $suite->addTestSuite('Zend_Validate_EmailAddressTest'); - $suite->addTest(Zend_Validate_File_AllTests::suite()); - $suite->addTestSuite('Zend_Validate_FloatTest'); - $suite->addTestSuite('Zend_Validate_GreaterThanTest'); - $suite->addTestSuite('Zend_Validate_HexTest'); - $suite->addTestSuite('Zend_Validate_HostnameTest'); - $suite->addTestSuite('Zend_Validate_IdenticalTest'); - $suite->addTestSuite('Zend_Validate_InArrayTest'); - $suite->addTestSuite('Zend_Validate_IntTest'); - $suite->addTestSuite('Zend_Validate_IpTest'); - $suite->addTestSuite('Zend_Validate_LessThanTest'); - $suite->addTestSuite('Zend_Validate_MessageTest'); - $suite->addTestSuite('Zend_Validate_NotEmptyTest'); - $suite->addTestSuite('Zend_Validate_RegexTest'); - $suite->addTestSuite('Zend_Validate_StringLengthTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Validate_AllTests::main') { - Zend_Validate_AllTests::main(); -} diff --git a/tests/Zend/Validate/AlnumTest.php b/tests/Zend/Validate/AlnumTest.php deleted file mode 100644 index 0ab780565321cd58c9ba2f199587590c1e9294a9..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/AlnumTest.php +++ /dev/null @@ -1,178 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AlnumTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Alnum - */ -require_once 'Zend/Validate/Alnum.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_AlnumTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Alnum object - * - * @var Zend_Validate_Alnum - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Alnum object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Alnum(); - } - - /** - * Ensures that the validator follows expected behavior for basic input values - * - * @return void - */ - public function testExpectedResultsWithBasicInputValues() - { - $valuesExpected = array( - 'abc123' => true, - 'abc 123' => false, - 'abcxyz' => true, - 'AZ@#4.3' => false, - 'aBc123' => true, - '' => false, - ' ' => false, - "\n" => false, - 'foobar1' => true - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $this->_validator->isValid($input)); - } - } - - /** - * Ensures that getMessages() returns expected initial value - * - * @return void - */ - public function testMessagesEmptyInitially() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * Ensures that the allowWhiteSpace option works as expected - * - * @return void - */ - public function testOptionToAllowWhiteSpaceWithBasicInputValues() - { - $this->_validator->allowWhiteSpace = true; - - $valuesExpected = array( - 'abc123' => true, - 'abc 123' => true, - 'abcxyz' => true, - 'AZ@#4.3' => false, - 'aBc123' => true, - '' => false, - ' ' => true, - "\n" => true, - " \t " => true, - 'foobar1' => true - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals( - $result, - $this->_validator->isValid($input), - "Expected '$input' to be considered " . ($result ? '' : 'in') . "valid" - ); - } - } - - /** - * @return void - */ - public function testEmptyStringValueResultsInProperValidationFailureMessages() - { - $this->assertFalse($this->_validator->isValid('')); - $messages = $this->_validator->getMessages(); - $arrayExpected = array( - Zend_Validate_Alnum::STRING_EMPTY => '\'\' is an empty string' - ); - $this->assertThat($messages, $this->identicalTo($arrayExpected)); - } - - /** - * @return void - * @deprecated Since 1.5.0 - */ - public function testEmptyStringValueResultsInProperValidationFailureErrors() - { - $this->assertFalse($this->_validator->isValid('')); - $errors = $this->_validator->getErrors(); - $arrayExpected = array( - Zend_Validate_Alnum::STRING_EMPTY - ); - $this->assertThat($errors, $this->identicalTo($arrayExpected)); - } - - /** - * @return void - */ - public function testInvalidValueResultsInProperValidationFailureMessages() - { - $this->assertFalse($this->_validator->isValid('#')); - $messages = $this->_validator->getMessages(); - $arrayExpected = array( - Zend_Validate_Alnum::NOT_ALNUM => '\'#\' has not only alphabetic and digit characters' - ); - $this->assertThat($messages, $this->identicalTo($arrayExpected)); - } - - /** - * @return void - * @deprecated Since 1.5.0 - */ - public function testInvalidValueResultsInProperValidationFailureErrors() - { - $this->assertFalse($this->_validator->isValid('#')); - $errors = $this->_validator->getErrors(); - $arrayExpected = array( - Zend_Validate_Alnum::NOT_ALNUM - ); - $this->assertThat($errors, $this->identicalTo($arrayExpected)); - } -} diff --git a/tests/Zend/Validate/AlphaTest.php b/tests/Zend/Validate/AlphaTest.php deleted file mode 100644 index 7679420826aeffdbe4eeac60406674ca9cc31a28..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/AlphaTest.php +++ /dev/null @@ -1,125 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AlphaTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Alpha - */ -require_once 'Zend/Validate/Alpha.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_AlphaTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Alpha object - * - * @var Zend_Validate_Alpha - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Alpha object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Alpha(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - 'abc123' => false, - 'abc 123' => false, - 'abcxyz' => true, - 'AZ@#4.3' => false, - 'aBc123' => false, - 'aBcDeF' => true, - '' => false, - ' ' => false, - "\n" => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $this->_validator->isValid($input)); - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * Ensures that the allowWhiteSpace option works as expected - * - * @return void - */ - public function testAllowWhiteSpace() - { - $this->_validator->allowWhiteSpace = true; - - $valuesExpected = array( - 'abc123' => false, - 'abc 123' => false, - 'abcxyz' => true, - 'AZ@#4.3' => false, - 'aBc123' => false, - 'aBcDeF' => true, - '' => false, - ' ' => true, - "\n" => true, - " \t " => true, - "a\tb c" => true - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals( - $result, - $this->_validator->isValid($input), - "Expected '$input' to be considered " . ($result ? '' : 'in') . "valid" - ); - } - } -} diff --git a/tests/Zend/Validate/BarcodeTest.php b/tests/Zend/Validate/BarcodeTest.php deleted file mode 100644 index 3c4cebc993944d6c05f9cdddd15990b81427e2f8..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/BarcodeTest.php +++ /dev/null @@ -1,91 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BarcodeTest.php 11792 2008-10-09 18:23:02Z andries $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Validate_Barcode */ -require_once 'Zend/Validate/Barcode.php'; - -/** - * Zend_Validate_Barcode - * - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @uses Zend_Validate_Barcode - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_BarcodeTest extends PHPUnit_Framework_TestCase -{ - public function testUpcA() - { - $barcode = new Zend_Validate_Barcode('upc-a'); - - $this->assertTrue($barcode->isValid('065100004327')); - $this->assertFalse($barcode->isValid('123')); - $this->assertFalse($barcode->isValid('065100004328')); - } - - public function testEan13() - { - $barcode = new Zend_Validate_Barcode('ean-13'); - - $this->assertTrue($barcode->isValid('0075678164125')); - $this->assertFalse($barcode->isValid('123')); - $this->assertFalse($barcode->isValid('0075678164124')); - } - - /** - * Test if EAN-13 contains only numeric characters - * - * @group ZF-3297 - */ - public function testEan13ContainsOnlyNumeric() - { - $barcode = new Zend_Validate_Barcode('ean-13'); - $this->assertFalse($barcode->isValid('3RH1131-1BB40')); - } - - public function testNoneExisting() - { - try { - $barcode = new Zend_Validate_Barcode('Zend'); - $this->fail("'Zend' is not a valid barcode type'"); - } catch (Exception $e) { - $this->assertContains("'Zend' is not supported", $e->getMessage()); - } - } - - public function testSetType() - { - $barcode = new Zend_Validate_Barcode('upc-a'); - $this->assertTrue($barcode->isValid('065100004327')); - - $barcode->setType('ean-13'); - $this->assertTrue($barcode->isValid('0075678164125')); - } -} diff --git a/tests/Zend/Validate/BetweenTest.php b/tests/Zend/Validate/BetweenTest.php deleted file mode 100644 index 72c5e8453dfaee7069a68e994486755a355a59e4..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/BetweenTest.php +++ /dev/null @@ -1,118 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BetweenTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Between - */ -require_once 'Zend/Validate/Between.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - /** - * The elements of each array are, in order: - * - minimum - * - maximum - * - inclusive - * - expected validation result - * - array of test input values - */ - $valuesExpected = array( - array(1, 100, true, true, array(1, 10, 100)), - array(1, 100, true, false, array(0, 0.99, 100.01, 101)), - array(1, 100, false, false, array(0, 1, 100, 101)), - array('a', 'z', true, true, array('a', 'b', 'y', 'z')), - array('a', 'z', false, false, array('!', 'a', 'z')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_Between($element[0], $element[1], $element[2]); - foreach ($element[4] as $input) { - $this->assertEquals($element[3], $validator->isValid($input)); - } - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $validator = new Zend_Validate_Between(1, 10); - $this->assertEquals(array(), $validator->getMessages()); - } - - /** - * Ensures that getMin() returns expected value - * - * @return void - */ - public function testGetMin() - { - $validator = new Zend_Validate_Between(1, 10); - $this->assertEquals(1, $validator->getMin()); - } - - /** - * Ensures that getMax() returns expected value - * - * @return void - */ - public function testGetMax() - { - $validator = new Zend_Validate_Between(1, 10); - $this->assertEquals(10, $validator->getMax()); - } - - /** - * Ensures that getInclusive() returns expected default value - * - * @return void - */ - public function testGetInclusive() - { - $validator = new Zend_Validate_Between(1, 10); - $this->assertEquals(true, $validator->getInclusive()); - } -} diff --git a/tests/Zend/Validate/CcnumTest.php b/tests/Zend/Validate/CcnumTest.php deleted file mode 100644 index 213b4eebde8ecd9bd4790c5b411f10ebbe2944ea..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/CcnumTest.php +++ /dev/null @@ -1,90 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CcnumTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Ccnum - */ -require_once 'Zend/Validate/Ccnum.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_CcnumTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Ccnum object - * - * @var Zend_Validate_Ccnum - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Ccnum object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Ccnum(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - '4929000000006' => true, - '5404000000000001' => true, - '374200000000004' => true, - '4444555566667777' => false, - 'ABCDEF' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $this->_validator->isValid($input)); - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } -} diff --git a/tests/Zend/Validate/DateTest.php b/tests/Zend/Validate/DateTest.php deleted file mode 100644 index d11620985252b47a7e8d9ddb50aa057ed1cbc785..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/DateTest.php +++ /dev/null @@ -1,208 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DateTest.php 11179 2008-09-01 09:25:19Z alexander $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Date - */ -require_once 'Zend/Validate/Date.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_DateTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Date object - * - * @var Zend_Validate_Date - */ - protected $_validator; - - /** - * Whether an error occurred - * - * @var boolean - */ - protected $_errorOccurred = false; - - /** - * Creates a new Zend_Validate_Date object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Date(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - '2007-01-01' => true, - '2007-02-28' => true, - '2007-02-29' => false, - '2008-02-29' => true, - '2007-02-30' => false, - '2007-02-99' => false, - '9999-99-99' => false, - 0 => false, - 999999999999 => false, - 'Jan 1 2007' => false, - 'asdasda' => false, - 'sdgsdg' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $this->_validator->isValid($input), - "'$input' expected to be " . ($result ? '' : 'in') . 'valid'); - } - } - - /** - * Ensures that characters trailing an otherwise valid date cause the input to be invalid - * - * @see http://framework.zend.com/issues/browse/ZF-1804 - * @return void - */ - public function testCharactersTrailingInvalid() - { - $dateValid = '2007-08-02'; - $charactersTrailing = 'something'; - $this->assertTrue($this->_validator->isValid($dateValid)); - $this->assertFalse($this->_validator->isValid($dateValid . $charactersTrailing)); - } - - /** - * Ensures that characters leading an otherwise valid date cause the input to be invalid - * - * @see http://framework.zend.com/issues/browse/ZF-1804 - * @return void - */ - public function testCharactersLeadingInvalid() - { - $dateValid = '2007-08-02'; - $charactersLeading = 'something'; - $this->assertTrue($this->_validator->isValid($dateValid)); - $this->assertFalse($this->_validator->isValid($charactersLeading . $dateValid)); - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * Ensures that the validator can handle different manual dateformats - * - * @see http://framework.zend.com/issues/browse/ZF-2003 - * @return void - */ - public function testUseManualFormat() - { - $this->assertTrue($this->_validator->setFormat('dd.MM.YYYY')->isValid('10.01.2008')); - $this->assertTrue($this->_validator->setFormat('MMM yyyy')->isValid('Jan 2010')); - $this->assertFalse($this->_validator->setFormat('dd/MM/yyyy')->isValid('2008/10/22')); - set_error_handler(array($this, 'errorHandlerIgnore')); - $result = $this->_validator->setFormat('s')->isValid(0); - restore_error_handler(); - if (!$this->_errorOccurred) { - $this->assertTrue($result); - } else { - $this->markTestSkipped('Affected by bug described in ZF-2789'); - } - $this->_errorOccurred = false; - } - - /** - * Ensures that the validator can handle different dateformats from locale - * - * @see http://framework.zend.com/issues/browse/ZF-2003 - * @return void - */ - public function testUseLocaleFormat() - { - $errorOccurredLocal = false; - set_error_handler(array($this, 'errorHandlerIgnore')); - $valuesExpected = array( - '10.01.2008' => true, - '32.02.2008' => false, - '20 April 2008' => true, - '1 Jul 2008' => true, - '2008/20/03' => false, - '99/99/2000' => false, - 0 => false, - 999999999999 => false, - 'Jan 1 2007' => false - ); - foreach ($valuesExpected as $input => $resultExpected) { - $resultActual = $this->_validator->setLocale('de_AT')->isValid($input); - if (!$this->_errorOccurred) { - $this->assertEquals($resultExpected, $resultActual, "'$input' expected to be " - . ($resultExpected ? '' : 'in') . 'valid'); - } else { - $errorOccurredLocal = true; - } - $this->_errorOccurred = false; - } - restore_error_handler(); - if ($errorOccurredLocal) { - $this->markTestSkipped('Affected by bug described in ZF-2789'); - } - } - - /** - * Ignores a raised PHP error when in effect, but throws a flag to indicate an error occurred - * - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - * @param array $errcontext - * @return void - * @see http://framework.zend.com/issues/browse/ZF-2789 - */ - public function errorHandlerIgnore($errno, $errstr, $errfile, $errline, array $errcontext) - { - $this->_errorOccurred = true; - } -} diff --git a/tests/Zend/Validate/DigitsTest.php b/tests/Zend/Validate/DigitsTest.php deleted file mode 100644 index c0b756c3d09b3c444e18a82be7ecafe67ba2a665..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/DigitsTest.php +++ /dev/null @@ -1,148 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DigitsTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Digits - */ -require_once 'Zend/Validate/Digits.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_DigitsTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Digits object - * - * @var Zend_Validate_Digits - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Digits object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Digits(); - } - - /** - * Ensures that the validator follows expected behavior for basic input values - * - * @return void - */ - public function testExpectedResultsWithBasicInputValues() - { - $valuesExpected = array( - 'abc123' => false, - 'abc 123' => false, - 'abcxyz' => false, - 'AZ@#4.3' => false, - '1.23' => false, - '0x9f' => false, - '123' => true, - '09' => true, - '' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $this->_validator->isValid($input)); - } - } - - /** - * Ensures that getMessages() returns expected initial value - * - * @return void - */ - public function testMessagesEmptyInitially() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * @return void - */ - public function testEmptyStringValueResultsInProperValidationFailureMessages() - { - $this->assertFalse($this->_validator->isValid('')); - $messages = $this->_validator->getMessages(); - $arrayExpected = array( - Zend_Validate_Digits::STRING_EMPTY => '\'\' is an empty string' - ); - $this->assertThat($messages, $this->identicalTo($arrayExpected)); - } - - /** - * @return void - * @deprecated Since 1.5.0 - */ - public function testEmptyStringValueResultsInProperValidationFailureErrors() - { - $this->assertFalse($this->_validator->isValid('')); - $errors = $this->_validator->getErrors(); - $arrayExpected = array( - Zend_Validate_Digits::STRING_EMPTY - ); - $this->assertThat($errors, $this->identicalTo($arrayExpected)); - } - - /** - * @return void - */ - public function testInvalidValueResultsInProperValidationFailureMessages() - { - $this->assertFalse($this->_validator->isValid('#')); - $messages = $this->_validator->getMessages(); - $arrayExpected = array( - Zend_Validate_Digits::NOT_DIGITS => '\'#\' contains not only digit characters' - ); - $this->assertThat($messages, $this->identicalTo($arrayExpected)); - } - - /** - * @return void - * @deprecated Since 1.5.0 - */ - public function testInvalidValueResultsInProperValidationFailureErrors() - { - $this->assertFalse($this->_validator->isValid('#')); - $errors = $this->_validator->getErrors(); - $arrayExpected = array( - Zend_Validate_Digits::NOT_DIGITS - ); - $this->assertThat($errors, $this->identicalTo($arrayExpected)); - } -} diff --git a/tests/Zend/Validate/EmailAddressTest.php b/tests/Zend/Validate/EmailAddressTest.php deleted file mode 100644 index dc30b7009594a780b2b9b6077d25c8cfc3bc2c64..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/EmailAddressTest.php +++ /dev/null @@ -1,399 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EmailAddressTest.php 8985 2008-03-21 21:37:24Z matthew $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_EmailAddress - */ -require_once 'Zend/Validate/EmailAddress.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_EmailAddressTest extends PHPUnit_Framework_TestCase -{ - /** - * Default instance created for all test methods - * - * @var Zend_Validate_EmailAddress - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_EmailAddress object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_EmailAddress(); - } - - /** - * Ensures that a basic valid e-mail address passes validation - * - * @return void - */ - public function testBasic() - { - $this->assertTrue($this->_validator->isValid('username@example.com')); - } - - /** - * Ensures that localhost address is valid - * - * @return void - */ - public function testLocalhostAllowed() - { - $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_ALL); - $this->assertTrue($validator->isValid('username@localhost')); - } - - /** - * Ensures that local domain names are valid - * - * @return void - */ - public function testLocaldomainAllowed() - { - $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_ALL); - $this->assertTrue($validator->isValid('username@localhost.localdomain')); - } - - /** - * Ensures that IP hostnames are valid - * - * @return void - */ - public function testIPAllowed() - { - $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_IP); - $valuesExpected = array( - array(Zend_Validate_Hostname::ALLOW_DNS, true, array('bob@212.212.20.4')), - array(Zend_Validate_Hostname::ALLOW_DNS, false, array('bob@localhost')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Ensures that validation fails when the local part is missing - * - * @return void - */ - public function testLocalPartMissing() - { - $this->assertFalse($this->_validator->isValid('@example.com')); - $messages = $this->_validator->getMessages(); - $this->assertEquals(1, count($messages)); - $this->assertContains('local-part@hostname', current($messages)); - } - - /** - * Ensures that validation fails and produces the expected messages when the local part is invalid - * - * @return void - */ - public function testLocalPartInvalid() - { - $this->assertFalse($this->_validator->isValid('Some User@example.com')); - - $messages = $this->_validator->getMessages(); - - $this->assertEquals(3, count($messages)); - - $this->assertContains('Some User', current($messages)); - $this->assertContains('dot-atom', current($messages)); - - $this->assertContains('Some User', next($messages)); - $this->assertContains('quoted-string', current($messages)); - - $this->assertContains('Some User', next($messages)); - $this->assertContains('not a valid local part', current($messages)); - } - - /** - * Ensures that no validation failure message is produced when the local part follows the quoted-string format - * - * @return void - */ - public function testLocalPartQuotedString() - { - $this->assertTrue($this->_validator->isValid('"Some User"@example.com')); - - $messages = $this->_validator->getMessages(); - - $this->assertType('array', $messages); - $this->assertEquals(0, count($messages)); - } - - /** - * Ensures that validation fails when the hostname is invalid - * - * @return void - */ - public function testHostnameInvalid() - { - $this->assertFalse($this->_validator->isValid('username@ example . com')); - $messages = $this->_validator->getMessages(); - $this->assertThat(count($messages), $this->greaterThanOrEqual(1)); - $this->assertContains('not a valid hostname', current($messages)); - } - - /** - * Ensures that quoted-string local part is considered valid - * - * @return void - */ - public function testQuotedString() - { - $emailAddresses = array( - '"username"@example.com', - '"bob%jones"@domain.com', - '"bob jones"@domain.com', - '"bob@jones"@domain.com', - '"[[ bob ]]"@domain.com', - '"jones"@domain.com' - ); - foreach ($emailAddresses as $input) { - $this->assertTrue($this->_validator->isValid($input), "$input failed to pass validation:\n" - . implode("\n", $this->_validator->getMessages())); - } - } - - /** - * Ensures that validation fails when the e-mail is given as for display, - * with angle brackets around the actual address - * - * @return void - */ - public function testEmailDisplay() - { - $this->assertFalse($this->_validator->isValid('User Name <username@example.com>')); - $messages = $this->_validator->getMessages(); - $this->assertThat(count($messages), $this->greaterThanOrEqual(3)); - $this->assertContains('not a valid hostname', current($messages)); - $this->assertContains('cannot extract TLD part', next($messages)); - $this->assertContains('does not appear to be a valid local network name', next($messages)); - } - - /** - * Ensures that the validator follows expected behavior for valid email addresses - * - * @return void - */ - public function testBasicValid() - { - $emailAddresses = array( - 'bob@domain.com', - 'bob.jones@domain.co.uk', - 'bob.jones.smythe@domain.co.uk', - 'BoB@domain.museum', - 'bobjones@domain.info', - "B.O'Callaghan@domain.com", - 'bob+jones@domain.us', - 'bob+jones@domain.co.uk', - 'bob@some.domain.uk.com', - 'bob@verylongdomainsupercalifragilisticexpialidociousspoonfulofsugar.com' - ); - foreach ($emailAddresses as $input) { - $this->assertTrue($this->_validator->isValid($input), "$input failed to pass validation:\n" - . implode("\n", $this->_validator->getMessages())); - } - } - - /** - * Ensures that the validator follows expected behavior for invalid email addresses - * - * @return void - */ - public function testBasicInvalid() - { - $emailAddresses = array( - '', - 'bob - - @domain.com', - 'bob jones@domain.com', - '.bobJones@studio24.com', - 'bobJones.@studio24.com', - 'bob.Jones.@studio24.com', - '"bob%jones@domain.com', - 'bob@verylongdomainsupercalifragilisticexpialidociousaspoonfulofsugar.com', - 'bob+domain.com', - 'bob.domain.com', - 'bob @domain.com', - 'bob@ domain.com', - 'bob @ domain.com' - ); - foreach ($emailAddresses as $input) { - $this->assertFalse($this->_validator->isValid($input)); - } - } - - /** - * Ensures that the validator follows expected behavior for valid email addresses with complex local parts - * - * @return void - */ - public function testComplexLocalValid() - { - $emailAddresses = array( - 'Bob.Jones@domain.com', - 'Bob.Jones!@domain.com', - 'Bob&Jones@domain.com', - '/Bob.Jones@domain.com', - '#Bob.Jones@domain.com', - 'Bob.Jones?@domain.com' - ); - foreach ($emailAddresses as $input) { - $this->assertTrue($this->_validator->isValid($input)); - } - } - - - /** - * Ensures that the validator follows expected behavior for checking MX records - * - * @return void - */ - public function testMXRecords() - { - $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS, true); - - // Are MX checks supported by this system? - if (!$validator->validateMxSupported()) { - return true; - } - - $valuesExpected = array( - array(true, array('Bob.Jones@zend.com', 'Bob.Jones@studio24.net')), - array(false, array('Bob.Jones@madeupdomain242424a.com', 'Bob.Jones@madeupdomain242424b.net')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - - // Try a check via setting the option via a method - unset($validator); - $validator = new Zend_Validate_EmailAddress(); - $validator->setValidateMx(true); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Test changing hostname settings via EmailAddress object - * - * @return void - */ - public function testHostnameSettings() - { - $validator = new Zend_Validate_EmailAddress(); - - // Check no IDN matching - $validator->hostnameValidator->setValidateIdn(false); - $valuesExpected = array( - array(false, array('name@b�rger.de', 'name@h�llo.de', 'name@h�llo.se')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - - // Check no TLD matching - $validator->hostnameValidator->setValidateTld(false); - $valuesExpected = array( - array(true, array('name@domain.xx', 'name@domain.zz', 'name@domain.madeup')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Ensures that getMessages() returns expected default value (an empty array) - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * @see ZF-2861 - */ - public function testHostnameValidatorMessagesShouldBeTranslated() - { - require_once 'Zend/Validate/Hostname.php'; - $hostnameValidator = new Zend_Validate_Hostname(); - require_once 'Zend/Translate.php'; - $translations = array( - 'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation', - 'hostnameUnknownTld' => 'hostnameUnknownTld translation', - 'hostnameDashCharacter' => 'hostnameDashCharacter translation', - 'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation', - 'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation', - 'hostnameInvalidHostname' => 'hostnameInvalidHostname translation', - 'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation', - 'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation', - ); - $translator = new Zend_Translate('array', $translations); - $this->_validator->setTranslator($translator)->setHostnameValidator($hostnameValidator); - - $this->_validator->isValid('_XX.!!3xx@0.239,512.777'); - $messages = $hostnameValidator->getMessages(); - $found = false; - foreach ($messages as $code => $message) { - if (array_key_exists($code, $translations)) { - $this->assertEquals($translations[$code], $message); - $found = true; - break; - } - } - $this->assertTrue($found); - } -} diff --git a/tests/Zend/Validate/File/AllTests.php b/tests/Zend/Validate/File/AllTests.php deleted file mode 100644 index 7162ba845dd34b03f268fbeb06b5b8dcffa02492..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/AllTests.php +++ /dev/null @@ -1,83 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Validate_File_AllTests::main'); -} - -require_once 'Zend/Validate/File/CountTest.php'; -require_once 'Zend/Validate/File/ExcludeExtensionTest.php'; -require_once 'Zend/Validate/File/ExcludeMimeTypeTest.php'; -require_once 'Zend/Validate/File/ExistsTest.php'; -require_once 'Zend/Validate/File/ExtensionTest.php'; -require_once 'Zend/Validate/File/FilesSizeTest.php'; -require_once 'Zend/Validate/File/ImageSizeTest.php'; -require_once 'Zend/Validate/File/IsCompressedTest.php'; -require_once 'Zend/Validate/File/IsImageTest.php'; -require_once 'Zend/Validate/File/MimeTypeTest.php'; -require_once 'Zend/Validate/File/NotExistsTest.php'; -require_once 'Zend/Validate/File/SizeTest.php'; -require_once 'Zend/Validate/File/UploadTest.php'; - -/** - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Validate_File'); - - $suite->addTestSuite('Zend_Validate_File_CountTest'); - $suite->addTestSuite('Zend_Validate_File_ExcludeExtensionTest'); - $suite->addTestSuite('Zend_Validate_File_ExistsTest'); - $suite->addTestSuite('Zend_Validate_File_ExtensionTest'); - $suite->addTestSuite('Zend_Validate_File_FilesSizeTest'); - $suite->addTestSuite('Zend_Validate_File_ImageSizeTest'); - $suite->addTestSuite('Zend_Validate_File_IsCompressedTest'); - $suite->addTestSuite('Zend_Validate_File_IsImageTest'); - $suite->addTestSuite('Zend_Validate_File_MimeTypeTest'); - $suite->addTestSuite('Zend_Validate_File_NotExistsTest'); - $suite->addTestSuite('Zend_Validate_File_SizeTest'); - $suite->addTestSuite('Zend_Validate_File_UploadTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Validate_File_AllTests::main') { - Zend_Validate_File_AllTests::main(); -} diff --git a/tests/Zend/Validate/File/CountTest.php b/tests/Zend/Validate/File/CountTest.php deleted file mode 100644 index ce5f006b9df9f75ec5e3ac3f41e43725c7235e09..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/CountTest.php +++ /dev/null @@ -1,197 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_CountTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_CountTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_Count - */ -require_once 'Zend/Validate/File/Count.php'; - -/** - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_CountTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_CountTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(5, null, true, true, true, true), - array(0, 3, true, true, true, false), - array(2, 3, false, true, true, false), - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Count($element[0], $element[1]); - $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo')); - $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo')); - $this->assertEquals($element[5], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo')); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Count(array($element[0], $element[1])); - $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo')); - $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo')); - $this->assertEquals($element[5], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo')); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Count(array('min' => $element[0], 'max' => $element[1])); - $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo')); - $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo')); - $this->assertEquals($element[5], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo')); - } - - $validator = new Zend_Validate_File_Count(array(1)); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo')); - } - - /** - * Ensures that getMin() returns expected value - * - * @return void - */ - public function testGetMin() - { - $validator = new Zend_Validate_File_Count(1, 5); - $this->assertEquals(1, $validator->getMin()); - - try { - $validator = new Zend_Validate_File_Count(5, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_Count(array(1, 5)); - $this->assertEquals(1, $validator->getMin()); - - try { - $validator = new Zend_Validate_File_Count(array(5, 1)); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that setMin() returns expected value - * - * @return void - */ - public function testSetMin() - { - $validator = new Zend_Validate_File_Count(1000, 10000); - $validator->setMin(100); - $this->assertEquals(100, $validator->getMin()); - - try { - $validator->setMin(20000); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("less than or equal", $e->getMessage()); - } - } - - /** - * Ensures that getMax() returns expected value - * - * @return void - */ - public function testGetMax() - { - $validator = new Zend_Validate_File_Count(1, 100); - $this->assertEquals(100, $validator->getMax()); - - try { - $validator = new Zend_Validate_File_Count(5, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_Count(array(1, 50)); - $this->assertEquals(50, $validator->getMax()); - - try { - $validator = new Zend_Validate_File_Count(array(50, 1)); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that setMax() returns expected value - * - * @return void - */ - public function testSetMax() - { - $validator = new Zend_Validate_File_Count(1000, 10000); - $validator->setMax(1000000); - $this->assertEquals(1000000, $validator->getMax()); - - $validator->setMin(100); - $this->assertEquals(1000000, $validator->getMax()); - - $validator->setMax(null); - $this->assertEquals(null, $validator->getMax()); - } -} - -// Call Zend_Validate_File_CountTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_CountTest::main") { - Zend_Validate_File_CountTest::main(); -} diff --git a/tests/Zend/Validate/File/ExcludeExtensionTest.php b/tests/Zend/Validate/File/ExcludeExtensionTest.php deleted file mode 100644 index b0e45b62bc5417cb3c2f1a5589a2d69b3dc01108..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/ExcludeExtensionTest.php +++ /dev/null @@ -1,201 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_ExcludeExtensionTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_ExcludeExtensionTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_ExcludeExtension - */ -require_once 'Zend/Validate/File/ExcludeExtension.php'; - -/** - * ExcludeExtension testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_ExcludeExtensionTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_ExcludeExtensionTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array('mo', false), - array('gif', true), - array(array('mo'), false), - array(array('gif'), true), - array(array('gif', 'pdf', 'mo', 'pict'), false), - array(array('gif', 'gz', 'hint'), true), - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_ExcludeExtension($element[0]); - $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - } - - $validator = new Zend_Validate_File_ExcludeExtension('mo'); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.mo')); - $this->assertTrue(array_key_exists('fileExcludeExtensionNotFound', $validator->getMessages())); - - $files = array( - 'name' => 'test1', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => 'tmp_test1', - 'error' => 0 - ); - $validator = new Zend_Validate_File_ExcludeExtension('mo'); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.mo', $files)); - $this->assertTrue(array_key_exists('fileExcludeExtensionNotFound', $validator->getMessages())); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_ExcludeExtension('mo'); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - $this->assertTrue(array_key_exists('fileExcludeExtensionFalse', $validator->getMessages())); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_ExcludeExtension('gif'); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - } - - public function testCaseTesting() - { - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_ExcludeExtension('MO', true); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - - $validator = new Zend_Validate_File_ExcludeExtension('MO', false); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - } - - /** - * Ensures that getExtension() returns expected value - * - * @return void - */ - public function testGetExtension() - { - $validator = new Zend_Validate_File_ExcludeExtension('mo'); - $this->assertEquals('mo', $validator->getExtension()); - - $validator = new Zend_Validate_File_ExcludeExtension(array('mo', 'gif', 'jpg')); - $this->assertEquals('mo,gif,jpg', $validator->getExtension()); - - $validator = new Zend_Validate_File_ExcludeExtension(array('mo', 'gif', 'jpg')); - $this->assertEquals(array('mo', 'gif', 'jpg'), $validator->getExtension(true)); - } - - /** - * Ensures that setExtension() returns expected value - * - * @return void - */ - public function testSetExtension() - { - $validator = new Zend_Validate_File_ExcludeExtension('mo'); - $validator->setExtension('gif'); - $this->assertEquals('gif', $validator->getExtension()); - $this->assertEquals(array('gif'), $validator->getExtension(true)); - - $validator->setExtension('jpg, mo'); - $this->assertEquals('jpg,mo', $validator->getExtension()); - $this->assertEquals(array('jpg', 'mo'), $validator->getExtension(true)); - - $validator->setExtension(array('zip', 'ti')); - $this->assertEquals('zip,ti', $validator->getExtension()); - $this->assertEquals(array('zip', 'ti'), $validator->getExtension(true)); - } - - /** - * Ensures that addExtension() returns expected value - * - * @return void - */ - public function testAddExtension() - { - $validator = new Zend_Validate_File_ExcludeExtension('mo'); - $validator->addExtension('gif'); - $this->assertEquals('mo,gif', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif'), $validator->getExtension(true)); - - $validator->addExtension('jpg, to'); - $this->assertEquals('mo,gif,jpg,to', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif', 'jpg', 'to'), $validator->getExtension(true)); - - $validator->addExtension(array('zip', 'ti')); - $this->assertEquals('mo,gif,jpg,to,zip,ti', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getExtension(true)); - - $validator->addExtension(''); - $this->assertEquals('mo,gif,jpg,to,zip,ti', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getExtension(true)); - } -} - -// Call Zend_Validate_File_ExcludeExtensionTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_ExcludeExtensionTest::main") { - Zend_Validate_File_ExtensionTest::main(); -} diff --git a/tests/Zend/Validate/File/ExcludeMimeTypeTest.php b/tests/Zend/Validate/File/ExcludeMimeTypeTest.php deleted file mode 100644 index 0b22a3b89f29760e7151897cab3257dbddc713fd..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/ExcludeMimeTypeTest.php +++ /dev/null @@ -1,158 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_ExcludeMimeTypeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_ExcludeMimeTypeTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_ExcludeMimeType - */ -require_once 'Zend/Validate/File/ExcludeMimeType.php'; - -/** - * ExcludeMimeType testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_ExcludeMimeTypeTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_ExcludeMimeTypeTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array('image/gif', false), - array('image', false), - array('test/notype', true), - array('image/gif, image/jpeg', false), - array(array('image/vasa', 'image/gif'), false), - array(array('image/jpeg', 'gif'), false), - array(array('image/jpeg', 'jpeg'), true), - ); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'image/gif', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_ExcludeMimeType($element[0]); - $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - } - } - - /** - * Ensures that getMimeType() returns expected value - * - * @return void - */ - public function testGetMimeType() - { - $validator = new Zend_Validate_File_ExcludeMimeType('image/gif'); - $this->assertEquals('image/gif', $validator->getMimeType()); - - $validator = new Zend_Validate_File_ExcludeMimeType(array('image/gif', 'video', 'text/test')); - $this->assertEquals('image/gif,video,text/test', $validator->getMimeType()); - - $validator = new Zend_Validate_File_ExcludeMimeType(array('image/gif', 'video', 'text/test')); - $this->assertEquals(array('image/gif', 'video', 'text/test'), $validator->getMimeType(true)); - } - - /** - * Ensures that setMimeType() returns expected value - * - * @return void - */ - public function testSetMimeType() - { - $validator = new Zend_Validate_File_ExcludeMimeType('image/gif'); - $validator->setMimeType('image/jpeg'); - $this->assertEquals('image/jpeg', $validator->getMimeType()); - $this->assertEquals(array('image/jpeg'), $validator->getMimeType(true)); - - $validator->setMimeType('image/gif, text/test'); - $this->assertEquals('image/gif,text/test', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text/test'), $validator->getMimeType(true)); - - $validator->setMimeType(array('video/mpeg', 'gif')); - $this->assertEquals('video/mpeg,gif', $validator->getMimeType()); - $this->assertEquals(array('video/mpeg', 'gif'), $validator->getMimeType(true)); - } - - /** - * Ensures that addMimeType() returns expected value - * - * @return void - */ - public function testAddMimeType() - { - $validator = new Zend_Validate_File_ExcludeMimeType('image/gif'); - $validator->addMimeType('text'); - $this->assertEquals('image/gif,text', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text'), $validator->getMimeType(true)); - - $validator->addMimeType('jpg, to'); - $this->assertEquals('image/gif,text,jpg,to', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to'), $validator->getMimeType(true)); - - $validator->addMimeType(array('zip', 'ti')); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - - $validator->addMimeType(''); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - } -} - -// Call Zend_Validate_File_ExcludeMimeTypeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_ExcludeMimeTypeTest::main") { - Zend_Validate_File_ExcludeMimeTypeTest::main(); -} diff --git a/tests/Zend/Validate/File/ExistsTest.php b/tests/Zend/Validate/File/ExistsTest.php deleted file mode 100644 index 0217d8deb27f7f8288969f5a400338e0d233e5ed..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/ExistsTest.php +++ /dev/null @@ -1,186 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_ExistsTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_ExistsTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_Size - */ -require_once 'Zend/Validate/File/Exists.php'; - -/** - * Exists testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_ExistsTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_ExistsTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $baseDir = dirname(__FILE__); - $valuesExpected = array( - array($baseDir, 'testsize.mo', false), - array($baseDir . '/_files', 'testsize.mo', true) - ); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Exists($element[0]); - $this->assertEquals($element[2], $validator->isValid($element[1])); - $this->assertEquals($element[2], $validator->isValid($element[1], $files)); - } - - $valuesExpected = array( - array($baseDir, 'testsize.mo', false), - array($baseDir . '/_files', 'testsize.mo', true) - ); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0, - 'destination' => dirname(__FILE__) . '/_files' - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Exists($element[0]); - $this->assertEquals($element[2], $validator->isValid($element[1])); - $this->assertEquals($element[2], $validator->isValid($element[1], $files)); - } - - $valuesExpected = array( - array($baseDir, 'testsize.mo', false, true), - array($baseDir . '/_files', 'testsize.mo', false, true) - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Exists(); - $this->assertEquals($element[2], $validator->isValid($element[1])); - $this->assertEquals($element[3], $validator->isValid($element[1], $files)); - } - } - - /** - * Ensures that getDirectory() returns expected value - * - * @return void - */ - public function testGetDirectory() - { - $validator = new Zend_Validate_File_Exists('C:/temp'); - $this->assertEquals('C:/temp', $validator->getDirectory()); - - $validator = new Zend_Validate_File_Exists(array('temp', 'dir', 'jpg')); - $this->assertEquals('temp,dir,jpg', $validator->getDirectory()); - - $validator = new Zend_Validate_File_Exists(array('temp', 'dir', 'jpg')); - $this->assertEquals(array('temp', 'dir', 'jpg'), $validator->getDirectory(true)); - } - - /** - * Ensures that setDirectory() returns expected value - * - * @return void - */ - public function testSetDirectory() - { - $validator = new Zend_Validate_File_Exists('temp'); - $validator->setDirectory('gif'); - $this->assertEquals('gif', $validator->getDirectory()); - $this->assertEquals(array('gif'), $validator->getDirectory(true)); - - $validator->setDirectory('jpg, temp'); - $this->assertEquals('jpg,temp', $validator->getDirectory()); - $this->assertEquals(array('jpg', 'temp'), $validator->getDirectory(true)); - - $validator->setDirectory(array('zip', 'ti')); - $this->assertEquals('zip,ti', $validator->getDirectory()); - $this->assertEquals(array('zip', 'ti'), $validator->getDirectory(true)); - } - - /** - * Ensures that addDirectory() returns expected value - * - * @return void - */ - public function testAddDirectory() - { - $validator = new Zend_Validate_File_Exists('temp'); - $validator->addDirectory('gif'); - $this->assertEquals('temp,gif', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif'), $validator->getDirectory(true)); - - $validator->addDirectory('jpg, to'); - $this->assertEquals('temp,gif,jpg,to', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif', 'jpg', 'to'), $validator->getDirectory(true)); - - $validator->addDirectory(array('zip', 'ti')); - $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true)); - - $validator->addDirectory(''); - $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true)); - } -} - -// Call Zend_Validate_File_ExistsTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_ExistsTest::main") { - Zend_Validate_File_ExistsTest::main(); -} diff --git a/tests/Zend/Validate/File/ExtensionTest.php b/tests/Zend/Validate/File/ExtensionTest.php deleted file mode 100644 index 3fe90d4568dc7955de439b1ca7d9b92bae31cbbf..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/ExtensionTest.php +++ /dev/null @@ -1,201 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_ExtensionTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_ExtensionTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_Extension - */ -require_once 'Zend/Validate/File/Extension.php'; - -/** - * Extension testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_ExtensionTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_ExtensionTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array('mo', true), - array('gif', false), - array(array('mo'), true), - array(array('gif'), false), - array(array('gif', 'pdf', 'mo', 'pict'), true), - array(array('gif', 'gz', 'hint'), false), - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Extension($element[0]); - $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - } - - $validator = new Zend_Validate_File_Extension('mo'); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.mo')); - $this->assertTrue(array_key_exists('fileExtensionNotFound', $validator->getMessages())); - - $files = array( - 'name' => 'test1', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => 'tmp_test1', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Extension('mo'); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.mo', $files)); - $this->assertTrue(array_key_exists('fileExtensionNotFound', $validator->getMessages())); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Extension('mo'); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Extension('gif'); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - $this->assertTrue(array_key_exists('fileExtensionFalse', $validator->getMessages())); - } - - public function testZF3891() - { - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Extension('MO', true); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - - $validator = new Zend_Validate_File_Extension('MO', false); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - } - - /** - * Ensures that getExtension() returns expected value - * - * @return void - */ - public function testGetExtension() - { - $validator = new Zend_Validate_File_Extension('mo'); - $this->assertEquals('mo', $validator->getExtension()); - - $validator = new Zend_Validate_File_Extension(array('mo', 'gif', 'jpg')); - $this->assertEquals('mo,gif,jpg', $validator->getExtension()); - - $validator = new Zend_Validate_File_Extension(array('mo', 'gif', 'jpg')); - $this->assertEquals(array('mo', 'gif', 'jpg'), $validator->getExtension(true)); - } - - /** - * Ensures that setExtension() returns expected value - * - * @return void - */ - public function testSetExtension() - { - $validator = new Zend_Validate_File_Extension('mo'); - $validator->setExtension('gif'); - $this->assertEquals('gif', $validator->getExtension()); - $this->assertEquals(array('gif'), $validator->getExtension(true)); - - $validator->setExtension('jpg, mo'); - $this->assertEquals('jpg,mo', $validator->getExtension()); - $this->assertEquals(array('jpg', 'mo'), $validator->getExtension(true)); - - $validator->setExtension(array('zip', 'ti')); - $this->assertEquals('zip,ti', $validator->getExtension()); - $this->assertEquals(array('zip', 'ti'), $validator->getExtension(true)); - } - - /** - * Ensures that addExtension() returns expected value - * - * @return void - */ - public function testAddExtension() - { - $validator = new Zend_Validate_File_Extension('mo'); - $validator->addExtension('gif'); - $this->assertEquals('mo,gif', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif'), $validator->getExtension(true)); - - $validator->addExtension('jpg, to'); - $this->assertEquals('mo,gif,jpg,to', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif', 'jpg', 'to'), $validator->getExtension(true)); - - $validator->addExtension(array('zip', 'ti')); - $this->assertEquals('mo,gif,jpg,to,zip,ti', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getExtension(true)); - - $validator->addExtension(''); - $this->assertEquals('mo,gif,jpg,to,zip,ti', $validator->getExtension()); - $this->assertEquals(array('mo', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getExtension(true)); - } -} - -// Call Zend_Validate_File_ExtensionTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_ExtensionTest::main") { - Zend_Validate_File_ExtensionTest::main(); -} diff --git a/tests/Zend/Validate/File/FilesSizeTest.php b/tests/Zend/Validate/File/FilesSizeTest.php deleted file mode 100644 index 6f95610a7c21add819888cb6640a70d07e4c2e1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/FilesSizeTest.php +++ /dev/null @@ -1,222 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_FilesSizeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_FilesSizeTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_FilesSize - */ -require_once 'Zend/Validate/File/FilesSize.php'; - -/** - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_FilesSizeTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_FilesSizeTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(0, 2000, true, true, false), - array(0, '2 MB', true, true, true), - array(0, '2MB', true, true, true), - array(0, '2 MB', true, true, true), - array(2000, null, true, true, false), - array(0, 500, false, false, false), - array(500, null, false, false, false) - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_FilesSize($element[0], $element[1]); - $this->assertEquals( - $element[2], - $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'), - "Tested with " . var_export($element, 1) - ); - $this->assertEquals( - $element[3], - $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'), - "Tested with " . var_export($element, 1) - ); - $this->assertEquals( - $element[4], - $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo'), - "Tested with " . var_export($element, 1) - ); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_FilesSize(array($element[0], $element[1])); - $this->assertEquals( - $element[2], - $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'), - "Tested with " . var_export($element, 1) - ); - $this->assertEquals( - $element[3], - $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'), - "Tested with " . var_export($element, 1) - ); - $this->assertEquals( - $element[4], - $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo'), - "Tested with " . var_export($element, 1) - ); - } - - $validator = new Zend_Validate_File_FilesSize(array(0, 200)); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.mo')); - $this->assertTrue(array_key_exists('fileFilesSizeNotReadable', $validator->getMessages())); - - $validator = new Zend_Validate_File_FilesSize(array(0, 500000)); - $this->assertEquals(true, $validator->isValid(array( - dirname(__FILE__) . '/_files/testsize.mo', - dirname(__FILE__) . '/_files/testsize.mo', - dirname(__FILE__) . '/_files/testsize2.mo'))); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - } - - /** - * Ensures that getMin() returns expected value - * - * @return void - */ - public function testGetMin() - { - $validator = new Zend_Validate_File_FilesSize(1, 100); - $this->assertEquals('1B', $validator->getMin()); - - try { - $validator = new Zend_Validate_File_FilesSize(100, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_FilesSize(array(1, 100)); - $this->assertEquals('1B', $validator->getMin()); - - try { - $validator = new Zend_Validate_File_FilesSize(array(100, 1)); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that setMin() returns expected value - * - * @return void - */ - public function testSetMin() - { - $validator = new Zend_Validate_File_FilesSize(1000, 10000); - $validator->setMin(100); - $this->assertEquals('100B', $validator->getMin()); - - try { - $validator->setMin(20000); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("less than or equal", $e->getMessage()); - } - } - - /** - * Ensures that getMax() returns expected value - * - * @return void - */ - public function testGetMax() - { - $validator = new Zend_Validate_File_FilesSize(1, 100); - $this->assertEquals('100B', $validator->getMax()); - - try { - $validator = new Zend_Validate_File_FilesSize(100, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_FilesSize(array(1, 100000)); - $this->assertEquals('97.66kB', $validator->getMax()); - - try { - $validator = new Zend_Validate_File_FilesSize(array(100, 1)); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_FilesSize(2000); - $this->assertEquals('2000', $validator->getMax(false)); - } - - /** - * Ensures that setMax() returns expected value - * - * @return void - */ - public function testSetMax() - { - $validator = new Zend_Validate_File_FilesSize(1000, 10000); - $validator->setMax(1000000); - $this->assertEquals('976.56kB', $validator->getMax()); - - $validator->setMin(100); - $this->assertEquals('976.56kB', $validator->getMax()); - } -} - -// Call Zend_Validate_File_FilesSizeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_FilesSizeTest::main") { - Zend_Validate_File_FilesSizeTest::main(); -} diff --git a/tests/Zend/Validate/File/ImageSizeTest.php b/tests/Zend/Validate/File/ImageSizeTest.php deleted file mode 100644 index 860e7afa23c63f96432fe74284590a742bc642bd..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/ImageSizeTest.php +++ /dev/null @@ -1,253 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_ImageSizeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_ImageSizeTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_ImageSize - */ -require_once 'Zend/Validate/File/ImageSize.php'; - -/** - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_ImageSizeTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_ImageSizeTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(0, 10, 1000, 2000, true), - array(0, 0, 200, 200, true), - array(150, 150, 200, 200, false), - array(80, 0, 80, 200, true), - array(0, 0, 60, 200, false), - array(90, 0, 200, 200, false), - array(0, 0, 200, 80, false), - array(0, 110, 200, 140, false) - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_ImageSize($element[0], $element[1], $element[2], $element[3]); - $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/picture.jpg')); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_ImageSize(array($element[0], $element[1], $element[2], $element[3])); - $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/picture.jpg')); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_ImageSize(array('minwidth' => $element[0], 'minheight' => $element[1], 'maxwidth' => $element[2], 'maxheight' => $element[3])); - $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/picture.jpg')); - } - - $validator = new Zend_Validate_File_ImageSize(0, 10, 1000, 2000); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.jpg')); - $failures = $validator->getMessages(); - $this->assertContains('can not be read', $failures['fileImageSizeNotReadable']); - - $file['name'] = 'TestName'; - $validator = new Zend_Validate_File_ImageSize(0, 10, 1000, 2000); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.jpg', $file)); - $failures = $validator->getMessages(); - $this->assertContains('TestName', $failures['fileImageSizeNotReadable']); - - $validator = new Zend_Validate_File_ImageSize(0, 10, 1000, 2000); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/badpicture.jpg')); - $failures = $validator->getMessages(); - $this->assertContains('could not be detected', $failures['fileImageSizeNotDetected']); - } - - /** - * Ensures that getImageMin() returns expected value - * - * @return void - */ - public function testGetImageMin() - { - $validator = new Zend_Validate_File_ImageSize(1, 10, 100, 1000); - $this->assertEquals(array(1, 10), $validator->getImageMin()); - - try { - $validator = new Zend_Validate_File_ImageSize(1000, 100, 10, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that setImageMin() returns expected value - * - * @return void - */ - public function testSetImageMin() - { - $validator = new Zend_Validate_File_ImageSize(100, 1000, 10000, 100000); - $validator->setImageMin(10, 10); - $this->assertEquals(array(10, 10), $validator->getImageMin()); - - $validator->setImageMin(9, 100); - $this->assertEquals(array(9, 100), $validator->getImageMin()); - - try { - $validator->setImageMin(20000, 20000); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("less than or equal", $e->getMessage()); - } - } - - /** - * Ensures that getImageMax() returns expected value - * - * @return void - */ - public function testGetImageMax() - { - $validator = new Zend_Validate_File_ImageSize(10, 100, 1000, 10000); - $this->assertEquals(array(1000, 10000), $validator->getImageMax()); - - try { - $validator = new Zend_Validate_File_ImageSize(10000, 1000, 100, 10); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that setImageMax() returns expected value - * - * @return void - */ - public function testSetImageMax() - { - $validator = new Zend_Validate_File_ImageSize(10, 100, 1000, 10000); - $validator->setImageMax(100, 100); - $this->assertEquals(array(100, 100), $validator->getImageMax()); - - $validator->setImageMax(110, 1000); - $this->assertEquals(array(110, 1000), $validator->getImageMax()); - - $validator->setImageMax(null, 1100); - $this->assertEquals(array(null, 1100), $validator->getImageMax()); - - $validator->setImageMax(120, null); - $this->assertEquals(array(120, null), $validator->getImageMax()); - - try { - $validator->setImageMax(10000, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that getImageWidth() returns expected value - * - * @return void - */ - public function testGetImageWidth() - { - $validator = new Zend_Validate_File_ImageSize(1, 10, 100, 1000); - $this->assertEquals(array(1, 100), $validator->getImageWidth()); - } - - /** - * Ensures that setImageWidth() returns expected value - * - * @return void - */ - public function testSetImageWidth() - { - $validator = new Zend_Validate_File_ImageSize(100, 1000, 10000, 100000); - $validator->setImageWidth(2000, 2200); - $this->assertEquals(array(2000, 2200), $validator->getImageWidth()); - - try { - $validator->setImageWidth(20000, 200); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("less than or equal", $e->getMessage()); - } - } - - /** - * Ensures that getImageHeight() returns expected value - * - * @return void - */ - public function testGetImageHeight() - { - $validator = new Zend_Validate_File_ImageSize(1, 10, 100, 1000); - $this->assertEquals(array(10, 1000), $validator->getImageHeight()); - } - - /** - * Ensures that setImageHeight() returns expected value - * - * @return void - */ - public function testSetImageHeight() - { - $validator = new Zend_Validate_File_ImageSize(100, 1000, 10000, 100000); - $validator->setImageHeight(2000, 2200); - $this->assertEquals(array(2000, 2200), $validator->getImageHeight()); - - try { - $validator->setImageHeight(20000, 200); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("less than or equal", $e->getMessage()); - } - } -} diff --git a/tests/Zend/Validate/File/IsCompressedTest.php b/tests/Zend/Validate/File/IsCompressedTest.php deleted file mode 100644 index 81fac76c250c537845cf83be1b8af359c0b565f5..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/IsCompressedTest.php +++ /dev/null @@ -1,158 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_MimeTypeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_MimeTypeTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_IsCompressed - */ -require_once 'Zend/Validate/File/IsCompressed.php'; - -/** - * IsCompressed testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_IsCompressedTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_IsCompressedTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(null, true), - array('zip', true), - array('test/notype', false), - array('application/zip, application/x-tar', true), - array(array('application/zip', 'application/x-tar'), true), - array(array('zip', 'tar'), true), - array(array('tar', 'arj'), false), - ); - - $files = array( - 'name' => 'test.zip', - 'type' => 'application/zip', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/test.zip', - 'error' => 0 - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_IsCompressed($element[0]); - $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/test.zip', $files)); - } - } - - /** - * Ensures that getMimeType() returns expected value - * - * @return void - */ - public function testGetMimeType() - { - $validator = new Zend_Validate_File_IsCompressed('image/gif'); - $this->assertEquals('image/gif', $validator->getMimeType()); - - $validator = new Zend_Validate_File_IsCompressed(array('image/gif', 'video', 'text/test')); - $this->assertEquals('image/gif,video,text/test', $validator->getMimeType()); - - $validator = new Zend_Validate_File_IsCompressed(array('image/gif', 'video', 'text/test')); - $this->assertEquals(array('image/gif', 'video', 'text/test'), $validator->getMimeType(true)); - } - - /** - * Ensures that setMimeType() returns expected value - * - * @return void - */ - public function testSetMimeType() - { - $validator = new Zend_Validate_File_IsCompressed('image/gif'); - $validator->setMimeType('image/jpeg'); - $this->assertEquals('image/jpeg', $validator->getMimeType()); - $this->assertEquals(array('image/jpeg'), $validator->getMimeType(true)); - - $validator->setMimeType('image/gif, text/test'); - $this->assertEquals('image/gif,text/test', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text/test'), $validator->getMimeType(true)); - - $validator->setMimeType(array('video/mpeg', 'gif')); - $this->assertEquals('video/mpeg,gif', $validator->getMimeType()); - $this->assertEquals(array('video/mpeg', 'gif'), $validator->getMimeType(true)); - } - - /** - * Ensures that addMimeType() returns expected value - * - * @return void - */ - public function testAddMimeType() - { - $validator = new Zend_Validate_File_IsCompressed('image/gif'); - $validator->addMimeType('text'); - $this->assertEquals('image/gif,text', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text'), $validator->getMimeType(true)); - - $validator->addMimeType('jpg, to'); - $this->assertEquals('image/gif,text,jpg,to', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to'), $validator->getMimeType(true)); - - $validator->addMimeType(array('zip', 'ti')); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - - $validator->addMimeType(''); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - } -} - -// Call Zend_Validate_File_MimeTypeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_IsCompressedTest::main") { - Zend_Validate_File_IsCompressedTest::main(); -} diff --git a/tests/Zend/Validate/File/IsImageTest.php b/tests/Zend/Validate/File/IsImageTest.php deleted file mode 100644 index c56b565db8e7cf42117152bfbc95b80771961dd8..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/IsImageTest.php +++ /dev/null @@ -1,158 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_IsImageTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_IsImageTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_IsImage - */ -require_once 'Zend/Validate/File/IsImage.php'; - -/** - * IsImage testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_IsImageTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_IsImageTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(null, true), - array('jpeg', true), - array('test/notype', false), - array('image/gif, image/jpeg', true), - array(array('image/vasa', 'image/jpeg'), true), - array(array('image/jpeg', 'gif'), true), - array(array('image/gif', 'gif'), false), - ); - - $files = array( - 'name' => 'picture.jpg', - 'type' => 'image/jpeg', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/picture.jpg', - 'error' => 0 - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_IsImage($element[0]); - $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/picture.jpg', $files)); - } - } - - /** - * Ensures that getMimeType() returns expected value - * - * @return void - */ - public function testGetMimeType() - { - $validator = new Zend_Validate_File_IsImage('image/gif'); - $this->assertEquals('image/gif', $validator->getMimeType()); - - $validator = new Zend_Validate_File_IsImage(array('image/gif', 'video', 'text/test')); - $this->assertEquals('image/gif,video,text/test', $validator->getMimeType()); - - $validator = new Zend_Validate_File_IsImage(array('image/gif', 'video', 'text/test')); - $this->assertEquals(array('image/gif', 'video', 'text/test'), $validator->getMimeType(true)); - } - - /** - * Ensures that setMimeType() returns expected value - * - * @return void - */ - public function testSetMimeType() - { - $validator = new Zend_Validate_File_IsImage('image/gif'); - $validator->setMimeType('image/jpeg'); - $this->assertEquals('image/jpeg', $validator->getMimeType()); - $this->assertEquals(array('image/jpeg'), $validator->getMimeType(true)); - - $validator->setMimeType('image/gif, text/test'); - $this->assertEquals('image/gif,text/test', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text/test'), $validator->getMimeType(true)); - - $validator->setMimeType(array('video/mpeg', 'gif')); - $this->assertEquals('video/mpeg,gif', $validator->getMimeType()); - $this->assertEquals(array('video/mpeg', 'gif'), $validator->getMimeType(true)); - } - - /** - * Ensures that addMimeType() returns expected value - * - * @return void - */ - public function testAddMimeType() - { - $validator = new Zend_Validate_File_IsImage('image/gif'); - $validator->addMimeType('text'); - $this->assertEquals('image/gif,text', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text'), $validator->getMimeType(true)); - - $validator->addMimeType('jpg, to'); - $this->assertEquals('image/gif,text,jpg,to', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to'), $validator->getMimeType(true)); - - $validator->addMimeType(array('zip', 'ti')); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - - $validator->addMimeType(''); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - } -} - -// Call Zend_Validate_File_IsImage::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_IsImage::main") { - Zend_Validate_File_IsImage::main(); -} diff --git a/tests/Zend/Validate/File/MimeTypeTest.php b/tests/Zend/Validate/File/MimeTypeTest.php deleted file mode 100644 index 28650665ddd02897f6e0ebb7f3d81b575a40dc8d..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/MimeTypeTest.php +++ /dev/null @@ -1,158 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_MimeTypeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_MimeTypeTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_MimeType - */ -require_once 'Zend/Validate/File/MimeType.php'; - -/** - * MimeType testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_MimeTypeTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_MimeTypeTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array('image/gif', true), - array('image', true), - array('test/notype', false), - array('image/gif, image/jpeg', true), - array(array('image/vasa', 'image/gif'), true), - array(array('image/jpeg', 'gif'), true), - array(array('image/jpeg', 'jpeg'), false), - ); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'image/gif', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_MimeType($element[0]); - $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - } - } - - /** - * Ensures that getMimeType() returns expected value - * - * @return void - */ - public function testGetMimeType() - { - $validator = new Zend_Validate_File_MimeType('image/gif'); - $this->assertEquals('image/gif', $validator->getMimeType()); - - $validator = new Zend_Validate_File_MimeType(array('image/gif', 'video', 'text/test')); - $this->assertEquals('image/gif,video,text/test', $validator->getMimeType()); - - $validator = new Zend_Validate_File_MimeType(array('image/gif', 'video', 'text/test')); - $this->assertEquals(array('image/gif', 'video', 'text/test'), $validator->getMimeType(true)); - } - - /** - * Ensures that setMimeType() returns expected value - * - * @return void - */ - public function testSetMimeType() - { - $validator = new Zend_Validate_File_MimeType('image/gif'); - $validator->setMimeType('image/jpeg'); - $this->assertEquals('image/jpeg', $validator->getMimeType()); - $this->assertEquals(array('image/jpeg'), $validator->getMimeType(true)); - - $validator->setMimeType('image/gif, text/test'); - $this->assertEquals('image/gif,text/test', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text/test'), $validator->getMimeType(true)); - - $validator->setMimeType(array('video/mpeg', 'gif')); - $this->assertEquals('video/mpeg,gif', $validator->getMimeType()); - $this->assertEquals(array('video/mpeg', 'gif'), $validator->getMimeType(true)); - } - - /** - * Ensures that addMimeType() returns expected value - * - * @return void - */ - public function testAddMimeType() - { - $validator = new Zend_Validate_File_MimeType('image/gif'); - $validator->addMimeType('text'); - $this->assertEquals('image/gif,text', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text'), $validator->getMimeType(true)); - - $validator->addMimeType('jpg, to'); - $this->assertEquals('image/gif,text,jpg,to', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to'), $validator->getMimeType(true)); - - $validator->addMimeType(array('zip', 'ti')); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - - $validator->addMimeType(''); - $this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType()); - $this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true)); - } -} - -// Call Zend_Validate_File_MimeTypeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_MimeTypeTest::main") { - Zend_Validate_File_MimeTypeTest::main(); -} diff --git a/tests/Zend/Validate/File/NotExistsTest.php b/tests/Zend/Validate/File/NotExistsTest.php deleted file mode 100644 index e4f34ccb61b3393ac40aa44ffa6b99b56536ed1d..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/NotExistsTest.php +++ /dev/null @@ -1,186 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_NotExistsTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_NotExistsTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_Size - */ -require_once 'Zend/Validate/File/NotExists.php'; - -/** - * NotExists testbed - * - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_NotExistsTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_NotExistsTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $baseDir = dirname(__FILE__); - $valuesExpected = array( - array($baseDir, 'testsize.mo', true), - array($baseDir . '/_files', 'testsize.mo', false) - ); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_NotExists($element[0]); - $this->assertEquals($element[2], $validator->isValid($element[1])); - $this->assertEquals($element[2], $validator->isValid($element[1], $files)); - } - - $valuesExpected = array( - array($baseDir, 'testsize.mo', true, false), - array($baseDir . '/_files', 'testsize.mo', false, false) - ); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0, - 'destination' => dirname(__FILE__) . '/_files' - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_NotExists($element[0]); - $this->assertEquals($element[2], $validator->isValid($element[1])); - $this->assertEquals($element[3], $validator->isValid($element[1], $files)); - } - - $valuesExpected = array( - array($baseDir, 'testsize.mo', false, false), - array($baseDir . '/_files', 'testsize.mo', false, false) - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_NotExists(); - $this->assertEquals($element[2], $validator->isValid($element[1])); - $this->assertEquals($element[3], $validator->isValid($element[1], $files)); - } - } - - /** - * Ensures that getDirectory() returns expected value - * - * @return void - */ - public function testGetDirectory() - { - $validator = new Zend_Validate_File_NotExists('C:/temp'); - $this->assertEquals('C:/temp', $validator->getDirectory()); - - $validator = new Zend_Validate_File_NotExists(array('temp', 'dir', 'jpg')); - $this->assertEquals('temp,dir,jpg', $validator->getDirectory()); - - $validator = new Zend_Validate_File_NotExists(array('temp', 'dir', 'jpg')); - $this->assertEquals(array('temp', 'dir', 'jpg'), $validator->getDirectory(true)); - } - - /** - * Ensures that setDirectory() returns expected value - * - * @return void - */ - public function testSetDirectory() - { - $validator = new Zend_Validate_File_NotExists('temp'); - $validator->setDirectory('gif'); - $this->assertEquals('gif', $validator->getDirectory()); - $this->assertEquals(array('gif'), $validator->getDirectory(true)); - - $validator->setDirectory('jpg, temp'); - $this->assertEquals('jpg,temp', $validator->getDirectory()); - $this->assertEquals(array('jpg', 'temp'), $validator->getDirectory(true)); - - $validator->setDirectory(array('zip', 'ti')); - $this->assertEquals('zip,ti', $validator->getDirectory()); - $this->assertEquals(array('zip', 'ti'), $validator->getDirectory(true)); - } - - /** - * Ensures that addDirectory() returns expected value - * - * @return void - */ - public function testAddDirectory() - { - $validator = new Zend_Validate_File_NotExists('temp'); - $validator->addDirectory('gif'); - $this->assertEquals('temp,gif', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif'), $validator->getDirectory(true)); - - $validator->addDirectory('jpg, to'); - $this->assertEquals('temp,gif,jpg,to', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif', 'jpg', 'to'), $validator->getDirectory(true)); - - $validator->addDirectory(array('zip', 'ti')); - $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true)); - - $validator->addDirectory(''); - $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory()); - $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true)); - } -} - -// Call Zend_Validate_File_NotExistsTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_NotExistsTest::main") { - Zend_Validate_File_NotExistsTest::main(); -} diff --git a/tests/Zend/Validate/File/SizeTest.php b/tests/Zend/Validate/File/SizeTest.php deleted file mode 100644 index a1040928e2f59f116beb166d353f0a93309e3e1a..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/SizeTest.php +++ /dev/null @@ -1,266 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_SizeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_SizeTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_Size - */ -require_once 'Zend/Validate/File/Size.php'; - -/** - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_SizeTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_SizeTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(0, 10000, true), - array(0, '10 MB', true), - array(0, '10MB', true), - array(0, '10 MB', true), - array(794, null, true), - array(0, 500, false), - array(500, null, false) - ); - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Size($element[0], $element[1]); - $this->assertEquals( - $element[2], - $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'), - "Tested with " . var_export($element, 1) - ); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Size(array($element[0], $element[1])); - $this->assertEquals( - $element[2], - $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'), - "Tested with " . var_export($element, 1) - ); - } - - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_File_Size(array('min' => $element[0], 'max' => $element[1])); - $this->assertEquals( - $element[2], - $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'), - "Tested with " . var_export($element, 1) - ); - } - - $validator = new Zend_Validate_File_Size(array(2000)); - $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - - $validator = new Zend_Validate_File_Size(array(1, 2, 3)); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo')); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Size(array(2000)); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/nofile.mo', $files)); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Size(array(0, 1)); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - - $files = array( - 'name' => 'testsize.mo', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', - 'error' => 0 - ); - $validator = new Zend_Validate_File_Size(array(5000, 10000)); - $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo', $files)); - } - - /** - * Ensures that getMin() returns expected value - * - * @return void - */ - public function testGetMin() - { - $validator = new Zend_Validate_File_Size(1, 100); - $this->assertEquals('1B', $validator->getMin()); - - try { - $validator = new Zend_Validate_File_Size(100, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_Size(array(1, 100)); - $this->assertEquals('1B', $validator->getMin()); - - try { - $validator = new Zend_Validate_File_Size(array(100, 1)); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - } - - /** - * Ensures that setMin() returns expected value - * - * @return void - */ - public function testSetMin() - { - $validator = new Zend_Validate_File_Size(1000, 10000); - $validator->setMin(100); - $this->assertEquals('100B', $validator->getMin()); - - try { - $validator->setMin(20000); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("less than or equal", $e->getMessage()); - } - } - - /** - * Ensures that getMax() returns expected value - * - * @return void - */ - public function testGetMax() - { - $validator = new Zend_Validate_File_Size(1, 100); - $this->assertEquals('100B', $validator->getMax()); - - try { - $validator = new Zend_Validate_File_Size(100, 1); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_Size(array(1, 100000)); - $this->assertEquals('97.66kB', $validator->getMax()); - - try { - $validator = new Zend_Validate_File_Size(array(100, 1)); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("greater than or equal", $e->getMessage()); - } - - $validator = new Zend_Validate_File_Size(2000); - $this->assertEquals('2000', $validator->getMax(false)); - } - - /** - * Ensures that setMax() returns expected value - * - * @return void - */ - public function testSetMax() - { - $validator = new Zend_Validate_File_Size(null, null); - $validator->setMax(null); - $this->assertEquals('0B', $validator->getMax()); - - $validator->setMax(1000000); - $this->assertEquals('976.56kB', $validator->getMax()); - - $validator->setMin(100); - $this->assertEquals('976.56kB', $validator->getMax()); - - $validator->setMax('100 AB'); - $this->assertEquals('100B', $validator->getMax()); - - $validator->setMax('100 kB'); - $this->assertEquals('100kB', $validator->getMax()); - - $validator->setMax('100 MB'); - $this->assertEquals('100MB', $validator->getMax()); - - $validator->setMax('1 GB'); - $this->assertEquals('1GB', $validator->getMax()); - - $validator->setMax('0.001 TB'); - $this->assertEquals('1.02GB', $validator->getMax()); - - $validator->setMax('0.000001 PB'); - $this->assertEquals('1.05GB', $validator->getMax()); - - $validator->setMax('0.000000001 EB'); - $this->assertEquals('1.07GB', $validator->getMax()); - - $validator->setMax('0.000000000001 ZB'); - $this->assertEquals('1.1GB', $validator->getMax()); - - $validator->setMax('0.000000000000001 YB'); - $this->assertEquals('1.13GB', $validator->getMax()); - } -} - -// Call Zend_Validate_File_SizeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_SizeTest::main") { - Zend_Validate_File_SizeTest::main(); -} diff --git a/tests/Zend/Validate/File/UploadTest.php b/tests/Zend/Validate/File/UploadTest.php deleted file mode 100644 index 352c4b1646d101677b3c55dbcaba243f49c987bd..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/File/UploadTest.php +++ /dev/null @@ -1,264 +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_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// Call Zend_Validate_File_UploadTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_UploadTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** - * @see Zend_Validate_File_Upload - */ -require_once 'Zend/Validate/File/Upload.php'; - -/** - * @category Zend - * @package Zend_Validate_File - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_File_UploadTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_UploadTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $_FILES = array( - 'test' => array( - 'name' => 'test1', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => 'tmp_test1', - 'error' => 0), - 'test2' => array( - 'name' => 'test2', - 'type' => 'text2', - 'size' => 202, - 'tmp_name' => 'tmp_test2', - 'error' => 1), - 'test3' => array( - 'name' => 'test3', - 'type' => 'text3', - 'size' => 203, - 'tmp_name' => 'tmp_test3', - 'error' => 2), - 'test4' => array( - 'name' => 'test4', - 'type' => 'text4', - 'size' => 204, - 'tmp_name' => 'tmp_test4', - 'error' => 3), - 'test5' => array( - 'name' => 'test5', - 'type' => 'text5', - 'size' => 205, - 'tmp_name' => 'tmp_test5', - 'error' => 4), - 'test6' => array( - 'name' => 'test6', - 'type' => 'text6', - 'size' => 206, - 'tmp_name' => 'tmp_test6', - 'error' => 5), - 'test7' => array( - 'name' => 'test7', - 'type' => 'text7', - 'size' => 207, - 'tmp_name' => 'tmp_test7', - 'error' => 6), - 'test8' => array( - 'name' => 'test8', - 'type' => 'text8', - 'size' => 208, - 'tmp_name' => 'tmp_test8', - 'error' => 7), - 'test9' => array( - 'name' => 'test9', - 'type' => 'text9', - 'size' => 209, - 'tmp_name' => 'tmp_test9', - 'error' => 8) - ); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test')); - $this->assertTrue(array_key_exists('fileUploadErrorAttack', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test2')); - $this->assertTrue(array_key_exists('fileUploadErrorIniSize', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test3')); - $this->assertTrue(array_key_exists('fileUploadErrorFormSize', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test4')); - $this->assertTrue(array_key_exists('fileUploadErrorPartial', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test5')); - $this->assertTrue(array_key_exists('fileUploadErrorNoFile', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test6')); - $this->assertTrue(array_key_exists('fileUploadErrorUnknown', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test7')); - $this->assertTrue(array_key_exists('fileUploadErrorNoTmpDir', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test8')); - $this->assertTrue(array_key_exists('fileUploadErrorCantWrite', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test9')); - $this->assertTrue(array_key_exists('fileUploadErrorExtension', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test1')); - $this->assertTrue(array_key_exists('fileUploadErrorAttack', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('tmp_test1')); - $this->assertTrue(array_key_exists('fileUploadErrorAttack', $validator->getMessages())); - - $validator = new Zend_Validate_File_Upload(); - $this->assertFalse($validator->isValid('test000')); - $this->assertTrue(array_key_exists('fileUploadErrorFileNotFound', $validator->getMessages())); - } - - /** - * Ensures that getFiles() returns expected value - * - * @return void - */ - public function testGetFiles() - { - $_FILES = array( - 'test' => array( - 'name' => 'test1', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => 'tmp_test1', - 'error' => 0), - 'test2' => array( - 'name' => 'test3', - 'type' => 'text2', - 'size' => 202, - 'tmp_name' => 'tmp_test2', - 'error' => 1)); - - $files = array( - 'test' => array( - 'name' => 'test1', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => 'tmp_test1', - 'error' => 0)); - - $files1 = array( - 'test2' => array( - 'name' => 'test3', - 'type' => 'text2', - 'size' => 202, - 'tmp_name' => 'tmp_test2', - 'error' => 1)); - - $validator = new Zend_Validate_File_Upload(); - $this->assertEquals($files, $validator->getFiles('test')); - $this->assertEquals($files, $validator->getFiles('test1')); - $this->assertEquals($files1, $validator->getFiles('test3')); - - try { - $this->assertEquals(array(), $validator->getFiles('test5')); - $this->fail("Missing exception"); - } catch (Zend_Validate_Exception $e) { - $this->assertContains("was not found", $e->getMessage()); - } - } - - /** - * Ensures that setFiles() returns expected value - * - * @return void - */ - public function testSetFiles() - { - $files = array( - 'test' => array( - 'name' => 'test1', - 'type' => 'text', - 'size' => 200, - 'tmp_name' => 'tmp_test1', - 'error' => 0), - 'test2' => array( - 'name' => 'test2', - 'type' => 'text2', - 'size' => 202, - 'tmp_name' => 'tmp_test2', - 'error' => 1)); - - $_FILES = array( - 'test' => array( - 'name' => 'test3', - 'type' => 'text3', - 'size' => 203, - 'tmp_name' => 'tmp_test3', - 'error' => 2)); - - - $validator = new Zend_Validate_File_Upload(); - $validator->setFiles(array()); - $this->assertEquals($_FILES, $validator->getFiles()); - $validator->setFiles(); - $this->assertEquals($_FILES, $validator->getFiles()); - $validator->setFiles($files); - $this->assertEquals($files, $validator->getFiles()); - } -} - -// Call Zend_Validate_File_UploadTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_UploadTest::main") { - Zend_Validate_File_UploadTest::main(); -} diff --git a/tests/Zend/Validate/File/_files/badpicture.jpg b/tests/Zend/Validate/File/_files/badpicture.jpg deleted file mode 100644 index 3ced007d49ca8ac1015fabaeff0e4556a6a79eba..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/badpicture.jpg and /dev/null differ diff --git a/tests/Zend/Validate/File/_files/picture.jpg b/tests/Zend/Validate/File/_files/picture.jpg deleted file mode 100644 index f267b3914f8686ad304c9dd7a55dd39b2311b1bb..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/picture.jpg and /dev/null differ diff --git a/tests/Zend/Validate/File/_files/test.zip b/tests/Zend/Validate/File/_files/test.zip deleted file mode 100644 index f6be0eeb901d17de9cdc997c70d0097c41a0b745..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/test.zip and /dev/null differ diff --git a/tests/Zend/Validate/File/_files/testsize.mo b/tests/Zend/Validate/File/_files/testsize.mo deleted file mode 100644 index 3ced007d49ca8ac1015fabaeff0e4556a6a79eba..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/testsize.mo and /dev/null differ diff --git a/tests/Zend/Validate/File/_files/testsize2.mo b/tests/Zend/Validate/File/_files/testsize2.mo deleted file mode 100644 index 3ced007d49ca8ac1015fabaeff0e4556a6a79eba..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/testsize2.mo and /dev/null differ diff --git a/tests/Zend/Validate/File/_files/testsize3.mo b/tests/Zend/Validate/File/_files/testsize3.mo deleted file mode 100644 index 3ced007d49ca8ac1015fabaeff0e4556a6a79eba..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/testsize3.mo and /dev/null differ diff --git a/tests/Zend/Validate/File/_files/testsize4.mo b/tests/Zend/Validate/File/_files/testsize4.mo deleted file mode 100644 index 3ced007d49ca8ac1015fabaeff0e4556a6a79eba..0000000000000000000000000000000000000000 Binary files a/tests/Zend/Validate/File/_files/testsize4.mo and /dev/null differ diff --git a/tests/Zend/Validate/FloatTest.php b/tests/Zend/Validate/FloatTest.php deleted file mode 100644 index b12f401d64f92ff7c93d63db5ed0277e030acd96..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/FloatTest.php +++ /dev/null @@ -1,91 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FloatTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Float - */ -require_once 'Zend/Validate/Float.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_FloatTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Float object - * - * @var Zend_Validate_Float - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Float object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Float(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(1.00, true), - array(0.01, true), - array(-0.1, true), - array('10.1', true), - array(1, true), - array('not a float', false), - ); - foreach ($valuesExpected as $element) { - $this->assertEquals($element[1], $this->_validator->isValid($element[0])); - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } -} diff --git a/tests/Zend/Validate/GreaterThanTest.php b/tests/Zend/Validate/GreaterThanTest.php deleted file mode 100644 index 7609a2f7844156bfb44e89ad4c6bc3dac40a6747..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/GreaterThanTest.php +++ /dev/null @@ -1,93 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: GreaterThanTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_GreaterThan - */ -require_once 'Zend/Validate/GreaterThan.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_GreaterThanTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - /** - * The elements of each array are, in order: - * - minimum - * - expected validation result - * - array of test input values - */ - $valuesExpected = array( - array(0, true, array(0.01, 1, 100)), - array(0, false, array(0, 0.00, -0.01, -1, -100)), - array('a', true, array('b', 'c', 'd')), - array('z', false, array('x', 'y', 'z')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_GreaterThan($element[0]); - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input)); - } - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $validator = new Zend_Validate_GreaterThan(10); - $this->assertEquals(array(), $validator->getMessages()); - } - - /** - * Ensures that getMin() returns expected value - * - * @return void - */ - public function testGetMin() - { - $validator = new Zend_Validate_GreaterThan(10); - $this->assertEquals(10, $validator->getMin()); - } -} diff --git a/tests/Zend/Validate/HexTest.php b/tests/Zend/Validate/HexTest.php deleted file mode 100644 index b4f43eb0c60a05296e6b84970fc75eb5d5880558..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/HexTest.php +++ /dev/null @@ -1,94 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HexTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Hex - */ -require_once 'Zend/Validate/Hex.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_HexTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Hex object - * - * @var Zend_Validate_Hex - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Hex object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Hex(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(1, true), - array(0x1, true), - array(0x123, true), - array('1', true), - array('abc123', true), - array('ABC123', true), - array('1234567890abcdef', true), - array('g', false), - array('1.2', false) - ); - foreach ($valuesExpected as $element) { - $this->assertEquals($element[1], $this->_validator->isValid($element[0]), $element[0]); - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } -} diff --git a/tests/Zend/Validate/HostnameTest.php b/tests/Zend/Validate/HostnameTest.php deleted file mode 100644 index 11a2f40299d74fec262e86426c9f70b3ca8e9bdd..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/HostnameTest.php +++ /dev/null @@ -1,253 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HostnameTest.php 8985 2008-03-21 21:37:24Z matthew $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Hostname - */ -require_once 'Zend/Validate/Hostname.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_HostnameTest extends PHPUnit_Framework_TestCase -{ - /** - * Default instance created for all test methods - * - * @var Zend_Validate_Hostname - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Hostname object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Hostname(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(Zend_Validate_Hostname::ALLOW_IP, true, array('1.2.3.4', '10.0.0.1', '255.255.255.255')), - array(Zend_Validate_Hostname::ALLOW_IP, false, array('1.2.3.4.5', '0.0.0.256')), - array(Zend_Validate_Hostname::ALLOW_DNS, true, array('example.com', 'example.museum', 'd.hatena.ne.jp')), - array(Zend_Validate_Hostname::ALLOW_DNS, false, array('localhost', 'localhost.localdomain', '1.2.3.4', 'domain.invalid')), - array(Zend_Validate_Hostname::ALLOW_LOCAL, true, array('localhost', 'localhost.localdomain', 'example.com')), - array(Zend_Validate_Hostname::ALLOW_ALL, true, array('localhost', 'example.com', '1.2.3.4')), - array(Zend_Validate_Hostname::ALLOW_LOCAL, false, array('local host', 'example,com', 'exam_ple.com')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_Hostname($element[0]); - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - public function testCombination() - { - $valuesExpected = array( - array(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_LOCAL, true, array('domain.com', 'localhost', 'local.localhost')), - array(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_LOCAL, false, array('1.2.3.4', '255.255.255.255')), - array(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_IP, true, array('1.2.3.4', '255.255.255.255')), - array(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_IP, false, array('localhost', 'local.localhost')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_Hostname($element[0]); - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Ensure the dash character tests work as expected - * - */ - public function testDashes() - { - $valuesExpected = array( - array(Zend_Validate_Hostname::ALLOW_DNS, true, array('domain.com', 'doma-in.com')), - array(Zend_Validate_Hostname::ALLOW_DNS, false, array('-domain.com', 'domain-.com', 'do--main.com')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_Hostname($element[0]); - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * Ensure the IDN check works as expected - * - */ - public function testIDN() - { - $validator = new Zend_Validate_Hostname(); - - // Check IDN matching - $valuesExpected = array( - array(true, array('bürger.de', 'hãllo.de', 'hÃ¥llo.se')), - array(true, array('bÜrger.de', 'hÃllo.de', 'hÃ…llo.se')), - array(false, array('hãllo.se', 'bürger.com', 'hãllo.uk')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - - // Check no IDN matching - $validator->setValidateIdn(false); - $valuesExpected = array( - array(false, array('bürger.de', 'hãllo.de', 'hÃ¥llo.se')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - - // Check setting no IDN matching via constructor - unset($validator); - $validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, false); - $valuesExpected = array( - array(false, array('bürger.de', 'hãllo.de', 'hÃ¥llo.se')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Ensure the TLD check works as expected - * - */ - public function testTLD() - { - $validator = new Zend_Validate_Hostname(); - - // Check TLD matching - $valuesExpected = array( - array(true, array('domain.co.uk', 'domain.uk.com', 'domain.tl', 'domain.zw')), - array(false, array('domain.xx', 'domain.zz', 'domain.madeup')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - - // Check no TLD matching - $validator->setValidateTld(false); - $valuesExpected = array( - array(true, array('domain.xx', 'domain.zz', 'domain.madeup')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - - // Check setting no TLD matching via constructor - unset($validator); - $validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, true, false); - $valuesExpected = array( - array(true, array('domain.xx', 'domain.zz', 'domain.madeup')) - ); - foreach ($valuesExpected as $element) { - foreach ($element[1] as $input) { - $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages())); - } - } - } - - /** - * Ensures that getAllow() returns expected default value - * - * @return void - */ - public function testGetAllow() - { - $this->assertEquals(Zend_Validate_Hostname::ALLOW_DNS, $this->_validator->getAllow()); - } - - /** - * @see ZF-2861 - */ - public function testIpValidatorMessagesShouldBeTranslated() - { - require_once 'Zend/Validate/Ip.php'; - $ipValidator = new Zend_Validate_Ip(); - require_once 'Zend/Translate.php'; - $translations = array( - 'notIpAddress' => 'this is the IP error message', - ); - $translator = new Zend_Translate('array', $translations); - $this->_validator->setTranslator($translator)->setIpValidator($ipValidator); - - $this->_validator->isValid('0.239,512.777'); - $messages = $ipValidator->getMessages(); - $found = false; - foreach ($messages as $code => $message) { - if (array_key_exists($code, $translations)) { - $found = true; - break; - } - } - $this->assertTrue($found); - $this->assertEquals($translations[$code], $message); - } -} diff --git a/tests/Zend/Validate/IdenticalTest.php b/tests/Zend/Validate/IdenticalTest.php deleted file mode 100644 index 43e0d0d8f8b4c7c456aa4c223fece69f0a5bd8fc..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/IdenticalTest.php +++ /dev/null @@ -1,108 +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 UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -// Call Zend_Validate_IdenticalTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Validate_IdenticalTest::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** Zend_Validate_Identical */ -require_once 'Zend/Validate/Identical.php'; - -/** - * Zend_Validate_Identical - * - * @category Zend - * @package UnitTests - * @uses Zend_Validate_Identical - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IdenticalTest.php 8118 2008-02-18 16:10:32Z matthew $ - */ -class Zend_Validate_IdenticalTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - $suite = new PHPUnit_Framework_TestSuite('Zend_Validate_IdenticalTest'); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->validator = new Zend_Validate_Identical; - } - - public function testTokenInitiallyNull() - { - $this->assertNull($this->validator->getToken()); - } - - public function testCanSetToken() - { - $this->testTokenInitiallyNull(); - $this->validator->setToken('foo'); - $this->assertEquals('foo', $this->validator->getToken()); - } - - public function testCanSetTokenViaConstructor() - { - $validator = new Zend_Validate_Identical('foo'); - $this->assertEquals('foo', $validator->getToken()); - } - - public function testValidatingWhenTokenNullReturnsFalse() - { - $this->assertFalse($this->validator->isValid('foo')); - } - - public function testValidatingWhenTokenNullSetsMissingTokenMessage() - { - $this->testValidatingWhenTokenNullReturnsFalse(); - $messages = $this->validator->getMessages(); - $this->assertTrue(array_key_exists('missingToken', $messages)); - } - - public function testValidatingAgainstTokenWithNonMatchingValueReturnsFalse() - { - $this->validator->setToken('foo'); - $this->assertFalse($this->validator->isValid('bar')); - } - - public function testValidatingAgainstTokenWithNonMatchingValueSetsNotSameMessage() - { - $this->testValidatingAgainstTokenWithNonMatchingValueReturnsFalse(); - $messages = $this->validator->getMessages(); - $this->assertTrue(array_key_exists('notSame', $messages)); - } - - public function testValidatingAgainstTokenWithMatchingValueReturnsTrue() - { - $this->validator->setToken('foo'); - $this->assertTrue($this->validator->isValid('foo')); - } -} - -// Call Zend_Validate_IdenticalTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == 'Zend_Validate_IdenticalTest::main') { - Zend_Validate_IdenticalTest::main(); -} diff --git a/tests/Zend/Validate/InArrayTest.php b/tests/Zend/Validate/InArrayTest.php deleted file mode 100644 index ddfb958702120e5febf698d19672a11cbe7aabcb..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/InArrayTest.php +++ /dev/null @@ -1,94 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: InArrayTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_InArray - */ -require_once 'Zend/Validate/InArray.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_InArrayTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $validator = new Zend_Validate_InArray(array(1, 'a', 2.3)); - $this->assertTrue($validator->isValid(1)); - $this->assertTrue($validator->isValid(1.0)); - $this->assertTrue($validator->isValid('1')); - $this->assertTrue($validator->isValid('a')); - $this->assertFalse($validator->isValid('A')); - $this->assertTrue($validator->isValid(2.3)); - $this->assertTrue($validator->isValid(2.3e0)); - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $validator = new Zend_Validate_InArray(array(1, 2, 3)); - $this->assertEquals(array(), $validator->getMessages()); - } - - /** - * Ensures that getHaystack() returns expected value - * - * @return void - */ - public function testGetHaystack() - { - $validator = new Zend_Validate_InArray(array(1, 2, 3)); - $this->assertEquals(array(1, 2, 3), $validator->getHaystack()); - } - - /** - * Ensures that getStrict() returns expected default value - * - * @return void - */ - public function testGetStrict() - { - $validator = new Zend_Validate_InArray(array(1, 2, 3)); - $this->assertEquals(false, $validator->getStrict()); - } -} diff --git a/tests/Zend/Validate/IntTest.php b/tests/Zend/Validate/IntTest.php deleted file mode 100644 index 51b88f783ca06291bbc99a54849b35ade3926d01..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/IntTest.php +++ /dev/null @@ -1,93 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IntTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Int - */ -require_once 'Zend/Validate/Int.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_IntTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Int object - * - * @var Zend_Validate_Int - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Int object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Int(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array(1.00, true), - array(0.00, true), - array(0.01, false), - array(-0.1, false), - array(-1, true), - array('10', true), - array(1, true), - array('not an int', false), - ); - foreach ($valuesExpected as $element) { - $this->assertEquals($element[1], $this->_validator->isValid($element[0])); - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } -} diff --git a/tests/Zend/Validate/IpTest.php b/tests/Zend/Validate/IpTest.php deleted file mode 100644 index 3ee026c7311a33d1012391ad6a07b20cc880ecc9..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/IpTest.php +++ /dev/null @@ -1,91 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IpTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Ip - */ -require_once 'Zend/Validate/Ip.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_IpTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate_Ip object - * - * @var Zend_Validate_Ip - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_Ip object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_Ip(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $this->assertTrue($this->_validator->isValid('1.2.3.4')); - $this->assertTrue($this->_validator->isValid('10.0.0.1')); - $this->assertTrue($this->_validator->isValid('255.255.255.255')); - - $this->assertFalse($this->_validator->isValid('0.0.0.256')); - $this->assertFalse($this->_validator->isValid('1.2.3.4.5')); - } - - public function testZeroIpForZF2420() - { - $this->assertTrue($this->_validator->isValid('0.0.0.0')); - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } -} diff --git a/tests/Zend/Validate/LessThanTest.php b/tests/Zend/Validate/LessThanTest.php deleted file mode 100644 index 8b97a546d045aadd8debf4a4fe59d59bd068983c..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/LessThanTest.php +++ /dev/null @@ -1,93 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LessThanTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_LessThan - */ -require_once 'Zend/Validate/LessThan.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_LessThanTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - /** - * The elements of each array are, in order: - * - maximum - * - expected validation result - * - array of test input values - */ - $valuesExpected = array( - array(100, true, array(-1, 0, 0.01, 1, 99.999)), - array(100, false, array(100, 100.0, 100.01)), - array('a', false, array('a', 'b', 'c', 'd')), - array('z', true, array('x', 'y')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_LessThan($element[0]); - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input)); - } - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $validator = new Zend_Validate_LessThan(10); - $this->assertEquals(array(), $validator->getMessages()); - } - - /** - * Ensures that getMax() returns expected value - * - * @return void - */ - public function testGetMax() - { - $validator = new Zend_Validate_LessThan(10); - $this->assertEquals(10, $validator->getMax()); - } -} diff --git a/tests/Zend/Validate/MessageTest.php b/tests/Zend/Validate/MessageTest.php deleted file mode 100644 index 0414176c49f21ff04f4d0ea8814b27e603de4305..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/MessageTest.php +++ /dev/null @@ -1,306 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MessageTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_StringLength - */ -require_once 'Zend/Validate/StringLength.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_MessageTest extends PHPUnit_Framework_TestCase -{ - /** - * Default instance created for all test methods - * - * @var Zend_Validate_StringLength - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_StringLength object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_StringLength(4, 8); - } - - /** - * Ensures that we can change a specified message template by its key - * and that this message is returned when the input is invalid. - * - * @return void - */ - public function testSetMessage() - { - $inputInvalid = 'abcdefghij'; - $this->assertFalse($this->_validator->isValid($inputInvalid)); - $messages = $this->_validator->getMessages(); - $this->assertEquals("'$inputInvalid' is greater than 8 characters long", current($messages)); - - $this->_validator->setMessage( - 'Your value is too long', - Zend_Validate_StringLength::TOO_LONG - ); - - $this->assertFalse($this->_validator->isValid('abcdefghij')); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too long', current($messages)); - } - - /** - * Ensures that if we don't specify the message key, it uses - * the first one in the list of message templates. - * In the case of Zend_Validate_StringLength, TOO_SHORT is - * the one we should expect to change. - * - * @return void - */ - public function testSetMessageDefaultKey() - { - $this->_validator->setMessage( - 'Your value is too short' - ); - - $this->assertFalse($this->_validator->isValid('abc')); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too short', current($messages)); - $errors = $this->_validator->getErrors(); - $this->assertEquals(Zend_Validate_StringLength::TOO_SHORT, current($errors)); - } - - /** - * Ensures that we can include the %value% parameter in the message, - * and that it is substituted with the value we are validating. - * - * @return void - */ - public function testSetMessageWithValueParam() - { - $this->_validator->setMessage( - "Your value '%value%' is too long", - Zend_Validate_StringLength::TOO_LONG - ); - - $inputInvalid = 'abcdefghij'; - $this->assertFalse($this->_validator->isValid($inputInvalid)); - $messages = $this->_validator->getMessages(); - $this->assertEquals("Your value '$inputInvalid' is too long", current($messages)); - } - - /** - * Ensures that we can include another parameter, defined on a - * class-by-class basis, in the message string. - * In the case of Zend_Validate_StringLength, one such parameter - * is %max%. - * - * @return void - */ - public function testSetMessageWithOtherParam() - { - $this->_validator->setMessage( - 'Your value is too long, it should be no longer than %max%', - Zend_Validate_StringLength::TOO_LONG - ); - - $inputInvalid = 'abcdefghij'; - $this->assertFalse($this->_validator->isValid($inputInvalid)); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too long, it should be no longer than 8', current($messages)); - } - - /** - * Ensures that if we set a parameter in the message that is not - * known to the validator class, it is not changed; %shazam% is - * left as literal text in the message. - * - * @return void - */ - public function testSetMessageWithUnknownParam() - { - $this->_validator->setMessage( - 'Your value is too long, and btw, %shazam%!', - Zend_Validate_StringLength::TOO_LONG - ); - - $inputInvalid = 'abcdefghij'; - $this->assertFalse($this->_validator->isValid($inputInvalid)); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too long, and btw, %shazam%!', current($messages)); - } - - /** - * Ensures that the validator throws an exception when we - * try to set a message for a key that is unknown to the class. - * - * @return void - */ - public function testSetMessageExceptionInvalidKey() - { - $keyInvalid = 'invalidKey'; - try { - $this->_validator->setMessage( - 'Your value is too long', - $keyInvalid - ); - $this->fail('Expected to catch Zend_Validate_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Validate_Exception', $e, - 'Expected exception of type Zend_Validate_Exception, got ' . get_class($e)); - $this->assertEquals("No message template exists for key '$keyInvalid'", $e->getMessage()); - } - } - - /** - * Ensures that we can set more than one message at a time, - * by passing an array of key/message pairs. Both messages - * should be defined. - * - * @return void - */ - public function testSetMessages() - { - $this->_validator->setMessages( - array( - Zend_Validate_StringLength::TOO_LONG => 'Your value is too long', - Zend_Validate_StringLength::TOO_SHORT => 'Your value is too short' - ) - ); - - $this->assertFalse($this->_validator->isValid('abcdefghij')); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too long', current($messages)); - - $this->assertFalse($this->_validator->isValid('abc')); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too short', current($messages)); - } - - /** - * Ensures that the magic getter gives us access to properties - * that are permitted to be substituted in the message string. - * The access is by the parameter name, not by the protected - * property variable name. - * - * @return void - */ - public function testGetProperty() - { - $this->_validator->setMessage( - 'Your value is too long', - Zend_Validate_StringLength::TOO_LONG - ); - - $inputInvalid = 'abcdefghij'; - - $this->assertFalse($this->_validator->isValid($inputInvalid)); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too long', current($messages)); - - $this->assertEquals($inputInvalid, $this->_validator->value); - $this->assertEquals(8, $this->_validator->max); - $this->assertEquals(4, $this->_validator->min); - } - - /** - * Ensures that the class throws an exception when we try to - * access a property that doesn't exist as a parameter. - * - * @return void - */ - public function testGetPropertyException() - { - $this->_validator->setMessage( - 'Your value is too long', - Zend_Validate_StringLength::TOO_LONG - ); - - $this->assertFalse($this->_validator->isValid('abcdefghij')); - $messages = $this->_validator->getMessages(); - $this->assertEquals('Your value is too long', current($messages)); - - try { - $property = $this->_validator->unknownProperty; - $this->fail('Expected to catch Zend_Validate_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Validate_Exception', $e, - 'Expected exception of type Zend_Validate_Exception, got ' . get_class($e)); - $this->assertEquals("No property exists by the name 'unknownProperty'", $e->getMessage()); - } - } - - /** - * Ensures that the getError() function returns an array of - * message key values corresponding to the messages. - * - * @return void - */ - public function testGetErrors() - { - $inputInvalid = 'abcdefghij'; - $this->assertFalse($this->_validator->isValid($inputInvalid)); - - $messages = $this->_validator->getMessages(); - $this->assertEquals("'$inputInvalid' is greater than 8 characters long", current($messages)); - - $errors = $this->_validator->getErrors(); - $this->assertEquals(Zend_Validate_StringLength::TOO_LONG, current($errors)); - } - - /** - * Ensures that getMessageVariables() returns an array of - * strings and that these strings that can be used as variables - * in a message. - */ - public function testGetMessageVariables() - { - $vars = $this->_validator->getMessageVariables(); - - $this->assertType('array', $vars); - $this->assertEquals(array('min', 'max'), $vars); - $message = 'variables: %notvar% '; - foreach ($vars as $var) { - $message .= "%$var% "; - } - $this->_validator->setMessage($message); - - $this->assertFalse($this->_validator->isValid('abc')); - $messages = $this->_validator->getMessages(); - $this->assertEquals('variables: %notvar% 4 8 ', current($messages)); - } - -} diff --git a/tests/Zend/Validate/NotEmptyTest.php b/tests/Zend/Validate/NotEmptyTest.php deleted file mode 100644 index dfdcaa05105bfc784427625ac4bbe9eb9da1e338..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/NotEmptyTest.php +++ /dev/null @@ -1,121 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NotEmptyTest.php 10371 2008-07-24 16:22:50Z matthew $ - */ - -// Call Zend_Validate_NotEmptyTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_Validate_NotEmptyTest::main"); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_NotEmpty - */ -require_once 'Zend/Validate/NotEmpty.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_NotEmptyTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_NotEmptyTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Zend_Validate_NotEmpty object - * - * @var Zend_Validate_NotEmpty - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_NotEmpty object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_NotEmpty(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - $valuesExpected = array( - array('word', true), - array('', false), - array(1, true), - array(0, false), - array(true, true), - array(false, false), - array(null, false), - ); - foreach ($valuesExpected as $i => $element) { - $this->assertEquals($element[1], $this->_validator->isValid($element[0]), - "Failed test #$i"); - } - } - - /** - * @see ZF-3236 - */ - public function testStringWithZeroShouldNotBeTreatedAsEmpty() - { - $this->assertTrue($this->_validator->isValid('0')); - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } -} - -// Call Zend_Validate_NotEmptyTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_Validate_NotEmptyTest::main") { - Zend_Validate_NotEmptyTest::main(); -} diff --git a/tests/Zend/Validate/RegexTest.php b/tests/Zend/Validate/RegexTest.php deleted file mode 100644 index f00838502e0377d9cb17ff12e5b49cd14bb408a9..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/RegexTest.php +++ /dev/null @@ -1,107 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RegexTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_Regex - */ -require_once 'Zend/Validate/Regex.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_RegexTest extends PHPUnit_Framework_TestCase -{ - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - /** - * The elements of each array are, in order: - * - pattern - * - expected validation result - * - array of test input values - */ - $valuesExpected = array( - array('/[a-z]/', true, array('abc123', 'foo', 'a', 'z')), - array('/[a-z]/', false, array('123', 'A')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_Regex($element[0]); - foreach ($element[2] as $input) { - $this->assertEquals($element[1], $validator->isValid($input)); - } - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $validator = new Zend_Validate_Regex('/./'); - $this->assertEquals(array(), $validator->getMessages()); - } - - /** - * Ensures that getPattern() returns expected value - * - * @return void - */ - public function testGetPattern() - { - $validator = new Zend_Validate_Regex('/./'); - $this->assertEquals('/./', $validator->getPattern()); - } - - /** - * Ensures that a bad pattern results in a thrown exception upon isValid() call - * - * @return void - */ - public function testBadPattern() - { - $validator = new Zend_Validate_Regex('/'); - try { - $validator->isValid('anything'); - $this->fail('Expected Zend_Validate_Exception not thrown for bad pattern'); - } catch (Zend_Validate_Exception $e) { - $this->assertContains('Internal error matching pattern', $e->getMessage()); - } - } -} diff --git a/tests/Zend/Validate/StringLengthTest.php b/tests/Zend/Validate/StringLengthTest.php deleted file mode 100644 index 76fcf7aabfe46df48eeb68977e445fb5c4939bf0..0000000000000000000000000000000000000000 --- a/tests/Zend/Validate/StringLengthTest.php +++ /dev/null @@ -1,165 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringLengthTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -/** - * @see Zend_Validate_StringLength - */ -require_once 'Zend/Validate/StringLength.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_StringLengthTest extends PHPUnit_Framework_TestCase -{ - /** - * Default instance created for all test methods - * - * @var Zend_Validate_StringLength - */ - protected $_validator; - - /** - * Creates a new Zend_Validate_StringLength object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate_StringLength(); - } - - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() - { - iconv_set_encoding('internal_encoding', 'UTF-8'); - /** - * The elements of each array are, in order: - * - minimum length - * - maximum length - * - expected validation result - * - array of test input values - */ - $valuesExpected = array( - array(0, null, true, array('', 'a', 'ab')), - array(-1, null, true, array('')), - array(2, 2, true, array('ab', ' ')), - array(2, 2, false, array('a', 'abc')), - array(1, null, false, array('')), - array(2, 3, true, array('ab', 'abc')), - array(2, 3, false, array('a', 'abcd')), - array(3, 3, true, array('äöü')), - array(6, 6, true, array('Müller')) - ); - foreach ($valuesExpected as $element) { - $validator = new Zend_Validate_StringLength($element[0], $element[1]); - foreach ($element[3] as $input) { - $this->assertEquals($element[2], $validator->isValid($input)); - } - } - } - - /** - * Ensures that getMessages() returns expected default value - * - * @return void - */ - public function testGetMessages() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - } - - /** - * Ensures that getMin() returns expected default value - * - * @return void - */ - public function testGetMin() - { - $this->assertEquals(0, $this->_validator->getMin()); - } - - /** - * Ensures that getMax() returns expected default value - * - * @return void - */ - public function testGetMax() - { - $this->assertEquals(null, $this->_validator->getMax()); - } - - /** - * Ensures that setMin() throws an exception when given a value greater than the maximum - * - * @return void - */ - public function testSetMinExceptionGreaterThanMax() - { - $max = 1; - $min = 2; - try { - $this->_validator->setMax($max)->setMin($min); - $this->fail('Expected Zend_Validate_Exception not thrown'); - } catch (Zend_Validate_Exception $e) { - $this->assertEquals( - "The minimum must be less than or equal to the maximum length, but $min > $max", - $e->getMessage() - ); - } - } - - /** - * Ensures that setMax() throws an exception when given a value less than the minimum - * - * @return void - */ - public function testSetMaxExceptionLessThanMin() - { - $max = 1; - $min = 2; - try { - $this->_validator->setMin($min)->setMax($max); - $this->fail('Expected Zend_Validate_Exception not thrown'); - } catch (Zend_Validate_Exception $e) { - $this->assertEquals( - "The maximum must be greater than or equal to the minimum length, but $max < $min", - $e->getMessage() - ); - } - } -} diff --git a/tests/Zend/ValidateTest.php b/tests/Zend/ValidateTest.php deleted file mode 100644 index 321d29472d663e3189bb9382129f5599a3457d95..0000000000000000000000000000000000000000 --- a/tests/Zend/ValidateTest.php +++ /dev/null @@ -1,180 +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_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ValidateTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * @see Zend_Validate - */ -require_once 'Zend/Validate.php'; - -/** - * @see Zend_Validate_Abstract - */ -require_once 'Zend/Validate/Abstract.php'; - - -/** - * @category Zend - * @package Zend_Validate - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_ValidateTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_Validate object - * - * @var Zend_Validate - */ - protected $_validator; - - /** - * Creates a new Zend_Validate object for each test method - * - * @return void - */ - public function setUp() - { - $this->_validator = new Zend_Validate(); - } - - /** - * Ensures expected results from empty validator chain - * - * @return void - */ - public function testEmpty() - { - $this->assertEquals(array(), $this->_validator->getMessages()); - $this->assertEquals(array(), $this->_validator->getErrors()); - $this->assertTrue($this->_validator->isValid('something')); - $this->assertEquals(array(), $this->_validator->getErrors()); - } - - /** - * Ensures expected behavior from a validator known to succeed - * - * @return void - */ - public function testTrue() - { - $this->_validator->addValidator(new Zend_ValidateTest_True()); - $this->assertTrue($this->_validator->isValid(null)); - $this->assertEquals(array(), $this->_validator->getMessages()); - $this->assertEquals(array(), $this->_validator->getErrors()); - } - - /** - * Ensures expected behavior from a validator known to fail - * - * @return void - */ - public function testFalse() - { - $this->_validator->addValidator(new Zend_ValidateTest_False()); - $this->assertFalse($this->_validator->isValid(null)); - $this->assertEquals(array('error' => 'validation failed'), $this->_validator->getMessages()); - } - - /** - * Ensures that a validator may break the chain - * - * @return void - */ - public function testBreakChainOnFailure() - { - $this->_validator->addValidator(new Zend_ValidateTest_False(), true) - ->addValidator(new Zend_ValidateTest_False()); - $this->assertFalse($this->_validator->isValid(null)); - $this->assertEquals(array('error' => 'validation failed'), $this->_validator->getMessages()); - } - - /** - * Ensures that we can call the static method is() - * to instantiate a named validator by its class basename - * and it returns the result of isValid() with the input. - */ - public function testStaticFactory() - { - $this->assertTrue(Zend_Validate::is('1234', 'Digits')); - $this->assertFalse(Zend_Validate::is('abc', 'Digits')); - } - - /** - * Ensures that a validator with constructor arguments can be called - * with the static method is(). - */ - public function testStaticFactoryWithConstructorArguments() - { - $this->assertTrue(Zend_Validate::is('12', 'Between', array(1, 12))); - $this->assertFalse(Zend_Validate::is('24', 'Between', array(1, 12))); - } - - /** - * Ensures that if we specify a validator class basename that doesn't - * exist in the namespace, is() throws an exception. - */ - public function testStaticFactoryClassNotFound() - { - try { - $this->assertTrue(Zend_Validate::is('1234', 'UnknownValidator')); - $this->fail('Expected to catch Zend_Validate_Exception'); - } catch (Zend_Exception $e) { - $this->assertType('Zend_Validate_Exception', $e, - 'Expected exception of type Zend_Validate_Exception, got '.get_class($e)); - $this->assertEquals("Validate class not found from basename 'UnknownValidator'", $e->getMessage()); - } - } - -} - - -/** - * Validator to return true to any input. - */ -class Zend_ValidateTest_True extends Zend_Validate_Abstract -{ - public function isValid($value) - { - return true; - } -} - - -/** - * Validator to return false to any input. - */ -class Zend_ValidateTest_False extends Zend_Validate_Abstract -{ - public function isValid($value) - { - $this->_messages = array('error' => 'validation failed'); - return false; - } -} diff --git a/tests/Zend/VersionTest.php b/tests/Zend/VersionTest.php deleted file mode 100644 index 763224ab56e01f2665dd5c0e97fce389e9203f62..0000000000000000000000000000000000000000 --- a/tests/Zend/VersionTest.php +++ /dev/null @@ -1,82 +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_Version - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: VersionTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * @see Zend_Version - */ -require_once 'Zend/Version.php'; - -/** - * @category Zend - * @package Zend_Version - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_VersionTest extends PHPUnit_Framework_TestCase -{ - /** - * Tests that version_compare() and its "proxy" - * Zend_Version::compareVersion() work as expected. - */ - public function testVersionCompare() - { - $expect = -1; - // unit test breaks if ZF version > 1.x - for ($i=0; $i <= 1; $i++) { - for ($j=0; $j < 10; $j++) { - for ($k=0; $k < 20; $k++) { - foreach (array('PR', 'dev', 'alpha', 'beta', 'RC', 'RC1', 'RC2', 'RC3', '', 'pl') as $rel) { - $ver = "$i.$j.$k$rel"; - if ($ver === Zend_Version::VERSION - || "$i.$j.$k-$rel" === Zend_Version::VERSION - || "$i.$j.$k.$rel" === Zend_Version::VERSION - || "$i.$j.$k $rel" === Zend_Version::VERSION) { - - if ($expect != -1) { - $this->fail("Unexpected double match for Zend_Version::VERSION (" - . Zend_Version::VERSION . ")"); - } - else { - $expect = 1; - } - } else { - $this->assertSame(Zend_Version::compareVersion($ver), $expect, - "For version '$ver' and Zend_Version::VERSION = '" - . Zend_Version::VERSION . "': result=" . (Zend_Version::compareVersion($ver)) - . ', but expected ' . $expect); - } - } - } - } - } - if ($expect === -1) { - $this->fail('Unable to recognize Zend_Version::VERSION ('. Zend_Version::VERSION . ')'); - } - } - -} diff --git a/tests/Zend/View/AllTests.php b/tests/Zend/View/AllTests.php deleted file mode 100644 index e334d663f2a0639146b6b21fb370066ef92ba0f9..0000000000000000000000000000000000000000 --- a/tests/Zend/View/AllTests.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_View_AllTests::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -// error_reporting(E_ALL); - -require_once 'Helper/AllTests.php'; - -class Zend_View_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_View'); - - $suite->addTest(Zend_View_Helper_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_View_AllTests::main') { - Zend_View_AllTests::main(); -} diff --git a/tests/Zend/View/Helper/ActionTest.php b/tests/Zend/View/Helper/ActionTest.php deleted file mode 100644 index 4914b5fd009d6964d619ee115640c5b3d0fee99d..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/ActionTest.php +++ /dev/null @@ -1,308 +0,0 @@ -<?php -// Call Zend_View_Helper_ActionTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_ActionTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_View_Helper_Action */ -require_once 'Zend/View/Helper/Action.php'; - -/** Zend_Controller_Front */ -require_once 'Zend/Controller/Front.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** Zend_Controller_Response_Http */ -require_once 'Zend/Controller/Response/Http.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_Action. - */ -class Zend_View_Helper_ActionTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_ActionTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - - $this->request = new Zend_Controller_Request_Http('http://framework.zend.com/foo'); - $this->response = new Zend_Controller_Response_Http(); - $this->response->headersSentThrowsException = false; - $front->setRequest($this->request) - ->setResponse($this->response) - ->addModuleDirectory(dirname(__FILE__) . '/_files/modules'); - - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_Action(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->request, $this->response, $this->helper); - } - - /** - * @return void - */ - public function testInitialStateHasClonedObjects() - { - $this->assertNotSame($this->request, $this->helper->request); - $this->assertNotSame($this->response, $this->helper->response); - - $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); - $this->assertNotSame($dispatcher, $this->helper->dispatcher); - } - - /** - * @return void - */ - public function testInitialStateHasDefaultModuleName() - { - $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); - $module = $dispatcher->getDefaultModule(); - $this->assertEquals($module, $this->helper->defaultModule); - - $dispatcher->setDefaultModule('foo'); - $helper = new Zend_View_Helper_Action(); - $this->assertEquals('foo', $helper->defaultModule); - } - - /** - * @return void - */ - public function testResetObjectsClearsRequestVars() - { - $this->helper->request->setParam('foo', 'bar'); - $this->helper->resetObjects(); - $this->assertNull($this->helper->request->getParam('foo')); - } - - /** - * @return void - */ - public function testResetObjectsClearsResponseBody() - { - $this->helper->response->setBody('foobarbaz'); - $this->helper->resetObjects(); - $body = $this->helper->response->getBody(); - $this->assertTrue(empty($body)); - } - - /** - * @return void - */ - public function testResetObjectsClearsResponseHeaders() - { - $this->helper->response->setHeader('X-Foo', 'Bar') - ->setRawHeader('HTTP/1.1'); - $this->helper->resetObjects(); - $headers = $this->helper->response->getHeaders(); - $rawHeaders = $this->helper->response->getRawHeaders(); - $this->assertTrue(empty($headers)); - $this->assertTrue(empty($rawHeaders)); - } - - /** - * @return void - */ - public function testActionReturnsContentFromDefaultModule() - { - $value = $this->helper->action('bar', 'foo'); - $this->assertContains('In default module, FooController::barAction()', $value); - } - - /** - * @return void - */ - public function testActionReturnsContentFromSpecifiedModule() - { - $value = $this->helper->action('bar', 'foo', 'foo'); - $this->assertContains('In foo module, Foo_FooController::barAction()', $value); - } - - /** - * @return void - */ - public function testActionReturnsContentReflectingPassedParams() - { - $value = $this->helper->action('baz', 'foo', null, array('bat' => 'This is my message')); - $this->assertNotContains('BOGUS', $value, var_export($this->helper->request->getUserParams(), 1)); - $this->assertContains('This is my message', $value); - } - - /** - * @return void - */ - public function testActionReturnsEmptyStringWhenForwardDetected() - { - $value = $this->helper->action('forward', 'foo'); - $this->assertEquals('', $value); - } - - /** - * @return void - */ - public function testActionReturnsEmptyStringWhenRedirectDetected() - { - $value = $this->helper->action('redirect', 'foo'); - $this->assertEquals('', $value); - } - - /** - * @return void - */ - public function testConstructorThrowsExceptionWithNoControllerDirsInFrontController() - { - Zend_Controller_Front::getInstance()->resetInstance(); - try { - $helper = new Zend_View_Helper_Action(); - $this->fail('Empty front controller should cause action helper to throw exception'); - } catch (Exception $e) { - } - } - - /** - * @return void - */ - public function testConstructorThrowsExceptionWithNoRequestInFrontController() - { - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - - $response = new Zend_Controller_Response_Http(); - $response->headersSentThrowsException = false; - $front->setResponse($response) - ->addModuleDirectory(dirname(__FILE__) . '/_files/modules'); - try { - $helper = new Zend_View_Helper_Action(); - $this->fail('No request in front controller should cause action helper to throw exception'); - } catch (Exception $e) { - } - } - - /** - * @return void - */ - public function testConstructorThrowsExceptionWithNoResponseInFrontController() - { - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - - $request = new Zend_Controller_Request_Http('http://framework.zend.com/foo'); - $front->setRequest($this->request) - ->addModuleDirectory(dirname(__FILE__) . '/_files/modules'); - try { - $helper = new Zend_View_Helper_Action(); - $this->fail('No response in front controller should cause action helper to throw exception'); - } catch (Exception $e) { - } - } - - public function testViewObjectRemainsUnchangedAfterAction() - { - $value = $this->helper->action('bar', 'foo', 'foo'); - $this->assertContains('In foo module, Foo_FooController::barAction()', $value); - $this->assertNull($this->view->bar); - } - - public function testNestingActionsDoesNotBreakPlaceholderHelpers() - { - $html = $this->helper->action('nest', 'foo', 'foo'); - $title = $this->view->headTitle()->toString(); - $this->assertContains(' - ', $title, $title); - $this->assertContains('Foo Nest', $title); - $this->assertContains('Nested Stuff', $title); - } - - /** - * @issue ZF-2716 - */ - public function testActionWithPartialsUseOfViewRendererReturnsToOriginatingViewState() - { - require_once 'Zend/View/Helper/Partial.php'; - $partial = new Zend_View_Helper_Partial(); - $this->view->setScriptPath(dirname(__FILE__) . '/_files/modules/default/views/scripts/'); - $partial->setView($this->view); - - Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view = $this->view; - - $partial->partial('partialActionCall.phtml'); - - $this->assertSame($this->view, Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view); - - } - - /** - * Future ViewRenderer State issues should be included in this test. - * - * @issue ZF-2846 - */ - public function testActionReturnsViewRendererToOriginalState() - { - /* Setup the VR as if we were inside an action controller */ - $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(); - $viewRenderer->init(); - Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); - - // make sure noRender is false - $this->assertFalse($viewRenderer->getNoRender()); - - $value = $this->helper->action('bar', 'foo'); - - $viewRendererPostAction = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - - // ViewRenderer noRender should still be false - $this->assertFalse($viewRendererPostAction->getNoRender()); - $this->assertSame($viewRenderer, $viewRendererPostAction); - } - - /** - * Multiple call state issue - * - * - * @group ZF-3456 - */ - public function testActionCalledWithinActionResetsResponseState() - { - $value = $this->helper->action('bar-one', 'baz', 'foo'); - $this->assertEquals('Baz-Three-View-Script|Baz-Two-View-Script|Baz-One-View-Script', $value); - } - - - -} - -// Call Zend_View_Helper_ActionTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_ActionTest::main") { - Zend_View_Helper_ActionTest::main(); -} diff --git a/tests/Zend/View/Helper/AllTests.php b/tests/Zend/View/Helper/AllTests.php deleted file mode 100644 index 47bc363b0e276d4faf81c723ee3bcf414458f9f0..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/AllTests.php +++ /dev/null @@ -1,116 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_View_Helper_AllTests::main'); -} -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/ActionTest.php'; -require_once 'Zend/View/Helper/DeclareVarsTest.php'; -require_once 'Zend/View/Helper/DoctypeTest.php'; -require_once 'Zend/View/Helper/FieldsetTest.php'; -require_once 'Zend/View/Helper/FormButtonTest.php'; -require_once 'Zend/View/Helper/FormCheckboxTest.php'; -require_once 'Zend/View/Helper/FormErrorsTest.php'; -require_once 'Zend/View/Helper/FormFileTest.php'; -require_once 'Zend/View/Helper/FormImageTest.php'; -require_once 'Zend/View/Helper/FormLabelTest.php'; -require_once 'Zend/View/Helper/FormMultiCheckboxTest.php'; -require_once 'Zend/View/Helper/FormPasswordTest.php'; -require_once 'Zend/View/Helper/FormRadioTest.php'; -require_once 'Zend/View/Helper/FormResetTest.php'; -require_once 'Zend/View/Helper/FormSelectTest.php'; -require_once 'Zend/View/Helper/FormSubmitTest.php'; -require_once 'Zend/View/Helper/FormTest.php'; -require_once 'Zend/View/Helper/FormTextTest.php'; -require_once 'Zend/View/Helper/FormTextareaTest.php'; -require_once 'Zend/View/Helper/HeadLinkTest.php'; -require_once 'Zend/View/Helper/HeadMetaTest.php'; -require_once 'Zend/View/Helper/HeadScriptTest.php'; -require_once 'Zend/View/Helper/HeadStyleTest.php'; -require_once 'Zend/View/Helper/HeadTitleTest.php'; -require_once 'Zend/View/Helper/HtmlFlashTest.php'; -require_once 'Zend/View/Helper/HtmlListTest.php'; -require_once 'Zend/View/Helper/HtmlObjectTest.php'; -require_once 'Zend/View/Helper/HtmlPageTest.php'; -require_once 'Zend/View/Helper/HtmlQuicktimeTest.php'; -require_once 'Zend/View/Helper/InlineScriptTest.php'; -require_once 'Zend/View/Helper/JsonTest.php'; -require_once 'Zend/View/Helper/LayoutTest.php'; -require_once 'Zend/View/Helper/PaginationControlTest.php'; -require_once 'Zend/View/Helper/PartialTest.php'; -require_once 'Zend/View/Helper/PartialLoopTest.php'; -require_once 'Zend/View/Helper/PlaceholderTest.php'; -require_once 'Zend/View/Helper/Placeholder/ContainerTest.php'; -require_once 'Zend/View/Helper/Placeholder/RegistryTest.php'; -require_once 'Zend/View/Helper/Placeholder/StandaloneContainerTest.php'; -require_once 'Zend/View/Helper/TranslateTest.php'; -require_once 'Zend/View/Helper/UrlTest.php'; - - -/** - * @category Zend - * @package Zend_View - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_View_Helper_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_View_Helper'); - - $suite->addTestSuite('Zend_View_Helper_ActionTest'); - $suite->addTestSuite('Zend_View_Helper_DeclareVarsTest'); - $suite->addTestSuite('Zend_View_Helper_DoctypeTest'); - $suite->addTestSuite('Zend_View_Helper_FieldsetTest'); - $suite->addTestSuite('Zend_View_Helper_FormButtonTest'); - $suite->addTestSuite('Zend_View_Helper_FormCheckboxTest'); - $suite->addTestSuite('Zend_View_Helper_FormErrorsTest'); - $suite->addTestSuite('Zend_View_Helper_FormFileTest'); - $suite->addTestSuite('Zend_View_Helper_FormImageTest'); - $suite->addTestSuite('Zend_View_Helper_FormLabelTest'); - $suite->addTestSuite('Zend_View_Helper_FormMultiCheckboxTest'); - $suite->addTestSuite('Zend_View_Helper_FormPasswordTest'); - $suite->addTestSuite('Zend_View_Helper_FormRadioTest'); - $suite->addTestSuite('Zend_View_Helper_FormResetTest'); - $suite->addTestSuite('Zend_View_Helper_FormSelectTest'); - $suite->addTestSuite('Zend_View_Helper_FormSubmitTest'); - $suite->addTestSuite('Zend_View_Helper_FormTest'); - $suite->addTestSuite('Zend_View_Helper_FormTextTest'); - $suite->addTestSuite('Zend_View_Helper_FormTextareaTest'); - $suite->addTestSuite('Zend_View_Helper_HeadLinkTest'); - $suite->addTestSuite('Zend_View_Helper_HeadMetaTest'); - $suite->addTestSuite('Zend_View_Helper_HeadScriptTest'); - $suite->addTestSuite('Zend_View_Helper_HeadStyleTest'); - $suite->addTestSuite('Zend_View_Helper_HeadTitleTest'); - $suite->addTestSuite('Zend_View_Helper_HtmlFlashTest'); - $suite->addTestSuite('Zend_View_Helper_HtmlListTest'); - $suite->addTestSuite('Zend_View_Helper_HtmlObjectTest'); - $suite->addTestSuite('Zend_View_Helper_HtmlPageTest'); - $suite->addTestSuite('Zend_View_Helper_HtmlQuicktimeTest'); - $suite->addTestSuite('Zend_View_Helper_InlineScriptTest'); - $suite->addTestSuite('Zend_View_Helper_JsonTest'); - $suite->addTestSuite('Zend_View_Helper_LayoutTest'); - $suite->addTestSuite('Zend_View_Helper_PaginationControlTest'); - $suite->addTestSuite('Zend_View_Helper_PartialTest'); - $suite->addTestSuite('Zend_View_Helper_PartialLoopTest'); - $suite->addTestSuite('Zend_View_Helper_PlaceholderTest'); - $suite->addTestSuite('Zend_View_Helper_Placeholder_ContainerTest'); - $suite->addTestSuite('Zend_View_Helper_Placeholder_RegistryTest'); - $suite->addTestSuite('Zend_View_Helper_Placeholder_StandaloneContainerTest'); - $suite->addTestSuite('Zend_View_Helper_TranslateTest'); - $suite->addTestSuite('Zend_View_Helper_UrlTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_View_Helper_AllTests::main') { - Zend_View_Helper_AllTests::main(); -} diff --git a/tests/Zend/View/Helper/DeclareVarsTest.php b/tests/Zend/View/Helper/DeclareVarsTest.php deleted file mode 100644 index 9cb4ac7bf00557cc3474d4b9b6102361adb7329f..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/DeclareVarsTest.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php -// Call Zend_View_Helper_DeclareVarsTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_DeclareVarsTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/DeclareVars.php'; - -class Zend_View_Helper_DeclareVarsTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_DeclareVarsTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $view = new Zend_View(); - $base = str_replace('/', DIRECTORY_SEPARATOR, '/../_templates'); - $view->setScriptPath(dirname(__FILE__) . $base); - $view->strictVars(true); - $this->view = $view; - } - - public function tearDown() - { - unset($this->view); - } - - protected function _declareVars() - { - $this->view->declareVars( - 'varName1', - 'varName2', - array( - 'varName3' => 'defaultValue', - 'varName4' => array() - ) - ); - } - - public function testDeclareUndeclaredVars() - { - $this->_declareVars(); - - $this->assertTrue(isset($this->view->varName1)); - $this->assertTrue(isset($this->view->varName2)); - $this->assertTrue(isset($this->view->varName3)); - $this->assertTrue(isset($this->view->varName4)); - - $this->assertEquals('defaultValue', $this->view->varName3); - $this->assertEquals(array(), $this->view->varName4); - } - - public function testDeclareDeclaredVars() - { - $this->view->varName2 = 'alreadySet'; - $this->view->varName3 = 'myValue'; - $this->view->varName5 = 'additionalValue'; - - $this->_declareVars(); - - $this->assertTrue(isset($this->view->varName1)); - $this->assertTrue(isset($this->view->varName2)); - $this->assertTrue(isset($this->view->varName3)); - $this->assertTrue(isset($this->view->varName4)); - $this->assertTrue(isset($this->view->varName5)); - - $this->assertEquals('alreadySet', $this->view->varName2); - $this->assertEquals('myValue', $this->view->varName3); - $this->assertEquals('additionalValue', $this->view->varName5); - } -} - -// Call Zend_View_Helper_DeclareVarsTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_DeclareVarsTest::main") { - Zend_View_Helper_DeclareVarsTest::main(); -} diff --git a/tests/Zend/View/Helper/DoctypeTest.php b/tests/Zend/View/Helper/DoctypeTest.php deleted file mode 100644 index 6affe64123c4674c71ef89e51f7a7ac47a14be7d..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/DoctypeTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -// Call Zend_View_Helper_DoctypeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_DoctypeTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_Doctype */ -require_once 'Zend/View/Helper/Doctype.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_Doctype. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_DoctypeTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_Doctype - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_DoctypeTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $regKey = 'Zend_View_Helper_Doctype'; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - $this->helper = new Zend_View_Helper_Doctype(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testRegistryEntryCreatedAfterInstantiation() - { - $this->assertTrue(Zend_Registry::isRegistered('Zend_View_Helper_Doctype')); - $doctype = Zend_Registry::get('Zend_View_Helper_Doctype'); - $this->assertTrue($doctype instanceof ArrayObject); - $this->assertTrue(isset($doctype['doctype'])); - $this->assertTrue(isset($doctype['doctypes'])); - $this->assertTrue(is_array($doctype['doctypes'])); - } - - public function testDoctypeMethodReturnsObjectInstance() - { - $doctype = $this->helper->doctype(); - $this->assertTrue($doctype instanceof Zend_View_Helper_Doctype); - } - - public function testPassingDoctypeSetsDoctype() - { - $doctype = $this->helper->doctype('XHTML1_STRICT'); - $this->assertEquals('XHTML1_STRICT', $doctype->getDoctype()); - } - - public function testIsXhtmlReturnsTrueForXhtmlDoctypes() - { - foreach (array('XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET') as $type) { - $doctype = $this->helper->doctype($type); - $this->assertEquals($type, $doctype->getDoctype()); - $this->assertTrue($doctype->isXhtml()); - } - - $doctype = $this->helper->doctype('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://framework.zend.com/foo/DTD/xhtml1-custom.dtd">'); - $this->assertEquals('CUSTOM_XHTML', $doctype->getDoctype()); - $this->assertTrue($doctype->isXhtml()); - } - - public function testIsXhtmlReturnsFalseForNonXhtmlDoctypes() - { - foreach (array('HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET') as $type) { - $doctype = $this->helper->doctype($type); - $this->assertEquals($type, $doctype->getDoctype()); - $this->assertFalse($doctype->isXhtml()); - } - - $doctype = $this->helper->doctype('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 10.0 Strict//EN" "http://framework.zend.com/foo/DTD/html10-custom.dtd">'); - $this->assertEquals('CUSTOM', $doctype->getDoctype()); - $this->assertFalse($doctype->isXhtml()); - } - - public function testCanRegisterCustomXhtmlDoctype() - { - $doctype = $this->helper->doctype('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://framework.zend.com/foo/DTD/xhtml1-custom.dtd">'); - $this->assertEquals('CUSTOM_XHTML', $doctype->getDoctype()); - $this->assertTrue($doctype->isXhtml()); - } - - public function testCanRegisterCustomHtmlDoctype() - { - $doctype = $this->helper->doctype('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 10.0 Strict//EN" "http://framework.zend.com/foo/DTD/html10-custom.dtd">'); - $this->assertEquals('CUSTOM', $doctype->getDoctype()); - $this->assertFalse($doctype->isXhtml()); - } - - public function testMalformedCustomDoctypeRaisesException() - { - try { - $doctype = $this->helper->doctype('<!FOO HTML>'); - $this->fail('Malformed doctype should raise exception'); - } catch (Exception $e) { - } - } - - public function testStringificationReturnsDoctypeString() - { - $doctype = $this->helper->doctype('XHTML1_STRICT'); - $string = $doctype->__toString(); - $registry = Zend_Registry::get('Zend_View_Helper_Doctype'); - $this->assertEquals($registry['doctypes']['XHTML1_STRICT'], $string); - } -} - -// Call Zend_View_Helper_DoctypeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_DoctypeTest::main") { - Zend_View_Helper_DoctypeTest::main(); -} diff --git a/tests/Zend/View/Helper/FieldsetTest.php b/tests/Zend/View/Helper/FieldsetTest.php deleted file mode 100644 index ce8a04448ae765975923e04626ea2b5b5d03944e..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FieldsetTest.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php -// Call Zend_FieldsetTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FieldsetTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View/Helper/Fieldset.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_Fieldset - */ -class Zend_View_Helper_FieldsetTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FieldsetTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_Fieldset(); - $this->helper->setView($this->view); - ob_start(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - ob_end_clean(); - } - - public function testFieldsetHelperCreatesFieldsetWithProvidedContent() - { - $html = $this->helper->fieldset('foo', 'foobar'); - $this->assertRegexp('#<fieldset[^>]+id="foo".*?>#', $html); - $this->assertContains('</fieldset>', $html); - $this->assertContains('foobar', $html); - } - - public function testProvidingLegendOptionToFieldsetCreatesLegendTag() - { - $html = $this->helper->fieldset('foo', 'foobar', array('legend' => 'Great Scott!')); - $this->assertRegexp('#<legend>Great Scott!</legend>#', $html); - } - - /** - * @see ZF-2913 - */ - public function testEmptyLegendShouldNotRenderLegendTag() - { - foreach (array(null, '', ' ', false) as $legend) { - $html = $this->helper->fieldset('foo', 'foobar', array('legend' => $legend)); - $this->assertNotContains('<legend>', $html, 'Failed with value ' . var_export($legend, 1) . ': ' . $html); - } - } - - /** - * @group ZF-3632 - */ - public function testHelperShouldAllowDisablingEscapingOfLegend() - { - $html = $this->helper->fieldset('foo', 'foobar', array('legend' => '<b>Great Scott!</b>', 'escape' => false)); - $this->assertRegexp('#<legend><b>Great Scott!</b></legend>#', $html, $html); - } -} - -// Call Zend_View_Helper_FieldsetTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FieldsetTest::main") { - Zend_View_Helper_FieldsetTest::main(); -} diff --git a/tests/Zend/View/Helper/FormButtonTest.php b/tests/Zend/View/Helper/FormButtonTest.php deleted file mode 100644 index ddce01418982196cb9e273988ff3a6af7f910992..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormButtonTest.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -// Call Zend_View_Helper_FormButtonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormButtonTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormButton.php'; - -/** - * Test class for Zend_View_Helper_FormButton. - */ -class Zend_View_Helper_FormButtonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormButtonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormButton(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - } - - public function testFormButtonRendersButtonXhtml() - { - $button = $this->helper->formButton('foo', 'bar'); - $this->assertRegexp('/<button[^>]*?value="bar"/', $button); - $this->assertRegexp('/<button[^>]*?name="foo"/', $button); - $this->assertRegexp('/<button[^>]*?id="foo"/', $button); - $this->assertContains('</button>', $button); - } - - public function testCanPassContentViaContentAttribKey() - { - $button = $this->helper->formButton('foo', 'bar', array('content' => 'Display this')); - $this->assertContains('>Display this<', $button); - $this->assertContains('<button', $button); - $this->assertContains('</button>', $button); - } - - public function testCanDisableContentEscaping() - { - $button = $this->helper->formButton('foo', 'bar', array('content' => '<b>Display this</b>', 'escape' => false)); - $this->assertContains('><b>Display this</b><', $button); - - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('content' => '<b>Display this</b>', 'escape' => false))); - $this->assertContains('><b>Display this</b><', $button); - - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'escape' => false, 'attribs' => array('content' => '<b>Display this</b>'))); - $this->assertContains('><b>Display this</b><', $button); - $this->assertContains('<button', $button); - $this->assertContains('</button>', $button); - } - - public function testValueUsedForContentWhenNoContentProvided() - { - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar')); - $this->assertRegexp('#<button[^>]*?value="bar"[^>]*>bar</button>#', $button); - } - - public function testButtonTypeIsButtonByDefault() - { - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar')); - $this->assertContains('type="button"', $button); - } - - public function testButtonTypeMayOnlyBeValidXhtmlButtonType() - { - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'submit'))); - $this->assertContains('type="submit"', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'reset'))); - $this->assertContains('type="reset"', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'button'))); - $this->assertContains('type="button"', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'bogus'))); - $this->assertContains('type="button"', $button); - } -} - -// Call Zend_View_Helper_FormButtonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormButtonTest::main") { - Zend_View_Helper_FormButtonTest::main(); -} diff --git a/tests/Zend/View/Helper/FormCheckboxTest.php b/tests/Zend/View/Helper/FormCheckboxTest.php deleted file mode 100644 index f1f35b3698159a1e3ea120962a76b1d83044f64c..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormCheckboxTest.php +++ /dev/null @@ -1,256 +0,0 @@ -<?php -// Call Zend_View_Helper_FormCheckboxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormCheckboxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormCheckbox.php'; -require_once 'Zend/View.php'; -require_once 'Zend/Registry.php'; - -/** - * Zend_View_Helper_FormCheckboxTest - * - * Tests formCheckbox helper - * - * @uses PHPUnit_Framework_TestCase - */ -class Zend_View_Helper_FormCheckboxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormCheckboxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormCheckbox(); - $this->helper->setView($this->view); - } - - public function testIdSetFromName() - { - $element = $this->helper->formCheckbox('foo'); - $this->assertContains('name="foo"', $element); - $this->assertContains('id="foo"', $element); - } - - public function testSetIdFromAttribs() - { - $element = $this->helper->formCheckbox('foo', null, array('id' => 'bar')); - $this->assertContains('name="foo"', $element); - $this->assertContains('id="bar"', $element); - } - - /** - * ZF-2513 - */ - public function testCanDisableCheckbox() - { - $html = $this->helper->formCheckbox(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs'=> array('disable' => true) - )); - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html); - } - - /** - * ZF-3505 - */ - public function testCheckboxNotDisabled() - { - $html = $this->helper->formCheckbox(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs'=> array('disable' => false) - )); - $this->assertNotContains('disabled="disabled"', $html); - } - - public function testCanSelectCheckbox() - { - $html = $this->helper->formCheckbox(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs'=> array('checked' => true) - )); - $this->assertRegexp('/<input[^>]*?(checked="checked")/', $html); - $count = substr_count($html, 'checked'); - $this->assertEquals(2, $count); - } - - /** - * ZF-1955 - */ - public function testNameBracketsStrippedWhenCreatingId() - { - $html = $this->helper->formCheckbox(array( - 'name' => 'foo[]', - 'value' => 'bar' - )); - $this->assertRegexp('/<input[^>]*?(id="foo")/', $html); - - $html = $this->helper->formCheckbox(array( - 'name' => 'foo[bar]', - 'value' => 'bar' - )); - $this->assertRegexp('/<input[^>]*?(id="foo-bar")/', $html); - - $html = $this->helper->formCheckbox(array( - 'name' => 'foo[bar][baz]', - 'value' => 'bar' - )); - $this->assertRegexp('/<input[^>]*?(id="foo-bar-baz")/', $html); - } - - /** - * @see ZF-2230 - */ - public function testDoesNotRenderHiddenElementsForCheckboxArray() - { - $html = $this->helper->formCheckbox(array( - 'name' => 'foo[]', - 'value' => 'bar' - )); - $this->assertNotRegexp('/<input[^>]*?(type="hidden")/', $html); - } - - /** - * @see ZF-3149 - */ - public function testShouldRenderHiddenElementShowingUncheckedOptionForNonArrayNames() - { - $html1 = $this->helper->formCheckbox( - 'foo', - 'bar', - array('checked' => true), - array( - 'checked' => 'bar', - 'unChecked' => 'baz' - ) - ); - $html2 = $this->helper->formCheckbox( - 'foo', - 'bar', - array('checked' => true), - array( - 'bar', - 'baz' - ) - ); - $html3 = $this->helper->formCheckbox( - 'foo', - 'bar', - array('checked' => false), - array( - 'checked' => 'bar', - 'unChecked' => 'baz' - ) - ); - $html4 = $this->helper->formCheckbox( - 'foo', - 'bar', - array('checked' => false), - array( - 'bar', - 'baz' - ) - ); - foreach (array('html1', 'html2', 'html3', 'html4') as $html) { - if (!preg_match_all('/(<input [^>]+>)/', $$html, $matches)) { - $this->fail('Unexpected output generated by helper'); - } - $this->assertEquals(2, count($matches[1])); - foreach ($matches[1] as $element) { - if (strstr($element, 'hidden')) { - $this->assertContains('baz', $element, 'Failed using ' . $html); - } else { - $this->assertContains('bar', $element, 'Failed using ' . $html); - $this->assertContains('checked', $element, 'Failed using ' . $html); - } - } - } - } - - /** - * @see ZF-3149 - */ - public function testCheckedAttributeNotRenderedIfItEvaluatesToFalse() - { - $test = $this->helper->formCheckbox('foo', 'value', array('checked' => false)); - $this->assertNotContains('checked', $test); - } - - public function testCanSpecifyValue() - { - $test = $this->helper->formCheckbox('foo', 'bar'); - $this->assertContains('value="bar"', $test); - } - - /** - * @see ZF-3149 - */ - public function testShouldCheckValueIfValueMatchesCheckedOption() - { - $test = $this->helper->formCheckbox('foo', 'bar', array(), array('bar', 'baz')); - $this->assertContains('value="bar"', $test); - $this->assertContains('checked', $test); - - $test = $this->helper->formCheckbox('foo', 'bar', array(), array('checked' => 'bar', 'unChecked' => 'baz')); - $this->assertContains('value="bar"', $test); - $this->assertContains('checked', $test); - } - - /** - * @see ZF-3149 - */ - public function testShouldOnlySetValueIfValueMatchesCheckedOption() - { - $test = $this->helper->formCheckbox('foo', 'baz', array(), array('bar', 'baz')); - $this->assertContains('value="bar"', $test); - } - - /** - * @see ZF-3149 - */ - public function testShouldNotCheckValueIfValueDoesNotMatchCheckedOption() - { - $test = $this->helper->formCheckbox('foo', 'baz', array(), array('bar', 'baz')); - $this->assertContains('value="bar"', $test); - $this->assertNotContains('checked', $test); - } - - public function testRendersAsHtmlByDefault() - { - $test = $this->helper->formCheckbox('foo', 'bar'); - $this->assertNotContains(' />', $test, $test); - } - - public function testCanRendersAsXHtml() - { - $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formCheckbox('foo', 'bar'); - $this->assertContains(' />', $test); - } -} - -// Call Zend_View_Helper_FormCheckboxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormCheckboxTest::main") { - Zend_View_Helper_FormCheckboxTest::main(); -} - diff --git a/tests/Zend/View/Helper/FormErrorsTest.php b/tests/Zend/View/Helper/FormErrorsTest.php deleted file mode 100644 index 664f12efb42b87c7f40ba39b1f467ee5551e5740..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormErrorsTest.php +++ /dev/null @@ -1,141 +0,0 @@ -<?php -// Call Zend_FormErrorsTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormErrorsTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormErrors.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_FormErrors - */ -class Zend_View_Helper_FormErrorsTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormErrorsTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormErrors(); - $this->helper->setView($this->view); - ob_start(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - ob_end_clean(); - } - - public function testGetElementEndReturnsDefaultValue() - { - $this->assertEquals('</li></ul>', $this->helper->getElementEnd()); - } - - public function testGetElementSeparatorReturnsDefaultValue() - { - $this->assertEquals('</li><li>', $this->helper->getElementSeparator()); - } - - public function testGetElementStartReturnsDefaultValue() - { - $this->assertEquals('<ul class="errors"%s><li>', $this->helper->getElementStart()); - } - - public function testCanSetElementEndString() - { - $this->testGetElementEndReturnsDefaultValue(); - $this->helper->setElementEnd('</pre></div>'); - $this->assertEquals('</pre></div>', $this->helper->getElementEnd()); - } - - public function testCanSetElementSeparatorString() - { - $this->testGetElementSeparatorReturnsDefaultValue(); - $this->helper->setElementSeparator('<br />'); - $this->assertEquals('<br />', $this->helper->getElementSeparator()); - } - - public function testCanSetElementStartString() - { - $this->testGetElementStartReturnsDefaultValue(); - $this->helper->setElementStart('<div><pre>'); - $this->assertEquals('<div><pre>', $this->helper->getElementStart()); - } - - public function testFormErrorsRendersUnorderedListByDefault() - { - $errors = array('foo', 'bar', 'baz'); - $html = $this->helper->formErrors($errors); - $this->assertContains('<ul', $html); - foreach ($errors as $error) { - $this->assertContains('<li>' . $error . '</li>', $html); - } - $this->assertContains('</ul>', $html); - } - - public function testFormErrorsRendersWithSpecifiedStrings() - { - $this->helper->setElementStart('<dl><dt>') - ->setElementSeparator('</dt><dt>') - ->setElementEnd('</dt></dl>'); - $errors = array('foo', 'bar', 'baz'); - $html = $this->helper->formErrors($errors); - $this->assertContains('<dl>', $html); - foreach ($errors as $error) { - $this->assertContains('<dt>' . $error . '</dt>', $html); - } - $this->assertContains('</dl>', $html); - } - - public function testFormErrorsPreventsXssAttacks() - { - $errors = array( - 'bad' => '\"><script>alert("xss");</script>', - ); - $html = $this->helper->formErrors($errors); - $this->assertNotContains($errors['bad'], $html); - $this->assertContains('&', $html); - } - - public function testCanDisableEscapingErrorMessages() - { - $errors = array( - 'foo' => '<b>Field is required</b>', - 'bar' => '<a href="/help">Please click here for more information</a>' - ); - $html = $this->helper->formErrors($errors, array('escape' => false)); - $this->assertContains($errors['foo'], $html); - $this->assertContains($errors['bar'], $html); - } -} - -// Call Zend_View_Helper_FormErrorsTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormErrorsTest::main") { - Zend_View_Helper_FormErrorsTest::main(); -} diff --git a/tests/Zend/View/Helper/FormFileTest.php b/tests/Zend/View/Helper/FormFileTest.php deleted file mode 100644 index cb5c715c85e5ecdabe306886f630d20abeeee40f..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormFileTest.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -// Call Zend_View_Helper_FormFileTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormFileTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormFile.php'; -require_once 'Zend/Registry.php'; - -/** - * Zend_View_Helper_FormFileTest - * - * Tests formFile helper - * - * @uses PHPUnit_Framework_TestCase - */ -class Zend_View_Helper_FormFileTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormFileTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormFile(); - $this->helper->setView($this->view); - } - - /** - * ZF-1666 - */ - public function testCanDisableElement() - { - $html = $this->helper->formFile(array( - 'name' => 'foo', - 'attribs' => array('disable' => true) - )); - - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html); - } - - /** - * ZF-1666 - */ - public function testDisablingElementDoesNotRenderHiddenElements() - { - $html = $this->helper->formFile(array( - 'name' => 'foo', - 'attribs' => array('disable' => true) - )); - - $this->assertNotRegexp('/<input[^>]*?(type="hidden")/', $html); - } - - - public function testRendersAsHtmlByDefault() - { - $test = $this->helper->formFile(array( - 'name' => 'foo', - )); - $this->assertNotContains(' />', $test); - } - - public function testCanRendersAsXHtml() - { - $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formFile(array( - 'name' => 'foo', - )); - $this->assertContains(' />', $test); - } -} - -// Call Zend_View_Helper_FormFileTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormFileTest::main") { - Zend_View_Helper_FormFileTest::main(); -} diff --git a/tests/Zend/View/Helper/FormImageTest.php b/tests/Zend/View/Helper/FormImageTest.php deleted file mode 100644 index de3879dc02f61b75163e9cf8f276f1600b96d74e..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormImageTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -// Call Zend_View_Helper_FormImageTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormImageTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormImage.php'; - -/** - * Test class for Zend_View_Helper_FormImage. - */ -class Zend_View_Helper_FormImageTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormImageTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormImage(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - } - - public function testFormImageRendersFormImageXhtml() - { - $button = $this->helper->formImage('foo', 'bar'); - $this->assertRegexp('/<input[^>]*?src="bar"/', $button); - $this->assertRegexp('/<input[^>]*?name="foo"/', $button); - $this->assertRegexp('/<input[^>]*?type="image"/', $button); - } - - public function testDisablingFormImageRendersImageInputWithDisableAttribute() - { - $button = $this->helper->formImage('foo', 'bar', array('disable' => true)); - $this->assertRegexp('/<input[^>]*?disabled="disabled"/', $button); - $this->assertRegexp('/<input[^>]*?src="bar"/', $button); - $this->assertRegexp('/<input[^>]*?name="foo"/', $button); - $this->assertRegexp('/<input[^>]*?type="image"/', $button); - } -} - -// Call Zend_View_Helper_FormImageTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormImageTest::main") { - Zend_View_Helper_FormImageTest::main(); -} diff --git a/tests/Zend/View/Helper/FormLabelTest.php b/tests/Zend/View/Helper/FormLabelTest.php deleted file mode 100644 index 529c1254c6923fcb00f555a55209be2f8f106c68..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormLabelTest.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -// Call Zend_View_Helper_FormLabelTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormLabelTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormLabel.php'; - -/** - * Test class for Zend_View_Helper_FormLabel. - * Generated by PHPUnit_Util_Skeleton on 2007-05-16 at 16:09:28. - */ -class Zend_View_Helper_FormLabelTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormLabelTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormLabel(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - } - - public function testFormLabelWithSaneInput() - { - $label = $this->helper->formLabel('foo', 'bar'); - $this->assertEquals('<label for="foo">bar</label>', $label); - } - - public function testFormLabelWithInputNeedingEscapesUsesViewEscaping() - { - $label = $this->helper->formLabel('<&foo', '</bar>'); - $expected = '<label for="' . $this->view->escape('<&foo') . '">' . $this->view->escape('</bar>') . '</label>'; - $this->assertEquals($expected, $label); - } - - public function testViewIsSetAndSameAsCallingViewObject() - { - $this->assertTrue(isset($this->helper->view)); - $this->assertTrue($this->helper->view instanceof Zend_View_Interface); - $this->assertSame($this->view, $this->helper->view); - } - - public function testAttribsAreSet() - { - $label = $this->helper->formLabel('foo', 'bar', array('class' => 'baz')); - $this->assertEquals('<label for="foo" class="baz">bar</label>', $label); - } - - public function testNameAndIdForZF2154() - { - $label = $this->helper->formLabel('name', 'value', array('id' => 'id')); - $this->assertEquals('<label for="id">value</label>', $label); - } - - /** - * ZF-2473 - */ - public function testCanDisableEscapingLabelValue() - { - $label = $this->helper->formLabel('foo', '<b>Label This!</b>', array('escape' => false)); - $this->assertContains('<b>Label This!</b>', $label); - $label = $this->helper->formLabel(array('name' => 'foo', 'value' => '<b>Label This!</b>', 'escape' => false)); - $this->assertContains('<b>Label This!</b>', $label); - $label = $this->helper->formLabel(array('name' => 'foo', 'value' => '<b>Label This!</b>', 'attribs' => array('escape' => false))); - $this->assertContains('<b>Label This!</b>', $label); - } -} - -// Call Zend_View_Helper_FormLabelTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormLabelTest::main") { - Zend_View_Helper_FormLabelTest::main(); -} diff --git a/tests/Zend/View/Helper/FormMultiCheckboxTest.php b/tests/Zend/View/Helper/FormMultiCheckboxTest.php deleted file mode 100644 index 45b80abe888f058dbc7f38c9364df15a7b90a75d..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormMultiCheckboxTest.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php -// Call Zend_FormMultiCheckboxTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormMultiCheckboxTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormMultiCheckbox.php'; -require_once 'Zend/View.php'; -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_FormMultiCheckbox - */ -class Zend_View_Helper_FormMultiCheckboxTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormMultiCheckboxTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormMultiCheckbox(); - $this->helper->setView($this->view); - ob_start(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - ob_end_clean(); - } - - public function testMultiCheckboxHelperRendersLabelledCheckboxesForEachOption() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formMultiCheckbox(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - )); - foreach ($options as $key => $value) { - $pattern = '#((<label[^>]*>.*?)(<input[^>]*?("' . $key . '").*?>)(.*?</label>))#'; - if (!preg_match($pattern, $html, $matches)) { - $this->fail('Failed to match ' . $pattern . ': ' . $html); - } - $this->assertContains($value, $matches[5], var_export($matches, 1)); - $this->assertContains('type="checkbox"', $matches[3], var_export($matches, 1)); - $this->assertContains('name="foo[]"', $matches[3], var_export($matches, 1)); - $this->assertContains('value="' . $key . '"', $matches[3], var_export($matches, 1)); - } - } - - public function testRendersAsHtmlByDefault() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formMultiCheckbox(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - )); - foreach ($options as $key => $value) { - $pattern = '#(<input[^>]*?("' . $key . '").*?>)#'; - if (!preg_match($pattern, $html, $matches)) { - $this->fail('Failed to match ' . $pattern . ': ' . $html); - } - $this->assertNotContains(' />', $matches[1]); - } - } - - public function testCanRendersAsXHtml() - { - $this->view->doctype('XHTML1_STRICT'); - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formMultiCheckbox(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - )); - foreach ($options as $key => $value) { - $pattern = '#(<input[^>]*?("' . $key . '").*?>)#'; - if (!preg_match($pattern, $html, $matches)) { - $this->fail('Failed to match ' . $pattern . ': ' . $html); - } - $this->assertContains(' />', $matches[1]); - } - } -} - -// Call Zend_View_Helper_FormMultiCheckboxTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormMultiCheckboxTest::main") { - Zend_View_Helper_FormMultiCheckboxTest::main(); -} diff --git a/tests/Zend/View/Helper/FormPasswordTest.php b/tests/Zend/View/Helper/FormPasswordTest.php deleted file mode 100644 index f2f77e888610adb7910813b144410ba301fa9b48..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormPasswordTest.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -// Call Zend_View_Helper_FormPasswordTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormPasswordTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormPassword.php'; -require_once 'Zend/Registry.php'; - -/** - * Zend_View_Helper_FormPasswordTest - * - * Tests formPassword helper - * - * @uses PHPUnit_Framework_TestCase - */ -class Zend_View_Helper_FormPasswordTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormPasswordTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormPassword(); - $this->helper->setView($this->view); - } - - /** - * @see ZF-1666 - */ - public function testCanDisableElement() - { - $html = $this->helper->formPassword(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs' => array('disable' => true) - )); - - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html); - } - - /** - * @see ZF-1666 - */ - public function testDisablingElementDoesNotRenderHiddenElements() - { - $html = $this->helper->formPassword(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs' => array('disable' => true) - )); - - $this->assertNotRegexp('/<input[^>]*?(type="hidden")/', $html); - } - - public function testShouldRenderAsHtmlByDefault() - { - $test = $this->helper->formPassword('foo', 'bar'); - $this->assertNotContains(' />', $test); - } - - public function testShouldAllowRenderingAsXhtml() - { - $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formPassword('foo', 'bar'); - $this->assertContains(' />', $test); - } - - public function testShouldNotRenderValueByDefault() - { - $test = $this->helper->formPassword('foo', 'bar'); - $this->assertNotContains('bar', $test); - } - - /** - * @see ZF-2860 - */ - public function testShouldRenderValueWhenRenderPasswordFlagPresentAndTrue() - { - $test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => true)); - $this->assertContains('value="bar"', $test); - } - - /** - * @see ZF-2860 - */ - public function testRenderPasswordAttribShouldNeverBeRendered() - { - $test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => true)); - $this->assertNotContains('renderPassword', $test); - $test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => false)); - $this->assertNotContains('renderPassword', $test); - } -} - -// Call Zend_View_Helper_FormPasswordTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormPasswordTest::main") { - Zend_View_Helper_FormPasswordTest::main(); -} diff --git a/tests/Zend/View/Helper/FormRadioTest.php b/tests/Zend/View/Helper/FormRadioTest.php deleted file mode 100644 index 2bca98a5a67f5d88d22669ed17aac52514ef48c1..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormRadioTest.php +++ /dev/null @@ -1,349 +0,0 @@ -<?php -// Call Zend_View_Helper_FormRadioTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormRadioTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormRadio.php'; -require_once 'Zend/View.php'; - -/** - * Zend_View_Helper_FormRadioTest - * - * Tests formRadio helper - * - * @uses PHPUnit_Framework_TestCase - */ -class Zend_View_Helper_FormRadioTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormRadioTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormRadio(); - $this->helper->setView($this->view); - } - - public function testRendersRadioLabelsWhenRenderingMultipleOptions() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - )); - foreach ($options as $key => $value) { - $this->assertRegexp('#<label.*?>.*?' . $value . '.*?</label>#', $html, $html); - $this->assertRegexp('#<label.*?>.*?<input.*?</label>#', $html, $html); - } - } - - public function testCanSpecifyRadioLabelPlacement() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array('labelPlacement' => 'append') - )); - foreach ($options as $key => $value) { - $this->assertRegexp('#<label.*?>.*?<input .*?' . $value . '</label>#', $html, $html); - } - - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array('labelPlacement' => 'prepend') - )); - foreach ($options as $key => $value) { - $this->assertRegexp('#<label.*?>' . $value . '<input .*?</label>#', $html, $html); - } - } - - /** - * @see ZF-3206 - */ - public function testSpecifyingLabelPlacementShouldNotOverwriteValue() - { - $options = array( - 'bar' => 'Bar', - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array( - 'labelPlacement' => 'append', - ) - )); - $this->assertRegexp('#<input[^>]*(checked="checked")#', $html, $html); - } - - public function testCanSpecifyRadioLabelAttribs() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array('labelClass' => 'testclass', 'label_id' => 'testid') - )); - - foreach ($options as $key => $value) { - $this->assertRegexp('#<label[^>]*?class="testclass"[^>]*>.*?' . $value . '#', $html, $html); - $this->assertRegexp('#<label[^>]*?id="testid"[^>]*>.*?' . $value . '#', $html, $html); - } - } - - public function testCanSpecifyRadioSeparator() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'listsep' => '--FunkySep--', - )); - - $this->assertContains('--FunkySep--', $html); - $count = substr_count($html, '--FunkySep--'); - $this->assertEquals(2, $count); - } - - /** - * ZF-2513 - */ - public function testCanDisableAllRadios() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array('disable' => true) - )); - - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html, $html); - $count = substr_count($html, 'disabled="disabled"'); - $this->assertEquals(3, $count); - } - - /** - * ZF-2513 - */ - public function testCanDisableIndividualRadios() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array('disable' => array('bar')) - )); - - $this->assertRegexp('/<input[^>]*?(value="bar")[^>]*(disabled="disabled")/', $html, $html); - $count = substr_count($html, 'disabled="disabled"'); - $this->assertEquals(1, $count); - } - - /** - * ZF-2513 - */ - public function testCanDisableMultipleRadios() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - 'attribs' => array('disable' => array('foo', 'baz')) - )); - - foreach (array('foo', 'baz') as $test) { - $this->assertRegexp('/<input[^>]*?(value="' . $test . '")[^>]*?(disabled="disabled")/', $html, $html); - } - $this->assertNotRegexp('/<input[^>]*?(value="bar")[^>]*?(disabled="disabled")/', $html, $html); - $count = substr_count($html, 'disabled="disabled"'); - $this->assertEquals(2, $count); - } - - public function testLabelsAreEscapedByDefault() - { - $options = array( - 'bar' => '<b>Bar</b>', - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'options' => $options, - )); - - $this->assertNotContains($options['bar'], $html); - $this->assertContains('<b>Bar</b>', $html); - } - - public function testXhtmlLabelsAreAllowed() - { - $options = array( - 'bar' => '<b>Bar</b>', - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'options' => $options, - 'attribs' => array('escape' => false) - )); - - $this->assertContains($options['bar'], $html); - } - - /** - * ZF-1666 - */ - public function testDoesNotRenderHiddenElements() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'options' => $options, - )); - - $this->assertNotRegexp('/<input[^>]*?(type="hidden")/', $html); - } - - public function testSpecifyingAValueThatMatchesAnOptionChecksIt() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => 'bar', - 'options' => $options, - )); - - if (!preg_match('/(<input[^>]*?(value="bar")[^>]*>)/', $html, $matches)) { - $this->fail('Radio for a given option was not found?'); - } - $this->assertContains('checked="checked"', $matches[1], var_export($matches, 1)); - } - - public function testOptionsWithMatchesInAnArrayOfValuesAreChecked() - { - $options = array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo', - 'value' => array('foo', 'baz'), - 'options' => $options, - )); - - foreach (array('foo', 'baz') as $value) { - if (!preg_match('/(<input[^>]*?(value="' . $value . '")[^>]*>)/', $html, $matches)) { - $this->fail('Radio for a given option was not found?'); - } - $this->assertContains('checked="checked"', $matches[1], var_export($matches, 1)); - } - } - - public function testEachRadioShouldHaveIdCreatedByAppendingFilteredValue() - { - $options = array( - 'foo bar' => 'Foo', - 'bar baz' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo[]', - 'value' => 'bar', - 'options' => $options, - )); - - require_once 'Zend/Filter/Alnum.php'; - $filter = new Zend_Filter_Alnum(); - foreach ($options as $key => $value) { - $id = 'foo-' . $filter->filter($key); - $this->assertRegexp('/<input([^>]*)(id="' . $id . '")/', $html); - } - } - - public function testEachRadioShouldUseAttributeIdWhenSpecified() - { - $options = array( - 'foo bar' => 'Foo', - 'bar baz' => 'Bar', - 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( - 'name' => 'foo[bar]', - 'value' => 'bar', - 'attribs' => array('id' => 'foo-bar'), - 'options' => $options, - )); - - require_once 'Zend/Filter/Alnum.php'; - $filter = new Zend_Filter_Alnum(); - foreach ($options as $key => $value) { - $id = 'foo-bar-' . $filter->filter($key); - $this->assertRegexp('/<input([^>]*)(id="' . $id . '")/', $html); - } - } -} - -// Call Zend_View_Helper_FormRadioTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormRadioTest::main") { - Zend_View_Helper_FormRadioTest::main(); -} - diff --git a/tests/Zend/View/Helper/FormResetTest.php b/tests/Zend/View/Helper/FormResetTest.php deleted file mode 100644 index b803246b4636276c88330a30ab4e4587983c11cd..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormResetTest.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -// Call Zend_View_Helper_FormResetTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormResetTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormReset.php'; -require_once 'Zend/View.php'; -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_FormReset. - */ -class Zend_View_Helper_FormResetTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormResetTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormReset(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper, $this->view); - } - - public function testShouldRenderResetInput() - { - $html = $this->helper->formReset(array( - 'name' => 'foo', - 'value' => 'Reset', - )); - $this->assertRegexp('/<input[^>]*?(type="reset")/', $html); - } - - /** - * @see ZF-2845 - */ - public function testShouldAllowDisabling() - { - $html = $this->helper->formReset(array( - 'name' => 'foo', - 'value' => 'Reset', - 'attribs' => array('disable' => true) - )); - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html); - } - - public function testShouldRenderAsHtmlByDefault() - { - $test = $this->helper->formReset('foo', 'bar'); - $this->assertNotContains(' />', $test); - } - - public function testShouldAllowRenderingAsXHtml() - { - $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formReset('foo', 'bar'); - $this->assertContains(' />', $test); - } -} - -// Call Zend_View_Helper_FormResetTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormResetTest::main") { - Zend_View_Helper_FormResetTest::main(); -} diff --git a/tests/Zend/View/Helper/FormSelectTest.php b/tests/Zend/View/Helper/FormSelectTest.php deleted file mode 100644 index e5f424dd18d29f9e67939de0172519d37fe1883a..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormSelectTest.php +++ /dev/null @@ -1,292 +0,0 @@ -<?php -// Call Zend_View_Helper_FormSelectTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormSelectTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormSelect.php'; -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_FormSelect. - */ -class Zend_View_Helper_FormSelectTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormSelectTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormSelect(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper, $this->view); - } - - public function testFormSelectWithNameOnlyCreatesEmptySelect() - { - $html = $this->helper->formSelect('foo'); - $this->assertRegExp('#<select[^>]+name="foo"#', $html); - $this->assertContains('</select>', $html); - $this->assertNotContains('<option', $html); - } - - public function testFormSelectWithOptionsCreatesPopulatedSelect() - { - $html = $this->helper->formSelect('foo', null, null, array('foo' => 'Foobar', 'baz' => 'Bazbat')); - $this->assertRegExp('#<select[^>]+name="foo"#', $html); - $this->assertContains('</select>', $html); - $this->assertRegExp('#<option[^>]+value="foo".*?>Foobar</option>#', $html); - $this->assertRegExp('#<option[^>]+value="baz".*?>Bazbat</option>#', $html); - $this->assertEquals(2, substr_count($html, '<option')); - } - - public function testFormSelectWithOptionsAndValueSelectsAppropriateValue() - { - $html = $this->helper->formSelect('foo', 'baz', null, array('foo' => 'Foobar', 'baz' => 'Bazbat')); - $this->assertRegExp('#<option[^>]+value="baz"[^>]*selected.*?>Bazbat</option>#', $html); - } - - public function testFormSelectWithMultipleAttributeCreatesMultiSelect() - { - $html = $this->helper->formSelect('foo', null, array('multiple' => true), array('foo' => 'Foobar', 'baz' => 'Bazbat')); - $this->assertRegExp('#<select[^>]+name="foo\[\]"#', $html); - $this->assertRegExp('#<select[^>]+multiple="multiple"#', $html); - } - - public function testFormSelectWithMultipleAttributeAndValuesCreatesMultiSelectWithSelectedValues() - { - $html = $this->helper->formSelect('foo', array('foo', 'baz'), array('multiple' => true), array('foo' => 'Foobar', 'baz' => 'Bazbat')); - $this->assertRegExp('#<option[^>]+value="foo"[^>]*selected.*?>Foobar</option>#', $html); - $this->assertRegExp('#<option[^>]+value="baz"[^>]*selected.*?>Bazbat</option>#', $html); - } - - /** - * ZF-1930 - * @return void - */ - public function testFormSelectWithZeroValueSelectsValue() - { - $html = $this->helper->formSelect('foo', 0, null, array('foo' => 'Foobar', 0 => 'Bazbat')); - $this->assertRegExp('#<option[^>]+value="0"[^>]*selected.*?>Bazbat</option>#', $html); - } - - /** - * ZF-2513 - */ - public function testCanDisableEntireSelect() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar' - ), - 'attribs' => array( - 'disable' => true - ), - )); - $this->assertRegexp('/<select[^>]*?disabled/', $html, $html); - $this->assertNotRegexp('/<option[^>]*?disabled="disabled"/', $html, $html); - } - - /** - * ZF-2513 - */ - public function testCanDisableIndividualSelectOptionsOnly() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar' - ), - 'attribs' => array( - 'disable' => array('bar') - ), - )); - $this->assertNotRegexp('/<select[^>]*?disabled/', $html, $html); - $this->assertRegexp('/<option value="bar"[^>]*?disabled="disabled"/', $html, $html); - - $html = $this->helper->formSelect( - 'baz', - 'foo', - array( - 'disable' => array('bar') - ), - array( - 'foo' => 'Foo', - 'bar' => 'Bar' - ) - ); - $this->assertNotRegexp('/<select[^>]*?disabled/', $html, $html); - $this->assertRegexp('/<option value="bar"[^>]*?disabled="disabled"/', $html, $html); - } - - /** - * ZF-2513 - */ - public function testCanDisableMultipleSelectOptions() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz,' - ), - 'attribs' => array( - 'disable' => array('foo', 'baz') - ), - )); - $this->assertNotRegexp('/<select[^>]*?disabled/', $html, $html); - $this->assertRegexp('/<option value="foo"[^>]*?disabled="disabled"/', $html, $html); - $this->assertRegexp('/<option value="baz"[^>]*?disabled="disabled"/', $html, $html); - } - - /** - * ZF-2513 - */ - public function testCanDisableOptGroups() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => array( - '1' => 'one', - '2' => 'two' - ), - 'baz' => 'Baz,' - ), - 'attribs' => array( - 'disable' => array('bar') - ), - )); - $this->assertNotRegexp('/<select[^>]*?disabled/', $html, $html); - $this->assertRegexp('/<optgroup[^>]*?disabled="disabled"[^>]*?"bar"[^>]*?/', $html, $html); - $this->assertNotRegexp('/<option value="1"[^>]*?disabled="disabled"/', $html, $html); - $this->assertNotRegexp('/<option value="2"[^>]*?disabled="disabled"/', $html, $html); - } - - /** - * ZF-2513 - */ - public function testCanDisableOptGroupOptions() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => array( - '1' => 'one', - '2' => 'two' - ), - 'baz' => 'Baz,' - ), - 'attribs' => array( - 'disable' => array('2') - ), - )); - $this->assertNotRegexp('/<select[^>]*?disabled/', $html, $html); - $this->assertNotRegexp('/<optgroup[^>]*?disabled="disabled"[^>]*?"bar"[^>]*?/', $html, $html); - $this->assertNotRegexp('/<option value="1"[^>]*?disabled="disabled"/', $html, $html); - $this->assertRegexp('/<option value="2"[^>]*?disabled="disabled"/', $html, $html); - } - - public function testCanSpecifySelectMultipleThroughAttribute() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz,' - ), - 'attribs' => array( - 'multiple' => true - ), - )); - $this->assertRegexp('/<select[^>]*?(multiple="multiple")/', $html, $html); - } - - public function testSpecifyingSelectMultipleThroughAttributeAppendsNameWithBrackets() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz,' - ), - 'attribs' => array( - 'multiple' => true - ), - )); - $this->assertRegexp('/<select[^>]*?(name="baz\[\]")/', $html, $html); - } - - public function testCanSpecifySelectMultipleThroughName() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz[]', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz,' - ), - )); - $this->assertRegexp('/<select[^>]*?(multiple="multiple")/', $html, $html); - } - - /** - * ZF-1639 - */ - public function testNameCanContainBracketsButNotBeMultiple() - { - $html = $this->helper->formSelect(array( - 'name' => 'baz[]', - 'options' => array( - 'foo' => 'Foo', - 'bar' => 'Bar', - 'baz' => 'Baz,' - ), - 'attribs' => array( - 'multiple' => false - ), - )); - $this->assertRegexp('/<select[^>]*?(name="baz\[\]")/', $html, $html); - $this->assertNotRegexp('/<select[^>]*?(multiple="multiple")/', $html, $html); - } -} - -// Call Zend_View_Helper_FormSelectTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormSelectTest::main") { - Zend_View_Helper_FormSelectTest::main(); -} diff --git a/tests/Zend/View/Helper/FormSubmitTest.php b/tests/Zend/View/Helper/FormSubmitTest.php deleted file mode 100644 index 5a210757a749548770cc4729e931ccdaeeeb1ad3..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormSubmitTest.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -// Call Zend_View_Helper_FormSubmitTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormSubmitTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View/Helper/FormSubmit.php'; -require_once 'Zend/View.php'; -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_FormSubmit. - */ -class Zend_View_Helper_FormSubmitTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormSubmitTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormSubmit(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper, $this->view); - } - - public function testRendersSubmitInput() - { - $html = $this->helper->formSubmit(array( - 'name' => 'foo', - 'value' => 'Submit!', - )); - $this->assertRegexp('/<input[^>]*?(type="submit")/', $html); - } - - /** - * ZF-2254 - */ - public function testCanDisableSubmitButton() - { - $html = $this->helper->formSubmit(array( - 'name' => 'foo', - 'value' => 'Submit!', - 'attribs' => array('disable' => true) - )); - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html); - } - - /** - * ZF-2239 - */ - public function testValueAttributeIsAlwaysRendered() - { - $html = $this->helper->formSubmit(array( - 'name' => 'foo', - 'value' => '', - )); - $this->assertRegexp('/<input[^>]*?(value="")/', $html); - } - - public function testRendersAsHtmlByDefault() - { - $test = $this->helper->formSubmit('foo', 'bar'); - $this->assertNotContains(' />', $test); - } - - public function testCanRendersAsXHtml() - { - $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formSubmit('foo', 'bar'); - $this->assertContains(' />', $test); - } -} - -// Call Zend_View_Helper_FormSubmitTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormSubmitTest::main") { - Zend_View_Helper_FormSubmitTest::main(); -} diff --git a/tests/Zend/View/Helper/FormTest.php b/tests/Zend/View/Helper/FormTest.php deleted file mode 100644 index 1e7569a3176e8e318ecfeb02d190c5ed97ef871f..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -// Call Zend_View_Helper_FormTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/Form.php'; - -/** - * Test class for Zend_View_Helper_Form. - */ -class Zend_View_Helper_FormTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_Form(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - } - - public function testFormWithSaneInput() - { - $form = $this->helper->form('foo', array('action' => '/foo', 'method' => 'get')); - $this->assertRegexp('/<form[^>]*(id="foo")/', $form); - $this->assertRegexp('/<form[^>]*(action="\/foo")/', $form); - $this->assertRegexp('/<form[^>]*(method="get")/', $form); - } - - public function testFormWithInputNeedingEscapesUsesViewEscaping() - { - $form = $this->helper->form('<&foo'); - $this->assertContains($this->view->escape('<&foo'), $form); - } - - public function testPassingIdAsAttributeShouldRenderIdAttribAndNotName() - { - $form = $this->helper->form('foo', array('action' => '/foo', 'method' => 'get', 'id' => 'bar')); - $this->assertRegexp('/<form[^>]*(id="bar")/', $form); - $this->assertNotRegexp('/<form[^>]*(name="foo")/', $form); - } - - /** - * @see ZF-3832 - */ - public function testEmptyIdShouldNotRenderIdAttribute() - { - $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get')); - $this->assertNotRegexp('/<form[^>]*(id="")/', $form); - $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get', 'id' => null)); - $this->assertNotRegexp('/<form[^>]*(id="")/', $form); - } -} - -// Call Zend_View_Helper_FormTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTest::main") { - Zend_View_Helper_FormTest::main(); -} diff --git a/tests/Zend/View/Helper/FormTextTest.php b/tests/Zend/View/Helper/FormTextTest.php deleted file mode 100644 index 3922a17e11777e064f1a2be8b795d8c1e56b4684..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormTextTest.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php -// Call Zend_View_Helper_FormTextTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormTextTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormText.php'; -require_once 'Zend/Registry.php'; - -/** - * Zend_View_Helper_FormTextTest - * - * Tests formText helper, including some common functionality of all form helpers - * - * @uses PHPUnit_Framework_TestCase - * @version $Id: FormTextTest.php 8185 2008-02-19 22:27:55Z matthew $ - */ -class Zend_View_Helper_FormTextTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormTextTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - if (Zend_Registry::isRegistered('Zend_View_Helper_Doctype')) { - $registry = Zend_Registry::getInstance(); - unset($registry['Zend_View_Helper_Doctype']); - } - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormText(); - $this->helper->setView($this->view); - } - - public function testIdSetFromName() - { - $element = $this->helper->formText('foo'); - $this->assertContains('name="foo"', $element); - $this->assertContains('id="foo"', $element); - } - - public function testSetIdFromAttribs() - { - $element = $this->helper->formText('foo', null, array('id' => 'bar')); - $this->assertContains('name="foo"', $element); - $this->assertContains('id="bar"', $element); - } - - public function testSetValue() - { - $element = $this->helper->formText('foo', 'bar'); - $this->assertContains('name="foo"', $element); - $this->assertContains('value="bar"', $element); - } - - public function testReadOnlyAttribute() - { - $element = $this->helper->formText('foo', null, array('readonly' => 'readonly')); - $this->assertContains('readonly="readonly"', $element); - } - - /** - * ZF-1666 - */ - public function testCanDisableElement() - { - $html = $this->helper->formText(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs' => array('disable' => true) - )); - - $this->assertRegexp('/<input[^>]*?(disabled="disabled")/', $html); - } - - /** - * ZF-1666 - */ - public function testDisablingElementDoesNotRenderHiddenElements() - { - $html = $this->helper->formText(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs' => array('disable' => true) - )); - - $this->assertNotRegexp('/<input[^>]*?(type="hidden")/', $html); - } - - public function testRendersAsHtmlByDefault() - { - $test = $this->helper->formText('foo', 'bar'); - $this->assertNotContains(' />', $test); - } - - public function testCanRendersAsXHtml() - { - $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formText('foo', 'bar'); - $this->assertContains(' />', $test); - } -} - -// Call Zend_View_Helper_FormTextTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTextTest::main") { - Zend_View_Helper_FormTextTest::main(); -} diff --git a/tests/Zend/View/Helper/FormTextareaTest.php b/tests/Zend/View/Helper/FormTextareaTest.php deleted file mode 100644 index 6d6ba279a19da910808a35a2725fe32f6f649bf7..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/FormTextareaTest.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php -// Call Zend_View_Helper_FormTextareaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormTextareaTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/FormTextarea.php'; - -/** - * Zend_View_Helper_FormTextareaTest - * - * Tests formTextarea helper - * - * @uses PHPUnit_Framework_TestCase - */ -class Zend_View_Helper_FormTextareaTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormTextareaTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_FormTextarea(); - $this->helper->setView($this->view); - } - - /** - * ZF-1666 - */ - public function testCanDisableElement() - { - $html = $this->helper->formTextarea(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs' => array('disable' => true) - )); - - $this->assertRegexp('/<textarea[^>]*?(disabled="disabled")/', $html); - } - - /** - * ZF-1666 - */ - public function testDisablingElementDoesNotRenderHiddenElements() - { - $html = $this->helper->formTextarea(array( - 'name' => 'foo', - 'value' => 'bar', - 'attribs' => array('disable' => true) - )); - - $this->assertNotRegexp('/<textarea[^>]*?(type="hidden")/', $html); - } -} - -// Call Zend_View_Helper_FormTextareaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTextareaTest::main") { - Zend_View_Helper_FormTextareaTest::main(); -} diff --git a/tests/Zend/View/Helper/HeadLinkTest.php b/tests/Zend/View/Helper/HeadLinkTest.php deleted file mode 100644 index 69becd8c93e5f0d4c35f418bfa7d25b9df7c2af8..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HeadLinkTest.php +++ /dev/null @@ -1,383 +0,0 @@ -<?php -// Call Zend_View_Helper_HeadLinkTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HeadLinkTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_HeadLink */ -require_once 'Zend/View/Helper/HeadLink.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_HeadLink. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_HeadLinkTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HeadLink - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HeadLinkTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - foreach (array(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY, 'Zend_View_Helper_Doctype') as $key) { - if (Zend_Registry::isRegistered($key)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$key]); - } - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_HeadLink(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - if ($registry->containerExists('Zend_View_Helper_HeadLink')) { - $registry->deleteContainer('Zend_View_Helper_HeadLink'); - } - $this->assertFalse($registry->containerExists('Zend_View_Helper_HeadLink')); - $helper = new Zend_View_Helper_HeadLink(); - $this->assertTrue($registry->containerExists('Zend_View_Helper_HeadLink')); - } - - public function testHeadLinkReturnsObjectInstance() - { - $placeholder = $this->helper->headLink(); - $this->assertTrue($placeholder instanceof Zend_View_Helper_HeadLink); - } - - public function testPrependThrowsExceptionWithoutArrayArgument() - { - try { - $this->helper->prepend('foo'); - $this->fail('prepend should raise exception without array argument'); - } catch (Exception $e) { - } - } - - public function testAppendThrowsExceptionWithoutArrayArgument() - { - try { - $this->helper->append('foo'); - $this->fail('append should raise exception without array argument'); - } catch (Exception $e) { - } - } - - public function testSetThrowsExceptionWithoutArrayArgument() - { - try { - $this->helper->set('foo'); - $this->fail('set should raise exception without array argument'); - } catch (Exception $e) { - } - } - - public function testOffsetSetThrowsExceptionWithoutArrayArgument() - { - try { - $this->helper->offsetSet(1, 'foo'); - $this->fail('set should raise exception without array argument'); - } catch (Exception $e) { - } - } - - public function testCreatingLinkStackViaHeadScriptCreatesAppropriateOutput() - { - $links = array( - 'link1' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'foo'), - 'link2' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'bar'), - 'link3' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'baz'), - ); - $this->helper->headLink($links['link1']) - ->headLink($links['link2'], 'PREPEND') - ->headLink($links['link3']); - - $string = $this->helper->toString(); - $lines = substr_count($string, PHP_EOL); - $this->assertEquals(2, $lines); - $lines = substr_count($string, '<link '); - $this->assertEquals(3, $lines, $string); - - foreach ($links as $link) { - $substr = ' href="' . $link['href'] . '"'; - $this->assertContains($substr, $string); - $substr = ' rel="' . $link['rel'] . '"'; - $this->assertContains($substr, $string); - $substr = ' type="' . $link['type'] . '"'; - $this->assertContains($substr, $string); - } - - $order = array(); - foreach ($this->helper as $key => $value) { - if (isset($value->href)) { - $order[$key] = $value->href; - } - } - $expected = array('bar', 'foo', 'baz'); - $this->assertSame($expected, $order); - } - - public function testCreatingLinkStackViaStyleSheetMethodsCreatesAppropriateOutput() - { - $links = array( - 'link1' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'foo'), - 'link2' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'bar'), - 'link3' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'baz'), - ); - $this->helper->appendStylesheet($links['link1']['href']) - ->prependStylesheet($links['link2']['href']) - ->appendStylesheet($links['link3']['href']); - - $string = $this->helper->toString(); - $lines = substr_count($string, PHP_EOL); - $this->assertEquals(2, $lines); - $lines = substr_count($string, '<link '); - $this->assertEquals(3, $lines, $string); - - foreach ($links as $link) { - $substr = ' href="' . $link['href'] . '"'; - $this->assertContains($substr, $string); - $substr = ' rel="' . $link['rel'] . '"'; - $this->assertContains($substr, $string); - $substr = ' type="' . $link['type'] . '"'; - $this->assertContains($substr, $string); - } - - $order = array(); - foreach ($this->helper as $key => $value) { - if (isset($value->href)) { - $order[$key] = $value->href; - } - } - $expected = array('bar', 'foo', 'baz'); - $this->assertSame($expected, $order); - } - - public function testCreatingLinkStackViaAlternateMethodsCreatesAppropriateOutput() - { - $links = array( - 'link1' => array('title' => 'stylesheet', 'type' => 'text/css', 'href' => 'foo'), - 'link2' => array('title' => 'stylesheet', 'type' => 'text/css', 'href' => 'bar'), - 'link3' => array('title' => 'stylesheet', 'type' => 'text/css', 'href' => 'baz'), - ); - $where = 'append'; - foreach ($links as $link) { - $method = $where . 'Alternate'; - $this->helper->$method($link['href'], $link['type'], $link['title']); - $where = ('append' == $where) ? 'prepend' : 'append'; - } - - $string = $this->helper->toString(); - $lines = substr_count($string, PHP_EOL); - $this->assertEquals(2, $lines); - $lines = substr_count($string, '<link '); - $this->assertEquals(3, $lines, $string); - $lines = substr_count($string, ' rel="alternate"'); - $this->assertEquals(3, $lines, $string); - - foreach ($links as $link) { - $substr = ' href="' . $link['href'] . '"'; - $this->assertContains($substr, $string); - $substr = ' title="' . $link['title'] . '"'; - $this->assertContains($substr, $string); - $substr = ' type="' . $link['type'] . '"'; - $this->assertContains($substr, $string); - } - - $order = array(); - foreach ($this->helper as $key => $value) { - if (isset($value->href)) { - $order[$key] = $value->href; - } - } - $expected = array('bar', 'foo', 'baz'); - $this->assertSame($expected, $order); - } - - public function testOverloadingThrowsExceptionWithNoArguments() - { - try { - $this->helper->appendStylesheet(); - $this->fail('Helper should expect at least one argument'); - } catch (Zend_View_Exception $e) {} - } - - public function testOverloadingShouldAllowSingleArrayArgument() - { - $this->helper->setStylesheet(array('href' => '/styles.css')); - $link = $this->helper->getValue(); - $this->assertEquals('/styles.css', $link->href); - } - - public function testOverloadingUsingSingleArrayArgumentWithInvalidValuesThrowsException() - { - try { - $this->helper->setStylesheet(array('bogus' => 'unused')); - $this->fail('Invalid attribute values should raise exception'); - } catch (Zend_View_Exception $e) { } - } - - public function testOverloadingOffsetSetWorks() - { - $this->helper->offsetSetStylesheet(100, '/styles.css'); - $items = $this->helper->getArrayCopy(); - $this->assertTrue(isset($items[100])); - $link = $items[100]; - $this->assertEquals('/styles.css', $link->href); - } - - public function testOverloadingThrowsExceptionWithInvalidMethod() - { - try { - $this->helper->bogusMethod(); - $this->fail('Invalid method should raise exception'); - } catch (Zend_View_Exception $e) { } - } - - public function testStylesheetAttributesGetSet() - { - $this->helper->setStylesheet('/styles.css', 'projection', 'ie6'); - $item = $this->helper->getValue(); - $this->assertObjectHasAttribute('media', $item); - $this->assertObjectHasAttribute('conditionalStylesheet', $item); - - $this->assertEquals('projection', $item->media); - $this->assertEquals('ie6', $item->conditionalStylesheet); - } - - public function testConditionalStylesheetNotCreatedByDefault() - { - $this->helper->setStylesheet('/styles.css'); - $item = $this->helper->getValue(); - $this->assertObjectHasAttribute('conditionalStylesheet', $item); - $this->assertFalse($item->conditionalStylesheet); - - $string = $this->helper->toString(); - $this->assertContains('/styles.css', $string); - $this->assertNotContains('<!--[if', $string); - $this->assertNotContains(']>', $string); - $this->assertNotContains('<![endif]-->', $string); - } - - public function testConditionalStylesheetCreationOccursWhenRequested() - { - $this->helper->setStylesheet('/styles.css', 'screen', 'ie6'); - $item = $this->helper->getValue(); - $this->assertObjectHasAttribute('conditionalStylesheet', $item); - $this->assertEquals('ie6', $item->conditionalStylesheet); - - $string = $this->helper->toString(); - $this->assertContains('/styles.css', $string); - $this->assertContains('<!--[if ie6]>', $string); - $this->assertContains('<![endif]-->', $string); - } - - public function testSettingAlternateWithTooFewArgsRaisesException() - { - try { - $this->helper->setAlternate('foo'); - $this->fail('Setting alternate with fewer than 3 args should raise exception'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->setAlternate('foo', 'bar'); - $this->fail('Setting alternate with fewer than 3 args should raise exception'); - } catch (Zend_View_Exception $e) { } - } - - public function testIndentationIsHonored() - { - $this->helper->setIndent(4); - $this->helper->appendStylesheet('/css/screen.css'); - $this->helper->appendStylesheet('/css/rules.css'); - $string = $this->helper->toString(); - - $scripts = substr_count($string, ' <link '); - $this->assertEquals(2, $scripts); - } - - public function testLinkRendersAsPlainHtmlIfDoctypeNotXhtml() - { - $this->view->doctype('HTML4_STRICT'); - $this->helper->headLink(array('rel' => 'icon', 'src' => '/foo/bar')) - ->headLink(array('rel' => 'foo', 'href' => '/bar/baz')); - $test = $this->helper->toString(); - $this->assertNotContains(' />', $test); - } - - public function testDoesNotAllowDuplicateStylesheets() - { - $this->helper->appendStylesheet('foo'); - $this->helper->appendStylesheet('foo'); - $this->assertEquals(1, count($this->helper), var_export($this->helper->getContainer()->getArrayCopy(), 1)); - } - - /** - * test for ZF-2889 - */ - public function testBooleanStylesheet() - { - $this->helper->appendStylesheet(array('href' => '/bar/baz', 'conditionalStylesheet' => false)); - $test = $this->helper->toString(); - $this->assertNotContains('[if false]', $test); - } -} - -// Call Zend_View_Helper_HeadLinkTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HeadLinkTest::main") { - Zend_View_Helper_HeadLinkTest::main(); -} diff --git a/tests/Zend/View/Helper/HeadMetaTest.php b/tests/Zend/View/Helper/HeadMetaTest.php deleted file mode 100644 index 65ee8d8fb6be810f871c1ff5328b9137e9961985..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HeadMetaTest.php +++ /dev/null @@ -1,364 +0,0 @@ -<?php -// Call Zend_View_Helper_HeadMetaTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HeadMetaTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_View_Helper_HeadMeta */ -require_once 'Zend/View/Helper/HeadMeta.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_HeadMeta. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_HeadMetaTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HeadMeta - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HeadMetaTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - foreach (array(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY, 'Zend_View_Helper_Doctype') as $key) { - if (Zend_Registry::isRegistered($key)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$key]); - } - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->view = new Zend_View(); - $this->view->doctype('XHTML1_STRICT'); - $this->helper = new Zend_View_Helper_HeadMeta(); - $this->helper->setView($this->view); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - if ($registry->containerExists('Zend_View_Helper_HeadMeta')) { - $registry->deleteContainer('Zend_View_Helper_HeadMeta'); - } - $this->assertFalse($registry->containerExists('Zend_View_Helper_HeadMeta')); - $helper = new Zend_View_Helper_HeadMeta(); - $this->assertTrue($registry->containerExists('Zend_View_Helper_HeadMeta')); - } - - public function testHeadMetaReturnsObjectInstance() - { - $placeholder = $this->helper->headMeta(); - $this->assertTrue($placeholder instanceof Zend_View_Helper_HeadMeta); - } - - public function testAppendPrependAndSetThrowExceptionsWhenNonMetaValueProvided() - { - try { - $this->helper->append('foo'); - $this->fail('Non-meta value should not append'); - } catch (Zend_View_Exception $e) { - } - try { - $this->helper->offsetSet(3, 'foo'); - $this->fail('Non-meta value should not offsetSet'); - } catch (Zend_View_Exception $e) { - } - try { - $this->helper->prepend('foo'); - $this->fail('Non-meta value should not prepend'); - } catch (Zend_View_Exception $e) { - } - try { - $this->helper->set('foo'); - $this->fail('Non-meta value should not set'); - } catch (Zend_View_Exception $e) { - } - } - - protected function _inflectAction($type) - { - $type = str_replace('-', ' ', $type); - $type = ucwords($type); - $type = str_replace(' ', '', $type); - return $type; - } - - protected function _testOverloadAppend($type) - { - $action = 'append' . $this->_inflectAction($type); - $string = 'foo'; - for ($i = 0; $i < 3; ++$i) { - $string .= ' foo'; - $this->helper->$action('keywords', $string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals($i + 1, count($values)); - - $item = $values[$i]; - $this->assertObjectHasAttribute('type', $item); - $this->assertObjectHasAttribute('modifiers', $item); - $this->assertObjectHasAttribute('content', $item); - $this->assertObjectHasAttribute($item->type, $item); - $this->assertEquals('keywords', $item->{$item->type}); - $this->assertEquals($string, $item->content); - } - } - - protected function _testOverloadPrepend($type) - { - $action = 'prepend' . $this->_inflectAction($type); - $string = 'foo'; - for ($i = 0; $i < 3; ++$i) { - $string .= ' foo'; - $this->helper->$action('keywords', $string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals($i + 1, count($values)); - $item = array_shift($values); - - $this->assertObjectHasAttribute('type', $item); - $this->assertObjectHasAttribute('modifiers', $item); - $this->assertObjectHasAttribute('content', $item); - $this->assertObjectHasAttribute($item->type, $item); - $this->assertEquals('keywords', $item->{$item->type}); - $this->assertEquals($string, $item->content); - } - } - - protected function _testOverloadSet($type) - { - $setAction = 'set' . $this->_inflectAction($type); - $appendAction = 'append' . $this->_inflectAction($type); - $string = 'foo'; - for ($i = 0; $i < 3; ++$i) { - $this->helper->$appendAction('keywords', $string); - $string .= ' foo'; - } - $this->helper->$setAction('keywords', $string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - $item = array_shift($values); - - $this->assertObjectHasAttribute('type', $item); - $this->assertObjectHasAttribute('modifiers', $item); - $this->assertObjectHasAttribute('content', $item); - $this->assertObjectHasAttribute($item->type, $item); - $this->assertEquals('keywords', $item->{$item->type}); - $this->assertEquals($string, $item->content); - } - - public function testOverloadingAppendNameAppendsMetaTagToStack() - { - $this->_testOverloadAppend('name'); - } - - public function testOverloadingPrependNamePrependsMetaTagToStack() - { - $this->_testOverloadPrepend('name'); - } - - public function testOverloadingSetNameOverwritesMetaTagStack() - { - $this->_testOverloadSet('name'); - } - - public function testOverloadingAppendHttpEquivAppendsMetaTagToStack() - { - $this->_testOverloadAppend('http-equiv'); - } - - public function testOverloadingPrependHttpEquivPrependsMetaTagToStack() - { - $this->_testOverloadPrepend('http-equiv'); - } - - public function testOverloadingSetHttpEquivOverwritesMetaTagStack() - { - $this->_testOverloadSet('http-equiv'); - } - - public function testOverloadingThrowsExceptionWithFewerThanTwoArgs() - { - try { - $this->helper->setName('foo'); - $this->fail('Overloading should require at least two arguments'); - } catch (Zend_View_Exception $e) { - } - } - - public function testOverloadingThrowsExceptionWithInvalidMethodType() - { - try { - $this->helper->setFoo('foo'); - $this->fail('Overloading should only work for (set|prepend|append)(Name|HttpEquiv)'); - } catch (Zend_View_Exception $e) { - } - } - - public function testCanBuildMetaTagsWithAttributes() - { - $this->helper->setName('keywords', 'foo bar', array('lang' => 'us_en', 'scheme' => 'foo', 'bogus' => 'unused')); - $value = $this->helper->getValue(); - - $this->assertObjectHasAttribute('modifiers', $value); - $modifiers = $value->modifiers; - $this->assertTrue(array_key_exists('lang', $modifiers)); - $this->assertEquals('us_en', $modifiers['lang']); - $this->assertTrue(array_key_exists('scheme', $modifiers)); - $this->assertEquals('foo', $modifiers['scheme']); - } - - public function testToStringReturnsValidHtml() - { - $this->helper->setName('keywords', 'foo bar', array('lang' => 'us_en', 'scheme' => 'foo', 'bogus' => 'unused')) - ->prependName('title', 'boo bah') - ->appendHttpEquiv('screen', 'projection'); - $string = $this->helper->toString(); - - $metas = substr_count($string, '<meta '); - $this->assertEquals(3, $metas); - $metas = substr_count($string, '/>'); - $this->assertEquals(3, $metas); - $metas = substr_count($string, 'name="'); - $this->assertEquals(2, $metas); - $metas = substr_count($string, 'http-equiv="'); - $this->assertEquals(1, $metas); - - $this->assertContains('http-equiv="screen" content="projection"', $string); - $this->assertContains('name="keywords" content="foo bar"', $string); - $this->assertContains('lang="us_en"', $string); - $this->assertContains('scheme="foo"', $string); - $this->assertNotContains('bogus', $string); - $this->assertNotContains('unused', $string); - $this->assertContains('name="title" content="boo bah"', $string); - } - - public function testHeadMetaHelperCreatesItemEntry() - { - $this->helper->headMeta('foo', 'keywords'); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - $item = array_shift($values); - $this->assertEquals('foo', $item->content); - $this->assertEquals('name', $item->type); - $this->assertEquals('keywords', $item->name); - } - - public function testOverloadingOffsetInsertsAtOffset() - { - $this->helper->offsetSetName(100, 'keywords', 'foo'); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - $this->assertTrue(array_key_exists(100, $values)); - $item = $values[100]; - $this->assertEquals('foo', $item->content); - $this->assertEquals('name', $item->type); - $this->assertEquals('keywords', $item->name); - } - - public function testIndentationIsHonored() - { - $this->helper->setIndent(4); - $this->helper->appendName('keywords', 'foo bar'); - $this->helper->appendName('seo', 'baz bat'); - $string = $this->helper->toString(); - - $scripts = substr_count($string, ' <meta name='); - $this->assertEquals(2, $scripts); - } - - public function testStringRepresentationReflectsDoctype() - { - $this->view->doctype('HTML4_STRICT'); - $this->helper->headMeta('some content', 'foo'); - $test = $this->helper->toString(); - $this->assertNotContains('/>', $test); - $this->assertContains('some content', $test); - $this->assertContains('foo', $test); - } - - /** - * @issue ZF-2663 - */ - public function testSetNameDoesntClobber() - { - $view = new Zend_View(); - $view->headMeta()->setName('keywords', 'foo'); - $view->headMeta()->appendHttpEquiv('pragma', 'bar'); - $view->headMeta()->appendHttpEquiv('Cache-control', 'baz'); - $view->headMeta()->setName('keywords', 'bat'); - - $this->assertEquals( - '<meta http-equiv="pragma" content="bar" />' . PHP_EOL . '<meta http-equiv="Cache-control" content="baz" />' . PHP_EOL . '<meta name="keywords" content="bat" />', - $view->headMeta()->toString() - ); - } - - /** - * @issue ZF-2663 - */ - public function testSetNameDoesntClobberPart2() - { - $view = new Zend_View(); - $view->headMeta()->setName('keywords', 'foo'); - $view->headMeta()->setName('description', 'foo'); - $view->headMeta()->appendHttpEquiv('pragma', 'baz'); - $view->headMeta()->appendHttpEquiv('Cache-control', 'baz'); - $view->headMeta()->setName('keywords', 'bar'); - - $this->assertEquals( - '<meta name="description" content="foo" />' . PHP_EOL . '<meta http-equiv="pragma" content="baz" />' . PHP_EOL . '<meta http-equiv="Cache-control" content="baz" />' . PHP_EOL . '<meta name="keywords" content="bar" />', - $view->headMeta()->toString() - ); - } - -} - -// Call Zend_View_Helper_HeadMetaTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HeadMetaTest::main") { - Zend_View_Helper_HeadMetaTest::main(); -} diff --git a/tests/Zend/View/Helper/HeadScriptTest.php b/tests/Zend/View/Helper/HeadScriptTest.php deleted file mode 100644 index 8786449f557f33f5bce92a805e912e87d87967c0..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HeadScriptTest.php +++ /dev/null @@ -1,388 +0,0 @@ -<?php -// Call Zend_View_Helper_HeadScriptTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HeadScriptTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_View_Helper_HeadScript */ -require_once 'Zend/View/Helper/HeadScript.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_HeadScript. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_HeadScriptTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HeadScript - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HeadScriptTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_HeadScript(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - if ($registry->containerExists('Zend_View_Helper_HeadScript')) { - $registry->deleteContainer('Zend_View_Helper_HeadScript'); - } - $this->assertFalse($registry->containerExists('Zend_View_Helper_HeadScript')); - $helper = new Zend_View_Helper_HeadScript(); - $this->assertTrue($registry->containerExists('Zend_View_Helper_HeadScript')); - } - - public function testHeadScriptReturnsObjectInstance() - { - $placeholder = $this->helper->headScript(); - $this->assertTrue($placeholder instanceof Zend_View_Helper_HeadScript); - } - - public function testSetPrependAppendAndOffsetSetThrowExceptionsOnInvalidItems() - { - try { - $this->helper->append('foo'); - $this->fail('Append should throw exception with invalid item'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->offsetSet(1, 'foo'); - $this->fail('OffsetSet should throw exception with invalid item'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->prepend('foo'); - $this->fail('Prepend should throw exception with invalid item'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->set('foo'); - $this->fail('Set should throw exception with invalid item'); - } catch (Zend_View_Exception $e) { } - } - - protected function _inflectAction($type) - { - return ucfirst(strtolower($type)); - } - - protected function _testOverloadAppend($type) - { - $action = 'append' . $this->_inflectAction($type); - $string = 'foo'; - for ($i = 0; $i < 3; ++$i) { - $string .= ' foo'; - $this->helper->$action($string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals($i + 1, count($values)); - if ('file' == $type) { - $this->assertEquals($string, $values[$i]->attributes['src']); - } elseif ('script' == $type) { - $this->assertEquals($string, $values[$i]->source); - } - $this->assertEquals('text/javascript', $values[$i]->type); - } - } - - protected function _testOverloadPrepend($type) - { - $action = 'prepend' . $this->_inflectAction($type); - $string = 'foo'; - for ($i = 0; $i < 3; ++$i) { - $string .= ' foo'; - $this->helper->$action($string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals($i + 1, count($values)); - $first = array_shift($values); - if ('file' == $type) { - $this->assertEquals($string, $first->attributes['src']); - } elseif ('script' == $type) { - $this->assertEquals($string, $first->source); - } - $this->assertEquals('text/javascript', $first->type); - } - } - - protected function _testOverloadSet($type) - { - $action = 'set' . $this->_inflectAction($type); - $string = 'foo'; - for ($i = 0; $i < 3; ++$i) { - $this->helper->appendScript($string); - $string .= ' foo'; - } - $this->helper->$action($string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - if ('file' == $type) { - $this->assertEquals($string, $values[0]->attributes['src']); - } elseif ('script' == $type) { - $this->assertEquals($string, $values[0]->source); - } - $this->assertEquals('text/javascript', $values[0]->type); - } - - protected function _testOverloadOffsetSet($type) - { - $action = 'offsetSet' . $this->_inflectAction($type); - $string = 'foo'; - $this->helper->$action(5, $string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - if ('file' == $type) { - $this->assertEquals($string, $values[5]->attributes['src']); - } elseif ('script' == $type) { - $this->assertEquals($string, $values[5]->source); - } - $this->assertEquals('text/javascript', $values[5]->type); - } - - public function testOverloadAppendFileAppendsScriptsToStack() - { - $this->_testOverloadAppend('file'); - } - - public function testOverloadAppendScriptAppendsScriptsToStack() - { - $this->_testOverloadAppend('script'); - } - - public function testOverloadPrependFileAppendsScriptsToStack() - { - $this->_testOverloadPrepend('file'); - } - - public function testOverloadPrependScriptAppendsScriptsToStack() - { - $this->_testOverloadPrepend('script'); - } - - public function testOverloadSetFileOverwritesStack() - { - $this->_testOverloadSet('file'); - } - - public function testOverloadSetScriptOverwritesStack() - { - $this->_testOverloadSet('script'); - } - - public function testOverloadOffsetSetFileWritesToSpecifiedIndex() - { - $this->_testOverloadOffsetSet('file'); - } - - public function testOverloadOffsetSetScriptWritesToSpecifiedIndex() - { - $this->_testOverloadOffsetSet('script'); - } - - public function testOverloadingThrowsExceptionWithInvalidMethod() - { - try { - $this->helper->fooBar('foo'); - $this->fail('Invalid method should raise exception'); - } catch (Zend_View_Exception $e) { - } - } - - public function testOverloadingWithTooFewArgumentsRaisesException() - { - try { - $this->helper->setScript(); - $this->fail('Too few arguments should raise exception'); - } catch (Zend_View_Exception $e) { - } - - try { - $this->helper->offsetSetScript(5); - $this->fail('Too few arguments should raise exception'); - } catch (Zend_View_Exception $e) { - } - } - - public function testHeadScriptAppropriatelySetsScriptItems() - { - $this->helper->headScript('FILE', 'foo', 'set') - ->headScript('SCRIPT', 'bar', 'prepend') - ->headScript('SCRIPT', 'baz', 'append'); - $items = $this->helper->getArrayCopy(); - for ($i = 0; $i < 3; ++$i) { - $item = $items[$i]; - switch ($i) { - case 0: - $this->assertObjectHasAttribute('source', $item); - $this->assertEquals('bar', $item->source); - break; - case 1: - $this->assertObjectHasAttribute('attributes', $item); - $this->assertTrue(isset($item->attributes['src'])); - $this->assertEquals('foo', $item->attributes['src']); - break; - case 2: - $this->assertObjectHasAttribute('source', $item); - $this->assertEquals('baz', $item->source); - break; - } - } - } - - public function testToStringRendersValidHtml() - { - $this->helper->headScript('FILE', 'foo', 'set') - ->headScript('SCRIPT', 'bar', 'prepend') - ->headScript('SCRIPT', 'baz', 'append'); - $string = $this->helper->toString(); - - $scripts = substr_count($string, '<script '); - $this->assertEquals(3, $scripts); - $scripts = substr_count($string, '</script>'); - $this->assertEquals(3, $scripts); - $scripts = substr_count($string, 'src="'); - $this->assertEquals(1, $scripts); - $scripts = substr_count($string, '><'); - $this->assertEquals(1, $scripts); - - $this->assertContains('src="foo"', $string); - $this->assertContains('bar', $string); - $this->assertContains('baz', $string); - - $doc = new DOMDocument; - $dom = $doc->loadHtml($string); - $this->assertTrue($dom !== false); - } - - public function testCapturingCapturesToObject() - { - $this->helper->captureStart(); - echo 'foobar'; - $this->helper->captureEnd(); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values), var_export($values, 1)); - $item = array_shift($values); - $this->assertContains('foobar', $item->source); - } - - public function testIndentationIsHonored() - { - $this->helper->setIndent(4); - $this->helper->appendScript(' -var foo = "bar"; -document.write(foo.strlen());'); - $this->helper->appendScript(' -var bar = "baz"; -document.write(bar.strlen());'); - $string = $this->helper->toString(); - - $scripts = substr_count($string, ' <script'); - $this->assertEquals(2, $scripts); - $this->assertContains(' //', $string); - $this->assertContains(' var', $string); - $this->assertContains(' document', $string); - } - - public function testDoesNotAllowDuplicateFiles() - { - $this->helper->headScript('FILE', '/js/prototype.js'); - $this->helper->headScript('FILE', '/js/prototype.js'); - $this->assertEquals(1, count($this->helper)); - } - - public function testRenderingDoesNotRenderArbitraryAttributesByDefault() - { - $this->helper->headScript()->appendFile('/js/foo.js', 'text/javascript', array('bogus' => 'deferred')); - $test = $this->helper->headScript()->toString(); - $this->assertNotContains('bogus="deferred"', $test); - } - - public function testCanRenderArbitraryAttributesOnRequest() - { - $this->helper->headScript()->appendFile('/js/foo.js', 'text/javascript', array('bogus' => 'deferred')) - ->setAllowArbitraryAttributes(true); - $test = $this->helper->headScript()->toString(); - $this->assertContains('bogus="deferred"', $test); - } - - public function testCanPerformMultipleSerialCaptures() - { - $this->helper->headScript()->captureStart(); - echo "this is something captured"; - $this->helper->headScript()->captureEnd(); - try { - $this->helper->headScript()->captureStart(); - } catch (Zend_View_Exception $e) { - $this->fail('Serial captures should be allowed'); - } - echo "this is something else captured"; - $this->helper->headScript()->captureEnd(); - } - - public function testCannotNestCaptures() - { - $this->helper->headScript()->captureStart(); - echo "this is something captured"; - try { - $this->helper->headScript()->captureStart(); - $this->helper->headScript()->captureEnd(); - $this->fail('Should not be able to nest captures'); - } catch (Zend_View_Exception $e) { - $this->helper->headScript()->captureEnd(); - $this->assertContains('Cannot nest', $e->getMessage()); - } - $this->helper->headScript()->captureEnd(); - } -} - -// Call Zend_View_Helper_HeadScriptTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HeadScriptTest::main") { - Zend_View_Helper_HeadScriptTest::main(); -} diff --git a/tests/Zend/View/Helper/HeadStyleTest.php b/tests/Zend/View/Helper/HeadStyleTest.php deleted file mode 100644 index 20e9b3fa6b994372b28c43f34879987f39b18c91..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HeadStyleTest.php +++ /dev/null @@ -1,349 +0,0 @@ -<?php -// Call Zend_View_Helper_HeadStyleTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HeadStyleTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_HeadStyle */ -require_once 'Zend/View/Helper/HeadStyle.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_HeadStyle. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_HeadStyleTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HeadStyle - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HeadStyleTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_HeadStyle(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - if ($registry->containerExists('Zend_View_Helper_HeadStyle')) { - $registry->deleteContainer('Zend_View_Helper_HeadStyle'); - } - $this->assertFalse($registry->containerExists('Zend_View_Helper_HeadStyle')); - $helper = new Zend_View_Helper_HeadStyle(); - $this->assertTrue($registry->containerExists('Zend_View_Helper_HeadStyle')); - } - - public function testHeadStyleReturnsObjectInstance() - { - $placeholder = $this->helper->headStyle(); - $this->assertTrue($placeholder instanceof Zend_View_Helper_HeadStyle); - } - - public function testAppendPrependAndSetThrowExceptionsWhenNonStyleValueProvided() - { - try { - $this->helper->append('foo'); - $this->fail('Non-style value should not append'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->offsetSet(5, 'foo'); - $this->fail('Non-style value should not offsetSet'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->prepend('foo'); - $this->fail('Non-style value should not prepend'); - } catch (Zend_View_Exception $e) { } - try { - $this->helper->set('foo'); - $this->fail('Non-style value should not set'); - } catch (Zend_View_Exception $e) { } - } - - public function testOverloadAppendStyleAppendsStyleToStack() - { - $string = 'a {}'; - for ($i = 0; $i < 3; ++$i) { - $string .= PHP_EOL . 'a {}'; - $this->helper->appendStyle($string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals($i + 1, count($values)); - $item = $values[$i]; - - $this->assertTrue($item instanceof stdClass); - $this->assertObjectHasAttribute('content', $item); - $this->assertObjectHasAttribute('attributes', $item); - $this->assertEquals($string, $item->content); - } - } - - public function testOverloadPrependStylePrependsStyleToStack() - { - $string = 'a {}'; - for ($i = 0; $i < 3; ++$i) { - $string .= PHP_EOL . 'a {}'; - $this->helper->prependStyle($string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals($i + 1, count($values)); - $item = array_shift($values); - - $this->assertTrue($item instanceof stdClass); - $this->assertObjectHasAttribute('content', $item); - $this->assertObjectHasAttribute('attributes', $item); - $this->assertEquals($string, $item->content); - } - } - - public function testOverloadSetOversitesStack() - { - $string = 'a {}'; - for ($i = 0; $i < 3; ++$i) { - $this->helper->appendStyle($string); - $string .= PHP_EOL . 'a {}'; - } - $this->helper->setStyle($string); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - $item = array_shift($values); - - $this->assertTrue($item instanceof stdClass); - $this->assertObjectHasAttribute('content', $item); - $this->assertObjectHasAttribute('attributes', $item); - $this->assertEquals($string, $item->content); - } - - public function testCanBuildStyleTagsWithAttributes() - { - $this->helper->setStyle('a {}', array( - 'lang' => 'us_en', - 'title' => 'foo', - 'media' => 'projection', - 'dir' => 'rtol', - 'bogus' => 'unused' - )); - $value = $this->helper->getValue(); - - $this->assertObjectHasAttribute('attributes', $value); - $attributes = $value->attributes; - - $this->assertTrue(isset($attributes['lang'])); - $this->assertTrue(isset($attributes['title'])); - $this->assertTrue(isset($attributes['media'])); - $this->assertTrue(isset($attributes['dir'])); - $this->assertTrue(isset($attributes['bogus'])); - $this->assertEquals('us_en', $attributes['lang']); - $this->assertEquals('foo', $attributes['title']); - $this->assertEquals('projection', $attributes['media']); - $this->assertEquals('rtol', $attributes['dir']); - $this->assertEquals('unused', $attributes['bogus']); - } - - public function testRenderedStyleTagsContainHtmlEscaping() - { - $this->helper->setStyle('a {}', array( - 'lang' => 'us_en', - 'title' => 'foo', - 'media' => 'screen', - 'dir' => 'rtol', - 'bogus' => 'unused' - )); - $value = $this->helper->toString(); - $this->assertContains('<!--' . PHP_EOL, $value); - $this->assertContains(PHP_EOL . '-->', $value); - } - - public function testRenderedStyleTagsContainsDefaultMedia() - { - $this->helper->setStyle('a {}', array( - )); - $value = $this->helper->toString(); - $this->assertRegexp('#<style [^>]*?media="screen"#', $value, $value); - } - - public function testHeadStyleProxiesProperly() - { - $style1 = 'a {}'; - $style2 = 'a {}' . PHP_EOL . 'h1 {}'; - $style3 = 'a {}' . PHP_EOL . 'h2 {}'; - - $this->helper->headStyle($style1, 'SET') - ->headStyle($style2, 'PREPEND') - ->headStyle($style3, 'APPEND'); - $this->assertEquals(3, count($this->helper)); - $values = $this->helper->getArrayCopy(); - $this->assertTrue((strstr($values[0]->content, $style2)) ? true : false); - $this->assertTrue((strstr($values[1]->content, $style1)) ? true : false); - $this->assertTrue((strstr($values[2]->content, $style3)) ? true : false); - } - - public function testToStyleGeneratesValidHtml() - { - $style1 = 'a {}'; - $style2 = 'body {}' . PHP_EOL . 'h1 {}'; - $style3 = 'div {}' . PHP_EOL . 'li {}'; - - $this->helper->headStyle($style1, 'SET') - ->headStyle($style2, 'PREPEND') - ->headStyle($style3, 'APPEND'); - $html = $this->helper->toString(); - $doc = new DOMDocument; - $dom = $doc->loadHtml($html); - $this->assertTrue(($dom !== false)); - - $styles = substr_count($html, '<style type="text/css"'); - $this->assertEquals(3, $styles); - $styles = substr_count($html, '</style>'); - $this->assertEquals(3, $styles); - $this->assertContains($style3, $html); - $this->assertContains($style2, $html); - $this->assertContains($style1, $html); - } - - public function testCapturingCapturesToObject() - { - $this->helper->captureStart(); - echo 'foobar'; - $this->helper->captureEnd(); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - $item = array_shift($values); - $this->assertContains('foobar', $item->content); - } - - public function testOverloadingOffsetSetWritesToSpecifiedIndex() - { - $this->helper->offsetSetStyle(100, 'foobar'); - $values = $this->helper->getArrayCopy(); - $this->assertEquals(1, count($values)); - $this->assertTrue(isset($values[100])); - $item = $values[100]; - $this->assertContains('foobar', $item->content); - } - - public function testInvalidMethodRaisesException() - { - try { - $this->helper->bogusMethod(); - $this->fail('Invalid method should raise exception'); - } catch (Zend_View_Exception $e) { } - } - - public function testTooFewArgumentsRaisesException() - { - try { - $this->helper->appendStyle(); - $this->fail('Too few arguments should raise exception'); - } catch (Zend_View_Exception $e) { } - } - - public function testIndentationIsHonored() - { - $this->helper->setIndent(4); - $this->helper->appendStyle(' -a { - display: none; -}'); - $this->helper->appendStyle(' -h1 { - font-weight: bold -}'); - $string = $this->helper->toString(); - - $scripts = substr_count($string, ' <style'); - $this->assertEquals(2, $scripts); - $this->assertContains(' <!--', $string); - $this->assertContains(' a {', $string); - $this->assertContains(' h1 {', $string); - $this->assertContains(' display', $string); - $this->assertContains(' font-weight', $string); - $this->assertContains(' }', $string); - } - - public function testSerialCapturingWorks() - { - $this->helper->headStyle()->captureStart(); - echo "Captured text"; - $this->helper->headStyle()->captureEnd(); - - try { - $this->helper->headStyle()->captureStart(); - } catch (Zend_View_Exception $e) { - $this->fail('Serial capturing should work'); - } - $this->helper->headStyle()->captureEnd(); - } - - public function testNestedCapturingFails() - { - $this->helper->headStyle()->captureStart(); - echo "Captured text"; - try { - $this->helper->headStyle()->captureStart(); - $this->helper->headStyle()->captureEnd(); - $this->fail('Nested capturing should fail'); - } catch (Zend_View_Exception $e) { - $this->helper->headStyle()->captureEnd(); - $this->assertContains('Cannot nest', $e->getMessage()); - } - $this->helper->headStyle()->captureEnd(); - } -} - -// Call Zend_View_Helper_HeadStyleTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HeadStyleTest::main") { - Zend_View_Helper_HeadStyleTest::main(); -} diff --git a/tests/Zend/View/Helper/HeadTitleTest.php b/tests/Zend/View/Helper/HeadTitleTest.php deleted file mode 100644 index 4e162db1d2eadbeac22acd461cf063d35ddb54a6..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HeadTitleTest.php +++ /dev/null @@ -1,175 +0,0 @@ -<?php -// Call Zend_View_Helper_HeadTitleTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HeadTitleTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; - -/** Zend_View_Helper_HeadTitle */ -require_once 'Zend/View/Helper/HeadTitle.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_HeadTitle. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_HeadTitleTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HeadTitle - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HeadTitleTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_HeadTitle(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - if ($registry->containerExists('Zend_View_Helper_HeadTitle')) { - $registry->deleteContainer('Zend_View_Helper_HeadTitle'); - } - $this->assertFalse($registry->containerExists('Zend_View_Helper_HeadTitle')); - $helper = new Zend_View_Helper_HeadTitle(); - $this->assertTrue($registry->containerExists('Zend_View_Helper_HeadTitle')); - } - - public function testHeadTitleReturnsObjectInstance() - { - $placeholder = $this->helper->headTitle(); - $this->assertTrue($placeholder instanceof Zend_View_Helper_HeadTitle); - } - - public function testCanSetTitleViaHeadTitle() - { - $placeholder = $this->helper->headTitle('Foo Bar', 'SET'); - $this->assertContains('Foo Bar', $placeholder->toString()); - } - - public function testCanAppendTitleViaHeadTitle() - { - $placeholder = $this->helper->headTitle('Foo'); - $placeholder = $this->helper->headTitle('Bar'); - $this->assertContains('FooBar', $placeholder->toString()); - } - - public function testCanPrependTitleViaHeadTitle() - { - $placeholder = $this->helper->headTitle('Foo'); - $placeholder = $this->helper->headTitle('Bar', 'PREPEND'); - $this->assertContains('BarFoo', $placeholder->toString()); - } - - public function testReturnedPlaceholderToStringContainsFullTitleElement() - { - $placeholder = $this->helper->headTitle('Foo'); - $placeholder = $this->helper->headTitle('Bar', 'APPEND')->setSeparator(' :: '); - $this->assertEquals('<title>Foo :: Bar</title>', $placeholder->toString()); - } - - public function testToStringEscapesEntries() - { - $this->helper->headTitle('<script type="text/javascript">alert("foo");</script>'); - $string = $this->helper->toString(); - $this->assertNotContains('<script', $string); - $this->assertNotContains('</script>', $string); - } - - public function testToStringEscapesSeparator() - { - $this->helper->headTitle('Foo') - ->headTitle('Bar') - ->setSeparator(' <br /> '); - $string = $this->helper->toString(); - $this->assertNotContains('<br />', $string); - $this->assertContains('Foo', $string); - $this->assertContains('Bar', $string); - $this->assertContains('br /', $string); - } - - public function testIndentationIsHonored() - { - $this->helper->setIndent(4); - $this->helper->headTitle('foo'); - $string = $this->helper->toString(); - - $this->assertContains(' <title>', $string); - } - - public function testAutoEscapeIsHonored() - { - $this->helper->headTitle('Some Title ©right;'); - $this->assertEquals('<title>Some Title &copyright;</title>', $this->helper->toString()); - - $this->assertTrue($this->helper->headTitle()->getAutoEscape()); - $this->helper->headTitle()->setAutoEscape(false); - $this->assertFalse($this->helper->headTitle()->getAutoEscape()); - - - $this->assertEquals('<title>Some Title ©right;</title>', $this->helper->toString()); - } - - public function testZF2918() - { - $this->helper->headTitle('Some Title'); - $this->helper->setPrefix('Prefix: '); - $this->helper->setPostfix(' :Postfix'); - - $this->assertEquals('<title>Prefix: Some Title :Postfix</title>', $this->helper->toString()); - } -} - -// Call Zend_View_Helper_HeadTitleTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HeadTitleTest::main") { - Zend_View_Helper_HeadTitleTest::main(); -} diff --git a/tests/Zend/View/Helper/HtmlFlashTest.php b/tests/Zend/View/Helper/HtmlFlashTest.php deleted file mode 100644 index e79f800481a023ae2c58fc9ad73530652d595d1b..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HtmlFlashTest.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -// Call Zend_View_Helper_HtmlFlashTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HtmlFlashTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/HtmlFlash.php'; - -class Zend_View_Helper_HtmlFlashTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HtmlFlash - */ - public $helper; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HtmlFlashTest"); - PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_HtmlFlash(); - $this->helper->setView($this->view); - } - - public function tearDown() - { - unset($this->helper); - } - - public function testMakeHtmlFlash() - { - $htmlFlash = $this->helper->htmlFlash('/path/to/flash.swf'); - - $objectStartElement = '<object data="/path/to/flash.swf" type="application/x-shockwave-flash">'; - - $this->assertContains($objectStartElement, $htmlFlash); - $this->assertContains('</object>', $htmlFlash); - } -} - -// Call Zend_View_Helper_HtmlFlashTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HtmlFlashTest::main") { - Zend_View_Helper_HtmlFlashTest::main(); -} diff --git a/tests/Zend/View/Helper/HtmlListTest.php b/tests/Zend/View/Helper/HtmlListTest.php deleted file mode 100644 index af2eca69fb6b249b2a6357117b8d913201230570..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HtmlListTest.php +++ /dev/null @@ -1,224 +0,0 @@ -<?php -// Call Zend_View_Helper_HtmlListTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HtmlListTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/HtmlList.php'; - -class Zend_View_Helper_HtmlListTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HtmlList - */ - public $helper; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HtmlListTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_HtmlList(); - $this->helper->setView($this->view); - } - - public function tearDown() - { - unset($this->helper); - } - - public function testMakeUnorderedList() - { - $items = array('one', 'two', 'three'); - - $list = $this->helper->htmlList($items); - - $this->assertContains('<ul>', $list); - $this->assertContains('</ul>', $list); - foreach ($items as $item) { - $this->assertContains('<li>' . $item . '</li>', $list); - } - } - - public function testMakeOrderedList() - { - $items = array('one', 'two', 'three'); - - $list = $this->helper->htmlList($items, true); - - $this->assertContains('<ol>', $list); - $this->assertContains('</ol>', $list); - foreach ($items as $item) { - $this->assertContains('<li>' . $item . '</li>', $list); - } - } - - public function testMakeUnorderedListWithAttribs() - { - $items = array('one', 'two', 'three'); - $attribs = array('class' => 'selected', 'name' => 'list'); - - $list = $this->helper->htmlList($items, false, $attribs); - - $this->assertContains('<ul', $list); - $this->assertContains('class="selected"', $list); - $this->assertContains('name="list"', $list); - $this->assertContains('</ul>', $list); - foreach ($items as $item) { - $this->assertContains('<li>' . $item . '</li>', $list); - } - } - - public function testMakeOrderedListWithAttribs() - { - $items = array('one', 'two', 'three'); - $attribs = array('class' => 'selected', 'name' => 'list'); - - $list = $this->helper->htmlList($items, true, $attribs); - - $this->assertContains('<ol', $list); - $this->assertContains('class="selected"', $list); - $this->assertContains('name="list"', $list); - $this->assertContains('</ol>', $list); - foreach ($items as $item) { - $this->assertContains('<li>' . $item . '</li>', $list); - } - } - - public function testMakeNestedUnorderedList() - { - $items = array('one', array('four', 'five', 'six'), 'two', 'three'); - - $list = $this->helper->htmlList($items); - - $this->assertContains('<ul>', $list); - $this->assertContains('</ul>', $list); - $this->assertContains('one<ul><li>four', $list); - $this->assertContains('<li>six</li></ul></li><li>two', $list); - } - - public function testMakeNestedDeepUnorderedList() - { - $items = array('one', array('four', array('six', 'seven', 'eight'), 'five'), 'two', 'three'); - - $list = $this->helper->htmlList($items); - - $this->assertContains('<ul>', $list); - $this->assertContains('</ul>', $list); - $this->assertContains('one<ul><li>four', $list); - $this->assertContains('<li>four<ul><li>six', $list); - $this->assertContains('<li>five</li></ul></li><li>two', $list); - } - - public function testListWithValuesToEscapeForZF2283() - { - $items = array('one <small> test', 'second & third', 'And \'some\' "final" test'); - - $list = $this->helper->htmlList($items); - - $this->assertContains('<ul>', $list); - $this->assertContains('</ul>', $list); - - $this->assertContains('<li>one <small> test</li>', $list); - $this->assertContains('<li>second & third</li>', $list); - $this->assertContains('<li>And \'some\' "final" test</li>', $list); - } - - public function testListEscapeSwitchedOffForZF2283() - { - $items = array('one <b>small</b> test'); - - $list = $this->helper->htmlList($items, false, false, false); - - $this->assertContains('<ul>', $list); - $this->assertContains('</ul>', $list); - - $this->assertContains('<li>one <b>small</b> test</li>', $list); - } - - /** - * @see ZF-2527 - */ - public function testEscapeFlagHonoredForMultidimensionalLists() - { - $items = array('<b>one</b>', array('<b>four</b>', '<b>five</b>', '<b>six</b>'), '<b>two</b>', '<b>three</b>'); - - $list = $this->helper->htmlList($items, false, false, false); - - foreach ($items[1] as $item) { - $this->assertContains($item, $list); - } - } - - /** - * @see ZF-2527 - */ - public function testAttribsPassedIntoMultidimensionalLists() - { - $items = array('one', array('four', 'five', 'six'), 'two', 'three'); - - $list = $this->helper->htmlList($items, false, array('class' => 'foo')); - - foreach ($items[1] as $item) { - $this->assertRegexp('#<ul[^>]*?class="foo"[^>]*>.*?(<li>' . $item . ')#', $list); - } - } - - /** - * @see ZF-2870 - */ - public function testEscapeFlagShouldBePassedRecursively() - { - $items = array( - '<b>one</b>', - array( - '<b>four</b>', - '<b>five</b>', - '<b>six</b>', - array( - '<b>two</b>', - '<b>three</b>', - ), - ), - ); - - $list = $this->helper->htmlList($items, false, false, false); - - $this->assertContains('<ul>', $list); - $this->assertContains('</ul>', $list); - array_walk_recursive($items, array($this, 'validateItems'), $list); - } - - public function validateItems($value, $key, $userdata) - { - $this->assertContains('<li>' . $value, $userdata); - } -} - -// Call Zend_View_Helper_HtmlListTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HtmlListTest::main") { - Zend_View_Helper_HtmlListTest::main(); -} diff --git a/tests/Zend/View/Helper/HtmlObjectTest.php b/tests/Zend/View/Helper/HtmlObjectTest.php deleted file mode 100644 index a6d66e1728cdc08cf7c7aea5e884cbd6215b2674..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HtmlObjectTest.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php -// Call Zend_View_Helper_HtmlObjectTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HtmlObjectTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/HtmlObject.php'; - -class Zend_View_Helper_HtmlObjectTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HtmlObject - */ - public $helper; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HtmlObjectTest"); - PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_HtmlObject(); - $this->helper->setView($this->view); - } - - public function tearDown() - { - unset($this->helper); - } - - public function testViewObjectIsSet() - { - $this->assertType('Zend_View_Interface', $this->helper->view); - } - - public function testMakeHtmlObjectWithoutAttribsWithoutParams() - { - $htmlObject = $this->helper->htmlObject('datastring', 'typestring'); - - $this->assertContains('<object data="datastring" type="typestring">', $htmlObject); - $this->assertContains('</object>', $htmlObject); - } - - public function testMakeHtmlObjectWithAttribsWithoutParams() - { - $attribs = array('attribkey1' => 'attribvalue1', - 'attribkey2' => 'attribvalue2'); - - $htmlObject = $this->helper->htmlObject('datastring', 'typestring', $attribs); - - $this->assertContains('<object data="datastring" type="typestring" attribkey1="attribvalue1" attribkey2="attribvalue2">', $htmlObject); - $this->assertContains('</object>', $htmlObject); - } - - public function testMakeHtmlObjectWithoutAttribsWithParamsHtml() - { - $this->view->doctype(Zend_View_Helper_Doctype::HTML4_STRICT); - - $params = array('paramname1' => 'paramvalue1', - 'paramname2' => 'paramvalue2'); - - $htmlObject = $this->helper->htmlObject('datastring', 'typestring', array(), $params); - - $this->assertContains('<object data="datastring" type="typestring">', $htmlObject); - $this->assertContains('</object>', $htmlObject); - - foreach ($params as $key => $value) { - $param = '<param name="' . $key . '" value="' . $value . '">'; - - $this->assertContains($param, $htmlObject); - } - } - - public function testMakeHtmlObjectWithoutAttribsWithParamsXhtml() - { - $this->view->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT); - - $params = array('paramname1' => 'paramvalue1', - 'paramname2' => 'paramvalue2'); - - $htmlObject = $this->helper->htmlObject('datastring', 'typestring', array(), $params); - - $this->assertContains('<object data="datastring" type="typestring">', $htmlObject); - $this->assertContains('</object>', $htmlObject); - - foreach ($params as $key => $value) { - $param = '<param name="' . $key . '" value="' . $value . '" />'; - - $this->assertContains($param, $htmlObject); - } - } - - public function testMakeHtmlObjectWithContent() - { - $htmlObject = $this->helper->htmlObject('datastring', 'typestring', array(), array(), 'testcontent'); - - $this->assertContains('<object data="datastring" type="typestring">', $htmlObject); - $this->assertContains('testcontent', $htmlObject); - $this->assertContains('</object>', $htmlObject); - } -} - -// Call Zend_View_Helper_HtmlObjectTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HtmlObjectTest::main") { - Zend_View_Helper_HtmlObjectTest::main(); -} diff --git a/tests/Zend/View/Helper/HtmlPageTest.php b/tests/Zend/View/Helper/HtmlPageTest.php deleted file mode 100644 index a42e46b702fa199e2a095faec50aa6575f5fa91a..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HtmlPageTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -// Call Zend_View_Helper_HtmlPageTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HtmlPageTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/HtmlPage.php'; - -class Zend_View_Helper_HtmlPageTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HtmlPage - */ - public $helper; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HtmlPageTest"); - PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_HtmlPage(); - $this->helper->setView($this->view); - } - - public function tearDown() - { - unset($this->helper); - } - - public function testMakeHtmlPage() - { - $htmlPage = $this->helper->htmlPage('/path/to/page.html'); - - $objectStartElement = '<object data="/path/to/page.html"' - . ' type="text/html"' - . ' classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13">'; - - $this->assertContains($objectStartElement, $htmlPage); - $this->assertContains('</object>', $htmlPage); - } -} - -// Call Zend_View_Helper_HtmlPageTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HtmlPageTest::main") { - Zend_View_Helper_HtmlPageTest::main(); -} diff --git a/tests/Zend/View/Helper/HtmlQuicktimeTest.php b/tests/Zend/View/Helper/HtmlQuicktimeTest.php deleted file mode 100644 index cf258587fddede1cbe556d44c4781e86cbe4ab75..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/HtmlQuicktimeTest.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -// Call Zend_View_Helper_HtmlQuicktimeTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_HtmlQuicktimeTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/HtmlQuicktime.php'; - -class Zend_View_Helper_HtmlQuicktimeTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_HtmlQuicktime - */ - public $helper; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_HtmlQuicktimeTest"); - PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_HtmlQuicktime(); - $this->helper->setView($this->view); - } - - public function tearDown() - { - unset($this->helper); - } - - public function testMakeHtmlQuicktime() - { - $htmlQuicktime = $this->helper->htmlQuicktime('/path/to/quicktime.mov'); - - $objectStartElement = '<object data="/path/to/quicktime.mov"' - . ' type="video/quicktime"' - . ' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' - . ' codebase="http://www.apple.com/qtactivex/qtplugin.cab">'; - - $this->assertContains($objectStartElement, $htmlQuicktime); - $this->assertContains('</object>', $htmlQuicktime); - } -} - -// Call Zend_View_Helper_HtmlQuicktimeTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HtmlQuicktimeTest::main") { - Zend_View_Helper_HtmlQuicktimeTest::main(); -} diff --git a/tests/Zend/View/Helper/InlineScriptTest.php b/tests/Zend/View/Helper/InlineScriptTest.php deleted file mode 100644 index 4d19d07e30eb73aa7b572dd9176b0fcf088336c8..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/InlineScriptTest.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -// Call Zend_View_Helper_InlineScriptTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_InlineScriptTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_InlineScript */ -require_once 'Zend/View/Helper/InlineScript.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_InlineScript. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_InlineScriptTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_InlineScript - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_InlineScriptTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_InlineScript(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - if ($registry->containerExists('Zend_View_Helper_InlineScript')) { - $registry->deleteContainer('Zend_View_Helper_InlineScript'); - } - $this->assertFalse($registry->containerExists('Zend_View_Helper_InlineScript')); - $helper = new Zend_View_Helper_InlineScript(); - $this->assertTrue($registry->containerExists('Zend_View_Helper_InlineScript')); - } - - public function testInlineScriptReturnsObjectInstance() - { - $placeholder = $this->helper->inlineScript(); - $this->assertTrue($placeholder instanceof Zend_View_Helper_InlineScript); - } -} - -// Call Zend_View_Helper_InlineScriptTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_InlineScriptTest::main") { - Zend_View_Helper_InlineScriptTest::main(); -} diff --git a/tests/Zend/View/Helper/JsonTest.php b/tests/Zend/View/Helper/JsonTest.php deleted file mode 100644 index c9407c6cd1e44be5ddc169e3c8c21c0480fbfd3a..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/JsonTest.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -// Call Zend_View_Helper_JsonTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_JsonTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View/Helper/Json.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Response/Http.php'; -require_once 'Zend/Json.php'; -require_once 'Zend/Layout.php'; - -/** - * Test class for Zend_View_Helper_Json - */ -class Zend_View_Helper_JsonTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_JsonTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_View_Helper_JsonTest_Layout::$_mvcInstance = null; - - $this->response = new Zend_Controller_Response_Http(); - $this->response->headersSentThrowsException = false; - - $front = Zend_Controller_Front::getInstance(); - $front->resetInstance(); - $front->setResponse($this->response); - - $this->helper = new Zend_View_Helper_Json(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function verifyJsonHeader() - { - $headers = $this->response->getHeaders(); - - $found = false; - foreach ($headers as $header) { - if ('Content-Type' == $header['name']) { - $found = true; - $value = $header['value']; - break; - } - } - $this->assertTrue($found); - $this->assertEquals('application/json', $value); - } - - public function testJsonHelperSetsResponseHeader() - { - $this->helper->json('foobar'); - $this->verifyJsonHeader(); - } - - public function testJsonHelperReturnsJsonEncodedString() - { - $data = $this->helper->json(array('foobar')); - $this->assertTrue(is_string($data)); - $this->assertEquals(array('foobar'), Zend_Json::decode($data)); - } - - public function testJsonHelperDisablesLayoutsByDefault() - { - $layout = Zend_Layout::startMvc(); - $this->assertTrue($layout->isEnabled()); - $this->testJsonHelperReturnsJsonEncodedString(); - $this->assertFalse($layout->isEnabled()); - } - - public function testJsonHelperDoesNotDisableLayoutsWhenKeepLayoutFlagTrue() - { - $layout = Zend_Layout::startMvc(); - $this->assertTrue($layout->isEnabled()); - $data = $this->helper->json(array('foobar'), true); - $this->assertTrue($layout->isEnabled()); - } -} - -/** - * Zend_Layout subclass to allow resetting MVC instance - */ -class Zend_View_Helper_JsonTest_Layout extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_View_Helper_JsonTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_JsonTest::main") { - Zend_View_Helper_JsonTest::main(); -} diff --git a/tests/Zend/View/Helper/LayoutTest.php b/tests/Zend/View/Helper/LayoutTest.php deleted file mode 100644 index 2c645ba77517595476256ff4aa8d2765fd8b1f8d..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/LayoutTest.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -// Call Zend_LayoutTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_LayoutTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View/Helper/Layout.php'; -require_once 'Zend/Layout.php'; -require_once 'Zend/Controller/Front.php'; -require_once 'Zend/Controller/Action/HelperBroker.php'; - -/** - * Test class for Zend_View_Helper_Layout - */ -class Zend_View_Helper_LayoutTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_LayoutTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - Zend_Controller_Front::getInstance()->resetInstance(); - if (Zend_Controller_Action_HelperBroker::hasHelper('Layout')) { - Zend_Controller_Action_HelperBroker::removeHelper('Layout'); - } - if (Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) { - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - } - - Zend_View_Helper_LayoutTest_Layout::$_mvcInstance = null; - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - } - - public function testGetLayoutCreatesLayoutObjectWhenNoPluginRegistered() - { - $helper = new Zend_View_Helper_Layout(); - $layout = $helper->getLayout(); - $this->assertTrue($layout instanceof Zend_Layout); - } - - public function testGetLayoutPullsLayoutObjectFromRegisteredPlugin() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_View_Helper_Layout(); - $this->assertSame($layout, $helper->getLayout()); - } - - public function testSetLayoutReplacesExistingLayoutObject() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_View_Helper_Layout(); - $this->assertSame($layout, $helper->getLayout()); - - $newLayout = new Zend_Layout(); - $this->assertNotSame($layout, $newLayout); - - $helper->setLayout($newLayout); - $this->assertSame($newLayout, $helper->getLayout()); - } - - public function testHelperMethodFetchesLayoutObject() - { - $layout = Zend_Layout::startMvc(); - $helper = new Zend_View_Helper_Layout(); - - $received = $helper->layout(); - $this->assertSame($layout, $received); - } -} - -/** - * Zend_Layout extension to allow resetting MVC instance - */ -class Zend_View_Helper_LayoutTest_Layout extends Zend_Layout -{ - public static $_mvcInstance; -} - -// Call Zend_View_Helper_LayoutTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_LayoutTest::main") { - Zend_View_Helper_LayoutTest::main(); -} diff --git a/tests/Zend/View/Helper/PaginationControlTest.php b/tests/Zend/View/Helper/PaginationControlTest.php deleted file mode 100644 index 2d2a04547bdc3b0dcdb76aa7068a0b0fce7e5742..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/PaginationControlTest.php +++ /dev/null @@ -1,177 +0,0 @@ -<?php -// Call Zend_View_Helper_PaginationControlTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_PaginationControlTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -require_once 'Zend/View.php'; -require_once 'Zend/Paginator.php'; -require_once 'Zend/View/Helper/PaginationControl.php'; - -class Zend_View_Helper_PaginationControlTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_PaginationControl - */ - private $_viewHelper; - - private $_paginator; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_PaginationControlTest"); - PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $view = new Zend_View(); - $view->addBasePath(dirname(__FILE__) . '/_files'); - $view->addHelperPath('Zend/View/Helper/', 'Zend_View_Helper'); - - $this->_viewHelper = new Zend_View_Helper_PaginationControl(); - $this->_viewHelper->setView($view); - $this->_paginator = Zend_Paginator::factory(range(1, 101)); - } - - public function tearDown() - { - unset($this->_viewHelper); - unset($this->_paginator); - } - - public function testGetsAndSetsView() - { - $view = new Zend_View(); - $helper = new Zend_View_Helper_PaginationControl(); - $this->assertNull($helper->view); - $helper->setView($view); - $this->assertType('Zend_View_Interface', $helper->view); - } - - public function testGetsAndSetsDefaultViewPartial() - { - $this->assertNull(Zend_View_Helper_PaginationControl::getDefaultViewPartial()); - Zend_View_Helper_PaginationControl::setDefaultViewPartial('partial'); - $this->assertEquals('partial', Zend_View_Helper_PaginationControl::getDefaultViewPartial()); - Zend_View_Helper_PaginationControl::setDefaultViewPartial(null); - } - - public function testUsesDefaultViewPartialIfNoneSupplied() - { - Zend_View_Helper_PaginationControl::setDefaultViewPartial('testPagination.phtml'); - $output = $this->_viewHelper->paginationControl($this->_paginator); - $this->assertContains('pagination control', $output, $output); - Zend_View_Helper_PaginationControl::setDefaultViewPartial(null); - } - - public function testThrowsExceptionIfNoViewPartialFound() - { - try { - $this->_viewHelper->paginationControl($this->_paginator); - } catch (Exception $e) { - $this->assertType('Zend_View_Exception', $e); - $this->assertEquals('No view partial provided and no default set', $e->getMessage()); - } - } - - /** - * @group ZF-4037 - */ - public function testUsesDefaultScrollingStyleIfNoneSupplied() - { - // First we'll make sure the base case works - $output = $this->_viewHelper->paginationControl($this->_paginator, 'All', 'testPagination.phtml'); - $this->assertContains('page count (11) equals pages in range (11)', $output, $output); - - Zend_Paginator::setDefaultScrollingStyle('All'); - $output = $this->_viewHelper->paginationControl($this->_paginator, null, 'testPagination.phtml'); - $this->assertContains('page count (11) equals pages in range (11)', $output, $output); - - Zend_View_Helper_PaginationControl::setDefaultViewPartial('testPagination.phtml'); - $output = $this->_viewHelper->paginationControl($this->_paginator); - $this->assertContains('page count (11) equals pages in range (11)', $output, $output); - } - - /** - * @group ZF-4153 - */ - public function testUsesPaginatorFromViewIfNoneSupplied() - { - $this->_viewHelper->view->paginator = $this->_paginator; - Zend_View_Helper_PaginationControl::setDefaultViewPartial('testPagination.phtml'); - - try { - $output = $this->_viewHelper->paginationControl(); - } catch (Zend_View_Exception $e) { - $this->fail('Could not find paginator in the view instance'); - } - - $this->assertContains('pagination control', $output, $output); - } - - /** - * @group ZF-4153 - */ - public function testThrowsExceptionIfNoPaginatorFound() - { - Zend_View_Helper_PaginationControl::setDefaultViewPartial('testPagination.phtml'); - - try { - $output = $this->_viewHelper->paginationControl(); - } catch (Exception $e) { - $this->assertType('Zend_View_Exception', $e); - $this->assertEquals('No paginator instance provided nor found', $e->getMessage()); - } - } - - /** - * @group ZF-4233 - */ - public function testAcceptsViewPartialInOtherModule() - { - try { - $this->_viewHelper->paginationControl($this->_paginator, null, array('partial.phtml', 'test')); - } catch (Exception $e) { - /* We don't care whether or not the module exists--we just want to - * make sure it gets to Zend_View_Helper_Partial and it's recognized - * as a module. */ - $this->assertType('Zend_View_Helper_Partial_Exception', $e); - $this->assertEquals('Cannot render partial; module does not exist', $e->getMessage()); - } - } - - /** - * @group ZF-4328 - */ - public function testUsesPaginatorFromViewOnlyIfNoneSupplied() - { - $this->_viewHelper->view->paginator = $this->_paginator; - $paginator = Zend_Paginator::factory(range(1, 30)); - Zend_View_Helper_PaginationControl::setDefaultViewPartial('testPagination.phtml'); - - $output = $this->_viewHelper->paginationControl($paginator); - $this->assertContains('page count (3)', $output, $output); - } -} - -// Call Zend_View_Helper_PaginationControlTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_PaginationControlTest::main") { - Zend_View_Helper_PaginationControlTest::main(); -} diff --git a/tests/Zend/View/Helper/PartialLoopTest.php b/tests/Zend/View/Helper/PartialLoopTest.php deleted file mode 100644 index 2b125906a35cf623b4dea875a05933dbec1c0489..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/PartialLoopTest.php +++ /dev/null @@ -1,461 +0,0 @@ -<?php -// Call Zend_View_Helper_PartialLoopTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_PartialLoopTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_PartialLoop */ -require_once 'Zend/View/Helper/PartialLoop.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Controller_Front */ -require_once 'Zend/Controller/Front.php'; - -/** - * Test class for Zend_View_Helper_PartialLoop. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_PartialLoopTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_PartialLoop - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_PartialLoopTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_PartialLoop(); - Zend_Controller_Front::getInstance()->resetInstance(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - /** - * @return void - */ - public function testPartialLoopIteratesOverArray() - { - $data = array( - array('message' => 'foo'), - array('message' => 'bar'), - array('message' => 'baz'), - array('message' => 'bat') - ); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - $result = $this->helper->partialLoop('partialLoop.phtml', $data); - foreach ($data as $item) { - $string = 'This is an iteration: ' . $item['message']; - $this->assertContains($string, $result); - } - } - - /** - * @return void - */ - public function testPartialLoopIteratesOverIterator() - { - $data = array( - array('message' => 'foo'), - array('message' => 'bar'), - array('message' => 'baz'), - array('message' => 'bat') - ); - $o = new Zend_View_Helper_PartialLoop_IteratorTest($data); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - $result = $this->helper->partialLoop('partialLoop.phtml', $o); - foreach ($data as $item) { - $string = 'This is an iteration: ' . $item['message']; - $this->assertContains($string, $result); - } - } - - /** - * @return void - */ - public function testPartialLoopIteratesOverRecursiveIterator() - { - $rIterator = new Zend_View_Helper_PartialLoop_RecursiveIteratorTest(); - for ($i = 0; $i < 5; ++$i) { - $data = array( - 'message' => 'foo' . $i, - ); - $rIterator->addItem(new Zend_View_Helper_PartialLoop_IteratorTest($data)); - } - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - $result = $this->helper->partialLoop('partialLoop.phtml', $rIterator); - foreach ($rIterator as $item) { - foreach ($item as $key => $value) { - $this->assertContains($value, $result, var_export($value, 1)); - } - } - } - - /** - * @return void - */ - public function testPartialLoopThrowsExceptionWithBadIterator() - { - $data = array( - array('message' => 'foo'), - array('message' => 'bar'), - array('message' => 'baz'), - array('message' => 'bat') - ); - $o = new Zend_View_Helper_PartialLoop_BogusIteratorTest($data); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - try { - $result = $this->helper->partialLoop('partialLoop.phtml', $o); - $this->fail('PartialLoop should only work with arrays and iterators'); - } catch (Exception $e) { - } - } - - /** - * @return void - */ - public function testPartialLoopFindsModule() - { - Zend_Controller_Front::getInstance()->addModuleDirectory($this->basePath); - $data = array( - array('message' => 'foo'), - array('message' => 'bar'), - array('message' => 'baz'), - array('message' => 'bat') - ); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - $result = $this->helper->partialLoop('partialLoop.phtml', 'foo', $data); - foreach ($data as $item) { - $string = 'This is an iteration in the foo module: ' . $item['message']; - $this->assertContains($string, $result); - } - } - - public function testPassingNoArgsReturnsHelperInstance() - { - $test = $this->helper->partialLoop(); - $this->assertSame($this->helper, $test); - } - - public function testShouldAllowIteratingOverTraversableObjects() - { - $data = array( - array('message' => 'foo'), - array('message' => 'bar'), - array('message' => 'baz'), - array('message' => 'bat') - ); - $o = new ArrayObject($data); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - $result = $this->helper->partialLoop('partialLoop.phtml', $o); - foreach ($data as $item) { - $string = 'This is an iteration: ' . $item['message']; - $this->assertContains($string, $result); - } - } - - public function testShouldAllowIteratingOverObjectsImplementingToArray() - { - $data = array( - array('message' => 'foo'), - array('message' => 'bar'), - array('message' => 'baz'), - array('message' => 'bat') - ); - $o = new Zend_View_Helper_PartialLoop_ToArrayTest($data); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - $result = $this->helper->partialLoop('partialLoop.phtml', $o); - foreach ($data as $item) { - $string = 'This is an iteration: ' . $item['message']; - $this->assertContains($string, $result, $result); - } - } - - /** - * @see ZF-3350 - * @see ZF-3352 - */ - public function testShouldNotCastToArrayIfObjectIsTraversable() - { - $data = array( - new Zend_View_Helper_PartialLoop_IteratorWithToArrayTestContainer(array('message' => 'foo')), - new Zend_View_Helper_PartialLoop_IteratorWithToArrayTestContainer(array('message' => 'bar')), - new Zend_View_Helper_PartialLoop_IteratorWithToArrayTestContainer(array('message' => 'baz')), - new Zend_View_Helper_PartialLoop_IteratorWithToArrayTestContainer(array('message' => 'bat')), - ); - $o = new Zend_View_Helper_PartialLoop_IteratorWithToArrayTest($data); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - $this->helper->setObjectKey('obj'); - - $result = $this->helper->partialLoop('partialLoopObject.phtml', $o); - foreach ($data as $item) { - $string = 'This is an iteration: ' . $item->message; - $this->assertContains($string, $result, $result); - } - } - - /** - * @see ZF-3083 - */ - public function testEmptyArrayPassedToPartialLoopShouldNotThrowException() - { - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - try { - $result = $this->helper->partialLoop('partialLoop.phtml', array()); - } catch (Exception $e) { - $this->fail('Empty array should not cause partialLoop to throw exception'); - } - - try { - $result = $this->helper->partialLoop('partialLoop.phtml', null, array()); - } catch (Exception $e) { - $this->fail('Empty array should not cause partialLoop to throw exception'); - } - } -} - -class Zend_View_Helper_PartialLoop_IteratorTest implements Iterator -{ - public $items; - - public function __construct(array $array) - { - $this->items = $array; - } - - public function current() - { - return current($this->items); - } - - public function key() - { - return key($this->items); - } - - public function next() - { - return next($this->items); - } - - public function rewind() - { - return reset($this->items); - } - - public function valid() - { - return (current($this->items) !== false); - } - - public function toArray() - { - return $this->items; - } -} - -class Zend_View_Helper_PartialLoop_RecursiveIteratorTest implements Iterator -{ - public $items; - - public function __construct() - { - $this->items = array(); - } - - public function addItem(Iterator $iterator) - { - $this->items[] = $iterator; - return $this; - } - - public function current() - { - return current($this->items); - } - - public function key() - { - return key($this->items); - } - - public function next() - { - return next($this->items); - } - - public function rewind() - { - return reset($this->items); - } - - public function valid() - { - return (current($this->items) !== false); - } -} - -class Zend_View_Helper_PartialLoop_BogusIteratorTest -{ -} - -class Zend_View_Helper_PartialLoop_ToArrayTest -{ - public function __construct(array $data) - { - $this->data = $data; - } - - public function toArray() - { - return $this->data; - } -} - -class Zend_View_Helper_PartialLoop_IteratorWithToArrayTest implements Iterator -{ - public $items; - - public function __construct(array $array) - { - $this->items = $array; - } - - public function toArray() - { - return $this->items; - } - - public function current() - { - return current($this->items); - } - - public function key() - { - return key($this->items); - } - - public function next() - { - return next($this->items); - } - - public function rewind() - { - return reset($this->items); - } - - public function valid() - { - return (current($this->items) !== false); - } -} - -class Zend_View_Helper_PartialLoop_IteratorWithToArrayTestContainer -{ - protected $_info; - - public function __construct(array $info) - { - foreach ($info as $key => $value) { - $this->$key = $value; - } - $this->_info = $info; - } - - public function toArray() - { - return $this->_info; - } -} - -// Call Zend_View_Helper_PartialLoopTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_PartialLoopTest::main") { - Zend_View_Helper_PartialLoopTest::main(); -} diff --git a/tests/Zend/View/Helper/PartialTest.php b/tests/Zend/View/Helper/PartialTest.php deleted file mode 100644 index 17b04ea8728b0531510530583eb6a48e09aa9bd4..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/PartialTest.php +++ /dev/null @@ -1,277 +0,0 @@ -<?php -// Call Zend_View_Helper_PartialTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_PartialTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_Partial */ -require_once 'Zend/View/Helper/Partial.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** Zend_Controller_Front */ -require_once 'Zend/Controller/Front.php'; - -/** - * Test class for Zend_View_Helper_Partial. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_PartialTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_Partial - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_PartialTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_Partial(); - Zend_Controller_Front::getInstance()->resetInstance(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - /** - * @return void - */ - public function testPartialRendersScript() - { - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - $return = $this->helper->partial('partialOne.phtml'); - $this->assertContains('This is the first test partial', $return); - } - - /** - * @return void - */ - public function testPartialRendersScriptWithVars() - { - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $view->message = 'This should never be read'; - $this->helper->setView($view); - $return = $this->helper->partial('partialThree.phtml', array('message' => 'This message should be read')); - $this->assertNotContains($view->message, $return); - $this->assertContains('This message should be read', $return, $return); - } - - /** - * @return void - */ - public function testPartialRendersScriptInDifferentModuleWhenRequested() - { - Zend_Controller_Front::getInstance()->addModuleDirectory($this->basePath); - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - $return = $this->helper->partial('partialTwo.phtml', 'foo'); - $this->assertContains('This is the second partial', $return, $return); - } - - /** - * @return void - */ - public function testPartialThrowsExceptionWithInvalidModule() - { - Zend_Controller_Front::getInstance()->addModuleDirectory($this->basePath); - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - - try { - $return = $this->helper->partial('partialTwo.phtml', 'barbazbat'); - $this->fail('Partial should throw exception if module does not exist'); - } catch (Exception $e) { - } - } - - /** - * @return void - */ - public function testSetViewSetsViewProperty() - { - $view = new Zend_View(); - $this->helper->setView($view); - $this->assertSame($view, $this->helper->view); - } - - /** - * @return void - */ - public function testCloneViewReturnsDifferentViewInstance() - { - $view = new Zend_View(); - $this->helper->setView($view); - $clone = $this->helper->cloneView(); - $this->assertNotSame($view, $clone); - $this->assertTrue($clone instanceof Zend_View); - } - - /** - * @return void - */ - public function testCloneViewClearsViewVariables() - { - $view = new Zend_View(); - $view->foo = 'bar'; - $this->helper->setView($view); - - $clone = $this->helper->cloneView(); - $clonedVars = $clone->getVars(); - - $this->assertTrue(empty($clonedVars)); - $this->assertNull($clone->foo); - } - - public function testObjectModelWithPublicPropertiesSetsViewVariables() - { - $model = new stdClass(); - $model->foo = 'bar'; - $model->bar = 'baz'; - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - $return = $this->helper->partial('partialVars.phtml', $model); - - foreach (get_object_vars($model) as $key => $value) { - $string = sprintf('%s: %s', $key, $value); - $this->assertContains($string, $return); - } - } - - public function testObjectModelWithToArraySetsViewVariables() - { - $model = new Zend_View_Helper_PartialTest_Aggregate(); - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - $return = $this->helper->partial('partialVars.phtml', $model); - - foreach ($model->toArray() as $key => $value) { - $string = sprintf('%s: %s', $key, $value); - $this->assertContains($string, $return); - } - } - - public function testObjectModelSetInObjectKeyWhenKeyPresent() - { - $this->helper->setObjectKey('foo'); - $model = new stdClass(); - $model->footest = 'bar'; - $model->bartest = 'baz'; - - $view = new Zend_View(array( - 'scriptPath' => $this->basePath . '/default/views/scripts' - )); - $this->helper->setView($view); - $return = $this->helper->partial('partialObj.phtml', $model); - - $this->assertNotContains('No object model passed', $return); - - foreach (get_object_vars($model) as $key => $value) { - $string = sprintf('%s: %s', $key, $value); - $this->assertContains($string, $return); - } - } - - public function testPassingNoArgsReturnsHelperInstance() - { - $test = $this->helper->partial(); - $this->assertSame($this->helper, $test); - } - - public function testObjectKeyIsNullByDefault() - { - $this->assertNull($this->helper->getObjectKey()); - } - - public function testCanSetObjectKey() - { - $this->testObjectKeyIsNullByDefault(); - $this->helper->setObjectKey('foo'); - $this->assertEquals('foo', $this->helper->getObjectKey()); - } - - public function testCanSetObjectKeyToNullValue() - { - $this->testCanSetObjectKey(); - $this->helper->setObjectKey(null); - $this->assertNull($this->helper->getObjectKey()); - } - - public function testSetObjectKeyImplementsFluentInterface() - { - $test = $this->helper->setObjectKey('foo'); - $this->assertSame($this->helper, $test); - } -} - -class Zend_View_Helper_PartialTest_Aggregate -{ - public $vars = array( - 'foo' => 'bar', - 'bar' => 'baz' - ); - - public function toArray() - { - return $this->vars; - } -} - -// Call Zend_View_Helper_PartialTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_PartialTest::main") { - Zend_View_Helper_PartialTest::main(); -} diff --git a/tests/Zend/View/Helper/Placeholder/ContainerTest.php b/tests/Zend/View/Helper/Placeholder/ContainerTest.php deleted file mode 100644 index c4b3b3746382082e41d240f209fed5f1cba78616..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/Placeholder/ContainerTest.php +++ /dev/null @@ -1,430 +0,0 @@ -<?php -// Call Zend_View_Helper_Placeholder_Container_AbstractTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_Placeholder_ContainerTest::main"); -} - -require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_Placeholder_Container */ -require_once 'Zend/View/Helper/Placeholder/Container.php'; - -/** - * Test class for Zend_View_Helper_Placeholder_Container. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_Placeholder_ContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_Placeholder_Container - */ - public $container; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_Placeholder_ContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->container = new Zend_View_Helper_Placeholder_Container(array()); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->container); - } - - /** - * @return void - */ - public function testSetSetsASingleValue() - { - $this->container['foo'] = 'bar'; - $this->container['bar'] = 'baz'; - $this->assertEquals('bar', $this->container['foo']); - $this->assertEquals('baz', $this->container['bar']); - - $this->container->set('foo'); - $this->assertEquals(1, count($this->container)); - $this->assertEquals('foo', $this->container[0]); - } - - /** - * @return void - */ - public function testGetValueReturnsScalarWhenOneElementRegistered() - { - $this->container->set('foo'); - $this->assertEquals('foo', $this->container->getValue()); - } - - /** - * @return void - */ - public function testGetValueReturnsArrayWhenMultipleValuesPresent() - { - $this->container['foo'] = 'bar'; - $this->container['bar'] = 'baz'; - $expected = array('foo' => 'bar', 'bar' => 'baz'); - $return = $this->container->getValue(); - $this->assertEquals($expected, $return); - } - - /** - * @return void - */ - public function testPrefixAccesorsWork() - { - $this->assertEquals('', $this->container->getPrefix()); - $this->container->setPrefix('<ul><li>'); - $this->assertEquals('<ul><li>', $this->container->getPrefix()); - } - - /** - * @return void - */ - public function testSetPrefixImplementsFluentInterface() - { - $result = $this->container->setPrefix('<ul><li>'); - $this->assertSame($this->container, $result); - } - - /** - * @return void - */ - public function testPostfixAccesorsWork() - { - $this->assertEquals('', $this->container->getPostfix()); - $this->container->setPostfix('</li></ul>'); - $this->assertEquals('</li></ul>', $this->container->getPostfix()); - } - - /** - * @return void - */ - public function testSetPostfixImplementsFluentInterface() - { - $result = $this->container->setPostfix('</li></ul>'); - $this->assertSame($this->container, $result); - } - - /** - * @return void - */ - public function testSeparatorAccesorsWork() - { - $this->assertEquals('', $this->container->getSeparator()); - $this->container->setSeparator('</li><li>'); - $this->assertEquals('</li><li>', $this->container->getSeparator()); - } - - /** - * @return void - */ - public function testSetSeparatorImplementsFluentInterface() - { - $result = $this->container->setSeparator('</li><li>'); - $this->assertSame($this->container, $result); - } - - /** - * @return void - */ - public function testIndentAccesorsWork() - { - $this->assertEquals('', $this->container->getIndent()); - $this->container->setIndent(' '); - $this->assertEquals(' ', $this->container->getIndent()); - $this->container->setIndent(5); - $this->assertEquals(' ', $this->container->getIndent()); - } - - /** - * @return void - */ - public function testSetIndentImplementsFluentInterface() - { - $result = $this->container->setIndent(' '); - $this->assertSame($this->container, $result); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderStoresContent() - { - $this->container->captureStart(); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $value = $this->container->getValue(); - $this->assertContains('This is content intended for capture', $value); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderAppendsContent() - { - $this->container[] = 'foo'; - $originalCount = count($this->container); - - $this->container->captureStart(); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $this->assertEquals($originalCount + 1, count($this->container)); - - $value = $this->container->getValue(); - $keys = array_keys($value); - $lastIndex = array_pop($keys); - $this->assertEquals('foo', $value[$lastIndex - 1]); - $this->assertContains('This is content intended for capture', $value[$lastIndex]); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderUsingPrependPrependsContent() - { - $this->container[] = 'foo'; - $originalCount = count($this->container); - - $this->container->captureStart('PREPEND'); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $this->assertEquals($originalCount + 1, count($this->container)); - - $value = $this->container->getValue(); - $keys = array_keys($value); - $lastIndex = array_pop($keys); - $this->assertEquals('foo', $value[$lastIndex]); - $this->assertContains('This is content intended for capture', $value[$lastIndex - 1]); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderUsingSetOverwritesContent() - { - $this->container[] = 'foo'; - $this->container->captureStart('SET'); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $this->assertEquals(1, count($this->container)); - - $value = $this->container->getValue(); - $this->assertContains('This is content intended for capture', $value); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderKeyUsingSetCapturesContent() - { - $this->container->captureStart('SET', 'key'); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $this->assertEquals(1, count($this->container)); - $this->assertTrue(isset($this->container['key'])); - $value = $this->container['key']; - $this->assertContains('This is content intended for capture', $value); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderKeyUsingSetReplacesContentAtKey() - { - $this->container['key'] = 'Foobar'; - $this->container->captureStart('SET', 'key'); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $this->assertEquals(1, count($this->container)); - $this->assertTrue(isset($this->container['key'])); - $value = $this->container['key']; - $this->assertContains('This is content intended for capture', $value); - } - - /** - * @return void - */ - public function testCapturingToPlaceholderKeyUsingAppendAppendsContentAtKey() - { - $this->container['key'] = 'Foobar '; - $this->container->captureStart('APPEND', 'key'); - echo 'This is content intended for capture'; - $this->container->captureEnd(); - - $this->assertEquals(1, count($this->container)); - $this->assertTrue(isset($this->container['key'])); - $value = $this->container['key']; - $this->assertContains('Foobar This is content intended for capture', $value); - } - - /** - * @return void - */ - public function testNestedCapturesThrowsException() - { - $this->container[] = 'foo'; - $caught = false; - try { - $this->container->captureStart('SET'); - $this->container->captureStart('SET'); - $this->container->captureEnd(); - $this->container->captureEnd(); - } catch (Exception $e) { - $this->container->captureEnd(); - $caught = true; - } - - $this->assertTrue($caught, 'Nested captures should throw exceptions'); - } - - /** - * @return void - */ - public function testToStringWithNoModifiersAndSingleValueReturnsValue() - { - $this->container->set('foo'); - $value = $this->container->toString(); - $this->assertEquals($this->container->getValue(), $value); - } - - /** - * @return void - */ - public function testToStringWithModifiersAndSingleValueReturnsFormattedValue() - { - $this->container->set('foo'); - $this->container->setPrefix('<li>') - ->setPostfix('</li>'); - $value = $this->container->toString(); - $this->assertEquals('<li>foo</li>', $value); - } - - /** - * @return void - */ - public function testToStringWithNoModifiersAndCollectionReturnsImplodedString() - { - $this->container[] = 'foo'; - $this->container[] = 'bar'; - $this->container[] = 'baz'; - $value = $this->container->toString(); - $this->assertEquals('foobarbaz', $value); - } - - /** - * @return void - */ - public function testToStringWithModifiersAndCollectionReturnsFormattedString() - { - $this->container[] = 'foo'; - $this->container[] = 'bar'; - $this->container[] = 'baz'; - $this->container->setPrefix('<ul><li>') - ->setSeparator('</li><li>') - ->setPostfix('</li></ul>'); - $value = $this->container->toString(); - $this->assertEquals('<ul><li>foo</li><li>bar</li><li>baz</li></ul>', $value); - } - - /** - * @return void - */ - public function testToStringWithModifiersAndCollectionReturnsFormattedStringWithIndentation() - { - $this->container[] = 'foo'; - $this->container[] = 'bar'; - $this->container[] = 'baz'; - $this->container->setPrefix('<ul><li>') - ->setSeparator('</li>' . PHP_EOL . '<li>') - ->setPostfix('</li></ul>') - ->setIndent(' '); - $value = $this->container->toString(); - $expectedValue = ' <ul><li>foo</li>' . PHP_EOL . ' <li>bar</li>' . PHP_EOL . ' <li>baz</li></ul>'; - $this->assertEquals($expectedValue, $value); - } - - /** - * @return void - */ - public function test__toStringProxiesToToString() - { - $this->container[] = 'foo'; - $this->container[] = 'bar'; - $this->container[] = 'baz'; - $this->container->setPrefix('<ul><li>') - ->setSeparator('</li><li>') - ->setPostfix('</li></ul>'); - $value = $this->container->__toString(); - $this->assertEquals('<ul><li>foo</li><li>bar</li><li>baz</li></ul>', $value); - } - - /** - * @return void - */ - public function testPrependPushesValueToTopOfContainer() - { - $this->container['foo'] = 'bar'; - $this->container->prepend('baz'); - - $expected = array('baz', 'foo' => 'bar'); - $array = $this->container->getArrayCopy(); - $this->assertSame($expected, $array); - } - - public function testIndentationIsHonored() - { - $this->container->setIndent(4) - ->setPrefix("<ul>\n <li>") - ->setSeparator("</li>\n <li>") - ->setPostfix("</li>\n</ul>"); - $this->container->append('foo'); - $this->container->append('bar'); - $this->container->append('baz'); - $string = $this->container->toString(); - - $lis = substr_count($string, "\n <li>"); - $this->assertEquals(3, $lis); - $this->assertTrue((strstr($string, " <ul>\n")) ? true : false, $string); - $this->assertTrue((strstr($string, "\n </ul>")) ? true : false); - } -} - -// Call Zend_View_Helper_Placeholder_ContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_Placeholder_ContainerTest::main") { - Zend_View_Helper_Placeholder_ContainerTest::main(); -} diff --git a/tests/Zend/View/Helper/Placeholder/RegistryTest.php b/tests/Zend/View/Helper/Placeholder/RegistryTest.php deleted file mode 100644 index 942fe4fa9d506f94a6754f2484792c906e41e3a6..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/Placeholder/RegistryTest.php +++ /dev/null @@ -1,203 +0,0 @@ -<?php -// Call Zend_View_Helper_Placeholder_RegistryTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_Placeholder_RegistryTest::main"); -} - -require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** - * Test class for Zend_View_Helper_Placeholder_Registry. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_Placeholder_RegistryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_Placeholder_Registry - */ - public $registry; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_Placeholder_RegistryTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $registry = Zend_Registry::getInstance(); - if (isset($registry[Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY])) { - unset($registry[Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY]); - } - $this->registry = new Zend_View_Helper_Placeholder_Registry(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->registry); - } - - /** - * @return void - */ - public function testCreateContainer() - { - $this->assertFalse($this->registry->containerExists('foo')); - $this->registry->createContainer('foo'); - $this->assertTrue($this->registry->containerExists('foo')); - } - - /** - * @return void - */ - public function testCreateContainerCreatesDefaultContainerClass() - { - $this->assertFalse($this->registry->containerExists('foo')); - $container = $this->registry->createContainer('foo'); - $this->assertTrue($container instanceof Zend_View_Helper_Placeholder_Container); - } - - /** - * @return void - */ - public function testGetContainerCreatesContainerIfNonExistent() - { - $this->assertFalse($this->registry->containerExists('foo')); - $container = $this->registry->getContainer('foo'); - $this->assertTrue($container instanceof Zend_View_Helper_Placeholder_Container_Abstract); - $this->assertTrue($this->registry->containerExists('foo')); - } - - /** - * @return void - */ - public function testSetContainerCreatesRegistryEntry() - { - $foo = new Zend_View_Helper_Placeholder_Container(array('foo', 'bar')); - $this->assertFalse($this->registry->containerExists('foo')); - $this->registry->setContainer('foo', $foo); - $this->assertTrue($this->registry->containerExists('foo')); - } - - /** - * @return void - */ - public function testSetContainerCreatesRegistersContainerInstance() - { - $foo = new Zend_View_Helper_Placeholder_Container(array('foo', 'bar')); - $this->assertFalse($this->registry->containerExists('foo')); - $this->registry->setContainer('foo', $foo); - $container = $this->registry->getContainer('foo'); - $this->assertSame($foo, $container); - } - - /** - * @return void - */ - public function testContainerClassAccessorsSetState() - { - $this->assertEquals('Zend_View_Helper_Placeholder_Container', $this->registry->getContainerClass()); - $this->registry->setContainerClass('Zend_View_Helper_Placeholder_RegistryTest_Container'); - $this->assertEquals('Zend_View_Helper_Placeholder_RegistryTest_Container', $this->registry->getContainerClass()); - } - - /** - * @return void - */ - public function testSetContainerClassThrowsExceptionWithInvalidContainerClass() - { - try { - $this->registry->setContainerClass('Zend_View_Helper_Placeholder_RegistryTest_BogusContainer'); - $this->fail('Invalid container classes should not be accepted'); - } catch (Exception $e) { - } - } - - public function testDeletingContainerRemovesFromRegistry() - { - $this->registry->createContainer('foo'); - $this->assertTrue($this->registry->containerExists('foo')); - $result = $this->registry->deleteContainer('foo'); - $this->assertFalse($this->registry->containerExists('foo')); - $this->assertTrue($result); - } - - public function testDeleteContainerReturnsFalseIfContainerDoesNotExist() - { - $result = $this->registry->deleteContainer('foo'); - $this->assertFalse($result); - } - - /** - * @return void - */ - public function testUsingCustomContainerClassCreatesContainersOfCustomClass() - { - $this->registry->setContainerClass('Zend_View_Helper_Placeholder_RegistryTest_Container'); - $container = $this->registry->createContainer('foo'); - $this->assertTrue($container instanceof Zend_View_Helper_Placeholder_RegistryTest_Container); - } - - public function testGetRegistryReturnsRegistryInstance() - { - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - $this->assertTrue($registry instanceof Zend_View_Helper_Placeholder_Registry); - } - - public function testGetRegistrySubsequentTimesReturnsSameInstance() - { - $registry1 = Zend_View_Helper_Placeholder_Registry::getRegistry(); - $registry2 = Zend_View_Helper_Placeholder_Registry::getRegistry(); - $this->assertSame($registry1, $registry2); - } - - public function testGetRegistryRegistersWithGlobalRegistry() - { - $this->assertFalse(Zend_Registry::isRegistered(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY)); - $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); - $this->assertTrue(Zend_Registry::isRegistered(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY)); - - $registered = Zend_Registry::get(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY); - $this->assertSame($registry, $registered); - } -} - -class Zend_View_Helper_Placeholder_RegistryTest_Container extends Zend_View_Helper_Placeholder_Container_Abstract -{ -} - -class Zend_View_Helper_Placeholder_RegistryTest_BogusContainer -{ -} - -// Call Zend_View_Helper_Placeholder_RegistryTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_Placeholder_RegistryTest::main") { - Zend_View_Helper_Placeholder_RegistryTest::main(); -} diff --git a/tests/Zend/View/Helper/Placeholder/StandaloneContainerTest.php b/tests/Zend/View/Helper/Placeholder/StandaloneContainerTest.php deleted file mode 100644 index 0ea4020042b5e49cdcc9d3f74007c22c3c2de92a..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/Placeholder/StandaloneContainerTest.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -// Call Zend_View_Helper_Placeholder_StandaloneContainerTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_Placeholder_StandaloneContainerTest::main"); -} - -require_once dirname(__FILE__) . '/../../../../TestHelper.php'; - -/** Zend_View_Helper_Placeholder_Container_Standalone */ -require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_View */ -require_once 'Zend/View.php'; - -/** - * Test class for Zend_View_Helper_Placeholder_StandaloneContainer. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_Placeholder_StandaloneContainerTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_Placeholder_StandaloneContainerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - $this->basePath = dirname(__FILE__) . '/_files/modules'; - $this->helper = new Zend_View_Helper_Placeholder_StandaloneContainerTest_Foo(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testViewAccessorWorks() - { - $view = new Zend_View(); - $this->helper->setView($view); - $this->assertSame($view, $this->helper->view); - } - - public function testContainersPersistBetweenInstances() - { - $foo1 = new Zend_View_Helper_Placeholder_StandaloneContainerTest_Foo; - $foo1->append('Foo'); - $foo1->setSeparator(' - '); - - $foo2 = new Zend_View_Helper_Placeholder_StandaloneContainerTest_Foo; - $foo2->append('Bar'); - - $test = $foo1->toString(); - $this->assertContains('Foo', $test); - $this->assertContains(' - ', $test); - $this->assertContains('Bar', $test); - } -} - -class Zend_View_Helper_Placeholder_StandaloneContainerTest_Foo extends Zend_View_Helper_Placeholder_Container_Standalone -{ - protected $_regKey = 'foo'; -} - -// Call Zend_View_Helper_Placeholder_StandaloneContainerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_Placeholder_StandaloneContainerTest::main") { - Zend_View_Helper_Placeholder_StandaloneContainerTest::main(); -} diff --git a/tests/Zend/View/Helper/PlaceholderTest.php b/tests/Zend/View/Helper/PlaceholderTest.php deleted file mode 100644 index 75ca00a574396459862236d9b269db546c1d5a64..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/PlaceholderTest.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php -// Call Zend_View_Helper_PlaceholderTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_PlaceholderTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -/** Zend_View_Helper_Placeholder */ -require_once 'Zend/View/Helper/Placeholder.php'; - -/** Zend_View_Helper_Placeholder_Registry */ -require_once 'Zend/View/Helper/Placeholder/Registry.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** - * Test class for Zend_View_Helper_Placeholder. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_PlaceholderTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_Placeholder - */ - public $placeholder; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_PlaceholderTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->placeholder = new Zend_View_Helper_Placeholder(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->placeholder); - Zend_Registry::getInstance()->offsetUnset(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY); - } - - /** - * @return void - */ - public function testConstructorCreatesRegistryOffset() - { - $this->assertTrue(Zend_Registry::isRegistered(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY)); - } - - public function testMultiplePlaceholdersUseSameRegistry() - { - $this->assertTrue(Zend_Registry::isRegistered(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY)); - $registry = Zend_Registry::get(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY); - $this->assertSame($registry, $this->placeholder->getRegistry()); - - $placeholder = new Zend_View_Helper_Placeholder(); - - $this->assertSame($registry, $placeholder->getRegistry()); - $this->assertSame($this->placeholder->getRegistry(), $placeholder->getRegistry()); - } - - /** - * @return void - */ - public function testSetView() - { - include_once 'Zend/View.php'; - $view = new Zend_View(); - $this->placeholder->setView($view); - $this->assertSame($view, $this->placeholder->view); - } - - /** - * @return void - */ - public function testPlaceholderRetrievesContainer() - { - $container = $this->placeholder->placeholder('foo'); - $this->assertTrue($container instanceof Zend_View_Helper_Placeholder_Container_Abstract); - } - - /** - * @return void - */ - public function testPlaceholderRetrievesSameContainerOnSubsequentCalls() - { - $container1 = $this->placeholder->placeholder('foo'); - $container2 = $this->placeholder->placeholder('foo'); - $this->assertSame($container1, $container2); - } -} - -// Call Zend_View_Helper_PlaceholderTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_PlaceholderTest::main") { - Zend_View_Helper_PlaceholderTest::main(); -} diff --git a/tests/Zend/View/Helper/RenderToPlaceholderTest.php b/tests/Zend/View/Helper/RenderToPlaceholderTest.php deleted file mode 100644 index 848e8befa3233d1f627c8d3cf38d0adc32dd1ad7..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/RenderToPlaceholderTest.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -// Call Zend_View_Helper_RenderToPlaceholderTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_RenderToPlaceholderTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/Placeholder.php'; - - -class Zend_View_Helper_RenderToPlaceholderTest extends PHPUnit_Framework_TestCase -{ - - protected $_view = null; - - public function setUp() - { - $this->_view = new Zend_View(array('scriptPath'=>dirname(__FILE__).'/_files/scripts/')); - } - - public function testDefaultEmpty() - { - $this->_view->renderToPlaceholder('rendertoplaceholderscript.phtml', 'fooPlaceholder'); - $placeholder = new Zend_View_Helper_Placeholder(); - $this->assertEquals("Foo Bar\n", $placeholder->placeholder('fooPlaceholder')->getValue()); - } - -} - diff --git a/tests/Zend/View/Helper/TranslateTest.php b/tests/Zend/View/Helper/TranslateTest.php deleted file mode 100644 index e7781d0085070c3851243acb566d557bdc780180..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/TranslateTest.php +++ /dev/null @@ -1,224 +0,0 @@ -<?php -// Call Zend_View_Helper_TranslateTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_TranslateTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; - -/** Zend_View_Helper_Translate */ -require_once 'Zend/View/Helper/Translate.php'; - -/** Zend_Registry */ -require_once 'Zend/Registry.php'; - -/** Zend_Translate */ -require_once 'Zend/Translate.php'; -require_once 'Zend/Translate/Adapter/Array.php'; - -/** - * Test class for Zend_View_Helper_Translate. - * - * @category Zend - * @package Zend_View - * @subpackage UnitTests - */ -class Zend_View_Helper_TranslateTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Zend_View_Helper_Translate - */ - public $helper; - - /** - * @var string - */ - public $basePath; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_TranslateTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function clearRegistry() - { - $regKey = 'Zend_Translate'; - if (Zend_Registry::isRegistered($regKey)) { - $registry = Zend_Registry::getInstance(); - unset($registry[$regKey]); - } - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @return void - */ - public function setUp() - { - $this->clearRegistry(); - $this->helper = new Zend_View_Helper_Translate(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - $this->clearRegistry(); - } - - public function testTranslationObjectPassedToConstructorUsedForTranslation() - { - $trans = new Zend_Translate('array', array('one' => 'eins', 'two %1\$s' => 'zwei %1\$s'), 'de'); - - $helper = new Zend_View_Helper_Translate($trans); - $this->assertEquals('eins', $helper->translate('one')); - $this->assertEquals('three', $helper->translate('three')); - } - - public function testLocalTranslationObjectUsedForTranslationsWhenPresent() - { - $trans = new Zend_Translate('array', array('one' => 'eins', 'two %1\$s' => 'zwei %1\$s'), 'de'); - - $this->helper->setTranslator($trans); - $this->assertEquals('eins', $this->helper->translate('one')); - $this->assertEquals('three', $this->helper->translate('three')); - } - - public function testTranslationObjectInRegistryUsedForTranslationsInAbsenceOfLocalTranslationObject() - { - $trans = new Zend_Translate('array', array('one' => 'eins', 'two %1\$s' => 'zwei %1\$s'), 'de'); - Zend_Registry::set('Zend_Translate', $trans); - $this->assertEquals('eins', $this->helper->translate('one')); - } - - public function testOriginalMessagesAreReturnedWhenNoTranslationObjectPresent() - { - $this->assertEquals('one', $this->helper->translate('one')); - $this->assertEquals('three', $this->helper->translate('three')); - } - - public function testPassingNonNullNonTranslationObjectToConstructorThrowsException() - { - try { - $helper = new Zend_View_Helper_Translate('something'); - } catch (Zend_View_Exception $e) { - $this->assertContains('must set an instance of Zend_Translate', $e->getMessage()); - } - } - - public function testPassingNonTranslationObjectToSetTranslatorThrowsException() - { - try { - $this->helper->setTranslator('something'); - } catch (Zend_View_Exception $e) { - $this->assertContains('must set an instance of Zend_Translate', $e->getMessage()); - } - } - - public function testRetrievingLocaleWhenNoTranslationObjectSetThrowsException() - { - try { - $this->helper->getLocale(); - } catch (Zend_View_Exception $e) { - $this->assertContains('must set an instance of Zend_Translate', $e->getMessage()); - } - } - - public function testSettingLocaleWhenNoTranslationObjectSetThrowsException() - { - try { - $this->helper->setLocale('de'); - } catch (Zend_View_Exception $e) { - $this->assertContains('must set an instance of Zend_Translate', $e->getMessage()); - } - } - - public function testCanSetLocale() - { - $trans = new Zend_Translate('array', array('one' => 'eins', 'two %1\$s' => 'zwei %1\$s'), 'de'); - $trans->addTranslation(array('one' => 'uno', 'two %1\$s' => 'duo %2\$s'), 'it'); - $trans->setLocale('de'); - - $this->helper->setTranslator($trans); - $this->assertEquals('eins', $this->helper->translate('one')); - $new = $this->helper->setLocale('it'); - $this->assertTrue($new instanceof Zend_View_Helper_Translate); - $this->assertEquals('it', $new->getLocale()); - $this->assertEquals('uno', $this->helper->translate('one')); - } - - public function testHelperImplementsFluentInterface() - { - $trans = new Zend_Translate('array', array('one' => 'eins', 'two %1\$s' => 'zwei %1\$s'), 'de'); - $trans->addTranslation(array('one' => 'uno', 'two %1\$s' => 'duo %2\$s'), 'it'); - $trans->setLocale('de'); - - $locale = $this->helper->translate()->setTranslator($trans)->getLocale(); - - $this->assertEquals('de', $locale); - } - - public function testCanTranslateWithOptions() - { - $trans = new Zend_Translate('array', array('one' => 'eins', "two %1\$s" => "zwei %1\$s", - "three %1\$s %2\$s" => "drei %1\$s %2\$s"), 'de'); - $trans->addTranslation(array('one' => 'uno', "two %1\$s" => "duo %2\$s", - "three %1\$s %2\$s" => "tre %1\$s %2\$s"), 'it'); - $trans->setLocale('de'); - - $this->helper->setTranslator($trans); - $this->assertEquals("drei 100 200", $this->helper->translate("three %1\$s %2\$s", "100", "200")); - $this->assertEquals("tre 100 200", $this->helper->translate("three %1\$s %2\$s", "100", "200", 'it')); - $this->assertEquals("drei 100 200", $this->helper->translate("three %1\$s %2\$s", array("100", "200"))); - $this->assertEquals("tre 100 200", $this->helper->translate("three %1\$s %2\$s", array("100", "200"), 'it')); - } - - public function testTranslationObjectNullByDefault() - { - $this->assertNull($this->helper->getTranslator()); - } - - public function testLocalTranslationObjectIsPreferredOverRegistry() - { - $transReg = new Zend_Translate('array', array()); - Zend_Registry::set('Zend_Translate', $transReg); - - $this->assertSame($transReg->getAdapter(), $this->helper->getTranslator()); - - $transLoc = new Zend_Translate('array', array()); - $this->helper->setTranslator($transLoc); - $this->assertSame($transLoc->getAdapter(), $this->helper->getTranslator()); - $this->assertNotSame($transLoc->getAdapter(), $transReg->getAdapter()); - } - - public function testHelperObjectReturnedWhenNoArgumentsPassed() - { - $helper = $this->helper->translate(); - $this->assertSame($this->helper, $helper); - - $transLoc = new Zend_Translate('array', array()); - $this->helper->setTranslator($transLoc); - $helper = $this->helper->translate(); - $this->assertSame($this->helper, $helper); - } -} - -// Call Zend_View_Helper_TranslateTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_TranslateTest::main") { - Zend_View_Helper_TranslateTest::main(); -} diff --git a/tests/Zend/View/Helper/UrlTest.php b/tests/Zend/View/Helper/UrlTest.php deleted file mode 100644 index f09e732d52f24a3d12df0b4a096cacc003831963..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/UrlTest.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -// Call Zend_View_Helper_UrlTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_UrlTest::main"); -} - -require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php'; -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/View.php'; -require_once 'Zend/View/Helper/Url.php'; - -/* Test dependency on Front Controller because there is no way to get the Controller out of View instance dynamically */ -require_once 'Zend/Controller/Front.php'; - -require_once 'Zend/Controller/Request/Http.php'; - -/** - * Zend_View_Helper_UrlTest - * - * Tests formText helper, including some common functionality of all form helpers - * - * @uses PHPUnit_Framework_TestCase - * @version $Id: UrlTest.php 4828 2007-05-16 21:28:54Z matthew $ - */ -class Zend_View_Helper_UrlTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_UrlTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() - { - $this->front = Zend_Controller_Front::getInstance(); - $this->front->getRouter()->addDefaultRoutes(); - - // $this->view = new Zend_View(); - $this->helper = new Zend_View_Helper_Url(); - // $this->helper->setView($this->view); - } - - public function testDefaultEmpty() - { - $url = $this->helper->url(); - $this->assertEquals('/', $url); - } - - public function testDefault() - { - $url = $this->helper->url(array('controller' => 'ctrl', 'action' => 'act')); - $this->assertEquals('/ctrl/act', $url); - } - -} - -// Call Zend_View_Helper_UrlTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_UrlTest::main") { - Zend_View_Helper_UrlTest::main(); -} diff --git a/tests/Zend/View/Helper/_files/modules/default/controllers/BarController.php b/tests/Zend/View/Helper/_files/modules/default/controllers/BarController.php deleted file mode 100644 index e8bf23aa5838c871ce150c3cadc2786e6ef7e300..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/controllers/BarController.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -/** Zend_Controller_Action */ -require_once 'Zend/Controller/Action.php'; - -class BarController extends Zend_Controller_Action -{ - public function bazAction() - { - } -} diff --git a/tests/Zend/View/Helper/_files/modules/default/controllers/FooController.php b/tests/Zend/View/Helper/_files/modules/default/controllers/FooController.php deleted file mode 100644 index ce4a6c808fcc3ec50d9e7b333222577397488ac5..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/controllers/FooController.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** Zend_Controller_Action */ -require_once 'Zend/Controller/Action.php'; - -class FooController extends Zend_Controller_Action -{ - public function barAction() - { - } - - public function bazAction() - { - $this->view->message = $this->_getParam('bat', 'BOGUS'); - } - - public function forwardAction() - { - $this->_forward('bar'); - } - - public function redirectAction() - { - $this->_helper->redirector->setExit(false); - $this->_redirect('/foo/bar'); - } -} diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/bar/baz.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/bar/baz.phtml deleted file mode 100644 index 86f125f4d3a5eb84d5e02fde25eccddf0ebbf915..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/bar/baz.phtml +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -?> - -Hello \ No newline at end of file diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/foo/bar.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/foo/bar.phtml deleted file mode 100644 index c22e27e64a39ffa2d1d431e0f811b1273db283dd..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/foo/bar.phtml +++ /dev/null @@ -1 +0,0 @@ -In default module, FooController::barAction() diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/foo/baz.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/foo/baz.phtml deleted file mode 100644 index c209133dbde9e0e2236b2a70ff71bf826ceac2c4..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/foo/baz.phtml +++ /dev/null @@ -1 +0,0 @@ -Message: <?php echo $this->message ?> diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialActionCall.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialActionCall.phtml deleted file mode 100644 index d420166b23290be732f3d569f5b743ee6ac5febc..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialActionCall.phtml +++ /dev/null @@ -1,2 +0,0 @@ -<?php -$this->action('baz', 'bar', 'default', array('hello' => 'goodby')); diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialLoop.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialLoop.phtml deleted file mode 100644 index 308e0c52a28061c8038c770055c8259029ae8447..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialLoop.phtml +++ /dev/null @@ -1,2 +0,0 @@ -This is an iteration: <?php echo $this->message ?> - diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialLoopObject.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialLoopObject.phtml deleted file mode 100644 index 1db6a7a1d87a73e3dad14ddd5d9bd9858973308f..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialLoopObject.phtml +++ /dev/null @@ -1,6 +0,0 @@ -<? if (!isset($this->obj)): ?> -No object model passed -<? else: - echo 'This is an iteration: ' . $this->obj->message . "\n"; -endif ?> - diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialObj.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialObj.phtml deleted file mode 100644 index 9d4d0dc3ff735e68073f056e9b71eea0ae227cde..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialObj.phtml +++ /dev/null @@ -1,11 +0,0 @@ -<? if (!isset($this->foo)): ?> -No object model passed -<? else: - $vars = get_object_vars($this->foo); - foreach ($vars as $key => $value): ?> -<?= $key ?>: <?= $value ?> -<? endforeach; -endif ?> - - - diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialOne.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialOne.phtml deleted file mode 100644 index 83c5a41349140dacca35ebd74fdcc62d33f94a8a..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialOne.phtml +++ /dev/null @@ -1 +0,0 @@ -This is the first test partial diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialThree.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialThree.phtml deleted file mode 100644 index 8cb756fbd8aada5a93c8687a449cd0bf3541aec7..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialThree.phtml +++ /dev/null @@ -1,2 +0,0 @@ -Partial with variables: -<?php echo $this->message ?> diff --git a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialVars.phtml b/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialVars.phtml deleted file mode 100644 index 7b27c87a151028d041a5d00e7c2b5bd76f48650b..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/default/views/scripts/partialVars.phtml +++ /dev/null @@ -1,4 +0,0 @@ -<?php -foreach (get_object_vars($this) as $key => $value) { - printf("%s: %s\n", $key, $value); -} diff --git a/tests/Zend/View/Helper/_files/modules/foo/controllers/BazController.php b/tests/Zend/View/Helper/_files/modules/foo/controllers/BazController.php deleted file mode 100644 index bd8208d2d50d5d865b1019141553cc7c6c249ae0..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/controllers/BazController.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -require_once 'Zend/Controller/Action.php'; - -class Foo_BazController extends Zend_Controller_Action -{ - - public function barOneAction() - { - // this is for testActionCalledWithinActionResetsResponseState - } - - public function barTwoAction() - { - // this is for testActionCalledWithinActionResetsResponseState - } - - public function barThreeAction() - { - // this is for testActionCalledWithinActionResetsResponseState - } - -} - diff --git a/tests/Zend/View/Helper/_files/modules/foo/controllers/FooController.php b/tests/Zend/View/Helper/_files/modules/foo/controllers/FooController.php deleted file mode 100644 index b82ae3eb03253ee4b820c95d707906cf1d8b5e6c..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/controllers/FooController.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** Zend_Controller_Action */ -require_once 'Zend/Controller/Action.php'; - -class Foo_FooController extends Zend_Controller_Action -{ - public function barAction() - { - $this->view->bar = 'bar'; - } - - public function nestAction() - { - $this->render(); - } - - public function nestedAction() - { - $this->render(); - } -} diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-one.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-one.phtml deleted file mode 100644 index d3b6cbcac48a9af278a8e232895a53b334a3a190..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-one.phtml +++ /dev/null @@ -1 +0,0 @@ -<?= $this->action('bar-two', 'baz', 'foo'); ?>|Baz-One-View-Script \ No newline at end of file diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-three.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-three.phtml deleted file mode 100644 index b07ed26e9d8b4d23b9861920ed379b3a359c21d2..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-three.phtml +++ /dev/null @@ -1 +0,0 @@ -Baz-Three-View-Script \ No newline at end of file diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-two.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-two.phtml deleted file mode 100644 index b8c41595525ff37de2c25adfb5ca694dd0662cb0..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/baz/bar-two.phtml +++ /dev/null @@ -1 +0,0 @@ -<?= $this->action('bar-three', 'baz', 'foo') ?>|Baz-Two-View-Script \ No newline at end of file diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/bar.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/bar.phtml deleted file mode 100644 index 0fc9d8ba8f27d8337aeed734e2d56f40461d430d..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/bar.phtml +++ /dev/null @@ -1 +0,0 @@ -In foo module, Foo_FooController::barAction() diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/nest.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/nest.phtml deleted file mode 100644 index e43b1bf7b8fe23fff51d923312a4babb41c35e2c..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/nest.phtml +++ /dev/null @@ -1,4 +0,0 @@ -<? -$this->headTitle('Foo Nest') - ->headTitle()->setSeparator(' - '); -$this->action('nested', 'foo', 'foo'); diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/nested.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/nested.phtml deleted file mode 100644 index 2f57fcf40f03fddb2c4404300cc06b525d33574f..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/foo/nested.phtml +++ /dev/null @@ -1,3 +0,0 @@ -<? -$this->headTitle()->append('Nested Stuff'); - diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/partialLoop.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/partialLoop.phtml deleted file mode 100644 index 89513a04f1feb4659d8deefddc9637a174f49fcd..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/partialLoop.phtml +++ /dev/null @@ -1,2 +0,0 @@ -This is an iteration in the foo module: <?php echo $this->message ?> - diff --git a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/partialTwo.phtml b/tests/Zend/View/Helper/_files/modules/foo/views/scripts/partialTwo.phtml deleted file mode 100644 index 3381a6469e26b2e3aa7f8eedd4872d35a86af217..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/modules/foo/views/scripts/partialTwo.phtml +++ /dev/null @@ -1 +0,0 @@ -This is the second partial diff --git a/tests/Zend/View/Helper/_files/scripts/rendertoplaceholderscript.phtml b/tests/Zend/View/Helper/_files/scripts/rendertoplaceholderscript.phtml deleted file mode 100644 index 76c7ac2d0ce646cb709caa6b31b4e5b517b7145e..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/scripts/rendertoplaceholderscript.phtml +++ /dev/null @@ -1 +0,0 @@ -Foo Bar diff --git a/tests/Zend/View/Helper/_files/scripts/testPagination.phtml b/tests/Zend/View/Helper/_files/scripts/testPagination.phtml deleted file mode 100644 index df914ea048370deff0efd2729d8580254ee9b2eb..0000000000000000000000000000000000000000 --- a/tests/Zend/View/Helper/_files/scripts/testPagination.phtml +++ /dev/null @@ -1,3 +0,0 @@ -pagination control - -page count (<?php print $this->pageCount; ?>) <?php print ($this->pageCount == count($this->pagesInRange)) ? 'equals' : 'does not equal'; ?> pages in range (<?php print count($this->pagesInRange); ?>) \ No newline at end of file diff --git a/tests/Zend/View/_stubs/FilterDir1/Foo.php b/tests/Zend/View/_stubs/FilterDir1/Foo.php deleted file mode 100644 index fbc053cb1af875db605dc560deb7baef31bae311..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_stubs/FilterDir1/Foo.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_View_Filter_Foo -{ - public function filter($buffer) - { - return 'foo'; - } -} diff --git a/tests/Zend/View/_stubs/HelperDir1/Stub1.php b/tests/Zend/View/_stubs/HelperDir1/Stub1.php deleted file mode 100644 index 2f03fe24aa643ac280b8e46efdb11a5ac94ebf99..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_stubs/HelperDir1/Stub1.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Foo_View_Helper_Stub1 -{ - public function stub1() - { - return 'foo'; - } -} diff --git a/tests/Zend/View/_stubs/HelperDir1/StubEmpty.php b/tests/Zend/View/_stubs/HelperDir1/StubEmpty.php deleted file mode 100644 index 683b37aac102d8f17f03a26dc363b7f3f216a73d..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_stubs/HelperDir1/StubEmpty.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -// used to test when helper file is loaded but class is not within diff --git a/tests/Zend/View/_stubs/HelperDir2/Datetime.php b/tests/Zend/View/_stubs/HelperDir2/Datetime.php deleted file mode 100644 index 4002a7c2f9a1aa50bc5d4b662aafd2155b2fe184..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_stubs/HelperDir2/Datetime.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_View_Helper_Datetime -{ - public function datetime() - { - return $this; - } -} diff --git a/tests/Zend/View/_stubs/HelperDir2/Stub1.php b/tests/Zend/View/_stubs/HelperDir2/Stub1.php deleted file mode 100644 index 96e4e38202b60f1df41677cefdb3031da4c03240..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_stubs/HelperDir2/Stub1.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_View_Helper_Stub1 -{ - public function stub1() - { - return 'foo'; - } -} diff --git a/tests/Zend/View/_stubs/HelperDir2/Stub2.php b/tests/Zend/View/_stubs/HelperDir2/Stub2.php deleted file mode 100644 index 195e26838112c0d19f94866779eb2a48e9561b2b..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_stubs/HelperDir2/Stub2.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -class Zend_View_Helper_Stub2 -{ - public $view; - - public function stub2() - { - return 'bar'; - } - - public function setView(Zend_View $view) - { - $this->view = $view; - return $this; - } -} diff --git a/tests/Zend/View/_templates/test.phtml b/tests/Zend/View/_templates/test.phtml deleted file mode 100644 index ad8503ac2e7b35aac1fec5b9c99e718c483d543f..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_templates/test.phtml +++ /dev/null @@ -1,6 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -foo <?php echo $this->bar ?> baz diff --git a/tests/Zend/View/_templates/testParent.phtml b/tests/Zend/View/_templates/testParent.phtml deleted file mode 100644 index 7f7630f0d304138a0cac47f39a0b8f7fb3aa25a9..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_templates/testParent.phtml +++ /dev/null @@ -1,11 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -$content = $this->render($this->content); -require_once 'Zend/Log.php'; -require_once 'Zend/Log/Writer/Stream.php'; -$logger = new Zend_Log(new Zend_Log_Writer_Stream(dirname(__FILE__) . '/view.log')); -$logger->log(var_export($content, 1), Zend_Log::DEBUG); -$logger->log(var_export(__FILE__, 1), Zend_Log::DEBUG); diff --git a/tests/Zend/View/_templates/testStrictVars.phtml b/tests/Zend/View/_templates/testStrictVars.phtml deleted file mode 100644 index fbd5fc71b9744ad440568b23e0b0ace9375b2abf..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_templates/testStrictVars.phtml +++ /dev/null @@ -1,7 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -Testing strict variables -<?php echo $this->foo ?> should emit a notice. -As should <?php echo $this->bar ?>. diff --git a/tests/Zend/View/_templates/testSubTemplate.phtml b/tests/Zend/View/_templates/testSubTemplate.phtml deleted file mode 100644 index 2d13516e613d5d545a98b4cfce8f8bd0a932d2d1..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_templates/testSubTemplate.phtml +++ /dev/null @@ -1,6 +0,0 @@ -<?php -require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); -?> -This text should not be displayed. diff --git a/tests/Zend/View/_templates/testZf995.phtml b/tests/Zend/View/_templates/testZf995.phtml deleted file mode 100644 index d11854955b5f10f190efd02cacc08afefaace33e..0000000000000000000000000000000000000000 --- a/tests/Zend/View/_templates/testZf995.phtml +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -require_once 'PHPUnit/Util/Filter.php'; -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -echo $this->error -?> diff --git a/tests/Zend/ViewTest.php b/tests/Zend/ViewTest.php deleted file mode 100644 index 9e524d2b8f71c260a0ff2e1e6eba6ce374e9f7ff..0000000000000000000000000000000000000000 --- a/tests/Zend/ViewTest.php +++ /dev/null @@ -1,980 +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_View - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_ViewTest::main'); -} - -/** - * Test helper - */ -require_once dirname(__FILE__) . '/../TestHelper.php'; - -/** - * Zend_View - */ -require_once 'Zend/View.php'; - -/** - * Zend_View_Interface - */ -require_once 'Zend/View/Interface.php'; - -/** - * Zend_Loader - */ -require_once 'Zend/Loader.php'; - -/** - * @category Zend - * @package Zend_View - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_ViewTest extends PHPUnit_Framework_TestCase -{ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_ViewTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->notices = array(); - $this->errorReporting = error_reporting(); - $this->displayErrors = ini_get('display_errors'); - } - - public function tearDown() - { - error_reporting($this->errorReporting); - ini_set('display_errors', $this->displayErrors); - } - - /** - * Tests that the default script path is properly initialized - */ - public function testDefaultScriptPath() - { - $this->_testDefaultPath('script', false); - } - - public function normalizePath($path) - { - return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); - } - - /** - * Tests that the default helper path is properly initialized - * and the directory is readable - */ - public function testDefaultHelperPath() - { - $this->_testDefaultPath('helper'); - } - - /** - * Tests that the default filter path is properly initialized - * and the directory is readable - */ - public function testDefaultFilterPath() - { - $this->_testDefaultPath('filter', false); - } - - /** - * Tests that script paths are added, properly ordered, and that - * directory separators are handled correctly. - */ - public function testAddScriptPath() - { - $this->_testAddPath('script'); - } - - /** - * Tests that helper paths are added, properly ordered, and that - * directory separators are handled correctly. - */ - public function testAddHelperPath() - { - $this->_testAddPath('helper'); - } - - /** - * Tests that filter paths are added, properly ordered, and that - * directory separators are handled correctly. - */ - public function testAddFilterPath() - { - $this->_testAddPath('filter'); - } - - /** - * Tests that the (script|helper|filter) path array is properly - * initialized after instantiation. - * - * @param string $pathType one of "script", "helper", or "filter". - * @param boolean $testReadability check if the path is readable? - */ - protected function _testDefaultPath($pathType, $testReadability = true) - { - $view = new Zend_View(); - - $reflector = $view->getAllPaths(); - $paths = $reflector[$pathType]; - - // test default helper path - $this->assertType('array', $paths); - if ('script' == $pathType) { - $this->assertEquals(0, count($paths)); - } else { - $this->assertEquals(1, count($paths)); - - $prefix = 'Zend_View_' . ucfirst($pathType) . '_'; - $this->assertTrue(array_key_exists($prefix, $paths)); - - if ($testReadability) { - $path = current($paths[$prefix]); - $this->assertTrue(Zend_Loader::isReadable($path)); - } - } - } - - /** - * Tests (script|helper|filter) paths can be added, that they are added - * in the proper order, and that directory separators are properly handled. - * - * @param string $pathType one of "script", "helper", or "filter". - */ - protected function _testAddPath($pathType) - { - $view = new Zend_View(); - $prefix = 'Zend_View_' . ucfirst($pathType) . '_'; - - // introspect default paths and build expected results. - $reflector = $view->getAllPaths(); - $expectedPaths = $reflector[$pathType]; - - if ($pathType != 'script') { - $expectedPaths = $expectedPaths[$prefix]; - } - - array_push($expectedPaths, 'baz' . DIRECTORY_SEPARATOR); - array_push($expectedPaths, 'bar' . DIRECTORY_SEPARATOR); - array_push($expectedPaths, 'foo' . DIRECTORY_SEPARATOR); - - // add paths - $func = 'add' . ucfirst($pathType) . 'Path'; - $view->$func('baz'); // no separator - $view->$func('bar\\'); // windows - $view->$func('foo/'); // unix - - // introspect script paths after adding two new paths - $reflector = $view->getAllPaths(); - $actualPaths = $reflector[$pathType]; - - switch ($pathType) { - case 'script': - $this->assertSame(array_reverse($expectedPaths), $actualPaths); - break; - case 'helper': - case 'filter': - default: - $this->assertTrue(array_key_exists($prefix, $actualPaths)); - $this->assertSame($expectedPaths, $actualPaths[$prefix], 'Actual: ' . var_export($actualPaths, 1) . "\nExpected: " . var_export($expectedPaths, 1)); - } - } - - /** - * Tests that the Zend_View environment is clean of any instance variables - */ - public function testSandbox() - { - $view = new Zend_View(); - $this->assertSame(array(), get_object_vars($view)); - } - - /** - * Tests that isset() and empty() work correctly. This is a common problem - * because __isset() was not supported until PHP 5.1. - */ - public function testIssetEmpty() - { - $view = new Zend_View(); - $this->assertFalse(isset($view->foo)); - $this->assertTrue(empty($view->foo)); - - $view->foo = 'bar'; - $this->assertTrue(isset($view->foo)); - $this->assertFalse(empty($view->foo)); - } - - /** - * Tests that a help can be loaded from the search path - * - */ - public function testLoadHelper() - { - $view = new Zend_View(); - - $view->setHelperPath( - array( - dirname(__FILE__) . '/View/_stubs/HelperDir1', - dirname(__FILE__) . '/View/_stubs/HelperDir2' - ) - ); - - $this->assertEquals('foo', $view->stub1(), var_export($view->getHelperPaths(), 1)); - $this->assertEquals('bar', $view->stub2()); - - // erase the paths to the helper stubs - $view->setHelperPath(null); - - // verify that object handle of a stub was cache by calling it again - // without its path in the helper search paths - $this->assertEquals( 'foo', $view->stub1() ); - } - - /** - * Tests that calling a nonexistant helper file throws the expected exception - */ - public function testLoadHelperNonexistantFile() - { - $view = new Zend_View(); - - try { - $view->nonexistantHelper(); - // @todo fail if no exception? - } catch (Zend_Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - /** - * Tests that calling a helper whose file exists but class is not found within - * throws the expected exception - */ - public function testLoadHelperNonexistantClass() - { - $view = new Zend_View(); - - $view->setHelperPath(array(dirname(__FILE__) . '/View/_stubs/HelperDir1')); - - try { - // attempt to load the helper StubEmpty, whose file exists but - // does not contain the expected class within - $view->stubEmpty(); - // @todo fail if no exception? - } catch (Zend_Exception $e) { - $this->assertContains("not found", $e->getMessage()); - } - } - - public function testHelperPathMayBeRegisteredUnderMultiplePrefixes() - { - $view = new Zend_View(); - - $view->addHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', 'Foo_View_Helper'); - $view->addHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', 'Zend_View_Helper'); - - $helper = $view->getHelper('Stub1'); - $this->assertTrue($helper instanceof Foo_View_Helper_Stub1); - } - - /** - * Tests that render() can render a template. - */ - public function testRender() - { - $view = new Zend_View(); - - $view->setScriptPath(dirname(__FILE__) . '/View/_templates'); - - $view->bar = 'bar'; - - $this->assertEquals("foo bar baz\n", $view->render('test.phtml') ); - } - - /** - * Tests that render() works when called within a template, and that - * protected members are not available - */ - public function testRenderSubTemplates() - { - $view = new Zend_View(); - $view->setScriptPath(dirname(__FILE__) . '/View/_templates'); - $view->content = 'testSubTemplate.phtml'; - $this->assertEquals('', $view->render('testParent.phtml')); - - $logFile = dirname(__FILE__) . '/View/_templates/view.log'; - $this->assertTrue(file_exists($logFile)); - $log = file_get_contents($logFile); - unlink($logFile); // clean up... - $this->assertContains('This text should not be displayed', $log); - $this->assertNotContains('testSubTemplate.phtml', $log); - } - - /** - * Tests that array properties may be modified after being set (see [ZF-460] - * and [ZF-268] for symptoms leading to this test) - */ - public function testSetArrayProperty() - { - $view = new Zend_View(); - $view->foo = array(); - $view->foo[] = 42; - - $foo = $view->foo; - - $this->assertTrue(is_array($foo)); - $this->assertEquals(42, $foo[0], var_export($foo, 1)); - - $view->assign('bar', array()); - $view->bar[] = 'life'; - $bar = $view->bar; - $this->assertTrue(is_array($bar)); - $this->assertEquals('life', $bar[0], var_export($bar, 1)); - - $view->assign(array( - 'baz' => array('universe'), - )); - $view->baz[] = 'everything'; - $baz = $view->baz; - $this->assertTrue(is_array($baz)); - $this->assertEquals('universe', $baz[0]); - $this->assertEquals('everything', $baz[1], var_export($baz, 1)); - } - - /** - * Test that array properties are cleared following clearVars() call - */ - public function testClearVars() - { - $view = new Zend_View(); - $view->foo = array(); - $view->content = 'content'; - - $this->assertTrue(is_array($view->foo)); - $this->assertEquals('content', $view->content); - - $view->clearVars(); - $this->assertFalse(isset($view->foo)); - $this->assertFalse(isset($view->content)); - } - - /** - * Test that script paths are cleared following setScriptPath(null) call - */ - public function testClearScriptPath() - { - $view = new Zend_View(); - - // paths should be initially empty - $this->assertSame(array(), $view->getScriptPaths()); - - // add a path - $view->setScriptPath('foo'); - $scriptPaths = $view->getScriptPaths(); - $this->assertType('array', $scriptPaths); - $this->assertEquals(1, count($scriptPaths)); - - // clear paths - $view->setScriptPath(null); - $this->assertSame(array(), $view->getScriptPaths()); - } - - /** - * Test that an exception is thrown when no script path is set - */ - public function testNoPath() - { - $view = new Zend_View(); - try { - $view->render('somefootemplate.phtml'); - $this->fail('Rendering a template when no script path is set should raise an exception'); - } catch (Exception $e) { - // success... - // @todo assert something? - } - } - - /** - * Test that getEngine() returns the same object - */ - public function testGetEngine() - { - $view = new Zend_View(); - $this->assertSame($view, $view->getEngine()); - } - - public function testInstanceOfInterface() - { - $view = new Zend_View(); - $this->assertTrue($view instanceof Zend_View_Interface); - } - - public function testGetVars() - { - $view = new Zend_View(); - $view->foo = 'bar'; - $view->bar = 'baz'; - $view->baz = array('foo', 'bar'); - - $vars = $view->getVars(); - $this->assertEquals(3, count($vars)); - $this->assertEquals('bar', $vars['foo']); - $this->assertEquals('baz', $vars['bar']); - $this->assertEquals(array('foo', 'bar'), $vars['baz']); - } - - /** - * Test set/getEncoding() - */ - public function testSetGetEncoding() - { - $view = new Zend_View(); - $this->assertEquals('ISO-8859-1', $view->getEncoding()); - - $view->setEncoding('UTF-8'); - $this->assertEquals('UTF-8', $view->getEncoding()); - } - - public function testEmptyPropertiesReturnAppropriately() - { - $view = new Zend_View(); - $view->foo = false; - $view->bar = null; - $view->baz = ''; - $this->assertTrue(empty($view->foo)); - $this->assertTrue(empty($view->bar)); - $this->assertTrue(empty($view->baz)); - } - - public function testFluentInterfaces() - { - $view = new Zend_View(); - try { - $test = $view->setEscape('strip_tags') - ->setFilter('htmlspecialchars') - ->setEncoding('UTF-8') - ->setScriptPath(dirname(__FILE__) . '/View/_templates') - ->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1') - ->setFilterPath(dirname(__FILE__) . '/View/_stubs/HelperDir1') - ->assign('foo', 'bar'); - } catch (Exception $e){ - $this->fail('Setters should not throw exceptions'); - } - - $this->assertTrue($test instanceof Zend_View); - } - - public function testSetConfigInConstructor() - { - $scriptPath = $this->normalizePath(dirname(__FILE__) . '/View/_templates/'); - $helperPath = $this->normalizePath(dirname(__FILE__) . '/View/_stubs/HelperDir1/'); - $filterPath = $this->normalizePath(dirname(__FILE__) . '/View/_stubs/HelperDir1/'); - - $config = array( - 'escape' => 'strip_tags', - 'encoding' => 'UTF-8', - 'scriptPath' => $scriptPath, - 'helperPath' => $helperPath, - 'helperPathPrefix' => 'My_View_Helper', - 'filterPath' => $filterPath, - 'filterPathPrefix' => 'My_View_Filter', - 'filter' => 'urlencode', - ); - - $view = new Zend_View($config); - $scriptPaths = $view->getScriptPaths(); - $helperPaths = $view->getHelperPaths(); - $filterPaths = $view->getFilterPaths(); - - $this->assertContains($this->normalizePath($scriptPath), $scriptPaths); - - $found = false; - $prefix = false; - foreach ($helperPaths as $helperPrefix => $paths) { - foreach ($paths as $path) { - if (strstr($path, $helperPath)) { - $found = true; - $prefix = $helperPrefix; - } - } - /* - if (strstr($pathInfo['dir'], $helperPath)) { - $found = true; - $prefix = $pathInfo['prefix']; - } - */ - } - $this->assertTrue($found, var_export($helperPaths, 1)); - $this->assertEquals('My_View_Helper_', $prefix); - - $found = false; - $prefix = false; - foreach ($filterPaths as $classPrefix => $paths) { - foreach ($paths as $pathInfo) { - if (strstr($pathInfo, $filterPath)) { - $found = true; - $prefix = $classPrefix; - } - } - } - $this->assertTrue($found, var_export($filterPaths, 1)); - $this->assertEquals('My_View_Filter_', $prefix); - } - - public function testUnset() - { - $view = new Zend_View(); - unset($view->_path); - // @todo assert something? - } - - public function testSetProtectedThrowsException() - { - $view = new Zend_View(); - try { - $view->_path = 'bar'; - $this->fail('Should not be able to set protected properties'); - } catch (Exception $e) { - // success - // @todo assert something? - } - } - - public function testHelperPathWithPrefix() - { - $view = new Zend_View(); - $status = $view->addHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1/', 'My_View_Helper'); - $this->assertSame($view, $status); - $helperPaths = $view->getHelperPaths(); - $this->assertTrue(array_key_exists('My_View_Helper_', $helperPaths)); - $path = current($helperPaths['My_View_Helper_']); - $this->assertEquals($this->normalizePath(dirname(__FILE__) . '/View/_stubs/HelperDir1/'), $path); - - $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir2/', 'Other_View_Helper'); - $helperPaths = $view->getHelperPaths(); - $this->assertTrue(array_key_exists('Other_View_Helper_', $helperPaths)); - $path = current($helperPaths['Other_View_Helper_']); - $this->assertEquals($this->normalizePath(dirname(__FILE__) . '/View/_stubs/HelperDir2/'), $path); - } - - public function testHelperPathWithPrefixAndRelativePath() - { - $view = new Zend_View(); - $status = $view->addHelperPath('Zend/View/_stubs/HelperDir1/', 'My_View_Helper'); - $this->assertSame($view, $status); - $helperPaths = $view->getHelperPaths(); - $this->assertTrue(array_key_exists('My_View_Helper_', $helperPaths)); - $this->assertContains($this->normalizePath('Zend/View/_stubs/HelperDir1/'), current($helperPaths['My_View_Helper_'])); - } - - public function testFilterPathWithPrefix() - { - $view = new Zend_View(); - $status = $view->addFilterPath(dirname(__FILE__) . '/View/_stubs/HelperDir1/', 'My_View_Filter'); - $this->assertSame($view, $status); - $filterPaths = $view->getFilterPaths(); - $this->assertTrue(array_key_exists('My_View_Filter_', $filterPaths)); - $this->assertEquals($this->normalizePath(dirname(__FILE__) . '/View/_stubs/HelperDir1/'), current($filterPaths['My_View_Filter_'])); - - $view->setFilterPath(dirname(__FILE__) . '/View/_stubs/HelperDir2/', 'Other_View_Filter'); - $filterPaths = $view->getFilterPaths(); - $this->assertTrue(array_key_exists('Other_View_Filter_', $filterPaths)); - $this->assertEquals($this->normalizePath(dirname(__FILE__) . '/View/_stubs/HelperDir2/'), current($filterPaths['Other_View_Filter_'])); - } - - public function testAssignThrowsExceptionsOnBadValues() - { - $view = new Zend_View(); - try { - $view->assign('_path', dirname(__FILE__) . '/View/_stubs/HelperDir2/'); - $this->fail('Protected/private properties cannot be assigned'); - } catch (Exception $e) { - // success - // @todo assert something? - } - - try { - $view->assign(array('_path' => dirname(__FILE__) . '/View/_stubs/HelperDir2/')); - $this->fail('Protected/private properties cannot be assigned'); - } catch (Exception $e) { - // success - // @todo assert something? - } - - try { - $view->assign($this); - $this->fail('Assign spec requires string or array'); - } catch (Exception $e) { - // success - // @todo assert something? - } - } - - public function testEscape() - { - $view = new Zend_View(); - $original = "Me, Myself, & I"; - $escaped = $view->escape($original); - $this->assertNotEquals($original, $escaped); - $this->assertEquals("Me, Myself, & I", $escaped); - } - - public function testCustomEscape() - { - $view = new Zend_View(); - $view->setEscape('strip_tags'); - $original = "<p>Some text</p>"; - $escaped = $view->escape($original); - $this->assertNotEquals($original, $escaped); - $this->assertEquals("Some text", $escaped); - } - - public function testZf995UndefinedPropertiesReturnNull() - { - error_reporting(E_ALL | E_STRICT); - ini_set('display_errors', true); - $view = new Zend_View(); - $view->setScriptPath(dirname(__FILE__) . '/View/_templates'); - - ob_start(); - echo $view->render('testZf995.phtml'); - $content = ob_get_flush(); - $this->assertTrue(empty($content)); - } - - public function testInit() - { - $view = new Zend_ViewTest_Extension(); - $this->assertEquals('bar', $view->foo); - $paths = $view->getScriptPaths(); - $this->assertEquals(1, count($paths)); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . '_templates' . DIRECTORY_SEPARATOR, $paths[0]); - } - - public function testHelperViewAccessor() - { - $view = new Zend_View(); - $view->addHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir2/'); - $view->stub2(); - - $helpers = $view->getHelpers(); - $this->assertEquals(1, count($helpers)); - $this->assertTrue(isset($helpers['Stub2'])); - $stub2 = $helpers['Stub2']; - $this->assertTrue($stub2 instanceof Zend_View_Helper_Stub2); - $this->assertTrue(isset($stub2->view)); - $this->assertSame($view, $stub2->view); - } - - public function testSetBasePath() - { - $view = new Zend_View(); - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View'; - $view->setBasePath($base); - $this->_testBasePath($view, $base); - } - - public function testAddBasePath() - { - $view = new Zend_View(); - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View'; - $view->addBasePath($base); - $this->_testBasePath($view, $base); - - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View2'; - $view->addBasePath($base); - $this->_testBasePath($view, $base); - } - - public function testAddBasePathWithClassPrefix() - { - $view = new Zend_View(); - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View'; - $view->addBasePath($base, 'My_Foo'); - $this->_testBasePath($view, $base, 'My_Foo'); - } - - public function testSetBasePathFromConstructor() - { - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View'; - $view = new Zend_View(array('basePath' => $base)); - $this->_testBasePath($view, $base); - } - - public function testSetBasePathWithClassPrefix() - { - $view = new Zend_View(); - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View'; - $view->setBasePath($base, 'My_Foo'); - $this->_testBasePath($view, $base, 'My_Foo'); - } - - public function testSetBasePathFromConstructorWithClassPrefix() - { - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View'; - $view = new Zend_View(array('basePath' => $base, 'basePathPrefix' => 'My_Foo')); - $this->_testBasePath($view, $base); - } - - protected function _testBasePath(Zend_View $view, $base, $classPrefix = null) - { - $scriptPaths = $view->getScriptPaths(); - $helperPaths = $view->getHelperPaths(); - $filterPaths = $view->getFilterPaths(); - $this->assertContains($base . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR, $scriptPaths); - - $found = false; - $prefix = false; - foreach ($helperPaths as $pathPrefix => $paths) { - foreach ($paths as $path) { - if ($path == $base . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR) { - $found = true; - $prefix = $pathPrefix; - break; - } - } - } - $this->assertTrue($found, var_export($helperPaths, 1)); - if (null !== $classPrefix) { - $this->assertTrue($prefix !== false); - $this->assertEquals($classPrefix . '_Helper_', $prefix); - } - - $found = false; - $prefix = false; - foreach ($filterPaths as $pathPrefix => $paths) { - foreach ($paths as $path) { - if ($path == $base . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR) { - $found = true; - $prefix = $pathPrefix; - break; - } - } - } - $this->assertTrue($found, var_export($filterPaths, 1)); - if (null !== $classPrefix) { - $this->assertTrue($prefix !== false); - $this->assertEquals($classPrefix . '_Filter_', $prefix); - } - } - - public function handleNotices($errno, $errstr, $errfile, $errline) - { - if (!isset($this->notices)) { - $this->notices = array(); - } - if ($errno === E_USER_NOTICE) { - $this->notices[] = $errstr; - } - } - - public function testStrictVars() - { - $view = new Zend_View(); - $view->setScriptPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . '_templates'); - $view->strictVars(true); - set_error_handler(array($this, 'handleNotices'), E_USER_NOTICE); - $content = $view->render('testStrictVars.phtml'); - restore_error_handler(); - foreach (array('foo', 'bar') as $key) { - $this->assertContains('Key "' . $key . '" does not exist', $this->notices); - } - } - - public function testGetScriptPath() - { - $view = new Zend_View(); - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . '_templates'; - $view->setScriptPath($base); - $path = $view->getScriptPath('test.phtml'); - $this->assertEquals($base . DIRECTORY_SEPARATOR . 'test.phtml', $path); - } - - public function testGetHelper() - { - // require so we can do type hinting - require_once 'Zend/View/Helper/DeclareVars.php'; - $view = new Zend_View(); - $view->declareVars(); - $helper = $view->getHelper('declareVars'); - $this->assertTrue($helper instanceof Zend_View_Helper_DeclareVars); - } - - public function testGetHelperPath() - { - require_once 'Zend/View/Helper/DeclareVars.php'; - $reflection = new ReflectionClass('Zend_View_Helper_DeclareVars'); - $expected = $reflection->getFileName(); - - $view = new Zend_View(); - $view->declareVars(); - $helperPath = $view->getHelperPath('declareVars'); - $this->assertContains($helperPath, $expected); - } - - public function testGetFilter() - { - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR; - require_once $base . '_stubs' . DIRECTORY_SEPARATOR . 'FilterDir1' . DIRECTORY_SEPARATOR . 'Foo.php'; - - $view = new Zend_View(); - $view->setScriptPath($base . '_templates'); - $view->addFilterPath($base . '_stubs' . DIRECTORY_SEPARATOR . 'FilterDir1'); - - $filter = $view->getFilter('foo'); - $this->assertTrue($filter instanceof Zend_View_Filter_Foo); - } - - public function testGetFilterPath() - { - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR; - $expected = $base . '_stubs' . DIRECTORY_SEPARATOR . 'FilterDir1' . DIRECTORY_SEPARATOR . 'Foo.php'; - - $view = new Zend_View(); - $view->setScriptPath($base . '_templates'); - $view->addFilterPath($base . '_stubs' . DIRECTORY_SEPARATOR . 'FilterDir1'); - - $filterPath = $view->getFilterPath('foo'); - $this->assertEquals($expected, $filterPath); - } - - public function testGetFilters() - { - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR; - - $view = new Zend_View(); - $view->setScriptPath($base . '_templates'); - $view->addFilterPath($base . '_stubs' . DIRECTORY_SEPARATOR . 'FilterDir1'); - $view->addFilter('foo'); - - $filters = $view->getFilters(); - $this->assertEquals(1, count($filters)); - $this->assertEquals('foo', $filters[0]); - } - - public function testMissingViewScriptExceptionText() - { - $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR; - $view = new Zend_View(); - $view->setScriptPath($base . '_templates'); - - try { - $view->render('bazbatNotExists.php.tpl'); - $this->fail('Non-existent view script should cause an exception'); - } catch (Exception $e) { - $this->assertContains($base. '_templates', $e->getMessage()); - } - } - - public function testGetHelperIsCaseInsensitive() - { - $view = new Zend_View(); - $hidden = $view->formHidden('foo', 'bar'); - $this->assertContains('<input type="hidden"', $hidden); - - $hidden = $view->getHelper('formHidden')->formHidden('foo', 'bar'); - $this->assertContains('<input type="hidden"', $hidden); - - $hidden = $view->getHelper('FormHidden')->formHidden('foo', 'bar'); - $this->assertContains('<input type="hidden"', $hidden); - } - - public function testGetHelperUsingDifferentCasesReturnsSameInstance() - { - $view = new Zend_View(); - $helper1 = $view->getHelper('formHidden'); - $helper2 = $view->getHelper('FormHidden'); - - $this->assertSame($helper1, $helper2); - } - - /** - * @issue ZF-2742 - */ - public function testGetHelperWorksWithPredefinedClassNames() - { - $view = new Zend_View(); - - $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir2'); - try { - $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', null); - $this->fail('Exception for empty prefix was expected.'); - } catch (Exception $e) { - $this->assertContains('only takes strings', $e->getMessage()); - } - - try { - $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', null); - $this->fail('Exception for empty prefix was expected.'); - } catch (Exception $e) { - $this->assertContains('only takes strings', $e->getMessage()); - } - - - try { - $helper = $view->getHelper('Datetime'); - } catch (Exception $e) { - $this->assertContains('not found', $e->getMessage()); - } - } - - public function testUseStreamWrapperFlagShouldDefaultToFalse() - { - $this->view = new Zend_View(); - $this->assertFalse($this->view->useStreamWrapper()); - } - - public function testUseStreamWrapperStateShouldBeConfigurable() - { - $this->testUseStreamWrapperFlagShouldDefaultToFalse(); - $this->view->setUseStreamWrapper(true); - $this->assertTrue($this->view->useStreamWrapper()); - $this->view->setUseStreamWrapper(false); - $this->assertFalse($this->view->useStreamWrapper()); - } -} - -/** - * @category Zend - * @package Zend_View - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_ViewTest_Extension extends Zend_View -{ - public function init() - { - $this->assign('foo', 'bar'); - $this->setScriptPath(dirname(__FILE__) . '/View/_templates'); - } -} - -// Call Zend_ViewTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_ViewTest::main") { - Zend_ViewTest::main(); -} diff --git a/tests/Zend/Wildfire/AllTests.php b/tests/Zend/Wildfire/AllTests.php deleted file mode 100644 index 35d221314712f4375670506cf05271ca86116963..0000000000000000000000000000000000000000 --- a/tests/Zend/Wildfire/AllTests.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Wildfire_AllTests::main'); -} - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -require_once 'Zend/Wildfire/WildfireTest.php'; - - -class Zend_Wildfire_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Wildfire'); - - $suite->addTestSuite('Zend_Wildfire_WildfireTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Wildfire_AllTests::main') { - Zend_Wildfire_AllTests::main(); -} diff --git a/tests/Zend/Wildfire/WildfireTest.php b/tests/Zend/Wildfire/WildfireTest.php deleted file mode 100644 index 021452a9f1f0eaf217d69d199b3ec57acfefe770..0000000000000000000000000000000000000000 --- a/tests/Zend/Wildfire/WildfireTest.php +++ /dev/null @@ -1,712 +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_Wildfire - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: VersionTest.php 8064 2008-02-16 10:58:39Z thomas $ - */ - -require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; - -/** Zend_Wildfire_Channel_HttpHeaders */ -require_once 'Zend/Wildfire/Channel/HttpHeaders.php'; - -/** Zend_Wildfire_Plugin_FirePhp */ -require_once 'Zend/Wildfire/Plugin/FirePhp.php'; - -/** Zend_Wildfire_Plugin_FirePhp_Message */ -require_once 'Zend/Wildfire/Plugin/FirePhp/Message.php'; - -/** Zend_Controller_Request_Http */ -require_once 'Zend/Controller/Request/Http.php'; - -/** Zend_Controller_Response_Http */ -require_once 'Zend/Controller/Response/Http.php'; - -/** Zend_Controller_Front **/ -require_once 'Zend/Controller/Front.php'; - -/** Zend_Json */ -require_once 'Zend/Json.php'; - -/** Zend_Json_Encoder */ -require_once 'Zend/Json/Encoder.php'; - -/** - * @category Zend - * @package Zend_Wildfire - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Wildfire_WildfireTest extends PHPUnit_Framework_TestCase -{ - - protected $_controller = null; - protected $_request = null; - protected $_response = null; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_Wildfire_WildfireTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - date_default_timezone_set('America/Los_Angeles'); - } - - public function tearDown() - { - Zend_Controller_Front::getInstance()->resetInstance(); - Zend_Wildfire_Channel_HttpHeaders::destroyInstance(); - Zend_Wildfire_Plugin_FirePhp::destroyInstance(); - } - - protected function _setupWithFrontController() - { - $this->_request = new Zend_Wildfire_WildfireTest_Request(); - $this->_response = new Zend_Wildfire_WildfireTest_Response(); - $this->_controller = Zend_Controller_Front::getInstance(); - $this->_controller->resetInstance(); - $this->_controller->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files') - ->setRequest($this->_request) - ->setResponse($this->_response) - ->setParam('noErrorHandler', true) - ->setParam('noViewRenderer', true) - ->throwExceptions(false); - - $this->_request->setUserAgentExtensionEnabled(true); - } - - protected function _setupWithoutFrontController() - { - $this->_request = new Zend_Wildfire_WildfireTest_Request(); - $this->_response = new Zend_Wildfire_WildfireTest_Response(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $channel->setRequest($this->_request); - $channel->setResponse($this->_response); - - $this->_request->setUserAgentExtensionEnabled(true); - } - - public function testNoResponseObject() - { - Zend_Wildfire_Plugin_FirePhp::getInstance()->setEnabled(false); - Zend_Wildfire_Plugin_FirePhp::send('Hello World'); - - Zend_Wildfire_Plugin_FirePhp::getInstance()->setEnabled(true); - try { - Zend_Wildfire_Plugin_FirePhp::send('Hello World'); - $this->fail('Should throw a response object not initialized error'); - } catch (Exception $e) { - // success - } - } - - public function testIsReady1() - { - $this->_setupWithFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - - $this->assertTrue($channel->isReady()); - - $this->_request->setUserAgentExtensionEnabled(false); - - $this->assertFalse($channel->isReady()); - } - - public function testIsReady2() - { - $this->_setupWithoutFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - - $this->assertTrue($channel->isReady()); - - $this->_request->setUserAgentExtensionEnabled(false); - - $this->assertFalse($channel->isReady()); - } - - public function testFirePhpPluginInstanciation() - { - $this->_setupWithoutFrontController(); - try { - Zend_Wildfire_Plugin_FirePhp::getInstance(); - Zend_Wildfire_Plugin_FirePhp::init(null); - $this->fail('Should not be able to re-initialize'); - } catch (Exception $e) { - // success - } - } - - public function testFirePhpPluginEnablement() - { - $this->_setupWithoutFrontController(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $this->assertFalse($protocol->getMessages()); - - $this->assertTrue($firephp->getEnabled()); - - $this->assertTrue($firephp->send('Hello World')); - - $messages = array(Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE=> - array(Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI=> - array('[{"Type":"LOG"},"Hello World"]'))); - - $this->assertEquals(serialize($protocol->getMessages()), - serialize($messages)); - - $this->assertTrue($firephp->setEnabled(false)); - - $this->assertFalse($firephp->send('Hello World')); - - $this->assertFalse($protocol->getMessages()); - } - - public function testSetControllerPluginStackIndex1() - { - $this->_setupWithoutFrontController(); - $controller = Zend_Controller_Front::getInstance(); - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - $firephp->send('Hello World'); - - $plugins = $controller->getPlugins(); - - $this->assertEquals($plugins[999],$channel); - } - - public function testSetControllerPluginStackIndex2() - { - $this->_setupWithoutFrontController(); - $controller = Zend_Controller_Front::getInstance(); - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - - Zend_Wildfire_Channel_HttpHeaders::setControllerPluginStackIndex(99); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - $firephp->send('Hello World'); - - $plugins = $controller->getPlugins(); - - $this->assertEquals($plugins[99],$channel); - } - - public function testBasicLogging1() - { - $this->_setupWithoutFrontController(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - - $message = 'This is a log message!'; - - $firephp->send($message); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $headers = array(); - $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.1'; - $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; - $headers['X-Wf-1-1-1-1'] = '|[{"Type":"LOG"},"This is a log message!"]|'; - $headers['X-Wf-1-Index'] = '1'; - - $this->assertTrue($this->_response->verifyHeaders($headers)); - } - - public function testBasicLogging2() - { - $this->_setupWithFrontController(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - - $message = 'This is a log message!'; - - $firephp->send($message); - - $this->_controller->dispatch(); - - $headers = array(); - $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.1'; - $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; - $headers['X-Wf-1-1-1-1'] = '|[{"Type":"LOG"},"This is a log message!"]|'; - $headers['X-Wf-1-Index'] = '1'; - - $this->assertTrue($this->_response->verifyHeaders($headers)); - } - - /** - * At this point UTF-8 characters are not supported as Zend_Json_Decoder - * does not support them. - * Once ZF-4054 is resolved this test must be updated. - */ - public function testUTF8Logging() - { - $this->_setupWithFrontController(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - - $encodedMessage = $message = 'Отладочный'; - - if (function_exists('json_encode') && Zend_Json::$useBuiltinEncoderDecoder !== true) { - $encodedMessage = '\u041e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439'; - } - - $firephp->send($message); - - $this->_controller->dispatch(); - - $headers = array(); - $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.1'; - $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; - $headers['X-Wf-1-1-1-1'] = '|[{"Type":"LOG"},"'.$encodedMessage.'"]|'; - $headers['X-Wf-1-Index'] = '1'; - - $this->assertTrue($this->_response->verifyHeaders($headers)); - } - - public function testCyclicalObjectLogging() - { - $this->_setupWithFrontController(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - - $obj1 = new Zend_Wildfire_WildfireTest_JsonEncodingTestClass(); - $obj2 = new Zend_Wildfire_WildfireTest_JsonEncodingTestClass(); - - $obj1->child = $obj2; - $obj2->child = $obj1; - - $firephp->send($obj1); - - $this->_controller->dispatch(); - - $headers = array(); - $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.1'; - $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; - $headers['X-Wf-1-1-1-1'] = '|[{"Type":"LOG"},{"__className":"Zend_Wildfire_WildfireTest_JsonEncodingTestClass","undeclared:child":{"__className":"Zend_Wildfire_WildfireTest_JsonEncodingTestClass","undeclared:child":"** Recursion (Zend_Wildfire_WildfireTest_JsonEncodingTestClass) **"}}]|'; - $headers['X-Wf-1-Index'] = '1'; - - $this->assertTrue($this->_response->verifyHeaders($headers)); - } - - public function testAdvancedLogging() - { - $this->_setupWithoutFrontController(); - - $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance(); - - $message = 'This is a log message!'; - $label = 'Test Label'; - $table = array('Summary line for the table', - array( - array('Column 1', 'Column 2'), - array('Row 1 c 1',' Row 1 c 2'), - array('Row 2 c 1',' Row 2 c 2') - ) - ); - - $firephp->send($message, null, 'TRACE'); - $firephp->send($table, null, 'TABLE'); - - Zend_Wildfire_Plugin_FirePhp::send($message, $label); - Zend_Wildfire_Plugin_FirePhp::send($message, $label, Zend_Wildfire_Plugin_FirePhp::DUMP); - - try { - throw new Exception('Test Exception'); - } catch (Exception $e) { - Zend_Wildfire_Plugin_FirePhp::send($e); - } - - try { - Zend_Wildfire_Plugin_FirePhp::send($message, $label, 'UNKNOWN'); - $this->fail('Should not be able to log with undefined log style'); - } catch (Exception $e) { - // success - } - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $messages = array(Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE=> - array(Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI=> - array(1=>'[{"Type":"TABLE"},["Summary line for the table",[["Column 1","Column 2"],["Row 1 c 1"," Row 1 c 2"],["Row 2 c 1"," Row 2 c 2"]]]]', - 2=>'[{"Type":"LOG","Label":"Test Label"},"This is a log message!"]')), - Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_DUMP=> - array(Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI=> - array('{"Test Label":"This is a log message!"}'))); - - $qued_messages = $protocol->getMessages(); - unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0]); - unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][3]); - - $this->assertEquals(serialize($qued_messages), - serialize($messages)); - } - - - public function testMessage() - { - $this->_setupWithoutFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $message = new Zend_Wildfire_Plugin_FirePhp_Message(Zend_Wildfire_Plugin_FirePhp::LOG, 'Message 1'); - - - $this->assertEquals($message->getStyle(), Zend_Wildfire_Plugin_FirePhp::LOG); - - $message->setStyle(Zend_Wildfire_Plugin_FirePhp::INFO); - - $this->assertEquals($message->getStyle(), Zend_Wildfire_Plugin_FirePhp::INFO); - - - $this->assertNull($message->getLabel()); - - $message->setLabel('Label 1'); - - $this->assertEquals($message->getLabel(), 'Label 1'); - - - $this->assertFalse($message->getDestroy()); - - $message->setDestroy(true); - - $this->assertTrue($message->getDestroy()); - - - $this->assertEquals($message->getMessage(), 'Message 1'); - - $message->setMessage('Message 2'); - - $this->assertEquals($message->getMessage(), 'Message 2'); - - - - $message->setDestroy(true); - $this->assertfalse(Zend_Wildfire_Plugin_FirePhp::send($message)); - - $message->setDestroy(false); - $this->assertTrue(Zend_Wildfire_Plugin_FirePhp::send($message)); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $messages = $protocol->getMessages(); - - $this->assertEquals($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] - [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0], - '[{"Type":"INFO","Label":"Label 1"},"Message 2"]'); - } - - public function testMessageGroups() - { - $this->_setupWithFrontController(); - - Zend_Wildfire_Plugin_FirePhp::group('Test Group'); - Zend_Wildfire_Plugin_FirePhp::send('Test Message'); - Zend_Wildfire_Plugin_FirePhp::groupEnd(); - - $this->_controller->dispatch(); - - $headers = array(); - $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.1'; - $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; - $headers['X-Wf-1-1-1-1'] = '|[{"Type":"GROUP_START","Label":"Test Group"},null]|'; - $headers['X-Wf-1-1-1-2'] = '|[{"Type":"LOG"},"Test Message"]|'; - $headers['X-Wf-1-1-1-3'] = '|[{"Type":"GROUP_END"},null]|'; - $headers['X-Wf-1-Index'] = '3'; - - $this->assertTrue($this->_response->verifyHeaders($headers)); - } - - public function testMessageComparison() - { - $label = 'Message'; - - $message1 = new Zend_Wildfire_Plugin_FirePhp_Message(Zend_Wildfire_Plugin_FirePhp::LOG, $label); - - $message2 = new Zend_Wildfire_Plugin_FirePhp_Message(Zend_Wildfire_Plugin_FirePhp::LOG, $label); - - $this->assertNotEquals($message1,$message2); - } - - public function testBufferedMessage1() - { - $this->_setupWithoutFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $message = new Zend_Wildfire_Plugin_FirePhp_Message(Zend_Wildfire_Plugin_FirePhp::LOG, 'Message 1'); - $this->assertFalse($message->setBuffered(true)); - - Zend_Wildfire_Plugin_FirePhp::send($message); - - $this->assertFalse($protocol->getMessages()); - - $message->setMessage('Message 2'); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $messages = $protocol->getMessages(); - - $this->assertEquals($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] - [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0], - '[{"Type":"LOG"},"Message 2"]'); - } - - public function testBufferedMessage2() - { - $this->_setupWithFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $message = new Zend_Wildfire_Plugin_FirePhp_Message(Zend_Wildfire_Plugin_FirePhp::LOG, 'Message 1'); - $this->assertFalse($message->setBuffered(true)); - - Zend_Wildfire_Plugin_FirePhp::send($message); - - $this->assertFalse($protocol->getMessages()); - - $message->setMessage('Message 2'); - - $this->_controller->dispatch(); - - $messages = $protocol->getMessages(); - - $this->assertEquals($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] - [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0], - '[{"Type":"LOG"},"Message 2"]'); - } - - public function testDestroyedBufferedMessage() - { - $this->_setupWithoutFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI); - - $message = new Zend_Wildfire_Plugin_FirePhp_Message(Zend_Wildfire_Plugin_FirePhp::LOG, 'Message 1'); - $message->setBuffered(true); - - Zend_Wildfire_Plugin_FirePhp::send($message); - - $this->assertEquals($message->getStyle(), Zend_Wildfire_Plugin_FirePhp::LOG); - - $message->setStyle(Zend_Wildfire_Plugin_FirePhp::INFO); - - $this->assertEquals($message->getStyle(), Zend_Wildfire_Plugin_FirePhp::INFO); - - $message->setDestroy(true); - - Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); - - $this->assertFalse($protocol->getMessages()); - } - - public function testChannelInstanciation() - { - $this->_setupWithoutFrontController(); - try { - Zend_Wildfire_Channel_HttpHeaders::getInstance(); - Zend_Wildfire_Channel_HttpHeaders::init(null); - $this->fail('Should not be able to re-initialize'); - } catch (Exception $e) { - // success - } - } - - public function testChannelFlush() - { - $this->_setupWithoutFrontController(); - - $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); - - $this->assertFalse($channel->flush()); - - Zend_Wildfire_Plugin_FirePhp::send('Hello World'); - - $this->assertTrue($channel->flush()); - - $this->_request->setUserAgentExtensionEnabled(false); - - $this->assertFalse($channel->flush()); - } - - public function testFirePhpPluginSubclass() - { - - $firephp = Zend_Wildfire_Plugin_FirePhp::init('Zend_Wildfire_WildfireTest_FirePhpPlugin'); - - $this->assertEquals(get_class($firephp), - 'Zend_Wildfire_WildfireTest_FirePhpPlugin'); - - Zend_Wildfire_Plugin_FirePhp::destroyInstance(); - - try { - Zend_Wildfire_Plugin_FirePhp::init('Zend_Wildfire_WildfireTest_Request'); - $this->fail('Should not be able to initialize'); - } catch (Exception $e) { - // success - } - - $this->assertNull(Zend_Wildfire_Plugin_FirePhp::getInstance(true)); - - try { - Zend_Wildfire_Plugin_FirePhp::init(array()); - $this->fail('Should not be able to initialize'); - } catch (Exception $e) { - // success - } - - $this->assertNull(Zend_Wildfire_Plugin_FirePhp::getInstance(true)); - } - - public function testHttpHeadersChannelSubclass() - { - - $firephp = Zend_Wildfire_Channel_HttpHeaders::init('Zend_Wildfire_WildfireTest_HttpHeadersChannel'); - - $this->assertEquals(get_class($firephp), - 'Zend_Wildfire_WildfireTest_HttpHeadersChannel'); - - Zend_Wildfire_Channel_HttpHeaders::destroyInstance(); - - try { - Zend_Wildfire_Channel_HttpHeaders::init('Zend_Wildfire_WildfireTest_Request'); - $this->fail('Should not be able to initialize'); - } catch (Exception $e) { - // success - } - - $this->assertNull(Zend_Wildfire_Channel_HttpHeaders::getInstance(true)); - - try { - Zend_Wildfire_Channel_HttpHeaders::init(array()); - $this->fail('Should not be able to initialize'); - } catch (Exception $e) { - // success - } - - $this->assertNull(Zend_Wildfire_Channel_HttpHeaders::getInstance(true)); - } - -} - -class Zend_Wildfire_WildfireTest_JsonEncodingTestClass -{ -} - - -class Zend_Wildfire_WildfireTest_FirePhpPlugin extends Zend_Wildfire_Plugin_FirePhp -{ -} - -class Zend_Wildfire_WildfireTest_HttpHeadersChannel extends Zend_Wildfire_Channel_HttpHeaders -{ -} - -class Zend_Wildfire_WildfireTest_Request extends Zend_Controller_Request_Http -{ - - protected $_enabled = false; - - public function setUserAgentExtensionEnabled($enabled) { - $this->_enabled = $enabled; - } - - public function getHeader($header) - { - if ($header == 'User-Agent') { - if ($this->_enabled) { - return 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 FirePHP/0.1.0'; - } else { - return 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'; - } - } - } -} - - -class Zend_Wildfire_WildfireTest_Response extends Zend_Controller_Response_Http -{ - - public function verifyHeaders($headers) - { - $response_headers = $this->getHeaders(); - if (!$response_headers) { - return false; - } - - $keys1 = array_keys($headers); - sort($keys1); - $keys1 = serialize($keys1); - - $keys2 = array(); - foreach ($response_headers as $header ) { - $keys2[] = $header['name']; - } - sort($keys2); - $keys2 = serialize($keys2); - - if ($keys1 != $keys2) { - return false; - } - - $values1 = array_values($headers); - sort($values1); - $values1 = serialize($values1); - - $values2 = array(); - foreach ($response_headers as $header ) { - $values2[] = $header['value']; - } - sort($values2); - $values2 = serialize($values2); - - if ($values1 != $values2) { - return false; - } - - return true; - } - -} diff --git a/tests/Zend/Wildfire/_files/IndexController.php b/tests/Zend/Wildfire/_files/IndexController.php deleted file mode 100644 index de333f6bba5cb27dc1ac1c9eee53d1c716f5e588..0000000000000000000000000000000000000000 --- a/tests/Zend/Wildfire/_files/IndexController.php +++ /dev/null @@ -1,50 +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_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IndexController.php 9353 2008-05-04 19:16:09Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -require_once 'Zend/Controller/Action.php'; - -/** - * Mock file for testbed - * - * @category Zend - * @package Zend_Controller - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class IndexController extends Zend_Controller_Action -{ - - /** - * Test Function for indexAction - * - * @return void - */ - public function indexAction() - { - } - -} diff --git a/tests/Zend/XmlRpc/AllTests.php b/tests/Zend/XmlRpc/AllTests.php deleted file mode 100644 index 962f6af7efd16d3ce647c2ea6dc8637057834814..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/AllTests.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_XmlRpc_AllTests::main'); - set_include_path( - dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'tests' - . PATH_SEPARATOR . dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'library' - . PATH_SEPARATOR . get_include_path()); -} - -// require_once 'PHPUnit/Framework/TestSuite.php'; -// require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'Zend/XmlRpc/ValueTest.php'; -require_once 'Zend/XmlRpc/RequestTest.php'; -require_once 'Zend/XmlRpc/Request/HttpTest.php'; -require_once 'Zend/XmlRpc/ResponseTest.php'; -require_once 'Zend/XmlRpc/FaultTest.php'; -require_once 'Zend/XmlRpc/ClientTest.php'; -require_once 'Zend/XmlRpc/ServerTest.php'; -require_once 'Zend/XmlRpc/Server/CacheTest.php'; -require_once 'Zend/XmlRpc/Server/FaultTest.php'; - -class Zend_XmlRpc_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_XmlRpc'); - - $suite->addTestSuite('Zend_XmlRpc_ValueTest'); - $suite->addTestSuite('Zend_XmlRpc_RequestTest'); - $suite->addTestSuite('Zend_XmlRpc_Request_HttpTest'); - $suite->addTestSuite('Zend_XmlRpc_ResponseTest'); - $suite->addTestSuite('Zend_XmlRpc_FaultTest'); - $suite->addTestSuite('Zend_XmlRpc_ClientTest'); - $suite->addTestSuite('Zend_XmlRpc_ServerTest'); - $suite->addTestSuite('Zend_XmlRpc_Server_CacheTest'); - $suite->addTestSuite('Zend_XmlRpc_Server_FaultTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_XmlRpc_AllTests::main') { - Zend_XmlRpc_AllTests::main(); -} diff --git a/tests/Zend/XmlRpc/ClientTest.php b/tests/Zend/XmlRpc/ClientTest.php deleted file mode 100644 index 7ec0c4dc9423ad2d1f0c4fdc82b94758972c0e8d..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/ClientTest.php +++ /dev/null @@ -1,557 +0,0 @@ -<?php -// Call Zend_XmlRpc_ClientTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_XmlRpc_ClientTest::main"); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/XmlRpc/Client.php'; - -require_once 'Zend/XmlRpc/Response.php'; - -require_once 'Zend/Http/Client/Adapter/Test.php'; - -/** - * Test case for Zend_XmlRpc_Value - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id$ - */ -class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_ClientTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - public function setUp() - { - $this->httpAdapter = new Zend_Http_Client_Adapter_Test(); - $this->httpClient = new Zend_Http_Client('http://foo', - array('adapter' => $this->httpAdapter)); - - $this->xmlrpcClient = new Zend_XmlRpc_Client('http://foo'); - $this->xmlrpcClient->setHttpClient($this->httpClient); - } - - // HTTP Client - - public function testGettingDefaultHttpClient() - { - $xmlrpcClient = new Zend_XmlRpc_Client('http://foo'); - $httpClient = $xmlrpcClient->getHttpClient(); - $this->assertType('Zend_Http_Client', $httpClient); - $this->assertSame($httpClient, $xmlrpcClient->getHttpClient()); - } - - public function testSettingAndGettingHttpClient() - { - $xmlrpcClient = new Zend_XmlRpc_Client('http://foo'); - $httpClient = new Zend_Http_Client('http://foo'); - $this->assertNotSame($httpClient, $xmlrpcClient->getHttpClient()); - - $xmlrpcClient->setHttpClient($httpClient); - $this->assertSame($httpClient, $xmlrpcClient->getHttpClient()); - } - - public function testSettingHttpClientViaContructor() - { - $xmlrpcClient = new Zend_XmlRpc_Client('http://foo', $this->httpClient); - $httpClient = $xmlrpcClient->getHttpClient(); - $this->assertSame($this->httpClient, $httpClient); - } - - // Request & Response - - public function testLastRequestAndResponseAreInitiallyNull() - { - $this->assertNull($this->xmlrpcClient->getLastRequest()); - $this->assertNull($this->xmlrpcClient->getLastResponse()); - } - - public function testLastRequestAndResponseAreSetAfterRpcMethodCall() - { - $this->setServerResponseTo(true); - $this->xmlrpcClient->call('foo'); - - $this->assertType('Zend_XmlRpc_Request', $this->xmlrpcClient->getLastRequest()); - $this->assertType('Zend_XmlRpc_Response', $this->xmlrpcClient->getLastResponse()); - } - - public function testSuccessfulRpcMethodCallWithNoParameters() - { - $expectedMethod = 'foo.bar'; - $expectedReturn = 7; - - $this->setServerResponseTo($expectedReturn); - $this->assertSame($expectedReturn, $this->xmlrpcClient->call($expectedMethod)); - - $request = $this->xmlrpcClient->getLastRequest(); - $response = $this->xmlrpcClient->getLastResponse(); - - $this->assertSame($expectedMethod, $request->getMethod()); - $this->assertSame(array(), $request->getParams()); - $this->assertSame($expectedReturn, $response->getReturnValue()); - $this->assertFalse($response->isFault()); - } - - public function testSuccessfulRpcMethodCallWithParameters() - { - $expectedMethod = 'foo.bar'; - $expectedParams = array(1, 'foo' => 'bar', 1.1, true); - $expectedReturn = array(7, false, 'foo' => 'bar'); - - $this->setServerResponseTo($expectedReturn); - - $actualReturn = $this->xmlrpcClient->call($expectedMethod, $expectedParams); - $this->assertSame($expectedReturn, $actualReturn); - - $request = $this->xmlrpcClient->getLastRequest(); - $response = $this->xmlrpcClient->getLastResponse(); - - $this->assertSame($expectedMethod, $request->getMethod()); - $this->assertSame($expectedParams, $request->getParams()); - $this->assertSame($expectedReturn, $response->getReturnValue()); - $this->assertFalse($response->isFault()); - } - - /** - * @see ZF-2090 - */ - public function testSuccessfullyDetectsEmptyArrayParameterAsArray() - { - $expectedMethod = 'foo.bar'; - $expectedParams = array(array()); - $expectedReturn = array(true); - - $this->setServerResponseTo($expectedReturn); - - $actualReturn = $this->xmlrpcClient->call($expectedMethod, $expectedParams); - $this->assertSame($expectedReturn, $actualReturn); - - $request = $this->xmlrpcClient->getLastRequest(); - - $this->assertSame($expectedParams, $request->getParams()); - } - - /** - * Test for ZF-1412 - * - * @return void - */ - public function testSuccessfulRpcMethodCallWithMixedDateParameters() - { - $time = time(); - $expectedMethod = 'foo.bar'; - $expectedParams = array( - 'username', - new Zend_XmlRpc_Value_DateTime($time) - ); - $expectedReturn = array('username', $time); - - $this->setServerResponseTo($expectedReturn); - - $actualReturn = $this->xmlrpcClient->call($expectedMethod, $expectedParams); - $this->assertSame($expectedReturn, $actualReturn); - - $request = $this->xmlrpcClient->getLastRequest(); - $response = $this->xmlrpcClient->getLastResponse(); - - $this->assertSame($expectedMethod, $request->getMethod()); - $this->assertSame($expectedParams, $request->getParams()); - $this->assertSame($expectedReturn, $response->getReturnValue()); - $this->assertFalse($response->isFault()); - } - - /** - * @see ZF-1797 - */ - public function testSuccesfulRpcMethodCallWithXmlRpcValueParameters() - { - $time = time(); - $params = array( - new Zend_XmlRpc_Value_Boolean(true), - new Zend_XmlRpc_Value_Integer(4), - new Zend_XmlRpc_Value_String('foo') - ); - $expect = array(true, 4, 'foo'); - - $this->setServerResponseTo($expect); - - $result = $this->xmlrpcClient->call('foo.bar', $params); - $this->assertSame($expect, $result); - - $request = $this->xmlrpcClient->getLastRequest(); - $response = $this->xmlrpcClient->getLastResponse(); - - $this->assertSame('foo.bar', $request->getMethod()); - $this->assertSame($params, $request->getParams()); - $this->assertSame($expect, $response->getReturnValue()); - $this->assertFalse($response->isFault()); - } - - /**#@+ - * @see ZF-2978 - */ - public function testSkippingSystemCallDisabledByDefault() - { - $this->assertFalse($this->xmlrpcClient->skipSystemLookup()); - } - - public function testAllowsSkippingSystemCallForArrayStructLookup() - { - $this->xmlrpcClient->setSkipSystemLookup(true); - $this->assertTrue($this->xmlrpcClient->skipSystemLookup()); - } - - public function testSkipsSystemCallWhenDirected() - { - $this->markTestIncomplete('Cannot complete this test until we add logging of requests sent to HTTP test client'); - } - - /**#@-*/ - - // Faults - - public function testRpcMethodCallThrowsOnHttpFailure() - { - $status = 404; - $message = 'Not Found'; - $body = 'oops'; - - $response = $this->makeHttpResponseFrom($body, $status, $message); - $this->httpAdapter->setResponse($response); - - try { - $this->xmlrpcClient->call('foo'); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_XmlRpc_Client_HttpException', $e); - $this->assertEquals($message, $e->getMessage()); - $this->assertEquals($status, $e->getCode()); - } - } - - public function testRpcMethodCallThrowsOnXmlRpcFault() - { - $code = 9; - $message = 'foo'; - - $fault = new Zend_XmlRpc_Fault($code, $message); - $xml = $fault->saveXML(); - - $response = $this->makeHttpResponseFrom($xml); - $this->httpAdapter->setResponse($response); - - try { - $this->xmlrpcClient->call('foo'); - $this->fail(); - } catch (Exception $e) { - $this->assertType('Zend_XmlRpc_Client_FaultException', $e); - $this->assertEquals($message, $e->getMessage()); - $this->assertEquals($code, $e->getCode()); - } - } - - // Server Proxy - - public function testGetProxyReturnsServerProxy() - { - $class = 'Zend_XmlRpc_Client_ServerProxy'; - $this->assertType($class, $this->xmlrpcClient->getProxy()); - } - - public function testRpcMethodCallsThroughServerProxy() - { - $expectedReturn = array(7, false, 'foo' => 'bar'); - $this->setServerResponseTo($expectedReturn); - - $server = $this->xmlrpcClient->getProxy(); - $this->assertSame($expectedReturn, $server->listMethods()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('listMethods', $request->getMethod()); - } - - public function testRpcMethodCallsThroughNestedServerProxies() - { - $expectedReturn = array(7, false, 'foo' => 'bar'); - $this->setServerResponseTo($expectedReturn); - - $server = $this->xmlrpcClient->getProxy('foo'); - $this->assertSame($expectedReturn, $server->bar->baz->boo()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('foo.bar.baz.boo', $request->getMethod()); - } - - public function testClientCachesServerProxies() - { - $proxy = $this->xmlrpcClient->getProxy(); - $this->assertSame($proxy, $this->xmlrpcClient->getProxy()); - - $proxy = $this->xmlrpcClient->getProxy('foo'); - $this->assertSame($proxy, $this->xmlrpcClient->getProxy('foo')); - } - - public function testServerProxyCachesNestedProxies() - { - $proxy = $this->xmlrpcClient->getProxy(); - - $foo = $proxy->foo; - $this->assertSame($foo, $proxy->foo); - - $bar = $proxy->foo->bar; - $this->assertSame($bar, $proxy->foo->bar); - } - - // Introspection - - public function testGettingDefaultIntrospector() - { - $xmlrpcClient = new Zend_XmlRpc_Client('http://foo'); - $introspector = $xmlrpcClient->getIntrospector(); - $this->assertType('Zend_XmlRpc_Client_ServerIntrospection', $introspector); - $this->assertSame($introspector, $xmlrpcClient->getIntrospector()); - } - - public function testSettingAndGettingIntrospector() - { - $xmlrpcClient = new Zend_XmlRpc_Client('http://foo'); - $introspector = new Zend_XmlRpc_Client_ServerIntrospection($xmlrpcClient); - $this->assertNotSame($introspector, $xmlrpcClient->getIntrospector()); - - $xmlrpcClient->setIntrospector($introspector); - $this->assertSame($introspector, $xmlrpcClient->getIntrospector()); - } - - public function testGettingMethodSignature() - { - $method = 'foo'; - $signatures = array(array('int', 'int', 'int')); - $this->setServerResponseTo($signatures); - - $i = $this->xmlrpcClient->getIntrospector(); - $this->assertEquals($signatures, $i->getMethodSignature($method)); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('system.methodSignature', $request->getMethod()); - $this->assertEquals(array($method), $request->getParams()); - } - - public function testListingMethods() - { - $methods = array('foo', 'bar', 'baz'); - $this->setServerResponseTo($methods); - - $i = $this->xmlrpcClient->getIntrospector(); - $this->assertEquals($methods, $i->listMethods()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('system.listMethods', $request->getMethod()); - $this->assertEquals(array(), $request->getParams()); - } - - public function testGettingAllMethodSignaturesByLooping() - { - // system.listMethods() will return ['foo', 'bar'] - $methods = array('foo', 'bar'); - $response = $this->getServerResponseFor($methods); - $this->httpAdapter->setResponse($response); - - // system.methodSignature('foo') will return [['int'], ['int', 'string']] - $fooSignatures = array(array('int'), array('int', 'string')); - $response = $this->getServerResponseFor($fooSignatures); - $this->httpAdapter->addResponse($response); - - // system.methodSignature('bar') will return [['boolean']] - $barSignatures = array(array('boolean')); - $response = $this->getServerResponseFor($barSignatures); - $this->httpAdapter->addResponse($response); - - $expected = array('foo' => $fooSignatures, - 'bar' => $barSignatures); - - $i = $this->xmlrpcClient->getIntrospector(); - $this->assertEquals($expected, $i->getSignatureForEachMethodByLooping()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('system.methodSignature', $request->getMethod()); - $this->assertEquals(array('bar'), $request->getParams()); - } - - public function testGettingAllMethodSignaturesByMulticall() - { - // system.listMethods() will return ['foo', 'bar'] - $whatListMethodsReturns = array('foo', 'bar'); - $response = $this->getServerResponseFor($whatListMethodsReturns); - $this->httpAdapter->setResponse($response); - - // after system.listMethods(), these system.multicall() params are expected - $multicallParams = array(array('methodName' => 'system.methodSignature', - 'params' => array('foo')), - array('methodName' => 'system.methodSignature', - 'params' => array('bar'))); - - // system.multicall() will then return [fooSignatures, barSignatures] - $fooSignatures = array(array('int'), array('int', 'string')); - $barSignatures = array(array('boolean')); - $whatMulticallReturns = array($fooSignatures, $barSignatures); - $response = $this->getServerResponseFor($whatMulticallReturns); - $this->httpAdapter->addResponse($response); - - $i = $this->xmlrpcClient->getIntrospector(); - - $expected = array('foo' => $fooSignatures, - 'bar' => $barSignatures); - $this->assertEquals($expected, $i->getSignatureForEachMethodByMulticall()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('system.multicall', $request->getMethod()); - $this->assertEquals(array($multicallParams), $request->getParams()); - } - - public function testGettingAllMethodSignaturesByMulticallThrowsOnBadCount() - { - // system.listMethods() will return ['foo', 'bar'] - $whatListMethodsReturns = array('foo', 'bar'); - $response = $this->getServerResponseFor($whatListMethodsReturns); - $this->httpAdapter->setResponse($response); - - // system.multicall() will then return only [fooSignatures] - $fooSignatures = array(array('int'), array('int', 'string')); - $whatMulticallReturns = array($fooSignatures); // error! no bar signatures! - - $response = $this->getServerResponseFor($whatMulticallReturns); - $this->httpAdapter->addResponse($response); - - $i = $this->xmlrpcClient->getIntrospector(); - - try { - $i->getSignatureForEachMethodByMulticall(); - } catch (Zend_XmlRpc_Client_IntrospectException $e) { - $this->assertRegexp('/bad number/i', $e->getMessage()); - } - } - - public function testGettingAllMethodSignaturesByMulticallThrowsOnBadType() - { - // system.listMethods() will return ['foo', 'bar'] - $whatListMethodsReturns = array('foo', 'bar'); - $response = $this->getServerResponseFor($whatListMethodsReturns); - $this->httpAdapter->setResponse($response); - - // system.multicall() will then return only an int - $whatMulticallReturns = 1; // error! no signatures? - - $response = $this->getServerResponseFor($whatMulticallReturns); - $this->httpAdapter->addResponse($response); - - $i = $this->xmlrpcClient->getIntrospector(); - - try { - $i->getSignatureForEachMethodByMulticall(); - } catch (Zend_XmlRpc_Client_IntrospectException $e) { - $this->assertRegexp('/got integer/i', $e->getMessage()); - } - } - - public function testGettingAllMethodSignaturesDefaultsToMulticall() - { - // system.listMethods() will return ['foo', 'bar'] - $whatListMethodsReturns = array('foo', 'bar'); - $response = $this->getServerResponseFor($whatListMethodsReturns); - $this->httpAdapter->setResponse($response); - - // system.multicall() will then return [fooSignatures, barSignatures] - $fooSignatures = array(array('int'), array('int', 'string')); - $barSignatures = array(array('boolean')); - $whatMulticallReturns = array($fooSignatures, $barSignatures); - $response = $this->getServerResponseFor($whatMulticallReturns); - $this->httpAdapter->addResponse($response); - - $i = $this->xmlrpcClient->getIntrospector(); - - $expected = array('foo' => $fooSignatures, - 'bar' => $barSignatures); - $this->assertEquals($expected, $i->getSignatureForEachMethod()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('system.multicall', $request->getMethod()); - } - - public function testGettingAllMethodSignaturesDegradesToLooping() - { - // system.listMethods() will return ['foo', 'bar'] - $whatListMethodsReturns = array('foo', 'bar'); - $response = $this->getServerResponseFor($whatListMethodsReturns); - $this->httpAdapter->setResponse($response); - - // system.multicall() will return a fault - $fault = new Zend_XmlRpc_Fault(7, 'bad method'); - $xml = $fault->saveXML(); - $response = $this->makeHttpResponseFrom($xml); - $this->httpAdapter->addResponse($response); - - // system.methodSignature('foo') will return [['int'], ['int', 'string']] - $fooSignatures = array(array('int'), array('int', 'string')); - $response = $this->getServerResponseFor($fooSignatures); - $this->httpAdapter->addResponse($response); - - // system.methodSignature('bar') will return [['boolean']] - $barSignatures = array(array('boolean')); - $response = $this->getServerResponseFor($barSignatures); - $this->httpAdapter->addResponse($response); - - $i = $this->xmlrpcClient->getIntrospector(); - - $expected = array('foo' => $fooSignatures, - 'bar' => $barSignatures); - $this->assertEquals($expected, $i->getSignatureForEachMethod()); - - $request = $this->xmlrpcClient->getLastRequest(); - $this->assertEquals('system.methodSignature', $request->getMethod()); - } - - - // Helpers - - public function setServerResponseTo($nativeVars) - { - $response = $this->getServerResponseFor($nativeVars); - $this->httpAdapter->setResponse($response); - } - - public function getServerResponseFor($nativeVars) - { - $response = new Zend_XmlRpc_Response(); - $response->setReturnValue($nativeVars); - $xml = $response->saveXML(); - - $response = $this->makeHttpResponseFrom($xml); - return $response; - } - - public function makeHttpResponseFrom($data, $status=200, $message='OK') - { - $headers = array("HTTP/1.1 $status $message", - "Status: $status", - 'Content_Type: text/xml; charset=utf-8', - 'Content-Length: ' . strlen($data) - ); - return implode("\r\n", $headers) . "\r\n\r\n$data\r\n\r\n"; - } -} - -// Call Zend_XmlRpc_ClientTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ClientTest::main") { - Zend_XmlRpc_ClientTest::main(); -} diff --git a/tests/Zend/XmlRpc/FaultTest.php b/tests/Zend/XmlRpc/FaultTest.php deleted file mode 100644 index 76c868e59d4101b0c0b48f1abf5b34dee43012f4..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/FaultTest.php +++ /dev/null @@ -1,223 +0,0 @@ -<?php -require_once 'Zend/XmlRpc/Fault.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_XmlRpc_Fault - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: FaultTest.php 5279 2007-06-13 14:11:19Z matthew $ - */ -class Zend_XmlRpc_FaultTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_XmlRpc_Fault object - * @var Zend_XmlRpc_Fault - */ - protected $_fault; - - /** - * Setup environment - */ - public function setUp() - { - $this->_fault = new Zend_XmlRpc_Fault(); - } - - /** - * Teardown environment - */ - public function tearDown() - { - unset($this->_fault); - } - - /** - * __construct() test - */ - public function test__construct() - { - $this->assertTrue($this->_fault instanceof Zend_XmlRpc_Fault); - $this->assertEquals(404, $this->_fault->getCode()); - $this->assertEquals('Unknown Error', $this->_fault->getMessage()); - } - - /** - * get/setCode() test - */ - public function testCode() - { - $this->_fault->setCode('1000'); - $this->assertEquals(1000, $this->_fault->getCode()); - } - - /** - * get/setMessage() test - */ - public function testMessage() - { - $this->_fault->setMessage('Message'); - $this->assertEquals('Message', $this->_fault->getMessage()); - } - - protected function _createXml() - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $response = $dom->appendChild($dom->createElement('methodResponse')); - $fault = $response->appendChild($dom->createElement('fault')); - $value = $fault->appendChild($dom->createElement('value')); - $struct = $value->appendChild($dom->createElement('struct')); - - $member1 = $struct->appendChild($dom->createElement('member')); - $member1->appendChild($dom->createElement('name', 'faultCode')); - $value1 = $member1->appendChild($dom->createElement('value')); - $value1->appendChild($dom->createElement('int', 1000)); - - $member2 = $struct->appendChild($dom->createElement('member')); - $member2->appendChild($dom->createElement('name', 'faultString')); - $value2 = $member2->appendChild($dom->createElement('value')); - $value2->appendChild($dom->createElement('string', 'Error string')); - - return $dom->saveXML(); - } - - protected function _createNonStandardXml() - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $response = $dom->appendChild($dom->createElement('methodResponse')); - $fault = $response->appendChild($dom->createElement('fault')); - $value = $fault->appendChild($dom->createElement('value')); - $struct = $value->appendChild($dom->createElement('struct')); - - $member1 = $struct->appendChild($dom->createElement('member')); - $member1->appendChild($dom->createElement('name', 'faultCode')); - $value1 = $member1->appendChild($dom->createElement('value')); - $value1->appendChild($dom->createElement('int', 1000)); - - $member2 = $struct->appendChild($dom->createElement('member')); - $member2->appendChild($dom->createElement('name', 'faultString')); - $value2 = $member2->appendChild($dom->createElement('value', 'Error string')); - - return $dom->saveXML(); - } - - /** - * loadXml() test - */ - public function testLoadXml() - { - $xml = $this->_createXml(); - - try { - $parsed = $this->_fault->loadXml($xml); - } catch (Exception $e) { - $this->fail('Failed to parse XML: ' . $e->getMessage()); - } - $this->assertTrue($parsed, $xml); - - $this->assertEquals(1000, $this->_fault->getCode()); - $this->assertEquals('Error string', $this->_fault->getMessage()); - - try { - $parsed = $this->_fault->loadXml('foo'); - $this->fail('Should not parse invalid XML'); - } catch (Exception $e) { - // do nothing - } - } - - /** - * Zend_XmlRpc_Fault::isFault() test - */ - public function testIsFault() - { - $xml = $this->_createXml(); - - $this->assertTrue(Zend_XmlRpc_Fault::isFault($xml), $xml); - $this->assertFalse(Zend_XmlRpc_Fault::isFault('foo')); - $this->assertFalse(Zend_XmlRpc_Fault::isFault(array('foo'))); - } - - /** - * helper for saveXML() and __toString() tests - * - * @param string $xml - * @return void - */ - protected function _testXmlFault($xml) - { - try { - $sx = new SimpleXMLElement($xml); - } catch (Exception $e) { - $this->fail('Unable to parse generated XML'); - } - - $this->assertTrue($sx->fault ? true : false, $xml); - $this->assertTrue($sx->fault->value ? true : false, $xml); - $this->assertTrue($sx->fault->value->struct ? true : false, $xml); - $count = 0; - foreach ($sx->fault->value->struct->member as $member) { - $count++; - $this->assertTrue($member->name ? true : false, $xml); - $this->assertTrue($member->value ? true : false, $xml); - if ('faultCode' == (string) $member->name) { - $this->assertTrue($member->value->int ? true : false, $xml); - $this->assertEquals(1000, (int) $member->value->int, $xml); - } - if ('faultString' == (string) $member->name) { - $this->assertTrue($member->value->string ? true : false, $xml); - $this->assertEquals('Fault message', (string) $member->value->string, $xml); - } - } - - $this->assertEquals(2, $count, $xml); - } - - /** - * saveXML() test - */ - public function testSaveXML() - { - $this->_fault->setCode(1000); - $this->_fault->setMessage('Fault message'); - $xml = $this->_fault->saveXML(); - $this->_testXmlFault($xml); - } - - /** - * __toString() test - */ - public function test__toString() - { - $this->_fault->setCode(1000); - $this->_fault->setMessage('Fault message'); - $xml = $this->_fault->__toString(); - $this->_testXmlFault($xml); - } - - /** - * Test encoding settings - */ - public function testSetGetEncoding() - { - $this->assertEquals('UTF-8', $this->_fault->getEncoding()); - $this->_fault->setEncoding('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $this->_fault->getEncoding()); - } - - public function testFaultStringWithoutStringTypeDeclaration() - { - $xml = $this->_createNonStandardXml(); - - try { - $parsed = $this->_fault->loadXml($xml); - } catch (Exception $e) { - $this->fail('Failed to parse XML: ' . $e->getMessage()); - } - $this->assertTrue($parsed, $xml); - - $this->assertEquals('Error string', $this->_fault->getMessage()); - } -} diff --git a/tests/Zend/XmlRpc/Request/HttpTest.php b/tests/Zend/XmlRpc/Request/HttpTest.php deleted file mode 100644 index 54a9618e8feea0b3f32e4c64dade8699afc450a6..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/Request/HttpTest.php +++ /dev/null @@ -1,153 +0,0 @@ -<?php -// Call Zend_XmlRpc_Request_HttpTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_XmlRpc_Request_HttpTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -require_once 'Zend/XmlRpc/Request/Http.php'; - -/** - * Test case for Zend_XmlRpc_Request_Http - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: HttpTest.php 8611 2008-03-07 01:55:12Z matthew $ - */ -class Zend_XmlRpc_Request_HttpTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_Request_HttpTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Setup environment - */ - public function setUp() - { - $this->xml =<<<EOX -<?xml version="1.0" encoding="UTF-8"?> -<methodCall> - <methodName>test.userUpdate</methodName> - <params> - <param> - <value><string>blahblahblah</string></value> - </param> - <param> - <value><struct> - <member> - <name>salutation</name> - <value><string>Felsenblöcke</string></value> - </member> - <member> - <name>firstname</name> - <value><string>Lépiné</string></value> - </member> - <member> - <name>lastname</name> - <value><string>Géranté</string></value> - </member> - <member> - <name>company</name> - <value><string>Zend Technologies, Inc.</string></value> - </member> - </struct></value> - </param> - </params> -</methodCall> -EOX; - $this->request = new Zend_XmlRpc_Request_Http(); - $this->request->loadXml($this->xml); - - $this->server = $_SERVER; - foreach ($_SERVER as $key => $value) { - if ('HTTP_' == substr($key, 0, 5)) { - unset($_SERVER[$key]); - } - } - $_SERVER['HTTP_USER_AGENT'] = 'Zend_XmlRpc_Client'; - $_SERVER['HTTP_HOST'] = 'localhost'; - $_SERVER['HTTP_CONTENT_TYPE'] = 'text/xml'; - $_SERVER['HTTP_CONTENT_LENGTH'] = strlen($this->xml) + 1; - } - - /** - * Teardown environment - */ - public function tearDown() - { - $_SERVER = $this->server; - unset($this->request); - } - - public function testGetRawRequest() - { - $this->assertEquals($this->xml, $this->request->getRawRequest()); - } - - public function testGetHeaders() - { - $expected = array( - 'User-Agent' => 'Zend_XmlRpc_Client', - 'Host' => 'localhost', - 'Content-Type' => 'text/xml', - 'Content-Length' => 958 - ); - $this->assertEquals($expected, $this->request->getHeaders()); - } - - public function testGetFullRequest() - { - $expected =<<<EOT -User-Agent: Zend_XmlRpc_Client -Host: localhost -Content-Type: text/xml -Content-Length: 958 - -EOT; - $expected .= $this->xml; - - $this->assertEquals($expected, $this->request->getFullRequest()); - } - - public function testCanPassInMethodAndParams() - { - try { - $request = new Zend_XmlRpc_Request_Http('foo', array('bar', 'baz')); - } catch (Exception $e) { - $this->fail('Should be able to pass in methods and params to request'); - } - } - - public function testExtendingClassShouldBeAbleToReceiveMethodAndParams() - { - try { - $request = new Zend_XmlRpc_Request_HttpTest_Extension('foo', array('bar', 'baz')); - } catch (Exception $e) { - $this->fail('Should be able to pass in methods and params to request'); - } - $this->assertEquals('foo', $request->method); - $this->assertEquals(array('bar', 'baz'), $request->params); - } -} - -class Zend_XmlRpc_Request_HttpTest_Extension extends Zend_XmlRpc_Request_Http -{ - public function __construct($method = null, $params = null) - { - $this->method = $method; - $this->params = (array) $params; - } -} - -// Call Zend_XmlRpc_Request_HttpTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_Request_HttpTest::main") { - Zend_XmlRpc_Request_HttpTest::main(); -} diff --git a/tests/Zend/XmlRpc/RequestTest.php b/tests/Zend/XmlRpc/RequestTest.php deleted file mode 100644 index 12e084094170bf7cb900e7390d881ca9d6419241..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/RequestTest.php +++ /dev/null @@ -1,261 +0,0 @@ -<?php -require_once 'Zend/XmlRpc/Request.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_XmlRpc_Request - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: RequestTest.php 4901 2007-05-23 15:46:16Z matthew $ - */ -class Zend_XmlRpc_RequestTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_XmlRpc_Request object - * @var Zend_XmlRpc_Request - */ - protected $_request; - - /** - * Setup environment - */ - public function setUp() - { - $this->_request = new Zend_XmlRpc_Request(); - } - - /** - * Teardown environment - */ - public function tearDown() - { - unset($this->_request); - } - - /** - * get/setMethod() test - */ - public function testMethod() - { - $this->assertTrue($this->_request->setMethod('testMethod')); - $this->assertTrue($this->_request->setMethod('testMethod9')); - $this->assertTrue($this->_request->setMethod('test.Method')); - $this->assertTrue($this->_request->setMethod('test_method')); - $this->assertTrue($this->_request->setMethod('test:method')); - $this->assertTrue($this->_request->setMethod('test/method')); - $this->assertFalse($this->_request->setMethod('testMethod-bogus')); - - $this->assertEquals('test/method', $this->_request->getMethod()); - } - - - /** - * __construct() test - */ - public function testConstructorOptionallySetsMethodAndParams() - { - $r = new Zend_XmlRpc_Request(); - $this->assertEquals('', $r->getMethod()); - $this->assertEquals(array(), $r->getParams()); - - $method = 'foo.bar'; - $params = array('baz', 1, array('foo' => 'bar')); - $r = new Zend_XmlRpc_Request($method, $params); - $this->assertEquals($method, $r->getMethod()); - $this->assertEquals($params, $r->getParams()); - } - - - /** - * addParam()/getParams() test - */ - public function testAddParam() - { - $this->_request->addParam('string1'); - $params = $this->_request->getParams(); - $this->assertEquals(1, count($params)); - $this->assertEquals('string1', $params[0]); - - $this->_request->addParam('string2'); - $params = $this->_request->getParams(); - $this->assertEquals(2, count($params)); - $this->assertEquals('string1', $params[0]); - $this->assertEquals('string2', $params[1]); - } - - public function testAddDateParamGeneratesCorrectXml() - { - $time = time(); - $this->_request->addParam($time, Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME); - $this->_request->setMethod('foo.bar'); - $xml = $this->_request->saveXML(); - $sxl = new SimpleXMLElement($xml); - $param = $sxl->params->param->value; - $type = 'dateTime.iso8601'; - $this->assertTrue(isset($param->{$type}), var_export($param, 1)); - $this->assertEquals($time, strtotime((string) $param->{$type})); - } - - /** - * setParams()/getParams() test - */ - public function testSetParams() - { - $params = array( - 'string1', - true, - array('one', 'two') - ); - $this->_request->setParams($params); - $returned = $this->_request->getParams(); - $this->assertSame($params, $returned); - - $params = array( - 'string2', - array('two', 'one') - ); - $this->_request->setParams($params); - $returned = $this->_request->getParams(); - $this->assertSame($params, $returned); - } - - /** - * loadXml() test - */ - public function testLoadXml() - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $mCall = $dom->appendChild($dom->createElement('methodCall')); - $mName = $mCall->appendChild($dom->createElement('methodName', 'do.Something')); - $params = $mCall->appendChild($dom->createElement('params')); - $param1 = $params->appendChild($dom->createElement('param')); - $value1 = $param1->appendChild($dom->createElement('value')); - $value1->appendChild($dom->createElement('string', 'string1')); - - $param2 = $params->appendChild($dom->createElement('param')); - $value2 = $param2->appendChild($dom->createElement('value')); - $value2->appendChild($dom->createElement('boolean', 1)); - - - $xml = $dom->saveXML(); - - try { - $parsed = $this->_request->loadXml($xml); - } catch (Exception $e) { - $this->fail('Failed to parse XML: ' . $e->getMessage()); - } - $this->assertTrue($parsed, $xml); - - $this->assertEquals('do.Something', $this->_request->getMethod()); - $test = array('string1', true); - $params = $this->_request->getParams(); - $this->assertSame($test, $params); - - try { - $parsed = $this->_request->loadXml('foo'); - } catch (Exception $e) { - $this->fail('Failed to parse XML: ' . $e->getMessage()); - } - $this->assertFalse($parsed, 'Parsed non-XML string?'); - } - - /** - * isFault() test - */ - public function testIsFault() - { - $this->assertFalse($this->_request->isFault()); - $this->_request->loadXml('foo'); - $this->assertTrue($this->_request->isFault()); - } - - /** - * getFault() test - */ - public function testGetFault() - { - $fault = $this->_request->getFault(); - $this->assertTrue(null === $fault); - $this->_request->loadXml('foo'); - $fault = $this->_request->getFault(); - $this->assertTrue($fault instanceof Zend_XmlRpc_Fault); - } - - /** - * helper for saveXML() and __toString() tests - * - * @param string $xml - * @return void - */ - protected function _testXmlRequest($xml, $argv) - { - try { - $sx = new SimpleXMLElement($xml); - } catch (Exception $e) { - $this->fail('Invalid XML returned'); - } - - $result = $sx->xpath('//methodName'); - $count = 0; - while (list( , $node) = each($result)) { - ++$count; - } - $this->assertEquals(1, $count, $xml); - - $result = $sx->xpath('//params'); - $count = 0; - while (list( , $node) = each($result)) { - ++$count; - } - $this->assertEquals(1, $count, $xml); - - try { - $methodName = (string) $sx->methodName; - $params = array( - (string) $sx->params->param[0]->value->string, - (bool) $sx->params->param[1]->value->boolean - ); - } catch (Exception $e) { - $this->fail('One or more inconsistencies parsing generated XML: ' . $e->getMessage()); - } - - $this->assertEquals('do.Something', $methodName); - $this->assertSame($argv, $params, $xml); - } - - /** - * testSaveXML() test - */ - public function testSaveXML() - { - $argv = array('string', true); - $this->_request->setMethod('do.Something'); - $this->_request->setParams($argv); - $xml = $this->_request->saveXML(); - $this->_testXmlRequest($xml, $argv); - } - - /** - * __toString() test - */ - public function test__toString() - { - $argv = array('string', true); - $this->_request->setMethod('do.Something'); - $this->_request->setParams($argv); - $xml = $this->_request->__toString(); - $this->_testXmlRequest($xml, $argv); - } - - /** - * Test encoding settings - */ - public function testSetGetEncoding() - { - $this->assertEquals('UTF-8', $this->_request->getEncoding()); - $this->_request->setEncoding('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $this->_request->getEncoding()); - } -} diff --git a/tests/Zend/XmlRpc/ResponseTest.php b/tests/Zend/XmlRpc/ResponseTest.php deleted file mode 100644 index 3faf5784ef6e1cb3873a1f283cac6dd5b39956cc..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/ResponseTest.php +++ /dev/null @@ -1,176 +0,0 @@ -<?php -require_once 'Zend/XmlRpc/Response.php'; -// require_once 'PHPUnit/Framework/TestCase.php'; -// require_once 'PHPUnit/Framework/IncompleteTestError.php'; - -/** - * Test case for Zend_XmlRpc_Response - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: ResponseTest.php 5478 2007-06-28 20:20:08Z matthew $ - */ -class Zend_XmlRpc_ResponseTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_XmlRpc_Response object - * @var Zend_XmlRpc_Response - */ - protected $_response; - - /** - * Setup environment - */ - public function setUp() - { - $this->_response = new Zend_XmlRpc_Response(); - } - - /** - * Teardown environment - */ - public function tearDown() - { - unset($this->_response); - } - - /** - * __construct() test - */ - public function test__construct() - { - $this->assertTrue($this->_response instanceof Zend_XmlRpc_Response); - } - - /** - * get/setReturnValue() test - */ - public function testReturnValue() - { - $this->_response->setReturnValue('string'); - $this->assertEquals('string', $this->_response->getReturnValue()); - - $this->_response->setReturnValue(array('one', 'two')); - $this->assertSame(array('one', 'two'), $this->_response->getReturnValue()); - } - - /** - * isFault() test - * - * Call as method call - * - * Returns: boolean - */ - public function testIsFault() - { - $this->assertFalse($this->_response->isFault()); - $this->_response->loadXml('foo'); - $this->assertTrue($this->_response->isFault()); - } - - /** - * Tests getFault() returns NULL (no fault) or the fault object - */ - public function testGetFault() - { - $this->assertNull($this->_response->getFault()); - $this->_response->loadXml('foo'); - $this->assertType('Zend_XmlRpc_Fault', $this->_response->getFault()); - } - - /** - * loadXml() test - * - * Call as method call - * - * Expects: - * - response: - * - * Returns: boolean - */ - public function testLoadXml() - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $response = $dom->appendChild($dom->createElement('methodResponse')); - $params = $response->appendChild($dom->createElement('params')); - $param = $params->appendChild($dom->createElement('param')); - $value = $param->appendChild($dom->createElement('value')); - $value->appendChild($dom->createElement('string', 'Return value')); - - $xml = $dom->saveXML(); - - $parsed = $this->_response->loadXml($xml); - $this->assertTrue($parsed, $xml); - $this->assertEquals('Return value', $this->_response->getReturnValue()); - } - - /** - * helper for saveXML() and __toString() tests - * - * @param string $xml - * @return void - */ - protected function _testXmlResponse($xml) - { - try { - $sx = new SimpleXMLElement($xml); - } catch (Exception $e) { - $this->fail('Invalid XML returned'); - } - - $this->assertTrue($sx->params ? true : false); - $this->assertTrue($sx->params->param ? true : false); - $this->assertTrue($sx->params->param->value ? true : false); - $this->assertTrue($sx->params->param->value->string ? true : false); - $this->assertEquals('return value', (string) $sx->params->param->value->string); - } - - /** - * saveXML() test - */ - public function testSaveXML() - { - $this->_response->setReturnValue('return value'); - $xml = $this->_response->saveXML(); - $this->_testXmlResponse($xml); - } - - /** - * __toString() test - */ - public function test__toString() - { - $this->_response->setReturnValue('return value'); - $xml = $this->_response->__toString(); - $this->_testXmlResponse($xml); - } - - /** - * Test encoding settings - */ - public function testSetGetEncoding() - { - $this->assertEquals('UTF-8', $this->_response->getEncoding()); - $this->_response->setEncoding('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $this->_response->getEncoding()); - } - - public function testLoadXmlThrowsExceptionWithMissingNodes() - { - $sxl = new SimpleXMLElement('<?xml version="1.0"?><methodResponse><params><param>foo</param></params></methodResponse>'); - $this->_loadXml($sxl->asXML()); - $sxl = new SimpleXMLElement('<?xml version="1.0"?><methodResponse><params>foo</params></methodResponse>'); - $this->_loadXml($sxl->asXML()); - $sxl = new SimpleXMLElement('<?xml version="1.0"?><methodResponse><bar>foo</bar></methodResponse>'); - $this->_loadXml($sxl->asXML()); - } - - protected function _loadXml($xml) - { - try { - $this->_response->loadXml($xml); - $this->fail('Invalid XML-RPC response should raise an exception'); - } catch (Exception $e) { - } - } -} diff --git a/tests/Zend/XmlRpc/Server/CacheTest.php b/tests/Zend/XmlRpc/Server/CacheTest.php deleted file mode 100644 index a53d746f0bb414017204cd1afe793591fb8e5b1b..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/Server/CacheTest.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -// Call Zend_XmlRpc_Server_CacheTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Zend_XmlRpc_Server_CacheTest::main"); -} - -require_once dirname(__FILE__) . '/../../../TestHelper.php'; -require_once 'Zend/XmlRpc/Server.php'; -require_once 'Zend/XmlRpc/Server/Cache.php'; - -/** - * Test case for Zend_XmlRpc_Server_Cache - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: CacheTest.php 8617 2008-03-07 02:51:58Z matthew $ - */ -class Zend_XmlRpc_Server_CacheTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_Server_CacheTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Zend_XmlRpc_Server object - * @var Zend_XmlRpc_Server - */ - protected $_server; - - /** - * Local file for caching - * @var string - */ - protected $_file; - - /** - * Setup environment - */ - public function setUp() - { - $this->_file = realpath(dirname(__FILE__)) . '/xmlrpc.cache'; - $this->_server = new Zend_XmlRpc_Server(); - $this->_server->setClass('Zend_XmlRpc_Server_Cache', 'cache'); - } - - /** - * Teardown environment - */ - public function tearDown() - { - if (file_exists($this->_file)) { - unlink($this->_file); - } - unset($this->_server); - } - - /** - * Tests functionality of both get() and save() - */ - public function testGetSave() - { - if (!is_writeable('./')) { - $this->markTestIncomplete('Directory no writable'); - } - - $this->assertTrue(Zend_XmlRpc_Server_Cache::save($this->_file, $this->_server)); - $expected = $this->_server->listMethods(); - $server = new Zend_XmlRpc_Server(); - $this->assertTrue(Zend_XmlRpc_Server_Cache::get($this->_file, $server)); - $actual = $server->listMethods(); - - $this->assertSame($expected, $actual); - } - - /** - * Zend_XmlRpc_Server_Cache::delete() test - */ - public function testDelete() - { - if (!is_writeable('./')) { - $this->markTestIncomplete('Directory no writable'); - } - - $this->assertTrue(Zend_XmlRpc_Server_Cache::save($this->_file, $this->_server)); - $this->assertTrue(Zend_XmlRpc_Server_Cache::delete($this->_file)); - } - - public function testShouldReturnFalseWithInvalidCache() - { - if (!is_writeable('./')) { - $this->markTestIncomplete('Directory no writable'); - } - - file_put_contents($this->_file, 'blahblahblah'); - $server = new Zend_XmlRpc_Server(); - $this->assertFalse(Zend_XmlRpc_Server_Cache::get($this->_file, $server)); - } -} - -// Call Zend_XmlRpc_Server_CacheTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_Server_CacheTest::main") { - Zend_XmlRpc_Server_CacheTest::main(); -} diff --git a/tests/Zend/XmlRpc/Server/FaultTest.php b/tests/Zend/XmlRpc/Server/FaultTest.php deleted file mode 100644 index f6d71e93e16ceaef08837052f8605305b1f9af2b..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/Server/FaultTest.php +++ /dev/null @@ -1,259 +0,0 @@ -<?php -// Call Zend_XmlRpc_Server_FaultTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_XmlRpc_Server_FaultTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/XmlRpc/Server.php'; -require_once 'Zend/XmlRpc/Server/Fault.php'; - -/** - * Test case for Zend_XmlRpc_Server_Fault - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: FaultTest.php 6935 2007-11-26 15:41:31Z matthew $ - */ -class Zend_XmlRpc_Server_FaultTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_Server_FaultTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Zend_XmlRpc_Server_Fault::getInstance() test - */ - public function testGetInstance() - { - $e = new Zend_XmlRpc_Server_Exception('Testing fault', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - - $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault); - } - - /** - * Zend_XmlRpc_Server_Fault::attachFaultException() test - */ - public function testAttachFaultException() - { - Zend_XmlRpc_Server_Fault::attachFaultException('zxrs_fault_test_exception'); - $e = new zxrs_fault_test_exception('test exception', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('test exception', $fault->getMessage()); - $this->assertEquals(411, $fault->getCode()); - Zend_XmlRpc_Server_Fault::detachFaultException('zxrs_fault_test_exception'); - - $exceptions = array( - 'zxrs_fault_test_exception', - 'zxrs_fault_test_exception2', - 'zxrs_fault_test_exception3' - ); - Zend_XmlRpc_Server_Fault::attachFaultException($exceptions); - foreach ($exceptions as $class) { - $e = new $class('test exception', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('test exception', $fault->getMessage()); - $this->assertEquals(411, $fault->getCode()); - } - Zend_XmlRpc_Server_Fault::detachFaultException($exceptions); - } - - /** - * Tests ZF-1825 - * @return void - */ - public function testAttachFaultExceptionAllowsForDerivativeExceptionClasses() - { - Zend_XmlRpc_Server_Fault::attachFaultException('zxrs_fault_test_exception'); - $e = new zxrs_fault_test_exception4('test exception', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('test exception', $fault->getMessage()); - $this->assertEquals(411, $fault->getCode()); - Zend_XmlRpc_Server_Fault::detachFaultException('zxrs_fault_test_exception'); - } - - /** - * Zend_XmlRpc_Server_Fault::detachFaultException() test - */ - public function testDetachFaultException() - { - Zend_XmlRpc_Server_Fault::attachFaultException('zxrs_fault_test_exception'); - $e = new zxrs_fault_test_exception('test exception', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('test exception', $fault->getMessage()); - $this->assertEquals(411, $fault->getCode()); - Zend_XmlRpc_Server_Fault::detachFaultException('zxrs_fault_test_exception'); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('Unknown error', $fault->getMessage()); - $this->assertEquals(404, $fault->getCode()); - - - $exceptions = array( - 'zxrs_fault_test_exception', - 'zxrs_fault_test_exception2', - 'zxrs_fault_test_exception3' - ); - Zend_XmlRpc_Server_Fault::attachFaultException($exceptions); - foreach ($exceptions as $class) { - $e = new $class('test exception', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('test exception', $fault->getMessage()); - $this->assertEquals(411, $fault->getCode()); - } - Zend_XmlRpc_Server_Fault::detachFaultException($exceptions); - foreach ($exceptions as $class) { - $e = new $class('test exception', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $this->assertEquals('Unknown error', $fault->getMessage()); - $this->assertEquals(404, $fault->getCode()); - } - } - - /** - * Zend_XmlRpc_Server_Fault::attachObserver() test - */ - public function testAttachObserver() - { - Zend_XmlRpc_Server_Fault::attachObserver('zxrs_fault_observer'); - $e = new Zend_XmlRpc_Server_Exception('Checking observers', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $observed = zxrs_fault_observer::getObserved(); - zxrs_fault_observer::clearObserved(); - Zend_XmlRpc_Server_Fault::detachObserver('zxrs_fault_observer'); - - $this->assertTrue(!empty($observed)); - $f = array_shift($observed); - $this->assertTrue($f instanceof Zend_XmlRpc_Server_Fault); - $this->assertEquals('Checking observers', $f->getMessage()); - $this->assertEquals(411, $f->getCode()); - } - - /** - * Zend_XmlRpc_Server_Fault::detachObserver() test - */ - public function testDetachObserver() - { - Zend_XmlRpc_Server_Fault::attachObserver('zxrs_fault_observer'); - $e = new Zend_XmlRpc_Server_Exception('Checking observers', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - zxrs_fault_observer::clearObserved(); - Zend_XmlRpc_Server_Fault::detachObserver('zxrs_fault_observer'); - - $e = new Zend_XmlRpc_Server_Exception('Checking observers', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - $observed = zxrs_fault_observer::getObserved(); - $this->assertTrue(empty($observed)); - } - - /** - * getCode() test - */ - public function testGetCode() - { - $e = new Zend_XmlRpc_Server_Exception('Testing fault', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - - $this->assertEquals(411, $fault->getCode()); - } - - /** - * getMessage() test - */ - public function testGetMessage() - { - $e = new Zend_XmlRpc_Server_Exception('Testing fault', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - - $this->assertEquals('Testing fault', $fault->getMessage()); - } - - /** - * __toString() test - */ - public function test__toString() - { - $dom = new DOMDocument('1.0', 'ISO-8859-1'); - $r = $dom->appendChild($dom->createElement('methodResponse')); - $f = $r->appendChild($dom->createElement('fault')); - $v = $f->appendChild($dom->createElement('value')); - $s = $v->appendChild($dom->createElement('struct')); - - $m1 = $s->appendChild($dom->createElement('member')); - $m1->appendChild($dom->createElement('name', 'faultCode')); - $cv = $m1->appendChild($dom->createElement('value')); - $cv->appendChild($dom->createElement('int', 411)); - - $m2 = $s->appendChild($dom->createElement('member')); - $m2->appendChild($dom->createElement('name', 'faultString')); - $sv = $m2->appendChild($dom->createElement('value')); - $sv->appendChild($dom->createElement('string', 'Testing fault')); - - $xml = $dom->saveXML(); - - $e = new Zend_XmlRpc_Server_Exception('Testing fault', 411); - $fault = Zend_XmlRpc_Server_Fault::getInstance($e); - - $this->assertEquals($xml, $fault->__toString()); - } - - -} - -class zxrs_fault_test_exception extends Exception {} -class zxrs_fault_test_exception2 extends Exception {} -class zxrs_fault_test_exception3 extends Exception {} -class zxrs_fault_test_exception4 extends zxrs_fault_test_exception {} - -class zxrs_fault_observer -{ - private static $_instance = false; - - public $observed = array(); - - private function __construct() - { - } - - public static function getInstance() - { - if (!self::$_instance) { - self::$_instance = new self(); - } - - return self::$_instance; - } - - public static function observe(Zend_XmlRpc_Server_Fault $fault) - { - self::getInstance()->observed[] = $fault; - } - - public static function clearObserved() - { - self::getInstance()->observed = array(); - } - - public static function getObserved() - { - return self::getInstance()->observed; - } -} - -// Call Zend_XmlRpc_Server_FaultTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_Server_FaultTest::main") { - Zend_XmlRpc_Server_FaultTest::main(); -} diff --git a/tests/Zend/XmlRpc/ServerTest.php b/tests/Zend/XmlRpc/ServerTest.php deleted file mode 100644 index 1cb13e5eb8249701df75800cc3b93708cd7a6ddb..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/ServerTest.php +++ /dev/null @@ -1,613 +0,0 @@ -<?php -// Call Zend_XmlRpc_ServerTest::main() if this source file is executed directly. -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_XmlRpc_ServerTest::main'); -} - -require_once dirname(__FILE__) . '/../../TestHelper.php'; - -require_once 'Zend/XmlRpc/Server.php'; -require_once 'Zend/XmlRpc/Request.php'; -require_once 'Zend/XmlRpc/Response.php'; - -/** - * Test case for Zend_XmlRpc_Server - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: ServerTest.php 8974 2008-03-21 20:26:07Z matthew $ - */ -class Zend_XmlRpc_ServerTest extends PHPUnit_Framework_TestCase -{ - /** - * Zend_XmlRpc_Server object - * @var Zend_XmlRpc_Server - */ - protected $_server; - - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_ServerTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Setup environment - */ - public function setUp() - { - $this->_server = new Zend_XmlRpc_Server(); - } - - /** - * Teardown environment - */ - public function tearDown() - { - unset($this->_server); - } - - /** - * __construct() test - * - * Call as method call - * - * Returns: void - */ - public function test__construct() - { - $this->assertTrue($this->_server instanceof Zend_XmlRpc_Server); - } - - /** - * addFunction() test - * - * Call as method call - * - * Expects: - * - function: - * - namespace: Optional; has default; - * - * Returns: void - */ - public function testAddFunction() - { - try { - $this->_server->addFunction('Zend_XmlRpc_Server_testFunction', 'zsr'); - } catch (Exception $e) { - $this->fail('Attachment should have worked'); - } - - $methods = $this->_server->listMethods(); - $this->assertTrue(in_array('zsr.Zend_XmlRpc_Server_testFunction', $methods)); - - try { - $this->_server->addFunction('nosuchfunction'); - $this->fail('nosuchfunction() should not exist and should throw an exception'); - } catch (Exception $e) { - // do nothing - } - - $server = new Zend_XmlRpc_Server(); - try { - $server->addFunction( - array( - 'Zend_XmlRpc_Server_testFunction', - 'Zend_XmlRpc_Server_testFunction2', - ), - 'zsr' - ); - } catch (Exception $e) { - $this->fail('Error attaching array of functions: ' . $e->getMessage()); - } - $methods = $server->listMethods(); - $this->assertTrue(in_array('zsr.Zend_XmlRpc_Server_testFunction', $methods)); - $this->assertTrue(in_array('zsr.Zend_XmlRpc_Server_testFunction2', $methods)); - } - - /** - * get/loadFunctions() test - */ - public function testFunctions() - { - try { - $this->_server->addFunction( - array( - 'Zend_XmlRpc_Server_testFunction', - 'Zend_XmlRpc_Server_testFunction2', - ), - 'zsr' - ); - } catch (Exception $e) { - $this->fail('Error attaching functions: ' . $e->getMessage()); - } - - $expected = $this->_server->listMethods(); - - $functions = $this->_server->getFunctions(); - $server = new Zend_XmlRpc_Server(); - $server->loadFunctions($functions); - $actual = $server->listMethods(); - - $this->assertSame($expected, $actual); - } - - /** - * setClass() test - */ - public function testSetClass() - { - $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test'); - $methods = $this->_server->listMethods(); - $this->assertTrue(in_array('test.test1', $methods)); - $this->assertTrue(in_array('test.test2', $methods)); - $this->assertFalse(in_array('test._test3', $methods)); - $this->assertFalse(in_array('test.__construct', $methods)); - } - - /** - * fault() test - */ - public function testFault() - { - $fault = $this->_server->fault('This is a fault', 411); - $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault); - $this->assertEquals(411, $fault->getCode()); - $this->assertEquals('This is a fault', $fault->getMessage()); - - $fault = $this->_server->fault(new Zend_XmlRpc_Server_Exception('Exception fault', 511)); - $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault); - $this->assertEquals(511, $fault->getCode()); - $this->assertEquals('Exception fault', $fault->getMessage()); - } - - /** - * handle() test - * - * Call as method call - * - * Expects: - * - request: Optional; - * - * Returns: Zend_XmlRpc_Response|Zend_XmlRpc_Fault - */ - public function testHandle() - { - $request = new Zend_XmlRpc_Request(); - $request->setMethod('system.listMethods'); - $response = $this->_server->handle($request); - - $this->assertTrue($response instanceof Zend_XmlRpc_Response); - $return = $response->getReturnValue(); - $this->assertTrue(is_array($return)); - $this->assertTrue(in_array('system.multicall', $return)); - } - - /** - * Test that only calling methods using a valid parameter signature works - */ - public function testHandle2() - { - $request = new Zend_XmlRpc_Request(); - $request->setMethod('system.methodHelp'); - $response = $this->_server->handle($request); - - $this->assertTrue($response instanceof Zend_XmlRpc_Fault); - $this->assertEquals(623, $response->getCode()); - } - - /** - * setResponseClass() test - * - * Call as method call - * - * Expects: - * - class: - * - * Returns: boolean - */ - public function testSetResponseClass() - { - $this->_server->setResponseClass('Zend_XmlRpc_Server_testResponse'); - $request = new Zend_XmlRpc_Request(); - $request->setMethod('system.listMethods'); - $response = $this->_server->handle($request); - - $this->assertTrue($response instanceof Zend_XmlRpc_Response); - $this->assertTrue($response instanceof Zend_XmlRpc_Server_testResponse); - } - - /** - * listMethods() test - * - * Call as method call - * - * Returns: array - */ - public function testListMethods() - { - $methods = $this->_server->listMethods(); - $this->assertTrue(is_array($methods)); - $this->assertTrue(in_array('system.listMethods', $methods)); - $this->assertTrue(in_array('system.methodHelp', $methods)); - $this->assertTrue(in_array('system.methodSignature', $methods)); - $this->assertTrue(in_array('system.multicall', $methods)); - } - - /** - * methodHelp() test - * - * Call as method call - * - * Expects: - * - method: - * - * Returns: string - */ - public function testMethodHelp() - { - $help = $this->_server->methodHelp('system.listMethods'); - $this->assertContains('all available XMLRPC methods', $help); - } - - /** - * methodSignature() test - * - * Call as method call - * - * Expects: - * - method: - * - * Returns: array - */ - public function testMethodSignature() - { - $sig = $this->_server->methodSignature('system.methodSignature'); - $this->assertTrue(is_array($sig)); - $this->assertEquals(1, count($sig), var_export($sig, 1)); - } - - /** - * multicall() test - * - * Call as method call - * - * Expects: - * - methods: - * - * Returns: array - */ - public function testMulticall() - { - $struct = array( - array( - 'methodName' => 'system.listMethods', - 'params' => array() - ), - array( - 'methodName' => 'system.methodHelp', - 'params' => array('system.multicall') - ) - ); - $request = new Zend_XmlRpc_Request(); - $request->setMethod('system.multicall'); - $request->addParam($struct); - $response = $this->_server->handle($request); - - $this->assertTrue($response instanceof Zend_XmlRpc_Response, $response->__toString() . "\n\n" . $request->__toString()); - $returns = $response->getReturnValue(); - $this->assertTrue(is_array($returns)); - $this->assertEquals(2, count($returns)); - $this->assertTrue(is_array($returns[0]), var_export($returns[0], 1)); - $this->assertTrue(is_string($returns[1]), var_export($returns[1], 1)); - } - - /** - * Test get/setEncoding() - */ - public function testGetSetEncoding() - { - $this->assertEquals('UTF-8', $this->_server->getEncoding()); - $this->_server->setEncoding('ISO-8859-1'); - $this->assertEquals('ISO-8859-1', $this->_server->getEncoding()); - } - - /** - * Test request/response encoding - */ - public function testRequestResponseEncoding() - { - $response = $this->_server->handle(); - $request = $this->_server->getRequest(); - - $this->assertEquals('UTF-8', $request->getEncoding()); - $this->assertEquals('UTF-8', $response->getEncoding()); - } - - /** - * Test request/response encoding (alternate encoding) - */ - public function testRequestResponseEncoding2() - { - $this->_server->setEncoding('ISO-8859-1'); - $response = $this->_server->handle(); - $request = $this->_server->getRequest(); - - $this->assertEquals('ISO-8859-1', $request->getEncoding()); - $this->assertEquals('ISO-8859-1', $response->getEncoding()); - } - - public function testAddFunctionWithExtraArgs() - { - $this->_server->addFunction('Zend_XmlRpc_Server_testFunction', 'test', 'arg1'); - $methods = $this->_server->listMethods(); - $this->assertContains('test.Zend_XmlRpc_Server_testFunction', $methods); - } - - public function testAddFunctionThrowsExceptionWithBadData() - { - $o = new stdClass(); - try { - $this->_server->addFunction($o); - $this->fail('addFunction() should not accept objects'); - } catch (Exception $e) { - // success - } - } - - public function testLoadFunctionsThrowsExceptionWithBadData() - { - $o = new stdClass(); - try { - $this->_server->loadFunctions($o); - $this->fail('loadFunctions() should not accept objects'); - } catch (Exception $e) { - // success - } - - $o = array($o); - try { - $this->_server->loadFunctions($o); - $this->fail('loadFunctions() should not allow non-reflection objects in an array'); - } catch (Exception $e) { - // success - } - } - - public function testSetClassThrowsExceptionWithInvalidClass() - { - try { - $this->_server->setClass('mybogusclass'); - $this->fail('setClass() should not allow invalid classes'); - } catch (Exception $e) { - // success - } - } - - public function testSetRequestUsingString() - { - $this->_server->setRequest('Zend_XmlRpc_Server_testRequest'); - $req = $this->_server->getRequest(); - $this->assertTrue($req instanceof Zend_XmlRpc_Server_testRequest); - } - - public function testSetRequestThrowsExceptionOnBadClass() - { - try { - $this->_server->setRequest('Zend_XmlRpc_Server_testRequest2'); - $this->fail('Invalid request class should throw exception'); - } catch (Exception $e) { - // success - } - - try { - $this->_server->setRequest($this); - $this->fail('Invalid request object should throw exception'); - } catch (Exception $e) { - // success - } - } - - public function testHandleObjectMethod() - { - $this->_server->setClass('Zend_XmlRpc_Server_testClass'); - $request = new Zend_XmlRpc_Request(); - $request->setMethod('test1'); - $request->addParam('value'); - $response = $this->_server->handle($request); - $this->assertFalse($response instanceof Zend_XmlRpc_Fault); - $this->assertEquals('String: value', $response->getReturnValue()); - } - - public function testHandleClassStaticMethod() - { - $this->_server->setClass('Zend_XmlRpc_Server_testClass'); - $request = new Zend_XmlRpc_Request(); - $request->setMethod('test2'); - $request->addParam(array('value1', 'value2')); - $response = $this->_server->handle($request); - $this->assertFalse($response instanceof Zend_XmlRpc_Fault); - $this->assertEquals('value1; value2', $response->getReturnValue()); - } - - public function testHandleFunction() - { - $this->_server->addFunction('Zend_XmlRpc_Server_testFunction'); - $request = new Zend_XmlRpc_Request(); - $request->setMethod('Zend_XmlRpc_Server_testFunction'); - $request->setParams(array(array('value1'), 'key')); - $response = $this->_server->handle($request); - $this->assertFalse($response instanceof Zend_XmlRpc_Fault); - $this->assertEquals('key: value1', $response->getReturnValue()); - } - - public function testMulticallReturnsFaultsWithBadData() - { - // bad method array - $try = array( - 'system.listMethods', - array( - 'name' => 'system.listMethods' - ), - array( - 'methodName' => 'system.listMethods' - ), - array( - 'methodName' => 'system.listMethods', - 'params' => '' - ), - array( - 'methodName' => 'system.multicall', - 'params' => array() - ) - ); - $returned = $this->_server->multicall($try); - $this->assertTrue(is_array($returned)); - $this->assertEquals(5, count($returned)); - - $response = $returned[0]; - $this->assertTrue(is_array($response)); - $this->assertTrue(isset($response['faultCode'])); - $this->assertEquals(601, $response['faultCode']); - - $response = $returned[1]; - $this->assertTrue(is_array($response)); - $this->assertTrue(isset($response['faultCode'])); - $this->assertEquals(602, $response['faultCode']); - - $response = $returned[2]; - $this->assertTrue(is_array($response)); - $this->assertTrue(isset($response['faultCode'])); - $this->assertEquals(603, $response['faultCode']); - - $response = $returned[3]; - $this->assertTrue(is_array($response)); - $this->assertTrue(isset($response['faultCode'])); - $this->assertEquals(604, $response['faultCode']); - - $response = $returned[4]; - $this->assertTrue(is_array($response)); - $this->assertTrue(isset($response['faultCode'])); - $this->assertEquals(605, $response['faultCode']); - } - - /** - * @see ZF-2872 - */ - public function testCanMarshalBase64Requests() - { - $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test'); - $data = base64_encode('this is the payload'); - $param = array('type' => 'base64', 'value' => $data); - $request = new Zend_XmlRpc_Request('test.base64', array($param)); - - $response = $this->_server->handle($request); - $this->assertFalse($response instanceof Zend_XmlRpc_Fault); - $this->assertEquals($data, $response->getReturnValue()); - } -} - -/** - * Zend_XmlRpc_Server_testFunction - * - * Function for use with xmlrpc server unit tests - * - * @param array $var1 - * @param string $var2 - * @return string - */ -function Zend_XmlRpc_Server_testFunction($var1, $var2 = 'optional') -{ - return $var2 . ': ' . implode(',', (array) $var1); -} - -/** - * Zend_XmlRpc_Server_testFunction2 - * - * Function for use with xmlrpc server unit tests - * - * @return string - */ -function Zend_XmlRpc_Server_testFunction2() -{ - return 'function2'; -} - - -class Zend_XmlRpc_Server_testClass -{ - /** - * Constructor - * - * @return void - */ - public function __construct() - { - } - - /** - * Test1 - * - * Returns 'String: ' . $string - * - * @param string $string - * @return string - */ - public function test1($string) - { - return 'String: ' . (string) $string; - } - - /** - * Test2 - * - * Returns imploded array - * - * @param array $array - * @return string - */ - public static function test2($array) - { - return implode('; ', (array) $array); - } - - /** - * Test3 - * - * Should not be available... - * - * @return void - */ - protected function _test3() - { - } - - /** - * Test base64 encoding in request and response - * - * @param base64 $data - * @return base64 - */ - public function base64($data) - { - return $data; - } -} - -class Zend_XmlRpc_Server_testResponse extends Zend_XmlRpc_Response -{ -} - -class Zend_XmlRpc_Server_testRequest extends Zend_XmlRpc_Request -{ -} - -// Call Zend_XmlRpc_ServerTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ServerTest::main") { - Zend_XmlRpc_ServerTest::main(); -} diff --git a/tests/Zend/XmlRpc/ValueTest.php b/tests/Zend/XmlRpc/ValueTest.php deleted file mode 100644 index c0ab373ecc0dae64e12524bcbebfa76a306f4b69..0000000000000000000000000000000000000000 --- a/tests/Zend/XmlRpc/ValueTest.php +++ /dev/null @@ -1,428 +0,0 @@ -<?php -// Call Zend_XmlRpc_ValueTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - require_once dirname(__FILE__) . '/../../TestHelper.php'; - define("PHPUnit_MAIN_METHOD", "Zend_XmlRpc_ValueTest::main"); -} - -// // // require_once "PHPUnit/Framework/TestCase.php"; -// // // require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Zend/XmlRpc/Value.php'; -require_once 'Zend/XmlRpc/Value/Scalar.php'; -require_once 'Zend/XmlRpc/Value/Collection.php'; -require_once 'Zend/XmlRpc/Value/Array.php'; -require_once 'Zend/XmlRpc/Value/Base64.php'; -require_once 'Zend/XmlRpc/Value/Boolean.php'; -require_once 'Zend/XmlRpc/Value/DateTime.php'; -require_once 'Zend/XmlRpc/Value/Double.php'; -require_once 'Zend/XmlRpc/Value/Integer.php'; -require_once 'Zend/XmlRpc/Value/String.php'; -require_once 'Zend/XmlRpc/Value/Nil.php'; -require_once 'Zend/XmlRpc/Value/Struct.php'; - -/** - * Test case for Zend_XmlRpc_Value - * - * @package Zend_XmlRpc - * @subpackage UnitTests - * @version $Id: ValueTest.php 8955 2008-03-21 16:48:43Z matthew $ - */ -class Zend_XmlRpc_ValueTest extends PHPUnit_Framework_TestCase -{ - /** - * Runs the test methods of this class. - * - * @return void - */ - public static function main() - { - // // // require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_ValueTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - // Boolean - - public function testFactoryAutodetectsBoolean() - { - foreach (array(true, false) as $native) { - $val = Zend_XmlRpc_Value::getXmlRpcValue($native); - $this->assertXmlRpcType('boolean', $val); - } - } - - public function testMarshalBooleanFromNative() - { - $native = true; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_BOOLEAN); - - $this->assertXmlRpcType('boolean', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalBooleanFromXmlRpc() - { - $xml = '<value><boolean>1</boolean></value>'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('boolean', $val); - $this->assertEquals('boolean', $val->getType()); - $this->assertSame(true, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - // Integer - - public function testFactoryAutodetectsInteger() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue(1); - $this->assertXmlRpcType('integer', $val); - } - - public function testMarshalIntegerFromNative() - { - $native = 1; - $types = array(Zend_XmlRpc_Value::XMLRPC_TYPE_I4, - Zend_XmlRpc_Value::XMLRPC_TYPE_INTEGER); - - foreach ($types as $type) { - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, $type); - $this->assertXmlRpcType('integer', $val); - $this->assertSame($native, $val->getValue()); - } - } - - public function testMarshalIntegerFromXmlRpc() - { - $native = 1; - $xmls = array("<value><int>$native</int></value>", - "<value><i4>$native</i4></value>"); - - foreach ($xmls as $xml) { - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('integer', $val); - $this->assertEquals('int', $val->getType()); - $this->assertSame($native, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - } - - // Double - - public function testFactoryAutodetectsFloat() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue((float)1); - $this->assertXmlRpcType('double', $val); - } - - public function testMarshalDoubleFromNative() - { - $native = 1.1; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_DOUBLE); - - $this->assertXmlRpcType('double', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalDoubleFromXmlRpc() - { - $native = 1.1; - $xml = "<value><double>$native</double></value>"; - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('double', $val); - $this->assertEquals('double', $val->getType()); - $this->assertSame($native, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - // String - - public function testFactoryAutodetectsString() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue(''); - $this->assertXmlRpcType('string', $val); - } - - - public function testMarshalStringFromNative() - { - $native = 'foo'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_STRING); - - $this->assertXmlRpcType('string', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalStringFromXmlRpc() - { - $native = 'foo'; - $xml = "<value><string>$native</string></value>"; - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('string', $val); - $this->assertEquals('string', $val->getType()); - $this->assertSame($native, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - //Nil - - public function testFactoryAutodetectsNil() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue(NULL); - $this->assertXmlRpcType('nil', $val); - } - - public function testMarshalNilFromNative() - { - $native = NULL; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_NIL); - - $this->assertXmlRpcType('nil', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalNilFromXmlRpc() - { - $xml = '<value><nil/></value>'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('nil', $val); - $this->assertEquals('nil', $val->getType()); - $this->assertSame(NULL, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - // Array - - public function testFactoryAutodetectsArray() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue(array(0, 'foo')); - $this->assertXmlRpcType('array', $val); - } - - public function testMarshalArrayFromNative() - { - $native = array(0,1); - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_ARRAY); - - $this->assertXmlRpcType('array', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalArrayFromXmlRpc() - { - $native = array(0,1); - $xml = '<value><array><data><value><int>0</int></value>' - . '<value><int>1</int></value></data></array></value>'; - - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('array', $val); - $this->assertEquals('array', $val->getType()); - $this->assertSame($native, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - public function testEmptyXmlRpcArrayResultsInEmptyArray() - { - $native = array(); - $xml = '<value><array><data/></array></value>'; - - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('array', $val); - $this->assertEquals('array', $val->getType()); - $this->assertSame($native, $val->getValue()); - - $value = Zend_XmlRpc_Value::getXmlRpcValue($xml, Zend_XmlRpc_Value::XML_STRING); - $this->assertXmlRpcType('array', $value); - $this->assertEquals('array', $value->getType()); - $this->assertSame($native, $value->getValue()); - } - - // Struct - - public function testFactoryAutodetectsStruct() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue(array('foo' => 0)); - $this->assertXmlRpcType('struct', $val); - } - - public function testFactoryAutodetectsStructFromObject() - { - $val = Zend_XmlRpc_Value::getXmlRpcValue((object)array('foo' => 0)); - $this->assertXmlRpcType('struct', $val); - } - - public function testMarshalStructFromNative() - { - $native = array('foo' => 0); - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT); - - $this->assertXmlRpcType('struct', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalStructFromXmlRpc() - { - $native = array('foo' => 0); - $xml = '<value><struct><member><name>foo</name><value><int>0</int>' - . '</value></member></struct></value>'; - - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('struct', $val); - $this->assertEquals('struct', $val->getType()); - $this->assertSame($native, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - // DateTime - - public function testMarshalDateTimeFromNativeString() - { - $native = '1997-07-16T19:20+01:00'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME); - - $this->assertXmlRpcType('dateTime', $val); - - $expected = '1997-07-16T19:20+01:00'; - $this->assertSame(strtotime($native), strtotime($val->getValue())); - } - - public function testMarshalDateTimeFromNativeStringProducesIsoOutput() - { - $native = '1997-07-16T19:20+01:00'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME); - - $this->assertXmlRpcType('dateTime', $val); - - $expected = date('c', strtotime($native)); - $expected = substr($expected, 0, strlen($expected) - 6); - $expected = str_replace('-', '', $expected); - $received = $val->getValue(); - $this->assertEquals($expected, $received); - } - - public function testMarshalDateTimeFromNativeInteger() - { - $native = strtotime('1997-07-16T19:20+01:00'); - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME); - - $this->assertXmlRpcType('dateTime', $val); - $this->assertSame($native, strtotime($val->getValue())); - } - - public function testMarshalDateTimeFromXmlRpc() - { - $iso8601 = '1997-07-16T19:20+01:00'; - $xml = "<value><dateTime.iso8601>$iso8601</dateTime.iso8601></value>"; - - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('dateTime', $val); - $this->assertEquals('dateTime.iso8601', $val->getType()); - $this->assertSame(strtotime($iso8601), strtotime($val->getValue())); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - // Base64 - - public function testMarshalBase64FromString() - { - $native = 'foo'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64); - - $this->assertXmlRpcType('base64', $val); - $this->assertSame($native, $val->getValue()); - } - - public function testMarshalBase64FromXmlRpc() - { - $native = 'foo'; - $xml = '<value><base64>' .base64_encode($native). '</base64></value>'; - - $val = Zend_XmlRpc_Value::getXmlRpcValue($xml, - Zend_XmlRpc_Value::XML_STRING); - - $this->assertXmlRpcType('base64', $val); - $this->assertEquals('base64', $val->getType()); - $this->assertSame($native, $val->getValue()); - $this->assertType('DomElement', $val->getAsDOM()); - $this->assertEquals($this->wrapXml($xml), $val->saveXML()); - } - - public function testXmlRpcValueBase64GeneratedXmlContainsBase64EncodedText() - { - $native = 'foo'; - $val = Zend_XmlRpc_Value::getXmlRpcValue($native, - Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64); - - $this->assertXmlRpcType('base64', $val); - $xml = $val->saveXML(); - $encoded = base64_encode($native); - $this->assertContains($encoded, $xml); - } - - // Exceptions - - public function testFactoryThrowsWhenInvalidTypeSpecified() - { - try { - Zend_XmlRpc_Value::getXmlRpcValue('', 'bad type here'); - $this->fail(); - } catch (Exception $e) { - $this->assertRegexp('/given type is not/i', $e->getMessage()); - } - } - - // Custom Assertions and Helper Methods - - public function assertXmlRpcType($type, $object) - { - $type = 'Zend_XmlRpc_Value_' . ucfirst($type); - $this->assertType($type, $object); - } - - public function wrapXml($xml) - { - return "<?xml version=\"1.0\"?>\n$xml\n"; - } -} - -// Call Zend_XmlRpc_ValueTest::main() if this source file is executed directly. -if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ValueTest::main") { - Zend_XmlRpc_ValueTest::main(); -} diff --git a/tests/Zend/_files/_testDir1/Class1.php b/tests/Zend/_files/_testDir1/Class1.php deleted file mode 100644 index c0cb5e107a145f13b4882070890dd3b48f588fee..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir1/Class1.php +++ /dev/null @@ -1,37 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Class1.php 9352 2008-05-04 17:40:32Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty class that is used in unit testing by ZendTest::testLoadClassValid() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Class1 -{ -} diff --git a/tests/Zend/_files/_testDir1/Class1/Subclass2.php b/tests/Zend/_files/_testDir1/Class1/Subclass2.php deleted file mode 100644 index 8c806c50550d1e652a2080dfd170b31ac521dc89..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir1/Class1/Subclass2.php +++ /dev/null @@ -1,37 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Subclass2.php 9352 2008-05-04 17:40:32Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty class that is used in unit testing by ZendTest::testLoadClassValid() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Class1_Subclass2 -{ -} diff --git a/tests/Zend/_files/_testDir1/Class3.php b/tests/Zend/_files/_testDir1/Class3.php deleted file mode 100644 index 0b61bb1c677eb8f0de3473f9d044cbe6027aa4c3..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir1/Class3.php +++ /dev/null @@ -1,37 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty class that is used in unit testing by ZendTest::testLoadClassValid() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Class3 -{ -} diff --git a/tests/Zend/_files/_testDir1/Class4.php b/tests/Zend/_files/_testDir1/Class4.php deleted file mode 100644 index c953fcf729e59166673d511b748ea890969bf228..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir1/Class4.php +++ /dev/null @@ -1,37 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty class that is used in unit testing by ZendTest::testLoadClassValid() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Class4 -{ -} diff --git a/tests/Zend/_files/_testDir1/ClassNonexistent.php b/tests/Zend/_files/_testDir1/ClassNonexistent.php deleted file mode 100644 index d67cd048b8d5f5ba9d142e1080024a1416525e84..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir1/ClassNonexistent.php +++ /dev/null @@ -1,34 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ClassNonexistent.php 9352 2008-05-04 17:40:32Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty file that is used in unit testing by ZendTest::testLoadClassNonexistent() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ diff --git a/tests/Zend/_files/_testDir1/Interface1.php b/tests/Zend/_files/_testDir1/Interface1.php deleted file mode 100644 index f8797c7b37d6b846abf72794ddc1530794671f14..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir1/Interface1.php +++ /dev/null @@ -1,37 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface1.php 9352 2008-05-04 17:40:32Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty class that is used in unit testing by ZendTest::testLoadInterfaceValid() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Interface1 -{ -} diff --git a/tests/Zend/_files/_testDir2/Class2.php b/tests/Zend/_files/_testDir2/Class2.php deleted file mode 100644 index 2797a294515d46532581dbf2b09cab14b833fece..0000000000000000000000000000000000000000 --- a/tests/Zend/_files/_testDir2/Class2.php +++ /dev/null @@ -1,37 +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_Loader - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Class2.php 9352 2008-05-04 17:40:32Z thomas $ - */ - -// require_once 'PHPUnit/Util/Filter.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - -/** - * Empty class that is used in unit testing by ZendTest::testLoadClassSearchDirs() - * - * @category Zend - * @package Zend_Loader - * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Class2 -{ -}